|
View previous topic :: View next topic
|
| Author |
Message |
Yalini75
New User
Joined: 06 Aug 2025 Posts: 3 Location: USA
|
|
|
|
Hi all,
I have an Input file which has LRECL as 292 and RECFM - FB.
account no starts at 77and length is 8 and defined as PD
Tran-code starts at 31 - binary - 2 byte
X'03EF' (1007) / x'03f0' (1008)
Input file is having only 1007 or 1008 tran codes at the position 31.
Some of the accounts are having both 1007 and 1008 tran codes.
for example
111111111 1007
111111111 1008
222222222 1007
345677888 1007
345677888 1008
my Output file should have only
222222222 1007
I need to exclude the accounts which are having both 1007 and 1008 tran codes
If the account is having only 1007 then it should write into the file
Trying this code:
STEP1 – Create 1007 & 1008 accounts
//STEP1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=INPUT.FILE,DISP=SHR
//SORT7 DD DSN=&&ONLY7,UNIT=SYSDA,SPACE=(CYL,(1,1)),DISP=(,PASS)
//SORT8 DD DSN=&&ONLY8,UNIT=SYSDA,SPACE=(CYL,(1,1)),DISP=(,PASS)
//SYSIN DD *
SORT FIELDS=(77,8,PD,A)
OUTFIL FNAMES=SORT7,INCLUDE=(31,2,BI,EQ,X'03EF'),
OUTREC=(77,8)
OUTFIL FNAMES=SORT8,INCLUDE=(31,2,BI,EQ,X'03F0'),
OUTREC=(77,8)
/*
STEP 2 - &&BOTHC -> has list of accounts with both tran codes
//STEP2 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTJNF1 DD DSN=&&ONLY7,DISP=(OLD,DELETE)
//SORTJNF2 DD DSN=&&ONLY8,DISP=(OLD,DELETE)
//BOTH DD DSN=&&BOTHC,UNIT=SYSDA,SPACE=(CYL,(1,1)),DISP=(,PASS)
//SYSIN DD *
JOINKEYS F1=SORTJNF1,FIELDS=(1,8,PD,A)
JOINKEYS F2=SORTJNF2,FIELDS=(1,8,PD,A)
JOIN UNPAIRED F1,F2
REFORMAT FIELDS=(F1:1,8)
SORT FIELDS=(1,8,PD,A)
/*
STEP3 - Excludes accounts that have both the tran code
//STEP3 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//JOININ1 DD DSN=INPUT.FILE,DISP=SHR
//JOININ2 DD DSN=&&BOTHC,DISP=(OLD,DELETE)
//SORTOUT DD DSN=YOUR.OUTPUT.FILE,UNIT=SYSDA,SPACE=(CYL,(1,1)),
// DISP=(NEW,CATLG,DELETE)
//SYSIN DD *
JOINKEYS F1=SORTJNF1,FIELDS=(77,8,PD,A)
JOINKEYS F2=SORTJNF2,FIELDS=(1,8,PD,A)
JOIN UNPAIRED,F1,ONLY
REFORMAT FIELDS=(F1:1,292)
INCLUDE COND=(31,2,BI,EQ,x'03EF')
/*
But getting the empty output file, though the input file is having records.
Could you please help me on this
Thank you,
Yalini. |
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2264 Location: USA
|
|
|
|
There are so many senseless issues, that it is easier not to fix them, but start from scratch.
For test purposes only: generate automatically the test file in required format:
| Code: |
//*====================================================================
//* preparation step only, to generate appropriate test file
//*====================================================================
//GENBIN EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//*
//SORTIN DD *
345677888 1007
222222222 1007
111111111 1008
345677888 1008
111111111 1007
//*-+----1----+
//MASTER@ DD SYSOUT=* debug output
//MASTER DD DISP=(NEW,PASS),SPACE=(TRK,(10,10),RLSE),
// RECFM=FB,LRECL=292,
// DSN=&&MASTER
//SYSIN DD *
* reformat test record to giveen requirements
INREC OVERLAY=(77:1,8,ZD,TO=PDF,LENGTH=8,
31:11,4,ZD,TO=BI,LENGTH=2)
SORT FIELDS=COPY
OUTFIL FNAMES=(MASTER,MASTER@),
OVERLAY=(292:X'00') extend test record to full length
//* |
Finally, real step suitable for production run with any input file:
| Code: |
//*====================================================================
//* actual production step to handle any given input file
//*====================================================================
//GENFILE EXEC PGM=SYNCTOOL
//TOOLMSG DD SYSOUT=*
//SSMSG DD SYSOUT=*
//*
//MASTER DD DISP=(OLD,PASS),DSN=&&MASTER
//DETAIL@ DD SYSOUT=* debug output
//DETAIL DD DISP=(NEW,PASS),SPACE=(TRK,(10,10),RLSE),
// DSN=&&DETAIL
//TOOLIN DD *
SORT FROM(MASTER) TO(DETAIL) USING(FIND)
COPY JKFROM TO(OUTPUT) USING(JOIN)
//*
//FINDCNTL DD *
SORT FIELDS=(77,8,PD,A,
31,2,BI,A)
OUTFIL FNAMES=(DETAIL,DETAIL@),
OMIT=(31,2,BI,EQ,+1007), all accounts with bad transactions
REMOVECC,NODETAIL, leave a single record for any bad account
SECTIONS=(77,8,31,2,
TRAILER3=(1,84))
//*
//JOINCNTL DD *
JOINKEYS F1=MASTER,FIELDS=(77,8,A)
JOINKEYS F2=DETAIL,FIELDS=(77,8,A)
JOIN UNPAIRED,F1,ONLY exclude any account having bad transaction
INCLUDE COND=(31,2,BI,EQ,+1007) leave only good transactions
//*
//OUTPUT DD SYSOUT=*
//*==================================================================== |
|
|
| Back to top |
|
 |
Yalini75
New User
Joined: 06 Aug 2025 Posts: 3 Location: USA
|
|
|
|
Thank you so much for the reply!
Final output is empty.
Total input records : 22036
Accounts which are having 1007&1008 combinations - 14817
My final output should have - 7219 Records.
First step is working fine. Checked MAster@ -> Having records.
But in the second step - Detail@ - is having only 16 records and no Output is written. |
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2264 Location: USA
|
|
|
|
Start your test WITH SMALL TEST INPUT FILE, before going to production thousands of records.
With your initial example the result is fine. You are given FULL SOLUTION, from top to bottom. Please, do your own part by yourself: DEBUG THE GIVEN CODE.
Do you know what “debugging” means?
P.S.
I hope you do understand that the first step is presented only to generate test data.
For production run only the second step is needed. |
|
| Back to top |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1429 Location: Bamberg, Germany
|
|
|
|
Wouldn't this be sufficient? F1 and F2 have to point to the same Dataset.
| Code: |
//SYSIN DD *
OPTION COPY
JOINKEYS F1=F1,FIELDS=(77,8,A)
JOINKEYS F2=F2,FIELDS=(77,8,A)
JOIN UNPAIRED,F1,ONLY
END
/*
//JNF2CNTL DD *
OMIT COND=(31,2,BI,EQ,+1007)
END
/* |
|
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2264 Location: USA
|
|
|
|
| Joerg.Findeisen wrote: |
Wouldn't this be sufficient? F1 and F2 have to point to the same Dataset.
| Code: |
//SYSIN DD *
OPTION COPY
JOINKEYS F1=F1,FIELDS=(77,8,A)
JOINKEYS F2=F2,FIELDS=(77,8,A)
JOIN UNPAIRED,F1,ONLY
END
/*
//JNF2CNTL DD *
OMIT COND=(31,2,BI,EQ,+1007)
END
/* |
|
1) SORT on both 77,8,PD and 31,2,BI is needed; the original records order is unknown.
2) duplicated pairs may need to be excluded before JOIN UNPAIRED, or not necessary?
3) in some situations same DSN for different DDs is not desired, though it is an option.
4) the TS has no desire to wiggle a finger. |
|
| Back to top |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1429 Location: Bamberg, Germany
|
|
|
|
| 1) Not needed. Tested with SYNCSORT/DFSORT. |
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2264 Location: USA
|
|
|
|
| Joerg.Findeisen wrote: |
| 1) Not needed. Tested with SYNCSORT/DFSORT. |
OK.
Will test as soon as I have time.
Thank you. |
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2264 Location: USA
|
|
|
|
| Joerg.Findeisen wrote: |
Wouldn't this be sufficient? F1 and F2 have to point to the same Dataset.
| Code: |
//SYSIN DD *
OPTION COPY
JOINKEYS F1=F1,FIELDS=(77,8,A)
JOINKEYS F2=F2,FIELDS=(77,8,A)
JOIN UNPAIRED,F1,ONLY
END
/*
//JNF2CNTL DD *
OMIT COND=(31,2,BI,EQ,+1007)
END
/* |
|
Yes, with JOIN UNPAIRED,ONLY really no sort is necessary.
The only problem: when input file(s) are huge, the intermediate join within SORT may create extremely huge temporary file, much bigger than the input one, though invisible to the customer.
The source can be slightly simplified:
| Code: |
//SYSIN DD *
OPTION COPY
JOINKEYS F1=MASTER1,FIELDS=(77,8,A)
JOINKEYS F2=MASTER2,FIELDS=(77,8,A),
INCLUDE=(31,2,BI,NE,+1007)
JOIN UNPAIRED,F1,ONLY
END
//* |
P.S.
I hate the namings like F1, F2, Var123, DD01, PROC22, etc. etc. |
|
| Back to top |
|
 |
Yalini75
New User
Joined: 06 Aug 2025 Posts: 3 Location: USA
|
|
|
|
Thank you so much Joerg.Findeisen and sergeyken!
This solution worked.
Regards,
Yalini. |
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2264 Location: USA
|
|
|
|
| Yalini75 wrote: |
Thank you so much Joerg.Findeisen and sergeyken!
This solution worked.
Regards,
Yalini. |
Please, do not forget about my notice on fast growing size of intermediate hidden join file when created without removing duplicates in the second file to join. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|