# RPG II Problem with unsigned Packed decimal field

Author Message
Andi1982

New User

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

 Posted: Tue Sep 11, 2018 6:11 pm 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: 1348
Location: Israel

 Posted: Thu Sep 13, 2018 12:18 pm 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

 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 See data structures : 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

 PeterHolland wrote: See data structures : 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 Good luck.
ApexNC

New User

Joined: 10 Feb 2006
Posts: 18
Location: USA

 Posted: Thu Sep 13, 2018 5:36 pm 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.
 View Bookmarks All times are GMT + 6 Hours

 Topic Forum Replies Similar Topics Sysncsort - Justification problem SYNCSORT 6 HOW TO OVERLAY A Packed decimal VALUE... DFSORT/ICETOOL 5 Assembler - Packed Decimals - PACK in... PL/I & Assembler 3 Passing a field name to COBOL program COBOL Programming 10 BMS map length field greater than zero CICS 3
Search our Forums: