kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Tue Apr 21, 2015 10:32 am Post subject: |
|
|
Dinesh Kumar,
Use the following DFSORT JCL which will give you the desired results. I assumed your input LRECL is 80 bytes and has FB recfm. Since you wanted to updated both the header and detail records, we will use the joinkeys trick to find out if any of the detailed records have a "5" at position 23 and then we will update the entire group matching the key.
Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//INA DD *
111111104041615R 00040
11111120UNIDENTIFY 00000
111111305181227 5 5151 05
111111305181227LG 4 51 05
111111305181227SF 5 51 05
111111305181227TF 4 51 05
111111305250327 3 5151 08
111111305250327LG 4 51 08
111111305250327SF 3 51 08
222222104041615R 00002
22222220NORTH 40 O 99212
222222302008944SF Í 301 30 36
222222303403603TF á 4 34 08
//INB DD *
111111104041615R 00040
11111120UNIDENTIFY 00000
111111305181227 5 5151 05
111111305181227LG 4 51 05
111111305181227SF 5 51 05
111111305181227TF 4 51 05
111111305250327 3 5151 08
111111305250327LG 4 51 08
111111305250327SF 3 51 08
222222104041615R 00002
22222220NORTH 40 O 99212
222222302008944SF Í 301 30 36
222222303403603TF á 4 34 08
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
JOINKEYS F1=INA,FIELDS=(1,6,A),SORTED,NOSEQCK
JOINKEYS F2=INB,FIELDS=(1,6,A)
JOIN UNPAIRED
REFORMAT FIELDS=(F1:1,80,?)
INREC IFOUTLEN=80,
IFTHEN=(WHEN=(81,1,CH,EQ,C'B',AND,7,2,CH,EQ,C'10'),
OVERLAY=(09:C'3')),
IFTHEN=(WHEN=(81,1,CH,EQ,C'B',AND,7,2,CH,EQ,C'30'),
OVERLAY=(23:C'3'))
//*
//JNF2CNTL DD *
INCLUDE COND=(7,2,CH,EQ,C'30',AND,23,1,CH,EQ,C'5')
INREC BUILD=(1,6)
SUM FIELDS=NONE
//* |
The output from this is
Code: |
111111103041615R 00040
11111120UNIDENTIFY 00000
111111305181227 3 5151 05
111111305181227LG 3 51 05
111111305181227SF 3 51 05
111111305181227TF 3 51 05
111111305250327 3 5151 08
111111305250327LG 3 51 08
111111305250327SF 3 51 08
222222104041615R 00002
22222220NORTH 40 O 99212
222222302008944SF 301 30 36
222222303403603TF 4 34 08 |
_________________ Kolusu
www.linkedin.com/in/kolusu |
|