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

Need Help with Packed Decimal Signs


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

Active User


Joined: 10 Aug 2009
Posts: 184
Location: India

PostPosted: Tue Apr 11, 2023 8:38 pm
Reply with quote

Hi There,

Hope you are doing well.

I am in need of some help with DFSORT. I have a PD field of 5 bytes and I want to convert it into display format and show CR and DB in front of the value based on the sign (CR for +, DB for -) as mentioned below.

Input Sample Data:
Code:
=COLS> ----+
****** *****
000100     <
       01234
       0234C
------------
000200  ÂÄÀ(
       06664
       0234D
------------
000300  êëè*
       05555
       0234C
------------
000400  bcdý
       08888
       0234D
------------
000500     
       01111
       0234D
------------
000600  klm¸
       09999
       0234D


Expected Output is:
Code:
CR 001223344
DB 006263644
CR 005253545
DB 008283848
DB 001213141
DB 009293949


I have tried couple of ways but couldn't figure out exact solution for my scenario.

I have tried below sort cards
Code:
//SYSIN    DD   *           
   SORT FIELDS=COPY         
   OUTREC FIELDS=(1,5,PD,M3)
/*                         

Output:
 ----+----1----
 **************
    12,233.44 
    62,636.44CR
    52,535.45 
    82,838.48CR
    12,131.41CR
    92,939.49CR


//SYSIN    DD   *                                     
   SORT FIELDS=COPY                                   
   OUTREC FIELDS=(1,5,PD,EDIT=(STTTTTTTTT),SIGNS=(+,-))
/*                                                     

Output:
----+----1
**********
+001223344
-006263644
+005253545
-008283848
-001213141
-009293949


//SYSIN    DD   *                                       
   SORT FIELDS=COPY                                     
   OUTREC FIELDS=(1,5,PD,EDIT=(TTTTTTTTTS),SIGNS=(,,C,D))
/*                                                       

Output:
----+----1
**********
001223344C
006263644D
005253545C
008283848D
001213141D
009293949D


Kindly guide me in this regard. Thanks in advance.
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


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

PostPosted: Tue Apr 11, 2023 11:12 pm
Reply with quote

Quick hack:

Code:
//WHATEVER EXEC PGM=ICEMAN                             
//SORTIN   DD *                                       
    <                                                 
 klm¸                                                 
/*                                                     
//SYSOUT   DD SYSOUT=*                                 
//SORTOUT  DD SYSOUT=*                                 
//SYSIN    DD *                                       
  OPTION COPY                                         
  INREC IFTHEN=(WHEN=INIT,                             
    OVERLAY=(1,5,PD,EDIT=(STTTTTTTTTTT),SIGNS=(C,D),   
             1:1,1,CHANGE=(3,C'C',C'CR ',C'D',C'DB ')))
  END                                                 
/*
Back to top
View user's profile Send private message
satish.ms10

Active User


Joined: 10 Aug 2009
Posts: 184
Location: India

PostPosted: Wed Apr 12, 2023 12:18 pm
Reply with quote

Hi Joerg.Findeisen,

Thank you so much for your help. It worked for my scenario.
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


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

PostPosted: Wed Apr 12, 2023 12:34 pm
Reply with quote

If you have unsigned PD fields, you should add also a NOMATCH clause to the CHANGE operation. Other than that, you are good to go.
Back to top
View user's profile Send private message
satish.ms10

Active User


Joined: 10 Aug 2009
Posts: 184
Location: India

PostPosted: Wed Apr 12, 2023 4:30 pm
Reply with quote

Hi Joerg.Findeisen

There are no unsigned values in that field. Thank you icon_smile.gif
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 small int to zoned decimal conversion DFSORT/ICETOOL 3
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
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 Select a DB2 value in a specific deci... DB2 4
Search our Forums:

Back to Top