Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

writing combined record as well as header record usig sort

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
useit

Active User


Joined: 05 Oct 2006
Posts: 144

PostPosted: Mon Sep 19, 2011 11:23 am    Post subject: writing combined record as well as header record usig sort
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    Post subject:
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    Post subject:
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 Moderator


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

PostPosted: Mon Sep 19, 2011 11:04 pm    Post subject:
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: 144

PostPosted: Tue Sep 20, 2011 10:28 am    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SORT to unpack a feild shr_amar DFSORT/ICETOOL 7 Fri Jul 07, 2017 4:32 am
No new posts How to add header with Date(YYMMDD) i... Rajan Moorthy DFSORT/ICETOOL 2 Thu Jul 06, 2017 11:44 pm
No new posts How to write Specific Fields from Mul... Padhu SYNCSORT 6 Thu Jul 06, 2017 10:26 am
No new posts Writing a file using online program grvtomar PL/I & Assembler 3 Fri Jun 30, 2017 1:06 pm
No new posts Optimize sort inrec parse vishwakotin DFSORT/ICETOOL 6 Mon Jun 26, 2017 11:15 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us