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

Syncsort - Combining two records into one


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
notonly4u

New User


Joined: 26 Apr 2005
Posts: 87
Location: Hyderabad

PostPosted: Mon Mar 07, 2011 4:54 pm
Reply with quote

Dear Friends,

I have a file with records like this:

Code:
Unix: /test/ama/file01/rm_ext/daily/source/AMR_BIU_EU_R03_H20110303_H
Unix: EDC_AMACAUBHSTAB.dat                                                     
Unix: /test/ama/file01/rm_ext/daily/source/AMR_BIU_EU_R03_H20110302_H
Unix: EDC_AMACAUBHSTAB.dat                                                     
Unix: /test/ama/file01/rm_ext/daily/source/AMR_BIU_EU_R03_H20110301_H
Unix: EDC_AMACAUBHSTAB.dat                                                     

I want the output like this:


Code:
Unix: /test/ama/file01/rm_ext/daily/source/AMR_BIU_EU_R03_H20110303_HEDC_AMACAUBHSTAB.dat 
Unix: /test/ama/file01/rm_ext/daily/source/AMR_BIU_EU_R03_H20110302_HEDC_AMACAUBHSTAB.dat     
Unix: /test/ama/file01/rm_ext/daily/source/AMR_BIU_EU_R03_H20110301_HEDC_AMACAUBHSTAB.dat

Is this possible?
Thanks for your time.

My input file is FB, 200 bytes.

Regards
Tanden
Back to top
View user's profile Send private message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Mon Mar 07, 2011 11:53 pm
Reply with quote

Tanden, try this and see..........

SORTCARD:
Code:

//SORT0001 EXEC PGM=SORT                                             
//SORTJNF1 DD *                                                       
UNIX: /TEST/AMA/FILE01/RM_EXT/DAILY/SOURCE/AMR_BIU_EU_R03_H20110303_H
UNIX: /TEST/AMA/FILE01/RM_EXT/DAILY/SOURCE/AMR_BIU_EU_R03_H20110302_H
UNIX: /TEST/AMA/FILE01/RM_EXT/DAILY/SOURCE/AMR_BIU_EU_R03_H20110301_H
//SORTJNF2 DD *                                                       
UNIX: EDC_AMACAUBHSTAB.DAT                                           
UNIX: EDC_AMACAUBHSTAB.DAT                                           
UNIX: EDC_AMACAUBHSTAB.DAT                                           
//SORTOUT  DD SYSOUT=*                                               
//SYSOUT   DD SYSOUT=*                                               
//SYSIN    DD *                                                       
  JOINKEYS FILE=F1,FIELDS=(1,4,A)                                     
  JOINKEYS FILE=F2,FIELDS=(1,4,A)                                     
  REFORMAT FIELDS=(F1:1,69,F2:7,20)                                   
  SORT FIELDS=(1,89,CH,A)                                             
  SUM FIELDS=NONE                                                     
  END                                                                 
