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
 

 

Is following code ok?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Is following code ok?
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: 2150
Location: At my coffee table

PostPosted: Tue Mar 02, 2010 1:53 am    Post subject:
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    Post subject:
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: 2150
Location: At my coffee table

PostPosted: Tue Mar 02, 2010 2:13 am    Post subject:
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: 2502
Location: Atlanta, Georgia, USA

PostPosted: Tue Mar 02, 2010 2:31 am    Post subject: Reply to: Is following code ok?
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    Post subject:
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: 2150
Location: At my coffee table

PostPosted: Tue Mar 02, 2010 2:45 am    Post subject:
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

Site Director


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

PostPosted: Tue Mar 02, 2010 2:53 am    Post subject:
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: 2502
Location: Atlanta, Georgia, USA

PostPosted: Tue Mar 02, 2010 6:32 am    Post subject: Re: Reply to: Is following code ok?
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: 3158
Location: Tucson AZ

PostPosted: Tue Mar 02, 2010 6:54 am    Post subject: Re: Reply to: Is following code ok?
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    Post subject: Re: Reply to: Is following code ok?
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: 2502
Location: Atlanta, Georgia, USA

PostPosted: Tue Mar 02, 2010 4:40 pm    Post subject: Reply to: Is following code ok?
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    Post subject:
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    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 PL/I code tuning/Performance improvement Virendra Shambharkar PL/I & Assembler 3 Mon Dec 05, 2016 11:57 am
No new posts What is the code in CLIST to enable t... jackzhang75 CLIST & REXX 1 Fri Dec 02, 2016 3:02 am
No new posts IDEAL - Code Retrieval yugendran CA Products 0 Fri Nov 25, 2016 3:27 pm
This topic is locked: you cannot edit posts or make replies. Need to code a Rexx PGM sundaram.naveen CLIST & REXX 18 Thu Oct 06, 2016 6:45 pm
No new posts Need Help in understanding what is th... mainakdalal PL/I & Assembler 9 Mon Oct 03, 2016 8:03 pm


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