IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

To convert numeric to Packed Decimal


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
vinu78

Active User


Joined: 02 Oct 2008
Posts: 179
Location: India

PostPosted: Fri Jul 31, 2020 7:14 pm
Reply with quote

Hi All,

Could you please help me to reformat the following using SORT

Input file of record length 22 bytes
Code:
01  WS-REC.
      01  WS-ACCOUNT    PIC X(05).
      01  WS-AMOUNT     PIC 9(9).9(6)
      01  WS-IND        PIC X(1)
 
AA100       10.123456R   


Can you please help me to reformat the above record to as below using SORT card.

Code:
01  WS-REC.
      01  WS-ACCOUNT    PIC X(05).
      01  WS-AMOUNT     PIC 9(9)V9(6) COMP-3
      01  WS-IND        PIC X(1)


This output record length will be 14 bytes.

Thanks
Vinu
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Fri Jul 31, 2020 9:21 pm
Reply with quote

This has been discussed may a times on this forum, so please try searching and also do try for UFF to PD.
Back to top
View user's profile Send private message
vinu78

Active User


Joined: 02 Oct 2008
Posts: 179
Location: India

PostPosted: Sun Aug 02, 2020 1:02 pm
Reply with quote

Hi Rohit,

Thanks for the suggestion. I have tried using below SORT card, however not getting desired result

Code:
OPTION COPY
OUTREC FIELDS=(1:1,5,6:6,15,UFF,TO=PD,14:22,1)


I got the output as

Code:

WS-ACCOUNT     WS-DATE-CYCLE    WS-IND     
AA100          1.012345         R           


However I was expecting the output as 10.123456
Then I updated the SOrt card as

OPTION COPY
OUTREC FIELDS=(1:1,5,6:6,16,UFF,TO=PD,14:22,1)

But job abended with U0016.

Can you please help me.

Thanks
Vinu
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Sun Aug 02, 2020 4:19 pm
Reply with quote

How about posting the messages?
Back to top
View user's profile Send private message
vinu78

Active User


Joined: 02 Oct 2008
Posts: 179
Location: India

PostPosted: Sun Aug 02, 2020 6:22 pm
Reply with quote

Hi Nic,

Actually I got these records with amount in an excel sheet and my requirement is to put it in a Mainframe dataset with amount field as S9(9)V9(6) COMP-3

Thanks
Chidam
Back to top
View user's profile Send private message
vinu78

Active User


Joined: 02 Oct 2008
Posts: 179
Location: India

PostPosted: Sun Aug 02, 2020 10:21 pm
Reply with quote

Hi All,

Could you please help me to accomplish this using SORT card.

Thanks
Vinu
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


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

PostPosted: Sun Aug 02, 2020 11:11 pm
Reply with quote

Have you tried?
Code:
OUTREC BUILD=(1,5,6,16,UFF,TO=PD,LENGTH=8,22,1)
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Mon Aug 03, 2020 3:38 am
Reply with quote

vinu78 wrote:
Hi Nic,

Actually I got these records with amount in an excel sheet and my requirement is to put it in a Mainframe dataset with amount field as S9(9)V9(6) COMP-3

Thanks
Chidam

What has that to do with posting the DFSort messages that detail your error?
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2010
Location: USA

PostPosted: Mon Aug 03, 2020 3:57 am
Reply with quote

Joerg.Findeisen wrote:
Have you tried?
Code:
OUTREC BUILD=(1,5,
              6,16,UFF,TO=PD,LENGTH=8,
              22,1)

I guess, it would make sense to give explanation to TS: his target output field PIC 9(9)V9(6) COMP-3 has length 8 bytes (I hope he knows why?), but the default output length after conversion TO=PD is different. That’s why explicit parameter LENGTH=8 is needed.

Without this comment, 99% of TS just copy-and-paste the given solution (some of them also respond with “Thank you!”), - without a minor understanding: why it is required? Next day the same TS, or his milk brother, will ask exactly the same question in the same forum... icon_pray.gif
Back to top
View user's profile Send private message
vinu78

Active User


Joined: 02 Oct 2008
Posts: 179
Location: India

PostPosted: Sat Aug 29, 2020 7:04 pm
Reply with quote

Hi All,

Thanks very much.
The code suggested by Jeorg worked like a charm.
Thanks everybody.

Regards
Vinu
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Need to convert date format DFSORT/ICETOOL 20
No new posts PD not working for unsigned packed JO... DFSORT/ICETOOL 5
No new posts Def PD not working for unsigned packe... JCL & VSAM 3
No new posts Keep leading zero(s) after convert fl... SYNCSORT 7
Search our Forums:

Back to Top