MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Convert left justified Digits to Actual Numeric

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
DGM
Beginner


Joined: 21 Sep 2003
Posts: 12
Topics: 4

PostPosted: Sat Nov 12, 2005 11:27 am    Post subject: Convert left justified Digits to Actual Numeric Reply with quote

Hi
I have a requirment to get the numeric number which is left justfied with digits. This left justified digits are always digits.
I have Syncsort in my Shop.
I posted this question to Syncsort before knowing this forum.
Code:


Input file
COL1 (Length 9)
1
12
123
1234
12345


Output
000000001
000000012
000000123
000001234
000012345



Syncsort replies me with the following answer.

//SPLIT    EXEC PGM=SYNCSORT                       
//SORTIN   DD DSN=HLEVEL.INPUT1.DATA,DISP=SHR     
//SORTOF1  DD DSN=HLEVEL.TEMP1.DATA,DISP=SHR       
//SORTOF2  DD DSN=HLEVEL.TEMP2.DATA,DISP=SHR       
//SORTOF3  DD DSN=HLEVEL.TEMP3.DATA,DISP=SHR       
//SORTOF4  DD DSN=HLEVEL.TEMP4.DATA,DISP=SHR
//SORTOF5  DD DSN=HLEVEL.TEMP5.DATA,DISP=SHR
//*       
//SYSPRINT DD SYSOUT=*                             
//SYSOUT   DD SYSOUT=*                             
//SYSIN    DD *                                   
SORT FIELDS=COPY                                       
 OUTFIL FILES=1,                                         
 INCLUDE=(5,1,CH,EQ,C' ',AND,4,1,CH,NE,C' '),     
 OUTREC=(1,1,1C'0',1,4)                   
 OUTFIL FILES=2,                                         
 INCLUDE=(4,2,CH,EQ,C'  ',AND,3,1,CH,NE,C' '),     
 OUTREC=(1,2,1C'00',2,3)                 
 OUTFIL FILES=3,                                         
 INCLUDE=(3,3,CH,EQ,C'   ',AND,2,1,CH,NE,C' '),   
 OUTREC=(1,3,1C'000',3,2)                 
 OUTFIL FILES=4,                                         
 INCLUDE=(2,4,CH,EQ,C'    ',AND,1,1,CH,NE,C' '),                         
 OUTREC=(1,4,1C'0000',1,1)
 OUTFIL FILES=5,                                         
 INCLUDE=(1,1,CH,NE,C' ',AND,2,1,CH,NE,C' ',AND,   
          3,1,CH,NE,C' ',AND,4,1,CH,NE,C' ',AND,
          5,1,CH,NE,C' ')                             
 END                                                     
//COPY     EXEC PGM=SYNCSORT                       
//SORTIN1  DD DSN=HLEVEL.TEMP1.DATA,DISP=SHR       
//SORTIN2  DD DSN=HLEVEL.TEMP2.DATA,DISP=SHR       
//SORTIN3  DD DSN=HLEVEL.TEMP3.DATA,DISP=SHR       
//SORTIN4  DD DSN=HLEVEL.TEMP4.DATA,DISP=SHR
//SORTIN5  DD DSN=HLEVEL.TEMP5.DATA,DISP=SHR         
//SORTOUT  DD DSN=HLEVEL.OUTPUT.DATA,DISP=SHR       
//SYSPRINT DD SYSOUT=*                             
//SYSOUT   DD SYSOUT=*                             
//SYSIN    DD *                                     
 SORT FIELDS=COPY                                   
 END                                               
//


I am trying to find if there is better way to do this.
Back to top
View user's profile Send private message Send e-mail
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Sat Nov 12, 2005 11:38 am    Post subject: Reply with quote

For the record, there's a better way with DFSORT, but NOT with Syncsort. With DFSORT, you can use the UFF format to do this kind of thing quite easily as follows:

Code:

//S1   EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file
//SORTOUT  DD DSN=...  output file
//SYSIN    DD    *
  OPTION COPY
  INREC OVERLAY=(1:1,9,UFF,TO=ZD,LENGTH=9)
