Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
Andi1982

New User

Joined: 27 Mar 2008
Posts: 42
Location: Karlsruhe / Germany

 Posted: Tue Sep 11, 2018 6:11 pm    Post subject: RPG II Problem with unsigned Packed decimal field Hello, we have some RPG II program and nobody here know how to solve this problem. In our input file is a 3-Byte field with unsigned packed decimal value: 12 34 56 We need to bring it into packed format 01 23 45 6C. Does anybody has an idea how to do this in RPG II ? Best regards Andi

Marso

REXX Moderator

Joined: 13 Mar 2006
Posts: 1349
Location: Israel

 Posted: Thu Sep 13, 2018 12:18 pm    Post subject: I can't say I remember much of my small encounter with RPG II from 40 years ago... Is it possible to append a packed-decimal zero (x'0C' or x'0F') giving x'1234560C' and then divide the lot by ten ?
Andi1982

New User

Joined: 27 Mar 2008
Posts: 42
Location: Karlsruhe / Germany

Posted: Thu Sep 13, 2018 2:35 pm    Post subject:

 Marso wrote: Is it possible to append a packed-decimal zero (x'0C' or x'0F') giving x'1234560C' and then divide the lot by ten ?

Yes, in COBOL we are doing like that. PIC X redefined and then divide and multiply by 10.

But we don't know how to do this in RPG II. How to define this work-fields? How to work with them to multiply or divide.

We really don't have this RPG-Skills anymore in Company.
PeterHolland

Global Moderator

Joined: 27 Oct 2009
Posts: 2475
Location: Netherlands, Amstelveen

 Posted: Thu Sep 13, 2018 2:58 pm    Post subject: See data structures : https://www.ibm.com/support/knowledgecenter/ssw_i5_54/books/c0918180.pdf
Andi1982

New User

Joined: 27 Mar 2008
Posts: 42
Location: Karlsruhe / Germany

Posted: Thu Sep 13, 2018 3:03 pm    Post subject:

 PeterHolland wrote: See data structures : https://www.ibm.com/support/knowledgecenter/ssw_i5_54/books/c0918180.pdf

Thx a lot! I was not able to find that Kind of documentation. We will have a look at it and I will give Response if we were able to solve our Problem.
PeterHolland

Global Moderator

Joined: 27 Oct 2009
Posts: 2475
Location: Netherlands, Amstelveen

 Posted: Thu Sep 13, 2018 3:16 pm    Post subject: Good luck.
ApexNC

New User

Joined: 10 Feb 2006
Posts: 18
Location: USA

 Posted: Thu Sep 13, 2018 5:36 pm    Post subject: My RPG experience is likewise very old, but one of the COBOL conversion techniques I know very well should be easily adaptable. Decimal digits without a sign are called "Binary Coded Decimal" (BCD) and a typical usage for a six-digit BCD value is to hold a Gregorian Date with a two-digit year: MMDDYY. So, I'll use MMDDYY to explain the technique: (1) Move the 3-byte BCD field (right justified) to a 4-byte binary field. ==> MMDDYY becomes xxMMDDYY. (2) Multiply by 16 ==> xxMMDDYY becomes xMMDDYY0. (3) Add 15 ==> xMMDDYY0 becomes xMMDDYYF. (4) Declare the 4-byte binary field as 4-byte packed decimal (7-digits). Does RPG have a "redefines" feature, like COBOL? If so, use it. (5) Move the 4-byte packed decimal field to a 6-digit zoned-decimal (USAGE DISPLAY) field. ==> xMMDDYYF becomes .M.M.D.D.Y.Y ("." characters represent zone value of "F". Done.
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics To convert numeric to Packed Decimal vinu78 DFSORT/ICETOOL 8 Fri Jul 31, 2020 7:14 pm Problem getting record length of a re... amitc23 COBOL Programming 2 Thu Jul 02, 2020 10:52 pm Problem while trying to manipulate re... amitc23 DFSORT/ICETOOL 3 Tue Jun 30, 2020 1:19 pm TSO IOF problem josephineyeow TSO/ISPF 5 Fri Mar 27, 2020 10:18 pm Convert a packed decimal value to zon... Dinesh Mani DB2 6 Mon Mar 16, 2020 6:02 pm

 © 2003-2020 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us