I have the following code in a before/after subroutine:
OPENSEQ reportFile TO H.REPORT THEN
status FileInfo from H.REPORT ELSE STOP
fileRowCount = FileInfo<6>; * get the row count
CALL DSLogInfo("Row Count: " : fileRowCount, "EmailReportRoutine")
:
:
I need to find the row count. However, FileInfo<6> is not row count, it's character count. I only want to do something with the file if there is more than 1 row (the column headers, which are needed in the file). Does anyone know where I can find information about the various fields returned using the Status statement? And which field is row count?
And as long as I'm asking....anyone know how to email an attachment in 7.1. (Is it possible? Any wrapper I can add?) The above subroutine, opens the file, if it has more than 1 row, it reads the file and emails the data as inline text as part of the body of the email. This works okay for most cases, but some with lots of columns look horrible.
OPENSEQ Status Statement
Moderators: chulett, rschirm, roy
Yeah...I don't see anything in FileInfo about row count.
That's okay, I just realized that I might as well count the rows myself as I am reading through the file (building up my email message). So, I guess I don't need a function to do this.
Although it is a little annoying. You think there would be a simple function that you can use.
That's okay, I just realized that I might as well count the rows myself as I am reading through the file (building up my email message). So, I guess I don't need a function to do this.
Although it is a little annoying. You think there would be a simple function that you can use.
-
- Participant
- Posts: 232
- Joined: Sat May 07, 2005 2:49 pm
- Location: USA
Hi Jlock,
To get the count of lines in the file, you have two approaches.
1) After you open the file in your routine, loop through the file and keep incrementing a counter, that will give you the number of lines
2) Alternatively, you can use the UNIX command "wc -l" using DSExecute in your current routine.
The emailing part of your question has already been covered in previous post, please search for it in the forums.
To get the count of lines in the file, you have two approaches.
1) After you open the file in your routine, loop through the file and keep incrementing a counter, that will give you the number of lines
2) Alternatively, you can use the UNIX command "wc -l" using DSExecute in your current routine.
The emailing part of your question has already been covered in previous post, please search for it in the forums.
Thanks,
Naveen
Naveen
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
The sixth field of the dynamic array returned by the STATUS statement is the file size in bytes. You might have more luck with FileInfo<2> (have reached end-of-file) or FileInfo<4> (number of bytes available to read).
Preferably avoid FileInfo as a variable name, since it is also the name of an internal function within DataStage BASIC. Luckily the compiler can differentiate FileInfo from FileInfo( - the latter would be a function reference.
Preferably avoid FileInfo as a variable name, since it is also the name of an internal function within DataStage BASIC. Luckily the compiler can differentiate FileInfo from FileInfo( - the latter would be a function reference.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.