/*


Note that you can handle up to 31 digits this way.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Sat Nov 12, 2005 1:02 pm    Post subject: Reply with quote

DGM,

If your shop has easytrieve then the following JCL will give you the desired results.

Code:

  FILE INFILE                                               
       I-REC          01 01 A OCCURS 9 INDEX IDX           
                                                           
  FILE OUTPUT                                               
       O-REC          01 01 A OCCURS 9 INDEX ODX           
                                                           
  S-SPACE-FOUND   W 01 A                                   
  W-PADZERO-LEN   W 02 B 0                                 
  W-STR-LEN       W 02 B 0                                 

***********************************************************************
* MAINLINE                                                            *
***********************************************************************
                                                                       
 JOB INPUT INFILE                                                     
                                                                       
    S-SPACE-FOUND  = 'N'                                               
    IDX            = 1                                                 
    W-PADZERO-LEN  = 0                                                 
    W-STR-LEN      = 0                                                 
                                                                       
    DO UNTIL IDX > 10 OR S-SPACE-FOUND = 'Y'                           
       IF I-REC(IDX)  = ' '                                           
                                                                       
          S-SPACE-FOUND  = 'Y'                             
          W-PADZERO-LEN  = (9 - IDX) + 1                   
          ODX            = (9 - IDX) + 2                   
          W-STR-LEN      = IDX - 1                         
                                                           
          CASE IDX                                               
               WHEN 1                                           
                    MOVE '000000000' TO  O-REC(1)  W-PADZERO-LEN
               WHEN 2                                           
                    MOVE '00000000'  TO  O-REC(1)  W-PADZERO-LEN
               WHEN 3                                           
                    MOVE '0000000'   TO  O-REC(1)  W-PADZERO-LEN
               WHEN 4                                           
                    MOVE '000000'    TO  O-REC(1)  W-PADZERO-LEN
               WHEN 5                                           
                    MOVE '00000'     TO  O-REC(1)  W-PADZERO-LEN
               WHEN 6                                           
                    MOVE '0000'      TO  O-REC(1)  W-PADZERO-LEN
               WHEN 7                                           
                    MOVE '000'       TO  O-REC(1)  W-PADZERO-LEN
               WHEN 8                                           
                    MOVE '00'        TO  O-REC(1)  W-PADZERO-LEN
               WHEN 9                                           
                    MOVE '0'         TO  O-REC(1)  W-PADZERO-LEN
          END-CASE                                               

          MOVE I-REC(1) IDX          TO O-REC(ODX) W-STR-LEN
       END-IF                                       
       IDX = IDX + 1                                 
    END-DO                                           
    PUT OUTPUT                                       
                                                     


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
DGM
Beginner


Joined: 21 Sep 2003
Posts: 12
Topics: 4

PostPosted: Sat Nov 12, 2005 4:40 pm    Post subject: Reply with quote

Thanks Kolusu for considering my question.
I was looking for SORT Solution . I can't apply Frank's Method due TO limitation of Syncsort. I apreciate Franks help.
I did this in easytrieve in the following way.

Code:

FILE INFILE
I-REC 01 01 A OCCURS 9 INDEX IDX

FILE OUTPUT
O-REC 01 01 A OCCURS 9 INDEX ODX

JOB INPUT INFILE

IDX = 9
ODX = 9

DO WHILE IDX > 0
   IF I-REC(IDX) = ' '
      IDX = IDX - 1
   ELSE
      O-REC(ODX) = I-REC(IDX)
      IDX = IDX - 1
      ODX = ODX - 1
    END-IF
END-DO

DO WHILE ODX > 0
   MOVE '0' TO O-REC(ODX)
   ODX = ODX - 1
END-DO

PUT OUTPUT
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Sat Nov 12, 2005 4:47 pm    Post subject: Reply with quote

Quote:

Thanks Kolusu for considering my question.
I was looking for SORT Solution .


DGM,

Syncsort does not support UFF/SFF formats. so the only way it can be done using syncsort is shown by you. However there are a alternative ways of doing it ,however they CANNOT beat DFSORT's solution. check this link

http://www.mvsforums.com/helpboards/viewtopic.php?t=3173&highlight=pad

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group