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

Is following code ok?


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sauraso
Warnings : 1

New User


Joined: 27 Feb 2010
Posts: 16
Location: usa

PostPosted: Tue Mar 02, 2010 1:46 am
Reply with quote

Hi,

Will following code cause any errors or issues?

10 WS-OL-MO-BENE-AMT PIC 9(5)V99.

10 BF-OL-MO-BENE-AMT PIC S9(5)V99 COMP-3.


MOVE BF-OL-MO-BENE-AMT TO WS-OL-MO-BENE-AMT
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Tue Mar 02, 2010 1:53 am
Reply with quote

It's OK but only if the the sending field is positive.
If it is negative, the sign will be lost.
Back to top
View user's profile Send private message
sauraso
Warnings : 1

New User


Joined: 27 Feb 2010
Posts: 16
Location: usa

PostPosted: Tue Mar 02, 2010 1:58 am
Reply with quote

I am getting junk values in resultant field WS-OL-MO-BENE-AMT. any idea why?

Also if i want to include sign field then how should i define resultant field.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Tue Mar 02, 2010 2:13 am
Reply with quote

sauraso wrote:
I am getting junk values in resultant field WS-OL-MO-BENE-AMT. any idea why?
My guess would be that there is garbage in BF-OL-MO-BENE-AMT.....
The UNPK will unpack garbage without an exception...
Quote:
Also if i want to include sign field then how should i define resultant field.
10 WS-OL-MO-BENE-AMT PIC S9(5)V99.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Tue Mar 02, 2010 2:31 am
Reply with quote

Make sure your COMP-3 data is valid so that it unpacks correctly.

After the move (unpack) of valid data to the receiving field, the high-order nibble (4-Bit) of the last byte will equal X'C' or X'D' (positive and negative, respectively).

The low-order nibble will contain a X'0' through a X'4'.

You will never find a X'D0' (IE: Negative Zero), just a X'C0' in the last byte.

Bill
Back to top
View user's profile Send private message
sauraso
Warnings : 1

New User


Joined: 27 Feb 2010
Posts: 16
Location: usa

PostPosted: Tue Mar 02, 2010 2:39 am
Reply with quote

Is there any particular method to make sure comp-3 field is converted properly into numeric field.

Thanks Bill and CICS guy for responce.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Tue Mar 02, 2010 2:45 am
Reply with quote

sauraso wrote:
Is there any particular method to make sure comp-3 field is converted properly into numeric field.
A COBOL move from numeric to numeric will always convert correctly.
Bad sending data can cause the recieving data to appear as garbage or a S0C7.
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: Tue Mar 02, 2010 2:53 am
Reply with quote

Hello,

Suggest you identify/resolve how you have an "input" (i.e. sending field) comp-3 field that does not contain valid numerics. . .

Whatever causes this should be corrected.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Tue Mar 02, 2010 6:32 am
Reply with quote

Bill O'Boyle wrote:

The low-order nibble will contain a X'0' through a X'4'.

Oops, I must have been looking the other way while typing. icon_redface.gif

The correct value ranges are X'0' through X'9'.

Bill
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Tue Mar 02, 2010 6:54 am
Reply with quote

Bill O'Boyle wrote:
Oops, I must have been looking the other way while typing. icon_redface.gif
Thanks, I was really wondering what I was missing..... icon_wink.gif
Back to top
View user's profile Send private message
Kjeld

Active User


Joined: 15 Dec 2009
Posts: 365
Location: Denmark

PostPosted: Tue Mar 02, 2010 2:01 pm
Reply with quote

Bill O'Boyle wrote:
Make sure your COMP-3 data is valid so that it unpacks correctly.

After the move (unpack) of valid data to the receiving field, the high-order nibble (4-Bit) of the last byte will equal X'C' or X'D' (positive and negative, respectively).

The low-order nibble will contain a X'0' through a X'9'.

You will never find a X'D0' (IE: Negative Zero), just a X'C0' in the last byte.

(The typo was corrected in above quote).

As the WS-OL-MO-BENE-AMT was unsigned numeric I would expect the high order nibble to be x'F' in all bytes. It is only in signed fields you have the above signed values in the last byte.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Tue Mar 02, 2010 4:40 pm
Reply with quote

I guess yesterday was "Head up my A$$ day"? The receiving field was unsigned display-numeric and the high order nibble will always be X'F'. Perhaps it was wishful thinking on my part? icon_wink.gif

Bill
Back to top
View user's profile Send private message
Kjeld

Active User


Joined: 15 Dec 2009
Posts: 365
Location: Denmark

PostPosted: Tue Mar 02, 2010 5:03 pm
Reply with quote

It's Ok Bill, I am sure no harm done. Hope your head is in it's right place today icon_smile.gif

I think our topic poster have left us to investigate were his junk input came from...
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 run rexx code with jcl CLIST & REXX 15
No new posts Compile rexx code with jcl CLIST & REXX 6
No new posts REXX code to expand copybook in a cob... CLIST & REXX 2
No new posts VSAM return code 23 - for a Random read COBOL Programming 4
No new posts Monitoring production job progress. N... JCL & VSAM 4
Search our Forums:

Back to Top