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
 

 

Merge data from multiple records to a single record

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

New User


Joined: 30 Sep 2006
Posts: 60

PostPosted: Tue Jun 24, 2008 11:46 pm    Post subject: Merge data from multiple records to a single record
Reply with quote

Hi,

I have a file that has the data in the following format:

Code:

Id  Pos  Num Comment (Heading not part of file)
-------------------------------------------------------
Id1 Pos1 N1  Id1-Comment
Id1 Pos2 N2  Id1-Comment
Id1 Pos3 N3  Id1-Comment
Id2 Pos1 N1  Id2-Comment
Id2 Pos3 N2  Id2-Comment
Id3 Pos1 N1  Id3-Comment
Id3 Pos2 N5  Id3-Comment
Id4 Pos3 N6  Id4-Comment


The input file is FB of 80 bytes. The fields are:
ID 9(13)
Pos 9(4)
Num 9(5)
Comment X(58)


I need to reformat this file such that the data for a particular id is a single record with the data for the 3 positions concatenated.

Required Output
Code:

      Pos1 Pos2 Pos3
Id1 N1    N2     N3     Id1-Comment
Id2 N1             N2     Id2-Comment
Id3 N1    N5              Id3-Comment
Id4                  N6     Id4-Comment


I will have only 3 values of Pos in the input file - Pos1, Pos2 and Pos3.

Can this be done using splice?

Aneesh.
Back to top
View user's profile Send private message

Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Jun 25, 2008 1:19 am    Post subject: Reply to: Merge data from multiple records to a single recor
Reply with quote

Aneesh,

The following DFSORT JCL will give you the desired results. I assumed that pos field actually contains a number 1 ,2, 3 to designate the number

Code:

//STEP0100 EXEC PGM=ICEMAN 
//SYSOUT   DD SYSOUT=*     
//SORTIN   DD DSN=YOUR INPUT FILE,
//            DISP=SHR
//SORTOUT  DD DSN=your output file,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE)
//SYSIN    DD *                                         
  OPTION EQUALS                                         
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:16X'00')),       
        IFTHEN=(WHEN=(14,4,ZD,EQ,1),OVERLAY=(82:18,5)),
        IFTHEN=(WHEN=(14,4,ZD,EQ,2),OVERLAY=(87:18,5)),
        IFTHEN=(WHEN=(14,4,ZD,EQ,3),OVERLAY=(92:18,5)) 
  SORT FIELDS=(01,13,CH,A)                             
  SUM FIELDS=(81,8,89,8),FORMAT=BI                     
  OUTFIL BUILD=(1,13,82,15,23,58)                       
/*


Hope this helps...

Cheers
Back to top
View user's profile Send private message
Aneesh

New User


Joined: 30 Sep 2006
Posts: 60

PostPosted: Wed Jun 25, 2008 2:36 am    Post subject: Reply to: Merge data from multiple records to a single recor
Reply with quote

Thanks a lot.
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: Wed Aug 06, 2008 4:29 am    Post subject:
Reply with quote

You can now do this kind of thing with the new SELECT WITHANY function of DFSORT's ICETOOL available with z/OS DFSORT V1R5 PTF UK90013 (July, 2008) like this:

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//IN DD DSN=...  input file
//OUT DD DSN=...  output file
//TOOLIN DD *
SPLICE FROM(IN) TO(OUT) ON(1,13,CH) WITHANY KEEPNODUPS -
  WITH(14,5) WITH(19,5) WITH(24,5) USING(CTL1)
/*
//CTL1CNTL DD *
   INREC IFTHEN=(WHEN=(14,4,ZD,EQ,1),
           BUILD=(1,13,14:18,5,29:23,58)),
    IFTHEN=(WHEN=(14,4,ZD,EQ,2),
           BUILD=(1,13,19:18,5,29:23,58)),
    IFTHEN=(WHEN=(14,4,ZD,EQ,3),
           BUILD=(1,13,24:18,5,29:23,58))
/*


For complete details on the new WITHANY function and the other new functions available with PTF UK90013, see:

www.ibm.com/systems/support/storage/software/sort/mvs/ugpf/
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 Replace values in the input data Vikas Maharnawar DFSORT/ICETOOL 10 Thu May 11, 2017 2:18 pm
No new posts Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm
No new posts Adding big TEXT lines to each record ... bshkris SYNCSORT 4 Sat May 06, 2017 1:40 am
No new posts Unable to create multiple files using... mbattu COBOL Programming 3 Fri May 05, 2017 5:35 pm
This topic is locked: you cannot edit posts or make replies. Merge two files and update Trailer re... Yashashri JCL & VSAM 1 Thu May 04, 2017 12:54 pm


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