Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
RPG II Problem with unsigned Packed decimal field

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics
View previous topic :: :: View next topic  
Author Message
Andi1982

New User


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

PostPosted: Tue Sep 11, 2018 6:11 pm    Post subject: RPG II Problem with unsigned Packed decimal field
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: 1298
Location: Israel

PostPosted: Thu Sep 13, 2018 12:18 pm    Post subject:
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: 36
Location: Karlsruhe / Germany

PostPosted: Thu Sep 13, 2018 2:35 pm    Post subject:
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: 2461
Location: Netherlands, Amstelveen

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

See data structures : https://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: 36
Location: Karlsruhe / Germany

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

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

Global Moderator


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

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

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

New User


Joined: 10 Feb 2006
Posts: 17
Location: USA

PostPosted: Thu Sep 13, 2018 5:36 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Replace comp-3 field value to comp-3 ... dharmaraok DFSORT/ICETOOL 5 Fri Sep 14, 2018 3:46 pm
No new posts Extra data in overlay field speermb DFSORT/ICETOOL 2 Thu Sep 13, 2018 6:04 pm
No new posts Problem with Return or Exit from DCB ... Vishnu Priya M R PL/I & Assembler 6 Thu Aug 23, 2018 9:43 am
No new posts Formating of Amount field in CLIST be... Anil Kumar Prajapati CLIST & REXX 9 Fri Aug 03, 2018 6:34 pm
No new posts SMF IFAMGET macro GTPB_RETURNEDLENGT... ironheinrich7 IBM Tools 0 Thu Aug 02, 2018 6:53 pm

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