View previous topic :: View next topic
|
Author |
Message |
RahmanisGod
New User
Joined: 12 Aug 2008 Posts: 7 Location: Chennai, India
|
|
|
|
Hi all,
I have been challenged with a serious problem.
I have a file which contains the date field starting at postion 128 and is 10 byte long as shown below.
XXXXXXXXXXXXXXXX YYYY/MM/DD
I need to extract the data from the above file and put it in the header section of another file .The header is a pagewise header and hence I have to use the HEADER2 function. The date is in the same postion in the header record as it is in the input file (128,10).
the outputfile should look like
XXXXXXXXXXXXXXXX YYYY/MM/DD (HEADER)
RECORD 1
RECORD 2
RECORD 3
...........
..........
XXXXXXXXXXXXXXXX YYYY/MM/DD
RECORD 1
RECORD 2
RECORD 3
...........
..........
I only need to extract the value from a field and pass it to the header statement .Please help me ASAP
HEADER2=(1:'XXXX',128:????)
How do I perform this operation??? Can it be done using the PARSE function??? |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Quote: |
I need to extract the data from the above file |
Is there any way to identify the record you want to extract from file-1?
Thanks,
Arun |
|
Back to top |
|
|
RahmanisGod
New User
Joined: 12 Aug 2008 Posts: 7 Location: Chennai, India
|
|
|
|
Yes the record containing date is the first record in my input file which starts at 128 and is 10 bytes long. |
|
Back to top |
|
|
RahmanisGod
New User
Joined: 12 Aug 2008 Posts: 7 Location: Chennai, India
|
|
|
|
To be more specific the first record in the input file contains the date at position 128, the date field is 10 bytes long and the record starts with the string "HEADER"
I jus need a way by which I can extract the date from the above file, and pass it onto another file's header.
Is there any method by which any of the following operations is possible.
>> Extracting the date from the input file using a sort card
>> Passing on the date value to another sort card creating the pagewise header.
or
>> Using a sort card to read the date from the input file and insert in all instances where header occurs in the output file.
Please note that the OUTPUT file's header record also starts with teh string HEADER |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
What are the LRECL/RECFM of the files?
Thanks,
Arun |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
RahmanisGod,
Are the headers in both the files exactly the same except the date field?
Do you have more than one record in file-1 having the value 'HEADER' in pos-1?
Thanks,
Arun |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
RG,
Here's a DFSORT job that will do what you want. It creates a DFSORT symbol with the date from file1 and uses that symbol in HEADER2 for file2.
I assumed your input files have RECFM=FB but the job can be changed appropriately for RECFM=VB files.
Code: |
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file1 (FB)
//SORTOUT DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN DD *
OPTION COPY,STOPAFT=1
INREC BUILD=(C'TDATE,''',128,10,C'''',80:X)
//S2 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SORTIN DD DSN=... input file2 (FB)
//SORTOUT DD DSN=... output file (FB)
//SYSIN DD *
OPTION COPY
OUTFIL HEADER2=(1:'XXXX',128:TDATE)
/*
|
|
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
RahmanisGod,
You may try this too.
Code: |
//STEP00 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD DSN=input.file1
//IN2 DD DSN=input.file2
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//C1 DD DSN=&&C1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//OUT DD DSN=output.file
//TOOLIN DD *
COPY FROM(IN1) TO(C1) USING(CTL1)
COPY FROM(IN2) TO(OUT) USING(CTL2)
//CTL1CNTL DD *
OPTION COPY,STOPAFT=1
OUTREC BUILD=(C' 128:C''',128,10,C''')',80:X)
//CTL2CNTL DD *
OUTFIL FNAMES=OUT,HEADER2=(C'HEADER XXXXXXXXXXXXXXXXXXX ',
// DD DSN=*.C1,VOL=REF=*.C1,DISP=(OLD,PASS) |
Thanks,
Arun |
|
Back to top |
|
|
RahmanisGod
New User
Joined: 12 Aug 2008 Posts: 7 Location: Chennai, India
|
|
|
|
Thanks a lot guys..... It worked like a charm. I settled for Frank's solution because it was quiker and suited my problem better.
This forum rocks!! Waiting for my day in the sun...
|
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Quote: |
I settled for Frank's solution because it was quiker |
Frank
Any guess for the difference in performance? What did you do to SYMNAMES to make it run faster?
Thanks,
Arun |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Quote: |
Frank
Any guess for the difference in performance? What did you do to SYMNAMES to make it run faster? |
The performance of the two methods would be the same. The processing for SYMNAMES is negligible.
I prefer the SYMNAMES method because it doesn't require generating the actual DFSORT control statements - it allows you to set up the DFSORT control statements as you normally would and just substitute the symbol where you need it. |
|
Back to top |
|
|
|