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

RPG II Problem with unsigned Packed decimal field


IBM Mainframe Forums -> All Other Mainframe Topics
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Andi1982

New User


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

PostPosted: Tue Sep 11, 2018 6:11 pm
Reply with quote

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
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Thu Sep 13, 2018 12:18 pm
Reply with quote

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 ?
Back to top
View user's profile Send private message
Andi1982

New User


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

PostPosted: Thu Sep 13, 2018 2:35 pm
Reply with quote

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.
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


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

PostPosted: Thu Sep 13, 2018 2:58 pm
Reply with quote

See data structures : www.ibm.com/support/knowledgecenter/ssw_i5_54/books/c0918180.pdf
Back to top
View user's profile Send private message
Andi1982

New User


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

PostPosted: Thu Sep 13, 2018 3:03 pm
Reply with quote

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.
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


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

PostPosted: Thu Sep 13, 2018 3:16 pm
Reply with quote

Good luck.
Back to top
View user's profile Send private message
ApexNC

New User


Joined: 10 Feb 2006
Posts: 19
Location: USA

PostPosted: Thu Sep 13, 2018 5:36 pm
Reply with quote

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.
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 -> All Other Mainframe Topics

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Map Vols and Problem Dataset All Other Mainframe Topics 2
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
Search our Forums:

Back to Top