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
 

 

Move from Numeric to Comp-3

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Move from Numeric to Comp-3
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Thu Jul 03, 2014 11:58 am    Post subject: Reply to: Move from Numeric to Comp-3
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    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Thu Jul 03, 2014 12:53 pm    Post subject: Reply to: Move from Numeric to Comp-3
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: 1219
Location: Israel

PostPosted: Thu Jul 03, 2014 6:52 pm    Post subject:
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: 1219
Location: Israel

PostPosted: Thu Jul 03, 2014 6:58 pm    Post subject:
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: 1238
Location: Richfield, MN, USA

PostPosted: Thu Jul 03, 2014 7:18 pm    Post subject:
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    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
This topic is locked: you cannot edit posts or make replies. How to move a long alphanumeric data ... lind sh COBOL Programming 8 Mon Dec 05, 2016 7:51 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts Protection Exception while move 0 to ... Kevin Vaz CICS 10 Tue Oct 18, 2016 4:19 pm
No new posts How can we create a flat file in JAVA... rakesh.v18 Java & MQSeries 7 Fri Sep 23, 2016 10:46 pm
No new posts Casting a Binary Number to Numeric in... Bob Steinkraus Java & MQSeries 6 Tue Aug 09, 2016 5:58 pm


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