Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

How to move zoned decimal value into packed decimal

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: How to move zoned decimal value into packed decimal
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    Post subject:
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: 1235
Location: Israel

PostPosted: Tue Sep 28, 2010 3:46 pm    Post subject: Reply to: How to move zoned decimal value into packed decima
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Wed Sep 29, 2010 8:24 pm    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Wed Sep 29, 2010 8:53 pm    Post subject:
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: 1235
Location: Israel

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

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Move from Comp3 variable to Edited Va... sreekusr COBOL Programming 8 Thu Aug 10, 2017 4:20 pm
No new posts READ A PACKED "NEGATIVE" FI... jdesouza CA Products 3 Tue May 02, 2017 11:43 pm
No new posts Joinkeys with decimal scdinesh DFSORT/ICETOOL 3 Fri Feb 10, 2017 4:46 am
No new posts Converting decimal to numeric using I... Balaryan DFSORT/ICETOOL 4 Thu Feb 02, 2017 11:27 pm
No new posts DB2 9.1.0 not move values to Host-Var... Miguel Fernandez DB2 8 Wed Jan 25, 2017 8:24 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us