/*                                                                   


Output:
Code:

UNIX: /TEST/AMA/FILE01/RM_EXT/DAILY/SOURCE/AMR_BIU_EU_R03_H20110301_HEDC_AMACAUBHSTAB.DAT
UNIX: /TEST/AMA/FILE01/RM_EXT/DAILY/SOURCE/AMR_BIU_EU_R03_H20110302_HEDC_AMACAUBHSTAB.DAT
UNIX: /TEST/AMA/FILE01/RM_EXT/DAILY/SOURCE/AMR_BIU_EU_R03_H20110303_HEDC_AMACAUBHSTAB.DAT


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

New User


Joined: 26 Apr 2005
Posts: 87
Location: Hyderabad

PostPosted: Tue Mar 08, 2011 8:15 am
Reply with quote

Ramsri,

Thanks for your reply.
In this case, first I should split the records into two different files.

I do not want to take the risk as the order should not be changed in case of split since there is a possiblity that the file names inside the file could be different.

Regards
Tanden
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19245
Location: Inside the Matrix

PostPosted: Tue Mar 08, 2011 8:39 am
Reply with quote

Hello,

If the combined input file has the records in the right order and there is only 1 of each record for each pair, splitting the files will certainly not change the sequence of the records. . .

Why might you believe that spiltting the records would change the order?

If there are hundreds of millions of input records, splitting the records into 2 files might not be acceptable, but if the volume is small, using 2 temporary files should not be a problem.
Back to top
View user's profile Send private message
Ronald Burr

Active User


Joined: 22 Oct 2009
Posts: 293
Location: U.S.A.

PostPosted: Tue Mar 08, 2011 6:31 pm
Reply with quote

Tanden,
If the input records ALWAYS come in pairs, as shown in your example, one way to combine them without fancy sort techniques would be to simply override the input LRECL so that the I/O routines are led to believe that each input record is 400 bytes long instead of only 200 bytes long - as follows:
Code:

//STEP1 EXEC PGM=SORT           
//SORTIN   DD DSN=your.input.dsn,DISP=SHR,
//            DCB=(RECFM=FB,LRECL=400)
//SORTOUT  DD DSN=your.output.dsn,UNIT=xxxx,DISP=xxx,
//            DCB=(RECFM=FB,LRECL=200),
//            SPACE=xxxx
//SYSOUT   DD SYSOUT=*                                               
//SYSIN    DD *                                                       
  SORT FIELDS=COPY
  OUTREC FIELDS=(1,69,207,20,111X)                                                   
  END                                                                 
/*
Back to top
View user's profile Send private message
Alissa Margulies

SYNCSORT Support


Joined: 25 Jul 2007
Posts: 496
Location: USA

PostPosted: Wed Mar 09, 2011 12:24 am
Reply with quote

If you are not able to split the input file and utilize the JOIN REFORMAT feature, then here is another alternative:
Code:
//SORT1 EXEC PGM=SORT                                                 
//SORTIN  DD *                                                       
UNIX: /TEST/AMA/FILE01/RM_EXT/DAILY/SOURCE/AMR_BIU_EU_R03_H20110303_H
UNIX: EDC_AMACAUBHSTAB.DAT                                           
UNIX: /TEST/AMA/FILE01/RM_EXT/DAILY/SOURCE/AMR_BIU_EU_R03_H20110302_H
UNIX: EDC_AMACAUBHSTAB.DAT                                           
UNIX: /TEST/AMA/FILE01/RM_EXT/DAILY/SOURCE/AMR_BIU_EU_R03_H20110301_H
UNIX: EDC_AMACAUBHSTAB.DAT                                           
//SORTOUT DD SYSOUT=*                                                 
//SYSOUT  DD SYSOUT=*                                                 
//SYSIN   DD *                                                       
  INREC IFTHEN=(WHEN=GROUP,RECORDS=2,PUSH=(91:ID=8,99:SEQ=1)),       
        IFTHEN=(WHEN=(99,1,ZD,EQ,1),BUILD=(1,69,21Z,91,8)),           
        IFTHEN=(WHEN=NONE,BUILD=(69Z,7,21,91,8))                     
  SORT FIELDS=(91,8,ZD,A)                                             
  SUM FIELDS=(1,8,BI,9,8,BI,17,8,BI,25,8,BI,33,8,BI,41,8,BI,49,8,BI, 
    57,8,BI,65,8,BI,73,8,BI,81,8,BI,89,2,BI)                         
  OUTREC BUILD=(1,89)                                                 
/*                                                                   
Back to top
View user's profile Send private message
notonly4u

New User


Joined: 26 Apr 2005
Posts: 87
Location: Hyderabad

PostPosted: Wed Mar 09, 2011 9:42 am
Reply with quote

Hello Alissa,

It works perfect.
Thank you verymuch for your time.

Regards
Tanden
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
This topic is locked: you cannot edit posts or make replies. Sort to include records of file 2 int... Java & MQSeries 1
No new posts Cobol program to determine the sequen... COBOL Programming 2
No new posts Arithmetic division using Syncsort SYNCSORT 6
No new posts Merge a variable number of records fr... DFSORT/ICETOOL 5
This topic is locked: you cannot edit posts or make replies. SUM based on two conditions using SYN... SYNCSORT 7
Search our Forums:

Back to Top