|
View previous topic :: View next topic
|
| Author |
Message |
THINKSRINIII Warnings : 1 New User
.jpg)
Joined: 09 Jan 2009 Posts: 88 Location: India
|
|
|
|
Hi Guys,
I am trying to read two files and update based on the following
File 1- Reference file
| Code: |
CustomerNumber Receipt Number
1301A 3000
1501A 0501
1507A 9800
|
File 2 - Input file
| Code: |
Control Customer
1301A
body
trailer
Control Vendor
body
trailer
Control Customer
1507A
body
trailer
|
If column 1 to 7 of the Input file is "Control" then we needto check whether column 35 - 42 is "Customer". If it is customer then check for the next line for the customer number from the input file, match it with the reference file and populate the input file with the receipt number from column 6 to 10 and increment the receipt number in the reference file
OUTPUT :
| Code: |
Control Customer
1301A 3000
body
trailer
Control Vendor
body
trailer
Control Customer
1507A 9800
body
trailer
|
Reference file after the job runs
| Code: |
CustomerNumber Receipt Number
1301A 3001
1501A 0501
1507A 9801
|
Appreciate if someone could shed light on how to go about this using DFSORT
Thanks |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
THINKSRINIII,
What is the LRECL and RECFM of the input and output files? |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
THINKSRINIII,
What happens if the receipt number is 9999 and when you increment it would be a 5 byte number (10000). Do you go back to zero? or is the receipt number a field that can accommodate large numbers? If so what is the format of it? |
|
| Back to top |
|
 |
