Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Moving sign bit from X variable to 9

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
seahawk789

New User


Joined: 22 Feb 2010
Posts: 56
Location: Cochin

PostPosted: Mon Aug 11, 2014 2:45 am    Post subject: Moving sign bit from X variable to 9
Reply with quote

Hi,
I have the following requirement.


A variable is declared as below: ws-hold sign will contain + or - and ws-hold-amt will contain values like 222.99

Code:

01 WS-HOLD-FULL-AMT.
      05  WS-HOLD-SIGN  PIC X(01) VALUE SPACES.
      05  WS-HOLD-AMT   PIC 9(07)V(99).


Another variable is declared is declared as below

Code:
01 WS-FINAL-OUT PIC S9(07)V(99).


I need to store the value that is there in WS-HOLD-FULL-AMT group variable to WS-FINAL-OUT. Can we just use move statement to move WS-HOLD-FULL-AMT to WS-FINAL-OUT ?

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

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7314

PostPosted: Mon Aug 11, 2014 3:30 am    Post subject: Reply to: Moving sign bit from X variable to 9.
Reply with quote

No. But you can look at the SIGN clause in the COBOL manual, and make a definition which you can just MOVE to your destination field.
Back to top
View user's profile Send private message
seahawk789

New User


Joined: 22 Feb 2010
Posts: 56
Location: Cochin

PostPosted: Mon Aug 11, 2014 4:06 am    Post subject:
Reply with quote

well.. I cannot change the source layout as it is existing. Is there any way to do this using redefines ?
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 2173
Location: NY,USA

PostPosted: Mon Aug 11, 2014 5:15 am    Post subject:
Reply with quote

Code:
If ws-hold-sign = '-'
    Compute ws-final-out = ws-hold-amt × -1
Else
    Compute ws-final-out = ws-hold-amt × (+1)
End-if


Or use a redefine.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7314

PostPosted: Mon Aug 11, 2014 11:39 am    Post subject: Reply to: Moving sign bit from X variable to 9.
Reply with quote

Yes, it works with REDEFINES. Why wouldn't it?
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7314

PostPosted: Mon Aug 11, 2014 11:54 am    Post subject: Reply to: Moving sign bit from X variable to 9.
Reply with quote

Rohit,

Code:
If ws-hold-sign = '-'
    Compute ws-final-out = 0 - ws-hold-amt
Else
    Move ws-hold-amt To ws-final-out
End-if


The '-' is better as an 88, but then TS/OP is unable to change the definition...

seahawk789,

It is a little unclear, re-reading. That "." isn't in your data, is it?
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 2173
Location: NY,USA

PostPosted: Mon Aug 11, 2014 7:21 pm    Post subject:
Reply with quote

Bill,
Code:
The '-' is better as an 88, but then TS/OP is unable to change the definition...

You are right and as that would be as per the coding standards.
My understanding is TS could not be able to change below piece
Code:
01 WS-HOLD-FULL-AMT.
      05  WS-HOLD-SIGN  PIC X(01) VALUE SPACES.
      05  WS-HOLD-AMT   PIC 9(07)V(99).

But I thought he could add up a another 88 level and place the above logic.
Back to top
View user's profile Send private message
seahawk789

New User


Joined: 22 Feb 2010
Posts: 56
Location: Cochin

PostPosted: Tue Aug 12, 2014 7:32 am    Post subject:
Reply with quote

So will the below redefine work for the scenario ?

Code:
01 WS-FINAL-OUT PIC S9(07)V(99).

01 WS-HOLD-FULL-AMT REDEFINES WS-FINAL-OUT.
      05  WS-HOLD-SIGN  PIC X(01) VALUE SPACES.
      05  WS-HOLD-AMT   PIC 9(07)V(99).
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 2173
Location: NY,USA

PostPosted: Tue Aug 12, 2014 8:04 pm    Post subject:
Reply with quote

Quote:
So will the below redefine work for the scenario ?

I would prefer to say nothing but request you to try and let us know the results. YOu have two options already in your hand as a solution.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7314

PostPosted: Tue Aug 12, 2014 9:45 pm    Post subject: Reply to: Moving sign bit from X variable to 9.
Reply with quote

You've not clarified what you input data actually is and what output you want. I doubt that REDEFINES will give you what you want, but as Rohit said...
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 2173
Location: NY,USA

PostPosted: Wed Aug 13, 2014 7:41 pm    Post subject:
Reply with quote

Code:
PIC S9(7)V9(2) SIGN LEADING SEPARATE
what happens when you move to this directly btw?
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 Having problem passing a variable to ... markzasz JCL & VSAM 12 Thu Jul 11, 2019 5:31 pm
No new posts position, start pos, length of column... juares castro SYNCSORT 14 Fri Jun 21, 2019 8:47 pm
No new posts Identify who, from where, sign on CIC... Weilin Wen CICS 1 Thu May 09, 2019 1:23 pm
No new posts Need to loop & extract from varia... pkmurali CLIST & REXX 2 Thu Jan 10, 2019 11:42 pm
No new posts Confusion regarding length of SQLCA v... Vivek0410 DB2 4 Thu Oct 18, 2018 2:20 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us