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
 
To convert numeric to Packed Decimal

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: To convert numeric to Packed Decimal
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: 2467
Location: NY,USA

PostPosted: Fri Jul 31, 2020 9:21 pm    Post subject:
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    Post subject:
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: 2406
Location: Hampshire, UK

PostPosted: Sun Aug 02, 2020 4:19 pm    Post subject: Reply to: To convert numeric to Packed Decimal
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    Post subject:
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    Post subject:
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

Active User


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

PostPosted: Sun Aug 02, 2020 11:11 pm    Post subject:
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: 2406
Location: Hampshire, UK

PostPosted: Mon Aug 03, 2020 3:38 am    Post subject:
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

Active Member


Joined: 29 Apr 2008
Posts: 825
Location: Maryland

PostPosted: Mon Aug 03, 2020 3:57 am    Post subject:
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    Post subject:
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    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 how to convert Hex String t char hex Martylin PL/I & Assembler 6 Fri Jun 05, 2020 7:45 pm
No new posts Get next 5 numeric from a string of '... maxsubrat COBOL Programming 7 Fri Apr 24, 2020 2:30 pm
No new posts SCO 7 in numeric value gpnavinkumar COBOL Programming 7 Tue Apr 07, 2020 7:48 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 Convert a packed decimal value to zon... Dinesh Mani DB2 6 Mon Mar 16, 2020 6:02 pm

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