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

Merge data from multiple records to a single record


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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
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
Reply with quote

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

Use [URL] BBCode for External Links
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 Compare 2 files and retrive records f... DFSORT/ICETOOL 0
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Store the data for fixed length COBOL Programming 1
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
Search our Forums:

Back to Top