View previous topic :: View next topic
|
Author |
Message |
Gopalakrishnan V
Active User
Joined: 28 Jun 2010 Posts: 102 Location: chennai
|
|
|
|
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 |
|
|
Kjeld
Active User
Joined: 15 Dec 2009 Posts: 365 Location: Denmark
|
|
|
|
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 |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
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 |
|
|
Gopalakrishnan V
Active User
Joined: 28 Jun 2010 Posts: 102 Location: chennai
|
|
|
|
Hi,
Thank you for all, my problem resolved. |
|
Back to top |
|
|
Traveler
New User
Joined: 12 Aug 2010 Posts: 8 Location: Highlands, NJ
|
|
|
|
Did I miss something here? From the code presented where did the value "15" get introduced? |
|
Back to top |
|
|
Kjeld
Active User
Joined: 15 Dec 2009 Posts: 365 Location: Denmark
|
|
|
|
I think you missed the part of the OP's first post stating the observed results, opposed to the expected results. |
|
Back to top |
|
|
Traveler
New User
Joined: 12 Aug 2010 Posts: 8 Location: Highlands, NJ
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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
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 |
|
|
Traveler
New User
Joined: 12 Aug 2010 Posts: 8 Location: Highlands, NJ
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
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 |
|
|
|