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

How to modify the first record alone using Sort.


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

New User


Joined: 21 Sep 2006
Posts: 5

PostPosted: Tue Jan 22, 2008 8:27 pm
Reply with quote

The input file is

01UPC|BRAND|ITEM|U_SIZE|UNIT_OF_MEASURE|GROUP|
02UPC|HEALTH_CONDITION
03UPC|SUBSEGMENT
U|01|000004201943|GEROLSTEINER|Gerolsteiner Sp
U|03|000004201943|OGNONE
U|01|000004207705|DR HAUSCHKA|Dr Hauschka Lip
U|03|000004207705|OGCTBC


I was just loooking for a way to add a pipe symbol to the first 3 records alone.


where the output should be

|01UPC|BRAND|ITEM|U_SIZE|UNIT_OF_MEASURE|GROUP|
|02UPC|HEALTH_CONDITION
|03UPC|SUBSEGMENT
U|01|000004201943|GEROLSTEINER|Gerolsteiner Sp
U|03|000004201943|OGNONE
U|01|000004207705|DR HAUSCHKA|Dr Hauschka Lip
U|03|000004207705|OGCTBC

Can you please guide me on this.

Thanks,
Hema
Back to top
View user's profile Send private message
Ganesh.Deokar

New User


Joined: 30 Sep 2005
Posts: 26
Location: Buffalo,NY

PostPosted: Tue Jan 22, 2008 9:22 pm
Reply with quote

What is the input record length? what should be the output record length.

I tried this one with input lrecl as 80.

Code:
//SRT80301 EXEC PGM=SORT                                               
//*                                                                     
//SYSOUT   DD SYSOUT=*                                                 
//SYSPRINT DD SYSOUT=*                                                 
//*                                                                     
//SORTIN   DD DSN=YOUR.SORTIN.FILE,DISP=SHR                   
//SORTOUT  DD DSN=YOUR.SORTOUT.FILE,DISP=(NEW,CATLG,DELETE), 
//         SPACE=(TRK,(1,1)),DCB=*.SORTIN                               
//SYSIN    DD *                                                         
 SORT FIELDS=COPY                                                       
 INREC BUILD=(1,80,81:SEQNUM,8,ZD)                                     
 OUTREC IFTHEN=(WHEN=(81,8,ZD,LE,3),                                   
        BUILD=(1:C'|',2:1,80)),                                         
        IFTHEN=(WHEN=(81,8,ZD,GT,3),                                   
        BUILD=(1:1,80))                                                 
/*                                                                     
//                                                     
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: Tue Jan 22, 2008 10:39 pm
Reply with quote

Hema,

I assumed your input file has RECFM=FB and LRECL=80 and you want that for the output too, but the jobs can be changed for other attributes.

If the first three records can be identified by not having 'U' in position 1, then you can use a DFSORT job like this:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
01UPC|BRAND|ITEM|U_SIZE|UNIT_OF_MEASURE|GROUP|
02UPC|HEALTH_CONDITION
03UPC|SUBSEGMENT
U|01|000004201943|GEROLSTEINER|Gerolsteiner Sp
U|03|000004201943|OGNONE
U|01|000004207705|DR HAUSCHKA|Dr Hauschka Lip
U|03|000004207705|OGCTBC
/*
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
  OPTION COPY
  INREC IFTHEN=(WHEN=(1,1,CH,NE,C'U'),
    BUILD=(C'|',1,79))
/*


If the first three records can only be identified as the first three records, then you can use a DFSORT job like this:

Code:

//S2    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
01UPC|BRAND|ITEM|U_SIZE|UNIT_OF_MEASURE|GROUP|
02UPC|HEALTH_CONDITION
03UPC|SUBSEGMENT
U|01|000004201943|GEROLSTEINER|Gerolsteiner Sp
U|03|000004201943|OGNONE
U|01|000004207705|DR HAUSCHKA|Dr Hauschka Lip
U|03|000004207705|OGCTBC
/*
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
  OPTION COPY
  INREC IFOUTLEN=80,
   IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD)),
   IFTHEN=(WHEN=(81,8,ZD,LE,+3),BUILD=(C'|',1,79))
/*
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Tue Jan 22, 2008 11:31 pm
Reply with quote

Hemamalini Vasudevan
As per your sample i/p records i observerd that there is a PIPE(|) in 2nd position of every record other than the first 3 records....If that is the case u can use the below untested SORT card.

Code:
//S2    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
01UPC|BRAND|ITEM|U_SIZE|UNIT_OF_MEASURE|GROUP|
02UPC|HEALTH_CONDITION
03UPC|SUBSEGMENT
U|01|000004201943|GEROLSTEINER|Gerolsteiner Sp
U|03|000004201943|OGNONE
U|01|000004207705|DR HAUSCHKA|Dr Hauschka Lip
U|03|000004207705|OGCTBC
/*
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
  OPTION COPY
  INREC IFOUTLEN=80,
      IFTHEN=(WHEN=(2,1,CH,NE,C'|'),BUILD=(C'|',1,79))
/*
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: Tue Jan 22, 2008 11:38 pm
Reply with quote

Krisprems,

Your job is similar to my first job -it just checks a different value. This technique can be used for any value that will identify one set of records vs the other set of records.

Note that you don't need IFOUTLEN=80 since the input records are 80 bytes and the record you're building is 80 bytes.
Back to top
View user's profile Send private message
Hemamalini Vasudevan

New User


Joined: 21 Sep 2006
Posts: 5

PostPosted: Wed Jan 23, 2008 11:21 am
Reply with quote

Thanks a lot. Yes with INREC IFTHEN BUILD i was able to add PIPE to the first 3 records.

I tried all the options and it worked. Thanks a lot, i learned new syntax in sort.
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Wed Jan 23, 2008 2:05 pm
Reply with quote

Frank Yaeger wrote:
Krisprems,

Your job is similar to my first job
Infact i copy pasted your JOB and made the modifications icon_wink.gif
-it just checks a different value. This technique can be used for any value that will identify one set of records vs the other set of records.
I do agree, but i just thought that since we know how the records are in the sample i/p, we could avoid the sequence numbering.

Note that you don't need IFOUTLEN=80 since the input records are 80 bytes and the record you're building is 80 bytes.
Yes, i realised it ...(i didnt get a chance to test it....so..)
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 Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
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
Search our Forums:

Back to Top