Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

How to change 'K' or 'M' use Sort

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

New User


Joined: 26 Feb 2006
Posts: 16
Location: usa

PostPosted: Thu May 18, 2017 7:11 am    Post subject: How to change 'K' or 'M' use Sort
Reply with quote

Hello everyone,

I want to change below data
Code:
1M      1M      128K                     
145M    145M    0K                       
1024M   1024M   0K                       
0K      0K      0K                       
0K      0K      0K                       
256K    256K    64K                     
256K    256K    64K                     
1M      1M      64K                     
512K    512K    64K                     
22M     22M     128K                     
60M     60M     256K                     
1M      1M      128K                     
1M      1M      128K                     
198M    198M    0K                       
1024M   1024M   0K                       
0K      0K      0K                       
0K      0K      0K                       
256K    256K    64K                                             
256K    256K    64K                                             
1M      1M      64K                                             
256K    256K    64K


change to
Code:
                                                                 
1048576         1048576         131072                           
152043520       152043520       0                               
1073741824      1073741824      0                               
0               0               0                               
0               0               0                               
262144          262144          65536                           
262144          262144          65536                           
1048576         1048576         65536                           
524288          524288          65536                           
23068672        23068672        131072                           
62914560        62914560        262144                           
1048576         1048576         131072                           
1048576         1048576         131072                           
207618048       207618048       0                               
1073741824      1073741824      0                             
0               0               0                             
0               0               0                             
262144          262144          65536                           
262144          262144          65536                         
1048576         1048576         65536                           
262144          262144          65536                         


thanks in advance
Back to top
View user's profile Send private message

mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 283
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Thu May 18, 2017 1:12 pm    Post subject:
Reply with quote

I don't know if this is the most efficient way of doing it, but here is a sample rexx. You can expand it to process the complete dataset.

Code:
/******************rexx*******************/
string = '0M      60M     128K'
parse var string col1 col2 col3 .
do i = 1 to 3
  interpret "temp = col"i
  select
    when pos('K',temp) \= 0 then do
      interpret "col"i "=" (substr(temp,1,(pos('K',temp)-1))) * 1024
      end
    when pos('M',temp) \= 0 then do
      interpret "col"i "=" (substr(temp,1,(pos('M',temp)-1))) * 1048576
      end
    otherwise
  end
end
string = left(col1,10) || left(col2,10) || left(col3,10)
say string

Output:
Code:
0         62914560  131072

Hope this helps.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10257
Location: italy

PostPosted: Thu May 18, 2017 1:31 pm    Post subject: Reply to: How to change 'K' or 'M' use Sort
Reply with quote

not what the TS asked for, but
writing small rexx snippets is like doing crosswords for me icon_wink.gif

try with

the script
Code:

#! /usr/bin/env rexx
Trace "O"
numeric digits 15

in = "356 0M 60M 128K 2G 346Z"

mult.B = 1
mult.K = 1024
mult.M = 1024*1024
mult.G = 1024*1024*1024

ou = ""
sz = 16
do while ( in \= "" )
    parse var in tk in
    tk = translate(tk)
    mf = right(tk,1)
    if datatype(mf,"M") then ,
        tk = strip(tk,,mf)
    else ,
        mf = "B"
    if ( symbol("mult."mf) = "VAR" ) then ,
        ou = ou || left(tk * mult.mf,sz," ")
    else ,
        ou = ou || copies("*",sz-1)" "
end
say ">>"ou"<<"



(*) it is one of my pet peeves to decouple the real coding from the control data
adding a new multiplier factor will not make the coding to change

the result
Code:

>>356             0               62914560        131072          2147483648      *************** <<


doing it with sort could be pretty boring ...
shifting right to find the multiplier factor, and a bunch of ifthen to do the calculations

but probably not impossible

edited the code to deal with BYTES with or without the B suffix
the code assumes that the suffix is VALID
pretty easy to add the check ( done )
Back to top
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 283
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Thu May 18, 2017 2:15 pm    Post subject:
Reply with quote

Quote:
I don't know if this is the most efficient way of doing it

Now I know that was not icon_redface.gif
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10257
Location: italy

PostPosted: Thu May 18, 2017 2:52 pm    Post subject: Reply to: How to change 'K' or 'M' use Sort
Reply with quote

probably You have not written as many lines of Rexx code as I have done icon_wink.gif
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2276
Location: @my desk

PostPosted: Thu May 18, 2017 7:39 pm    Post subject:
Reply with quote

Quote:
doing it with sort could be pretty boring ...
I thought of taking up some of that, before I get to my much boring work icon_smile.gif. There could be better ways, but here is one of them that I can think of now.
Code:
//SYSIN     DD *                                       
  OPTION 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)))           

For the OP's input data provided in SORTIN, SORTOUT had
Code:
1048576         1048576         131072
152043520       152043520       0     
1073741824      1073741824      0     
0               0               0     
0               0               0     
262144          262144          65536
262144          262144          65536
1048576         1048576         65536
524288          524288          65536
23068672        23068672        131072
62914560        62914560        262144
1048576         1048576         131072
1048576         1048576         131072
207618048       207618048       0     
1073741824      1073741824      0     
0               0               0     
0               0               0     
262144          262144          65536
262144          262144          65536
1048576         1048576         65536
262144          262144          65536
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
No new posts Adding big TEXT lines to each record ... bshkris SYNCSORT 4 Sat May 06, 2017 1:40 am
This topic is locked: you cannot edit posts or make replies. SORT trick needed bshkris SYNCSORT 6 Tue May 02, 2017 4:35 am
No new posts SORT JSON type of data maxsubrat DFSORT/ICETOOL 8 Wed Apr 19, 2017 6:01 pm
No new posts Sort Large record length cmsmoon DFSORT/ICETOOL 14 Tue Apr 11, 2017 5:49 pm
No new posts Innovations in Your Mainframe Sort Arun Raj PC Guides & IT News 4 Wed Mar 15, 2017 10:38 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us