IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

writing combined record as well as header record usig sort


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
useit

Active User


Joined: 05 Oct 2006
Posts: 152

PostPosted: Mon Sep 19, 2011 11:23 am
Reply with quote

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
View user's profile Send private message
THINKSRINIII
Warnings : 1

New User


Joined: 09 Jan 2009
Posts: 88
Location: India

PostPosted: Mon Sep 19, 2011 5:30 pm
Reply with quote

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
View user's profile Send private message
THINKSRINIII
Warnings : 1

New User


Joined: 09 Jan 2009
Posts: 88
Location: India

PostPosted: Mon Sep 19, 2011 5:42 pm
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Mon Sep 19, 2011 11:04 pm
Reply with quote

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
View user's profile Send private message
useit

Active User


Joined: 05 Oct 2006
Posts: 152

PostPosted: Tue Sep 20, 2011 10:28 am
Reply with quote

hi all,

A Hearty Thanks..!

Its working fine:) thank you very much for providing a solution

Regds,
useit
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts To find whether record count are true... DFSORT/ICETOOL 6
Search our Forums:

Back to Top