View previous topic :: View next topic
Author
Message
useit Active User Joined: 05 Oct 2006Posts: 152
hi,
i have two files.first file is as below
in file1:
there can be multiple product id under same product number.
product number productid unit-size
(1-9) (10-18) (19-25)
050000111 000000008 10000.00
050000111 000000009 11000.00
050000222 000000100 20000.10
050000222 000000109 22000.10
050000333 000000128 30000.10
050000333 000000133 32000.10
in file2:
whse productid total-count
175 000000008 100.00
175 000000009 200.10
500 000000100 300.10
500 000000109 400.10
120 000000128 500.10
120 000000133 600.10
i have to compare two files based on the product ids. if matches i have to write joined record as below.(i know this is possible using joinkey)
but problem here is i need to write header record also.
(whse and product number as header
output file:
175 050000111 -Header
175 050000111 000000008 10000.00 100.00
175 050000111 000000009 11000.00 200.10
500 050000222 -Header
500 050000222 000000100 20000.10 300.10
500 050000222 000000109 22000.10 400.10
500 050000333 -Header
120 050000333 000000128 30000.10 500.10
120 050000333 000000133 32000.10 600.10
output layout is as below.
01 HEADER.
05 KEY.
10 WHSE PIC 999.
10 PRODUCT-NO PIC 9(9).
05 FILLER PIC X(12).
01 DETAIL REDEFINES HEADER.
05 KEY.
10 WHSE PIC 999.
10 PRODUCT-NO PIC 9(9).
05 JLDSPD-DATA.
10 PRODUCT-ID PIC 9(9).
10 UNIT-SIZE PIC 9(5)V99
10 TOTAL-COUNT PIC 9(3)V99
please help me in this regard.
Regds,
useit
Back to top
THINKSRINIII Warnings : 1 New User Joined: 09 Jan 2009Posts: 88 Location: India
Hi,
You can use joinkeys to get the records in the required format and then use the sort card below to add header accordingly.
Code:
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL REMOVECC,SECTIONS=(1,14,
HEADER3=(1,14))
Back to top
THINKSRINIII Warnings : 1 New User Joined: 09 Jan 2009Posts: 88 Location: India
Here it is:
Code:
//SYSIN DD *
SORT FIELDS=COPY
JOINKEYS FILE=F1,FIELDS=(11,9,A)
JOINKEYS FILE=F2,FIELDS=(5,9,A)
REFORMAT FIELDS=(F2:1,4,F1:1,29,F2:15,6)
OUTFIL REMOVECC,SECTIONS=(1,14,
HEADER3=(1,14))
Check it out
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
useit,
It would have helped if you'd given the starting position and length for each field in each file, but based on what you described, I believe the following DFSORT job will give you what you want:
Code:
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//IN1 DD DSN=... input file1 (FB/25)
//IN2 DD DSN=... input file2 (FB/17)
//SORTOUT DD DSN=... output file (FB/33)
//SYSIN DD *
JOINKEYS F1=IN1,FIELDS=(10,9,A),SORTED
JOINKEYS F2=IN2,FIELDS=(4,9,A),SORTED
REFORMAT FIELDS=(F2:1,3,F1:1,25,F2:13,5)
OPTION COPY
OUTFIL REMOVECC,
SECTIONS=(1,12,
HEADER3=(1,12))
/*
If I didn't get the positions and lengths right, adjust as appropriate.
Back to top
useit Active User Joined: 05 Oct 2006Posts: 152
hi all,
A Hearty Thanks..!
Its working fine:) thank you very much for providing a solution
Regds,
useit
Back to top
Please enable JavaScript!