Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
Gopalakrishnan V

Active User

Joined: 28 Jun 2010
Posts: 102
Location: chennai

Posted: Tue Sep 28, 2010 12:40 pm    Post subject: How to move zoned decimal value into packed decimal

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

Kjeld

Active User

Joined: 15 Dec 2009
Posts: 365
Location: Denmark

 Posted: Tue Sep 28, 2010 2:23 pm    Post subject: 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.
Marso

REXX Moderator

Joined: 13 Mar 2006
Posts: 1274
Location: Israel

Posted: Tue Sep 28, 2010 3:46 pm    Post subject: Reply to: How to move zoned decimal value into packed decima

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 ">"
Gopalakrishnan V

Active User

Joined: 28 Jun 2010
Posts: 102
Location: chennai

 Posted: Tue Sep 28, 2010 5:55 pm    Post subject: Hi, Thank you for all, my problem resolved.
Traveler

New User

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

 Posted: Wed Sep 29, 2010 6:21 pm    Post subject: Did I miss something here? From the code presented where did the value "15" get introduced?
Kjeld

Active User

Joined: 15 Dec 2009
Posts: 365
Location: Denmark

 Posted: Wed Sep 29, 2010 6:44 pm    Post subject: I think you missed the part of the OP's first post stating the observed results, opposed to the expected results.
Traveler

New User

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

Posted: Wed Sep 29, 2010 7:34 pm    Post subject:

 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?
dick scherrer

Site Director

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

Posted: Wed Sep 29, 2010 8:24 pm    Post subject:

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. . .?
Traveler

New User

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

 Posted: Wed Sep 29, 2010 8:39 pm    Post subject: 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.
dick scherrer

Site Director

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

Posted: Wed Sep 29, 2010 8:53 pm    Post subject:

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.
Marso

REXX Moderator

Joined: 13 Mar 2006
Posts: 1274
Location: Israel

 Posted: Sun Oct 03, 2010 9:23 pm    Post subject: Reply to: How to move zoned decimal value into packed decima 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...
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics How to group and sum the decimal value sakrat DFSORT/ICETOOL 2 Tue Mar 06, 2018 9:13 pm RMM Cannot move a volume from SHELF l... tspr52 IBM Tools 0 Thu Mar 01, 2018 3:48 pm how can i move s9(9) to s9(9) usage comp HARENDRA CHOUDHARY COBOL Programming 3 Mon Nov 06, 2017 12:10 am Move from Comp3 variable to Edited Va... Revathy.nair0485 COBOL Programming 7 Fri Nov 03, 2017 3:30 pm Extend the decimal values in DIVISION Balaryan DFSORT/ICETOOL 3 Thu Oct 05, 2017 4:05 pm

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us