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
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?
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.
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).
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
£
----+----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
However, C6-K90014 tells me that you don't have the Nov, 2009 PTF so you can't use JOINKEYS. Ask your System Programmer to install that PTF (it's free). For more information on the PTF, see: