Page 1 of 1

Moving the record

PostPosted: Mon Oct 20, 2008 9:05 pm
by ranga_subham
Hi,

Would you please tell me how to achieve it using SORT?

Input:
AAA
BBB
CCC


Expected Output:

AAA     
   BBB   
      CCC


Thank you.

Re: Moving the record

PostPosted: Tue Oct 21, 2008 12:18 am
by Alissa Margulies
Try the following:
//SORT     EXEC PGM=SORT                 
//SORTIN   DD *
AAA
BBB
CCC
//SORTOUT  DD DSN=OUTPUT.DATA                                     
//SYSOUT   DD SYSOUT=*                                     
//SYSIN    DD *                         
    SORT FIELDS=COPY                       
    OUTREC IFTHEN=(WHEN=INIT,             
      OVERLAY=(10:SEQNUM,1,ZD)),     
      IFTHEN=(WHEN=(10,1,CH,EQ,C'1'),
      BUILD=(1:1,3,6Z)),             
      IFTHEN=(WHEN=(10,1,CH,EQ,C'2'),
      BUILD=(3Z,4:1,3,3Z)),           
      IFTHEN=(WHEN=(10,1,CH,EQ,C'3'),
      BUILD=(6Z,7:1,3))
/*

Re: Moving the record

PostPosted: Tue Oct 21, 2008 3:12 pm
by ranga_subham
Excellent...........thanks Alissa.....

Does the 3Z or 6Z use zeros?

Disadvantages with this job !

PostPosted: Tue Oct 21, 2008 3:41 pm
by ranga_subham
Alissa, With the below job I could produce the same.

//STEP0002 EXEC PGM=SORT                               
//SORTIN   DD *                                         
AAA                                                     
BBB                                                     
CCC                                                     
/*                                                     
//SORTOUT  DD SYSOUT=*                                 
//SYSOUT   DD SYSOUT=*                                 
//SYSIN    DD *                                         
 SORT FIELDS=COPY                                       
 OUTREC IFTHEN=(WHEN=(1,3,CH,EQ,C'AAA'),BUILD=(1,3)),   
        IFTHEN=(WHEN=(1,3,CH,EQ,C'BBB'),BUILD=(3X,1,3)),
        IFTHEN=(WHEN=(1,3,CH,EQ,C'CCC'),BUILD=(6X,1,3))
/*


Please let me know if this is incorrect and the disadvantages.

Thanks for your time.

Re: Disadvantages with this job !

PostPosted: Tue Oct 21, 2008 5:59 pm
by ranga_subham
I am very sorry for creating a new post instead of replying to "Moving the record". :shock:

I request the moderator to combine this into "Moving the record". :|

Thanks.

Re: Moving the record

PostPosted: Tue Oct 21, 2008 7:36 pm
by Alissa Margulies
ranga_subham wrote:Does the 3Z or 6Z use zeros?

Yes, they are X'00'. If you would prefer actual blanks (X'40'), then in this application, you can specify 3X or 6X.

Re: Moving the record

PostPosted: Tue Oct 21, 2008 8:48 pm
by ranga_subham
Thanks for the info.......