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

Moving sign bit from X variable to 9


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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

Moderator Emeritus


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

PostPosted: Mon Aug 11, 2014 3:30 am
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
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

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Mon Aug 11, 2014 5:15 am
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

Moderator Emeritus


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

PostPosted: Mon Aug 11, 2014 11:39 am
Reply with quote

Yes, it works with REDEFINES. Why wouldn't it?
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: Mon Aug 11, 2014 11:54 am
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

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Mon Aug 11, 2014 7:21 pm
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
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

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Tue Aug 12, 2014 8:04 pm
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

Moderator Emeritus


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

PostPosted: Tue Aug 12, 2014 9:45 pm
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

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Wed Aug 13, 2014 7:41 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Variable Output file name DFSORT/ICETOOL 8
No new posts Moving Or setting POINTER to another ... COBOL Programming 2
No new posts parsing variable length/position data... DFSORT/ICETOOL 5
No new posts Masking variable size field - min 10 ... DFSORT/ICETOOL 4
Search our Forums:

Back to Top