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

How to move zoned decimal value into packed decimal


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Gopalakrishnan V

Active User


Joined: 28 Jun 2010
Posts: 102
Location: chennai

PostPosted: Tue Sep 28, 2010 12:40 pm
Reply with quote

working storage coding:
Code:

10 WORK-ON-HAND-QTY-SIGN             PIC  X(01).             
     88 WORK-ON-HAND-QTY-NEG              VALUE '-'.         
10 WORK-ON-HAND-QTY                  PIC  X(05).             
10 WORK-ON-HAND-QTY-9 REDEFINES WORK-ON-HAND-QTY PIC 9(05). 
10 OTRAN-Q-RMS-ON-HAND                PIC  S9(05) COMP-3.


pgm logic :
Code:

MOVE WORK-ON-HAND-QTY-9            TO   OTRAN-Q-RMS-ON-HAND
IF WORK-ON-HAND-QTY-NEG                 
   MULTIPLY OTRAN-Q-RMS-ON-HAND BY -1   
            GIVING  OTRAN-Q-RMS-ON-HAND
END-IF                                 



Displayed values:

I got the following result:

Code:

WORK-ON-HAND-QTY-NEG                         -
WORK-ON-HAND-QTY-9                             15
OTRAN-Q-RMS-ON-HAND                           15000
WITH SIGN OTRAN-Q-RMS-ON-HAND          1500}


But my expected result is:

Code:

WORK-ON-HAND-QTY-NEG                         -
WORK-ON-HAND-QTY-9                              15
OTRAN-Q-RMS-ON-HAND                            15
WITH SIGN OTRAN-Q-RMS-ON-HAND          -15
Back to top
View user's profile Send private message
Kjeld

Active User


Joined: 15 Dec 2009
Posts: 365
Location: Denmark

PostPosted: Tue Sep 28, 2010 2:23 pm
Reply with quote

Hi VGK,

Browse your output in hex mode (HEX ON), you will discover the character '}' probably corresponds to a x'0D', indicating a negative sign.

Packed decimal fields does not display a printable sign. In storage, your value of -15000 would be represented as x'0015000D'. The corresponding positive value would be x'0015000C'.

In your X(05) field, the characters '15' is justified left, padded with blanks. These blanks are converted to zeroes during the move to the packed field, as the compiler only takes the lower half byte of each character byte when packing.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Tue Sep 28, 2010 3:46 pm
Reply with quote

1. The expected result for "WITH SIGN OTRAN-Q-RMS-ON-HAND" should be "1N", not "-15".

2. When using DISPLAY, I often use delimiters before and after the field. Like this I can "see" where are the spaces if any:
Code:
DISPLAY "WORK-ON-HAND-QTY-9 <" WORK-ON-HAND-QTY-9 ">"
Back to top
View user's profile Send private message
Gopalakrishnan V

Active User


Joined: 28 Jun 2010
Posts: 102
Location: chennai

PostPosted: Tue Sep 28, 2010 5:55 pm
Reply with quote

Hi,

Thank you for all, my problem resolved.
Back to top
View user's profile Send private message
Traveler

New User


Joined: 12 Aug 2010
Posts: 8
Location: Highlands, NJ

PostPosted: Wed Sep 29, 2010 6:21 pm
Reply with quote

Did I miss something here? From the code presented where did the value "15" get introduced?
Back to top
View user's profile Send private message
Kjeld

Active User


Joined: 15 Dec 2009
Posts: 365
Location: Denmark

PostPosted: Wed Sep 29, 2010 6:44 pm
Reply with quote

I think you missed the part of the OP's first post stating the observed results, opposed to the expected results.
Back to top
View user's profile Send private message
Traveler

New User


Joined: 12 Aug 2010
Posts: 8
Location: Highlands, NJ

PostPosted: Wed Sep 29, 2010 7:34 pm
Reply with quote

Kjeld wrote:
I think you missed the part of the OP's first post stating the observed results, opposed to the expected results.


Pretty sure I read everything that was posted. Perhaps the PO can provide that information. How was the value "15" introduced?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Sep 29, 2010 8:24 pm
Reply with quote

Hello,

Quote:
Pretty sure I read everything that was posted. Perhaps the PO can provide that information. How was the value "15" introduced?
Maybe try one more time icon_wink.gif

The OP did provide this in the post that started the topic:
Quote:
I got the following result:
Code:
WORK-ON-HAND-QTY-NEG                         -
WORK-ON-HAND-QTY-9                             15
OTRAN-Q-RMS-ON-HAND                           15000
WITH SIGN OTRAN-Q-RMS-ON-HAND          1500}


Possibly there is something i am missing. . .?
Back to top
View user's profile Send private message
Traveler

New User


Joined: 12 Aug 2010
Posts: 8
Location: Highlands, NJ

PostPosted: Wed Sep 29, 2010 8:39 pm
Reply with quote

You are looking at the output and assuming that there was a value of "15" input into one of the fields.

I'm lookinig at the code presented and asking where the value of "15" came from? I don't see any code that moves 15 into a field or do I see a field with a value clause of 15. I'm looking the the code that was presented. I'm not assuming anything. Perhaps the 15 is just a value sitting in core at the time the program was executed? I don't know, that's why I asked.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Sep 29, 2010 8:53 pm
Reply with quote

Hello,

Quote:
You are looking at the output and assuming that there was a value of "15" input into one of the fields.
Yup, figured it (WORK-ON-HAND-QTY = 15) must have come from a "read" or a "move" not posted. . .

As the 15 is constant throughout, i accepted it as valid.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Sun Oct 03, 2010 9:23 pm
Reply with quote

According to the output displayed in the original question,
we can assume that field WORK-ON-HAND-QTY - which is defined as PIC X(05) - contained "15bbb" (b being a space)

I hope VGK used the FUNCTION NUMVAL to fix his problem...
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
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 COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts Need Help with Packed Decimal Signs DFSORT/ICETOOL 4
Search our Forums:

Back to Top