View previous topic :: :: View next topic
Author
Message
ramsri Active User Joined: 18 Oct 2008Posts: 380 Location: India
Hi,
How to copy pair or more of successive records based on first record's criteria?
Input:
Code:
----+----1----+----2
01GM2 DBPGM2EXTR
02GM2 DBPGM23095SDSC2008
03GM2 DBPGM23095SDSC2009
01G9K TBPG9KEXTR
06G9K TBPG9K3095SDSC2008
01J16 SKNJ16EXTR
06J16 SKNJ163095SDSC2009
01GM8 DBTGM8EXTR
02GM8 DBTGM83095SDSC2008
01GT8 DBTGT8 XTR
02GT8 DBTGT83095SDSC2009
Output : The criteria to copy is first record should have '01' at 1st column and 16th column should always have values and if the next following record has '02' at starting position then such pair or more of records should be copied to output file.
Code:
01GM2 DBPGM2EXTR
02GM2 DBPGM23095SDSC2008
03GM2 DBPGM23095SDSC2009
01GM8 DBTGM8EXTR
02GM8 DBTGM83095SDSC2008
Please help.
Back to top
dick scherrer Site Director Joined: 23 Nov 2006Posts: 19270 Location: Inside the Matrix
Hello,
If there is a reason to lock a topic, there is a reason to mention this when locking the topic. . . .
This topic was locked twice for no stated reason.
IMHO, there is nothing questionable about the topic or the manner in which it was posted.
Please refrain from willy-nilly locking. . .
Thank you,
d
Back to top
Arun Raj Moderator Joined: 17 Oct 2006Posts: 2352 Location: @my desk
Ramsri,
From whatever you posted, I assume you want to do the below validations.
1. Pos 1-2 has '01' and 16th pos has a non-blank character.
2. If next record has '02' at pos 1-2, copy all the records until the next '01' record.
Back to top
ramsri Active User Joined: 18 Oct 2008Posts: 380 Location: India
Yes Arun. You got it right.
Back to top
Arun Raj Moderator Joined: 17 Oct 2006Posts: 2352 Location: @my desk
Ramsri,
What is the input LRECL/RECFM?
Back to top
ramsri Active User Joined: 18 Oct 2008Posts: 380 Location: India
Hi,
LRECL = 83, RECFM=FB.
Thanks.
Back to top
Arun Raj Moderator Joined: 17 Oct 2006Posts: 2352 Location: @my desk
Ramsri,
The below SYNCTOOL job should work for your requirement.
Code:
//STEP1 EXEC PGM=SYNCTOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN= Input file, FB/LRECL=83
//CTL3JNF1 DD DSN=&&T1,DISP=(,PASS),UNIT=SYSDA
//CTL3JNF2 DD DSN=&&T2,DISP=(,PASS),UNIT=SYSDA
//OUT DD DSN= Output file, FB/LRECL=83
//TOOLIN DD *
SPLICE FROM(IN) TO(CTL3JNF1) ON(92,8,CH) WITHALL WITH(1,83) -
KEEPBASE KEEPNODUPS USING(CTL1)
COPY FROM(CTL3JNF1) TO(CTL3JNF2) USING(CTL2)
SORT FROM(CTL3JNF1) TO(OUT) USING(CTL3)
//CTL1CNTL DD *
INREC IFTHEN=(WHEN=INIT,
OVERLAY=(84:SEQNUM,8,ZD)),
IFTHEN=(WHEN=(1,2,CH,EQ,C'01'),
OVERLAY=(92:SEQNUM,8,ZD),HIT=NEXT),
IFTHEN=(WHEN=(1,2,CH,EQ,C'01',AND,16,1,CH,NE,C' '),
OVERLAY=(100:C'Y')),
IFTHEN=(WHEN=NONE,
OVERLAY=(92:SEQNUM,8,ZD,92:84,8,ZD,SUB,92,8,ZD,M11,LENGTH=8))
OUTFIL INCLUDE=(100,1,CH,EQ,C'Y')
//CTL2CNTL DD *
INREC OVERLAY=(101:SEQNUM,2,ZD,RESTART=(92,8))
OUTFIL INCLUDE=(100,3,CH,EQ,C'Y02',AND,1,2,CH,EQ,C'02'),
BUILD=(92,8)
//CTL3CNTL DD *
JOINKEYS FILE=F1,FIELDS=(92,8,A)
JOINKEYS FILE=F2,FIELDS=(01,8,A)
REFORMAT FIELDS=(F1:1,83)
SORT FIELDS=COPY
//*
Back to top
ramsri Active User Joined: 18 Oct 2008Posts: 380 Location: India
Arun, Thank you.
I will try it out today.
Back to top
ramsri Active User Joined: 18 Oct 2008Posts: 380 Location: India
Arun, thanks once again. It has solved my problem.
Back to top
Please enable JavaScript!