Page 1 of 1

OPENSEQ Status Statement

Posted: Thu Aug 25, 2005 11:53 am
by jlock23
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.

Posted: Thu Aug 25, 2005 12:26 pm
by chulett
FileInfo (etc) is documented in the BASIC reference manual.

For Windows and emailing attachments, you should look at 'blat'.

Posted: Thu Aug 25, 2005 12:46 pm
by jlock23
Okay, I just want to verify. According to what I've read, now, in the BASIC manual.

The Status Statement on OPENSEQ can not be used to determine row count.

Is there anyway to determine row count on a file in a subroutine?

Posted: Thu Aug 25, 2005 12:48 pm
by chulett
I think you need to look at the FileInfo function, not Status.

Posted: Thu Aug 25, 2005 1:03 pm
by jlock23
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.

Posted: Thu Aug 25, 2005 1:23 pm
by pnchowdary
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.

Posted: Thu Aug 25, 2005 5:41 pm
by ray.wurlod
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.