THINKSRINIII Warnings : 1 New User
.jpg)
Joined: 09 Jan 2009 Posts: 88 Location: India
|
|
|
|
Hi Kolusu,
Apologize for not posting those details earlier.
Both the files are FB
Reference file LRECL 23
Input file LRECL 115
And yes the Number should be back to '0000' once it reaches '9999'
Receipt number field can accommodate only 4 digits (integer)
The reference file is presorted by Customer number and there may be multiple records for the same customer number in the input file.
Many thanks for your help! |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
THINKSRINIII,
The following DFSORT jcl will give you the desired results. Since you haven't mentioned the positions of the key and the counter , I assumed them to be at pos 1 (key ) and counter at pos 15 for counter.
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//REF DD DSN=Your 23 byte ref file,DISP=SHR
//INP DD DSN=your input 115 fb file,DISP=SHR
//OUT1 DD SYSOUT=*
//OUT2 DD DSN=&&T,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE)
//SYSIN DD *
OPTION COPY
JOINKEYS F1=REF,FIELDS=(1,7,A)
JOINKEYS F2=INP,FIELDS=(1,7,A)
JOIN UNPAIRED
REFORMAT FIELDS=(F2:1,123,?,F1:1,23)
OUTFIL FNAMES=OUT1,INCLUDE=(124,1,SS,EQ,C'B,1'),
IFOUTLEN=23,IFTHEN=(WHEN=INIT,BUILD=(125,23,124,1)),
IFTHEN=(WHEN=(24,1,CH,EQ,C'B'),
OVERLAY=(15:15,4,ZD,ADD,+1,EDIT=(TTTT)))
OUTFIL FNAMES=OUT2,INCLUDE=(124,1,SS,EQ,C'B,2'),
IFOUTLEN=123,IFTHEN=(WHEN=(124,1,CH,EQ,C'B'),OVERLAY=(7:139,4))
/*
//JNF2CNTL DD *
INREC OVERLAY=(116:SEQNUM,8,ZD)
//*
//STEP0200 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=&&T,DISP=SHR
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=(116,8,CH,A)
OUTREC BUILD=(1,115)
//* |
|
|
| Back to top |
|
 |
THINKSRINIII Warnings : 1 New User
.jpg)
Joined: 09 Jan 2009 Posts: 88 Location: India
|
|
|
|
Hi kolusu,
Many thanks. Could you please let me know where we are checking for the word "Control" and "Customer" in the input file. The reference file does not have a header "Customer number" and "Receipt Number"( I have mentioned that just for a reference here).
Thanks |
|
| Back to top |
|
 |
THINKSRINIII Warnings : 1 New User
.jpg)
Joined: 09 Jan 2009 Posts: 88 Location: India
|
|
|
|
This the message i got when i tried to execute it
| Code: |
ICE143I 0 BLOCKSET COPY TECHNIQUE SELECTED
ICE250I 0 VISIT http://www.ibm.com/storage/dfsort FOR DFSORT PAPERS, EXAMPLES AN
ICE000I 1 - CONTROL STATEMENTS FOR 5694-A01, Z/OS DFSORT V1R10 - 03:30 ON TUE JU
OPTION COPY
JOINKEYS F1=REF,FIELDS=(1,7,A)
£
ICE005A 0 BLANK NEEDED IN COLUMN 1 OR OPERATION NOT DEFINED CORRECTLY
JOINKEYS F2=INP,FIELDS=(1,7,A)
£
ICE005A 0 BLANK NEEDED IN COLUMN 1 OR OPERATION NOT DEFINED CORRECTLY
JOIN UNPAIRED
£
|
|
|
| Back to top |
|
 |
CICS Guy
Senior Member

Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
Please post all of your input and ALL of your output.
That will help to determine the PTF level you are at and why you got those errors. |
|
| Back to top |
|
 |
THINKSRINIII Warnings : 1 New User
.jpg)
Joined: 09 Jan 2009 Posts: 88 Location: India
|
|
|
|
Hello there,
Here are the input and expected output files.
1. input file
| Code: |
----+----1----+----2----+----3----+----4----+----5----+----6-
***************************** Top of Data *******************
CONTROL CUSTOMER
1501A FO IFO6028
BODY 0670
TRAILER 1501B
CONTROL
1501B FO IFO6028
BODY 0670
TRAILER 1501B
CONTROL CUSTOMER
1501C FO IFO6028
BODY 0670
TRAILER 1501B
|
2. reference file
| Code: |
----+----1----+----2---
***************************** Top of Data ***
CUSTOMER NUMBER
1501A 2170
1501B 5350
1501C 0026
1501D 0001
1501G 1330
1501H 0036
|
Expected Output:
1. Output file
| Code: |
----+----1----+----2----+----3----+----4----+----5----+----6--
***************************** Top of Data ********************
CONTROL
1501A 2171 FO IFO6028
BODY 0670
TRAILER 1501B
CONTROL
1501B FO IFO6028
BODY 0670
TRAILER 1501B
CONTROL
1501C 0027 FO IFO6028
BODY 0670
TRAILER 1501C
|
2. Refr file after update
| Code: |
----+----1----+----2---
***************************** Top of Data ***
CUSTOMER NUMBER
1501A 2171
1501B 5350
1501C 0027
1501D 0001
1501G 1330
1501H 0036
|
output error message
| Code: |
ICE143I 0 BLOCKSET COPY TECHNIQUE SELECTED
ICE250I 0 VISIT http://www.ibm.com/storage/dfsort FOR DFSORT PAPERS, EXAMPLES A
ICE000I 1 - CONTROL STATEMENTS FOR 5694-A01, Z/OS DFSORT V1R10 - 03:30 ON TUE J
OPTION COPY
JOINKEYS F1=REF,FIELDS=(1,7,A)
£
ICE005A 0 BLANK NEEDED IN COLUMN 1 OR OPERATION NOT DEFINED CORRECTLY
JOINKEYS F2=INP,FIELDS=(1,7,A)
£
ICE005A 0 BLANK NEEDED IN COLUMN 1 OR OPERATION NOT DEFINED CORRECTLY
JOIN UNPAIRED
£
ICE005A 0 BLANK NEEDED IN COLUMN 1 OR OPERATION NOT DEFINED CORRECTLY
REFORMAT FIELDS=(F2:1,123,?,F1:1,23)
£
ICE005A 0 BLANK NEEDED IN COLUMN 1 OR OPERATION NOT DEFINED CORRECTLY
OUTFIL FNAMES=OUT1,INCLUDE=(124,1,SS,EQ,C'B,1'),
IFOUTLEN=23,IFTHEN=(WHEN=INIT,BUILD=(125,23,124,1)),
IFTHEN=(WHEN=(24,1,CH,EQ,C'B'),
OVERLAY=(15:15,4,ZD,ADD,+1,EDIT=(TTTT)))
OUTFIL FNAMES=OUT2,INCLUDE=(124,1,SS,EQ,C'B,2'),
IFOUTLEN=123,IFTHEN=(WHEN=(124,1,CH,EQ,C'B'),OVERLAY=(7:139,4))
ICE056A 0 SORTIN NOT DEFINED
ICE751I 0 C5-K48846 C6-K90014 C7-K45047 C8-K46331 E7-K48846
ICE052I 3 END OF DFSORT
|
|
|
| Back to top |
|
 |
dbzTHEdinosauer
Global Moderator

Joined: 20 Oct 2006 Posts: 6965 Location: porcelain throne
|
|
|
|
| ICE005A 0 BLANK NEEDED IN COLUMN 1 OR OPERATION NOT DEFINED CORRECTLY |
|
| Back to top |
|
 |
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
THINKSRINIII,
Your output shows that you don't have the PTF which supports Joinkeys . use the following DFSORT JCL which will give you the desired results
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=Your 23 byte reference file,DISP=SHR
//SORTOUT DD DSN=&&TMP,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE)
//HDR DD DSN=&&HDR,DISP=(,PASS),SPACE=(TRK,(1,0),RLSE)
//SYSIN DD *
OPTION COPY
OUTREC OVERLAY=(115:X)
OUTFIL FNAMES=HDR,REMOVECC,NODETAIL,HEADER1=(3C'$')
//*
//STEP0200 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=&&HDR,DISP=SHR,VOL=REF=*.STEP0100.HDR
// DD DSN=&&TMP,DISP=SHR
// DD DSN=&&HDR,DISP=SHR,VOL=REF=*.STEP0100.HDR
// DD DSN=your 115 byte input file,DISP=SHR
//OUT1 DD SYSOUT=*
//OUT2 DD SYSOUT=*
//SYSIN DD *
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'$$$'),PUSH=(116:ID=1)),
IFTHEN=(WHEN=GROUP,BEGIN=(1,7,CH,EQ,C'CONTROL'),
END=(1,7,CH,EQ,C'TRAILER'),PUSH=(118:ID=8,SEQ=8,1,115)),
IFTHEN=(WHEN=GROUP,BEGIN=(126,8,ZD,EQ,2),
END=(1,7,CH,EQ,C'TRAILER'),PUSH=(249:1,7)),
IFTHEN=(WHEN=(116,1,ZD,EQ,1),OVERLAY=(249:1,7))
SORT FIELDS=(249,7,CH,A),EQUALS
OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(256:SEQNUM,8,ZD,RESTART=(249,7))),
IFTHEN=(WHEN=GROUP,BEGIN=(256,8,ZD,EQ,1),PUSH=(117:116,1,264:1,23)),
IFTHEN=(WHEN=(116,2,ZD,EQ,21,AND,168,7,CH,EQ,C'CUSTOMER'),
OVERLAY=(278:278,4,ZD,ADD,+1,EDIT=(TTTT)))
OUTFIL FNAMES=OUT1,IFOUTLEN=115,
INCLUDE=(116,2,ZD,GE,21,AND,1,3,CH,NE,C'$$$',AND,249,7,CH,GT,C' '),
IFTHEN=(WHEN=(126,8,ZD,EQ,2,AND,168,7,CH,EQ,C'CUSTOMER'),
BUILD=(134,115,/,1,7,278,4,12,104)),
IFTHEN=(WHEN=(126,8,ZD,EQ,2,AND,168,7,CH,NE,C'CUSTOMER'),
BUILD=(134,115,/,1,115))
OUTFIL FNAMES=OUT2,BUILD=(23X),REMOVECC,NODETAIL,
INCLUDE=((116,2,ZD,EQ,11,AND,1,3,CH,NE,C'$$$'),OR,
(116,2,ZD,EQ,21,AND,256,8,ZD,EQ,2)),
SECTIONS=(249,7,TRAILER3=(264,23))
//* |
|
|
| Back to top |
|
 |
THINKSRINIII Warnings : 1 New User
.jpg)
Joined: 09 Jan 2009 Posts: 88 Location: India
|
|
|
|
Hi Kolusu,
Thanks a lot. it is working great.
"And yes the Number should be back to '0000' once it reaches '9999' "
can this number be back at 0001
Thanks |
|
| Back to top |
|
 |
THINKSRINIII Warnings : 1 New User
.jpg)
Joined: 09 Jan 2009 Posts: 88 Location: India
|
|
|
|
Hi Kolusu,
I have managed to figure that out. Many thanks for your help.
| Code: |
OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(256:SEQNUM,8,ZD,RESTART=(249,7))),
IFTHEN=(WHEN=GROUP,BEGIN=(256,8,ZD,EQ,1),PUSH=(117:116,1,264:1,23)),
IFTHEN=(WHEN=(116,2,ZD,EQ,21,AND,168,7,CH,EQ,C'CUSTOMER'),
OVERLAY=(278:278,4,ZD,ADD,+1,EDIT=(TTTT)),HIT=NEXT),
IFTHEN=(WHEN=(278,4,ZD,EQ,0000),
OVERLAY=(278:C'0001'))
|
|
|
| Back to top |
|
 |
Escapa
Senior Member

Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
Hi THINKSRINI,
Thanks for posting modified solution.  |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|