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
 

 

Add Trailing Zeroes depending upon the the decimal size

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

Senior Member


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

PostPosted: Fri Oct 23, 2015 1:47 am    Post subject: Add Trailing Zeroes depending upon the the decimal size
Reply with quote

I have a requirement as below.

Input file FB LREC=50
Code:
A1A1,VOL,123.67,,,,
A1A1,VOL,1723.673,JJ,,,
A1A1,,14523.6734,hh,,,

Expected Output:
Code:
A1A1,VOL,123.6700,,,
A1A1,VOL,1723.6730,JJ,,,
A1A1,,14523.6734,hh,,,


So basically, the format is DECIMAL(14,4)/PIC s9(10)V9(4) comp-3. I am trying to reformat this decimal field ( ONLY right portion of it after decimal ('.')to its max limit by adding zeroes as needed).
And later on I will rewrite this field as PD or if you can do it in the same step then thats is good.

I have tried something but that has more hardcoding stuff, so the approach was to take left portion of it (before '.') and multiply by 10000 and add right portion ( after'.') to it.

e.g.
123.67 ---> 123 multiply by 10000
1230000--- add/overlay 6700 .
1236700--- rewrite as PD

So when I read into PIC s9(10)V9(4) comp-3 then I get the right value back.


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

Rohit Umarjikar

Senior Member


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

PostPosted: Fri Oct 23, 2015 3:23 am    Post subject:
Reply with quote

I tried to do something like this which does add trailing zeroes and then convert that to PD which can be done in Build.
input
Code:
55.2
343.112
23222.11
23.7786


Sort card
Code:
SORT FIELDS=COPY                                         
INREC IFTHEN=(WHEN=INIT,                                 
      PARSE=(%01=(ABSPOS=1,ENDBEFR=C'.',FIXLEN=10),     
             %02=(ENDBEFR=C',',FIXLEN=04)),             
      BUILD=(%01,UFF,EDIT=(TTTTTTTTTT),%02)),           
      IFTHEN=(WHEN=INIT,                                 
      FINDREP=(INOUT=(C' ',C'0'),STARTPOS=11,ENDPOS=15))

Output:
Code:
00000000552000
00000003431120
00000232221100
00000000237786
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Fri Oct 23, 2015 6:02 am    Post subject: Reply to: Add Trailing Zeroes depending upon the the decimal size
Reply with quote

I think you are basically there.

A couple of things. You don't need the ABSPOS=1. That is the default value for the initial PARSEd field. You need ABSPOS when you want to start the next PARSEd field at a position other than it would naturally be (you want to skip some bytes, or include in the PARSE something you've already PARSEd).

There's also a little thing with ALTSEQ, which removes the need for the FINDREP.

Code:
 SORT FIELDS=COPY
 ALTSEQ   CODE=(40F0)
 INREC IFTHEN=(WHEN=INIT,
      PARSE=(%01=(ENDBEFR=C'.',FIXLEN=10),
             %02=(ENDBEFR=C',',FIXLEN=04)),
      BUILD=(%01,UFF,EDIT=(TTTTTTTTTT),%02,TRAN=ALTSEQ))


That will, for the %02 field, change spaces to zero.
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


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

PostPosted: Fri Oct 23, 2015 8:17 pm    Post subject:
Reply with quote

Thanks Bill for ABSPOS=1. and ALTSEQ.
I just coded ABSPOS=1 because I have this type of decimals appeared couple of times at different postions.
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 Comparing Decimal and CHAR columns rakesh17684 DB2 7 Thu Oct 20, 2016 2:33 am
No new posts Increase the screen size after split mistah kurtz TSO/ISPF 2 Fri Sep 02, 2016 6:39 pm
No new posts Convert Decimal to hexadecimal Steve Ironmonger DFSORT/ICETOOL 5 Fri May 27, 2016 4:19 pm
This topic is locked: you cannot edit posts or make replies. JCL to convert float decimal into rea... polymathtarun JCL & VSAM 3 Sun May 15, 2016 9:57 pm
No new posts conversion from char to packed decimal Musab Ahmed DFSORT/ICETOOL 7 Fri Apr 08, 2016 1:12 pm


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