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

Move from Numeric to Comp-3


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Sumit Gupta

New User


Joined: 01 May 2014
Posts: 4
Location: India

PostPosted: Thu Jul 03, 2014 11:37 am
Reply with quote

Hi,

I am receiving data from Oracle OSB via SOA service in my COBOL program in below format,
WS-VAR1 PIC 9(13)V99

I need to convert it to below format and pass it to downstream,
WS-VAR2 PIC S9(13)V99 COMP-3

I am successfully able to move the data from WS-VAR1 to WS-VAR2 but just wanted to make sure that I am doing it correctly.
Can anyone confirm if there will not be any data loss in this movement.

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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Jul 03, 2014 11:58 am
Reply with quote

There's a massive loss of human data, clarity, when you use data-names like "VAR1" and "VAR2".

"Hey, look at the program and tell me what the third field on the file is, please."

"Yeah, fine, it's VAR2."

"OooooKkkkkkk.... what does it contain?"

"Well, we move VAR1 to it."

Other than that, you have 13 integer digits and two decimal digits on both fields, what could go wrong? Oh, there's the signs. Your source is unsigned, your destination signed. Check that your source really has no sign, then check that you should actually bother with a sign on the destination - can it ever be negative?
Back to top
View user's profile Send private message
Sumit Gupta

New User


Joined: 01 May 2014
Posts: 4
Location: India

PostPosted: Thu Jul 03, 2014 12:18 pm
Reply with quote

Hi Bill,

This field contains amount which can go up to 13 digits and 2 decimal digits.

Also for your next question regarding sign, Source is not having sign and value can not be negative at any point of time and we have a requirement to send the sign to destination so cannot skip that.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Jul 03, 2014 12:53 pm
Reply with quote

Well, someday someone is going to be confused and waste time/cause a problem with the signed/unsigned thing, but it is the requirement....

Your are not losing any digits, anyway.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Thu Jul 03, 2014 6:52 pm
Reply with quote

You might want to check
Code:
IF WS-VAR1 IS NOT NUMERIC THEN
    DISPLAY 'VAR1 HAS JUNK !'
    MOVE 0 TO WS-VAR2
ELSE
    MOVE WS-VAR1 TO WS-VAR2
END-IF
or something like that.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Thu Jul 03, 2014 6:58 pm
Reply with quote

The signed/unsigned thing could be easily solved if the variables had a real name.
For example, WS-PRICE don't really need a sign (nothing costs -9.99$).
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Thu Jul 03, 2014 7:18 pm
Reply with quote

Marso wrote:
The signed/unsigned thing could be easily solved if the variables had a real name.
For example, WS-PRICE don't really need a sign (nothing costs -9.99$).
Just to play the devil's advocate, how about adjustments? You never know what future enhancements/requirements can come up. icon_smile.gif
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 Issues Converting From ZD to Signed N... DFSORT/ICETOOL 4
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts How to move the first field of each r... DFSORT/ICETOOL 5
No new posts Convert HEX to Numeric DB2 3
No new posts Converting ASCII values to COMP-3 (ZD... JCL & VSAM 2
Search our Forums:

Back to Top