Portal | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Covert k to 1000 / m to 1000000 using DFSORT

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
A_programmers

New User


Joined: 24 Mar 2010
Posts: 16
Location: USA

PostPosted: Tue Jun 23, 2020 6:52 pm    Post subject: Covert k to 1000 / m to 1000000 using DFSORT
Reply with quote

Dear Friend,

This specific query is related to converting Text representation of number to number using DFSORT.

I have a input file field of 40 bytes which contains data as below :

Code:
Amount 12K Required 20-June-2020
Amount 52.2M Available 15-June-2020
Amount 1252M Overspend 05-June-2020


I need to convert above data in such as way that 'K' is replaced by value before 'K' multiplied by 1000 and 'M' is replaced by value before 'M' multiplied by million as shown below :

Code:
Amount 12000 Required 20-June-2020
Amount 52200000 Available 15-June-2020
Amount 1252000000 Overspend 05-June-2020


Does anyone know how this can be achieved using DFSORT ?
Back to top
View user's profile Send private message

Joerg.Findeisen

Active User


Joined: 15 Aug 2015
Posts: 311
Location: Bamberg, Germany

PostPosted: Tue Jun 23, 2020 7:30 pm    Post subject:
Reply with quote

There was once a sample in the forum like this one:
Code:
//FORMAT   EXEC PGM=ICEMAN                           
//SORTIN   DD *                                                     
1M      1M      128K                                                 
145M    145M    0K                                                   
1024M   1024M   0K                                                   
0K      0K      0K                                                   
256K    256K    64K                                                 
/*                                                                   
//SYSOUT   DD SYSOUT=*                                               
//SORTOUT  DD SYSOUT=*                                               
//SYSIN    DD *                                                     
  SORT FIELDS=(COPY)                                                 
  OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(1:1,80,SQZ=(SHIFT=LEFT))),       
    IFTHEN=(WHEN=INIT,                                               
      FINDREP=(INOUT=(C'K',C',1024,',                               
                      C'M',C',1048576,',                             
                      C'G',C',1073741824,'))),                       
    IFTHEN=(WHEN=INIT,PARSE=(%1=(ENDBEFR=C',',FIXLEN=10,REPEAT=6)), 
      OVERLAY=(%1,UFF,MUL,%2,UFF,M10,LENGTH=16,                     
               01:01,16,JFY=(SHIFT=LEFT),                           
               %3,UFF,MUL,%4,UFF,M10,LENGTH=16,                     
               17:17,16,JFY=(SHIFT=LEFT),                           
               %5,UFF,MUL,%6,UFF,M10,LENGTH=16,                     
               33:33,16,JFY=(SHIFT=LEFT)))                           
  END                                                               
/*

Works pretty well.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 2467
Location: NY,USA

PostPosted: Tue Jun 23, 2020 9:08 pm    Post subject:
Reply with quote

That's this - http://ibmmainframes.com/viewtopic.php?t=65945&highlight=145m

You can try this as well -
1. INREC PARSE into 4 fields delimited by SPACE.
2. Pick the second one and do a SHIFT= RIGHT, look for 'K'/'M' at last position of the field and multiply the numeric part of the field by 1000/1000000.
Back to top
View user's profile Send private message
Joerg.Findeisen

Active User


Joined: 15 Aug 2015
Posts: 311
Location: Bamberg, Germany

PostPosted: Tue Jun 23, 2020 11:14 pm    Post subject:
Reply with quote

Code:
  OPTION COPY                                                         
  OUTREC IFTHEN=(WHEN=INIT,                                           
    PARSE=(%10=(ENDBEFR=BLANKS,FIXLEN=10),                             
           %21=(STARTAT=NUM,ENDBEFR=BLANKS,ENDBEFR=UC,FIXLEN=8),       
           %22=(SUBPOS=1,FIXLEN=1),                                   
           %30=(FIXLEN=61)),                                           
    OVERLAY=(81:%21,X,%22,CHANGE=(11,C' ',C'00000000001',             
                                     C'K',C'00000001000',             
                                     C'M',C'00001000000',             
                                     C'G',C'01000000000'))),           
    IFTHEN=(WHEN=INIT,                                                 
      PARSE=(%23=(ABSPOS=81,STARTAT=NUM,ENDBEFR=C'.',FIXLEN=4),       
             %24=(ENDBEFR=BLANKS,FIXLEN=4)),                           
      OVERLAY=(81:%23,UFF,M11,%24,JFY=(SHIFT=(LEFT),TRAIL=C'0000'))), 
    IFTHEN=(WHEN=INIT,                                                 
      OVERLAY=(%10,X,                                                 
               (81,8,ZD,MUL,90,11,ZD),DIV,+10000,LENGTH=16,X,         
               %30)),                                                 
    IFTHEN=(WHEN=INIT,BUILD=(1,80,SQZ=(SHIFT=LEFT,MID=C' ',LENGTH=80)))
  END

Output:
Code:
Amount 12000 Required 20-June-2020       
Amount 52200000 Available 15-June-2020   
Amount 1252000000 Overspend 05-June-2020
Back to top
View user's profile Send private message
A_programmers

New User


Joined: 24 Mar 2010
Posts: 16
Location: USA

PostPosted: Sun Jul 05, 2020 11:51 am    Post subject:
Reply with quote

Thanks Rohit and Joerg. It is working perfectly fine.

Initially it took me couple of parses of above logic to understand how it is working; at the end finally I understood the logic.
Back to top
View user's profile Send private message
Joerg.Findeisen

Active User


Joined: 15 Aug 2015
Posts: 311
Location: Bamberg, Germany

PostPosted: Sun Jul 05, 2020 12:06 pm    Post subject:
Reply with quote

Thank you for letting us know. icon_biggrin.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Parsing more than 1000 columns in a s... ssuthagar SYNCSORT 10 Tue Sep 22, 2020 12:23 am
No new posts DFSORT Output file order query A_programmers DFSORT/ICETOOL 2 Thu Mar 26, 2020 11:59 pm
This topic is locked: you cannot edit posts or make replies. DFSORT-How to convert ZD to ZS in DFSORT useit DFSORT/ICETOOL 2 Thu Mar 26, 2020 10:43 am
No new posts DFSORT to handle in between specific ... subratarec DFSORT/ICETOOL 6 Thu Feb 06, 2020 1:22 am
No new posts Need help with this dfsort problem kushkush DFSORT/ICETOOL 7 Sun Feb 02, 2020 6:34 pm

Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us