MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Cobol program to populate s9(4) field value

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
rajkumar_1981
Beginner


Joined: 05 Jan 2007
Posts: 5
Topics: 4

PostPosted: Wed Jun 06, 2007 5:01 am    Post subject: Cobol program to populate s9(4) field value Reply with quote

hi,

input
------
01 a pic x value '+'

01 b pic 9(4)

output
-------
01 c pic s9(4).



to populate the input value into output.

for example,

a=+(x) , b=1000(9(4))

c=+1000(in s9(4))

Please help me...
Back to top
View user's profile Send private message
CICS Guy
Intermediate


Joined: 30 Apr 2007
Posts: 292
Topics: 3

PostPosted: Wed Jun 06, 2007 5:45 am    Post subject: Reply with quote

If a will always be "+", just move b to c.
If a might be "+" or "-", use a conditional to set the sign such as:
move zero to c
if a = '+' add b to c
if a = '-' subtract b from c

The "S" in the pic of c is not a plus or minus sign, is is actually a difference in the high half of the low-order byte.
Back to top
View user's profile Send private message
rajkumar_1981
Beginner


Joined: 05 Jan 2007
Posts: 5
Topics: 4

PostPosted: Wed Jun 06, 2007 11:02 pm    Post subject: Re: Cobol program to populate s9(4) field value Reply with quote

rajkumar_1981 wrote:
hi,

input
------
01 a pic x value '+'

01 b pic 9(4)

output
-------
01 c pic s9(4).



to populate the input value into output.

for example,

a=+(x) , b=1000(9(4))

c=+1000(in s9(4))

it is not add or sub. it populate the inputs values (a, b ) to output variable
(c).i.e., it combine the input values(a, b) to populate into output variable.

Please help me...
Back to top
View user's profile Send private message
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Thu Jun 07, 2007 12:46 am    Post subject: Reply with quote

rajkumar_1981,

signed display numeric values can have their sign either leading or trailing - indicated by the 'leading or trailing clause' in the element definition.

If you wish to actually move the sign character, then c needs to be redefined. You should refer to the manual for information how to accomplish this for your student project.

A professional would write code that would work for either trailing/leading as well as display and Packed-decimal - or any other numeric designation. That way, if the data definition changes, the code must not.

Code:

MOVE b TO c
IF a = '-'
THEN
       COMPUTE         c = c * -1
       END-COMPUTE
END-IF


also, in the future please use BBcode to enable better readability
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group