Implement loop --- Header/Detail/Footer format input data fi

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
murur
Participant
Posts: 19
Joined: Wed Apr 14, 2004 7:55 am

Implement loop --- Header/Detail/Footer format input data fi

Post by murur »

I am getting a input file with header/detail/and fooder

EXample

<HEADER_STR><ORDER_NUM><HEADER_DATE>
<DETAILA><ORD_DETAIL_NO1><QTY>
<DETAILA><ORD_DETAIL_NO2><QTY>
<DETAILA><ORD_DETAIL_NO3><QTY>
<TRAILER><ORDER_NUM>

Output file should be
<ORDER_NUM><HEADER_DATE><ORD_DETAIL_NO1><QTY>
<ORDER_NUM><HEADER_DATE><ORD_DETAIL_NO2><QTY>
<ORDER_NUM><HEADER_DATE><ORD_DETAIL_NO3><QTY>

I want to store the <HEADER_DATE> AND <ORDER_DATE>
in a varaiable until I reach the next record header and use it for each detail record.

How do I implement this....

Any help is appriciated

Thank you
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The easiest way is to store the header string, order number and header date in stage variables, updating only when HeaderStr changes. After all of these have another, called svPrevHeaderStr, that records the incoming HeaderStr. Derivation of svHeaderDate, for example, is then

Code: Select all

If InLink.HeaderStr <> svPrevHeaderStr Then InLink.HeaderDate Else svHeaderDate
Derivation of the OrderNum and HeaderDate output columns is simply the value of the appropriate stage variable.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Amos.Rosmarin
Premium Member
Premium Member
Posts: 385
Joined: Tue Oct 07, 2003 4:55 am

Post by Amos.Rosmarin »

Since your file has a different format for each line type, you might have problems with the sequential stage. 'Suppress row trancation warnning might help' otherwise you can create a job that reads only the first line and pass the <HEADER_DATE> as user status.
Your second job will get the <HEADER_DATE> as a parameter and will read the file without the fist line (use 'first line iws column name' to ignore the header)

HTH,
Amos
Post Reply