View previous topic :: View next topic
|
Author |
Message |
avinashgup
New User
Joined: 03 Aug 2007 Posts: 19 Location: Naperville
|
|
|
|
Hi,
I have to insert a new record in given file that is sequenced and bounded by header and trailer. Header record starts with 1 and is also sequenced. Trailer records begins with '9' and is also sequenced . Detail record begins with '2'.Please see below.
10001HEADERFILE
20002aaaaaaaa
20003bbbbbbbb
20004eeeeeeee
90005TRAILER
Another record to be inserted in the above file
ccccccccc
Expected output
10001HEADERFILE
20002aaaaaaaaa
20003bbbbbbbbb
20004cccccccccc <-----record inserted based on location 6,13 ( lenght 7)
20005ddddddddd
90005TRAILER
Let me know if this can be done by using DFSORT? |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
It's not clear what you want to do. Your description is confusing.
How are you doing the insert? With a DFSORT job or some other way? Is the input to DFSORT both files (original input and record to be inserted), or one file with the new record already inserted, or what?
If the original sequence number of the trailer was 5 and you add a new data record, it would seem that you would want the trailer record sequence number to be 6, not 5. Do you really want the old sequence number in the trailer and if so, why?
Also, you show 20004eeeeeeee in the input file and 20005ddddddddd in the output file. Is that a typo? Should it really be 20005eeeeeeee in the output file? If not, where did the d record come from?
Please do a better job of explaining what you're trying to do here with a better example of input and expected output. Also, give the RECFM and LRECL of the input file. |
|
Back to top |
|
|
avinashgup
New User
Joined: 03 Aug 2007 Posts: 19 Location: Naperville
|
|
|
|
The record format is FB and LRECL=280.
There was a typo in the trailer sequence number should be 900006. The record that is inserted is in a separate file and the 5 records are in a separate file. I want to use the sort to concatenate them and arrange them in sequence. |
|
Back to top |
|
|
avinashgup
New User
Joined: 03 Aug 2007 Posts: 19 Location: Naperville
|
|
|
|
Earlier there was a typo in the expected record.
Expected output
10001HEADERFILE
20002aaaaaaaaa
20003bbbbbbbbb
20004cccccccccc <-----record inserted based on location 6,13 ( lenght 7)
20005eeeeeeeee
90005TRAILER |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
Avinash Gupta wrote: |
Earlier there was a typo in the expected record.
Expected output
10001HEADERFILE
20002aaaaaaaaa
20003bbbbbbbbb
20004cccccccccc <-----record inserted based on location 6,13 ( lenght 7)
20005eeeeeeeee
90005TRAILER
|
Do you want sequence number in trailer as it is of first input file??? |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Avinash,
I'm still not sure what you want to do since your various statements contradict each other, but I'm going to take a guess that this DFSORT/ICETOOL job will give you what you want:
Code: |
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN2 DD DSN=... insert file (FB/280)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//CON DD DSN=*.T1,VOL=REF=*.T1,DISP=(OLD,PASS)
// DD DSN=... input file (FB/280)
//OUT DD DSN=... output file (FB/280)
//TOOLIN DD *
COPY FROM(IN2) TO(T1) USING(CTL1)
SORT FROM(CON) TO(OUT) USING(CTL2)
/*
//CTL1CNTL DD *
INREC BUILD=(C'2',6:1,13,280:X)
/*
//CTL2CNTL DD *
SORT FIELDS=(1,1,CH,A,6,13,CH,A)
OUTREC OVERLAY=(2:SEQNUM,4,ZD)
/*
|
If the insert file has:
and the input file has:
Code: |
10001HEADERFILE
20002aaaaaaaa
20003bbbbbbbb
20004eeeeeeee
90005TRAILER
|
Then SORTOUT would have:
Code: |
10001HEADERFILE
20002aaaaaaaa
20003bbbbbbbb
20004ccccccccc
20005eeeeeeee
90006TRAILER
|
If that's not what you want then you need to do a better job of explaining what you do want. |
|
Back to top |
|
|
|