rundate from header record of the file

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
vikibemech
Participant
Posts: 46
Joined: Fri May 02, 2008 1:11 am
Location: Chennai

rundate from header record of the file

Post by vikibemech »

I need to take the batch rundate from the header record of the file and use it as a column vlaue in my job. ie Start date (column name in transformer) will be the run date in the transformer stage

Job design will be

Seq file -> Transformer->Dataset

Header record will be XXXXXXX20110414XXXXXXXXXX. Here I need to take the chars from lenght 8 to 15.
But not sure how to define in transformer (ie how to define he record starts with H). Please advice to achieve
Vignesh Kumar N
GJ_Stage
Participant
Posts: 131
Joined: Mon Oct 27, 2008 6:59 am

Post by GJ_Stage »

Please use below in Transformer stage. Assue Record is field name coming from Seq file.

if left(trim(DSLink2.Record,3) = "HDR" then
DSLink2.Record[8,3] else DSLink2.Record
Jothi
vikibemech
Participant
Posts: 46
Joined: Fri May 02, 2008 1:11 am
Location: Chennai

Post by vikibemech »

Thanks but not clear for me. Can you more specific. I am not clear how to define the header record in transformer.. then how to cut the data from the header record and populate the value

Header record will look similar like

HIAgree20110414000000004
Vignesh Kumar N
GJ_Stage
Participant
Posts: 131
Joined: Mon Oct 27, 2008 6:59 am

Post by GJ_Stage »

Record is field name from Seq file and you need to do in Transformer stage is as below assign this value to one variable.

if DSLink2.Record[1] = 'H' then
DSLink2.Record[8,3] else DSLink2.Record
Jothi
Ravi.K
Participant
Posts: 209
Joined: Sat Nov 20, 2010 11:33 pm
Location: Bangalore

Post by Ravi.K »

Define Stage Variable

If Inputcol[1,7]="HIAgree" Then Inputcol[8,8] Else svHEADERDATE
Cheers
Ravi K
GJ_Stage
Participant
Posts: 131
Joined: Mon Oct 27, 2008 6:59 am

Post by GJ_Stage »

Sorry for the confusion:

DSLink2.Record is field name from Seq file:

Sorry It is :

if DSLink2.Record[1,1] = 'H' then
DSLink2.Record[8,8] else DSLink2.Record

assign the above value to one variable.
Jothi
vikibemech
Participant
Posts: 46
Joined: Fri May 02, 2008 1:11 am
Location: Chennai

Post by vikibemech »

We came closer now. As you mentioned
if DSLink2.Record[1,1] = 'H' then
DSLink2.Record[8,8] else DSLink2.Record

My question starts here only, how can I define the column DSLink2.Record since this is a Header record.

I can use as below

if record type = H then ....... not sure how to define then statement since we dont have specific column
Vignesh Kumar N
samsuf2002
Premium Member
Premium Member
Posts: 397
Joined: Wed Apr 12, 2006 2:28 pm
Location: Tennesse

Post by samsuf2002 »

Does your file contain only header and no data ?
hi sam here
MarkB
Premium Member
Premium Member
Posts: 95
Joined: Fri Oct 27, 2006 9:13 am

Post by MarkB »

You haven't said much about the data in your file. Is it always one header record followed by detail records? If so, then one way to do this is to call your job from a Sequence job. Your job would have a parameter - call it RunDate. Create a Sequence. The sequence would be an Execute Command. The command would be something like head -1 C:\\somefilename.txt|awk '{print substr($0,8,8 )}' | tr -d '\n' . This would parse out the date. This (the Command.Output) would be passed to a Job Activity that runs your job as the value for the parameter Rundate. In the transformer of your job, constrain so that the first row (i.e. header row) does not get output, and set the StartDate column to the parameter RunDate. Of course, you need to make sure checks are in place to validate that the data you parse is the date. Again, this is one way to approach it.
jwiles
Premium Member
Premium Member
Posts: 1274
Joined: Sun Nov 14, 2004 8:50 pm
Contact:

Post by jwiles »

If the file is a basic text file, delimited or not, just read the entire record into one column ("Record" in the earlier posts) for all of the rows in the file. You can parse the data records later using Column Import.

Regards,
- james wiles


All generalizations are false, including this one - Mark Twain.
MarkB
Premium Member
Premium Member
Posts: 95
Joined: Fri Oct 27, 2006 9:13 am

Post by MarkB »

jwiles wrote:If the file is a basic text file, delimited or not, just read the entire record into one column ("Record" in the earlier posts) for all of the rows in the file. You can parse the data records later using Column Import.

Regards,
Like I said, more than one way to do it :D
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Copy the stream and use a Head stage to extract the first row. It can be parsed appropriately downstream of that.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
vikibemech
Participant
Posts: 46
Joined: Fri May 02, 2008 1:11 am
Location: Chennai

Post by vikibemech »

Sam,

No. Input file is a txt file. File has header and data as well.
Vignesh Kumar N
GJ_Stage
Participant
Posts: 131
Joined: Mon Oct 27, 2008 6:59 am

Post by GJ_Stage »

Again Today :D

Step 1:
Seq file Stage:

Reading record line by line in Seq file and assign each line as Record (this is variable name defined in columns field and declared as varchar 1000)

Step 2:
Transformer Stage:
Assume Link came from Seq Stage called DSLink2.

Do the below statement in Transformer Stage in Derivation part and assign this to BATCH_RUN_DATE

if DSLink2.Record[1,1] = 'H' then
DSLink2.Record[8,8] else DSLink2.Record

Step 3:
link the same to your Final DataSet.
Jothi
Post Reply