OPENSEQ Status Statement

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
jlock23
Participant
Posts: 18
Joined: Wed May 11, 2005 9:16 am

OPENSEQ Status Statement

Post 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.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

FileInfo (etc) is documented in the BASIC reference manual.

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

"You can never have too many knives" -- Logan Nine Fingers
jlock23
Participant
Posts: 18
Joined: Wed May 11, 2005 9:16 am

Post 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?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I think you need to look at the FileInfo function, not Status.
-craig

"You can never have too many knives" -- Logan Nine Fingers
jlock23
Participant
Posts: 18
Joined: Wed May 11, 2005 9:16 am

Post 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.
pnchowdary
Participant
Posts: 232
Joined: Sat May 07, 2005 2:49 pm
Location: USA

Post 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.
Thanks,
Naveen
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post 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.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply