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
 

 

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: 47
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: 7228

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: 47
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: 1609
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: 7228

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: 7228

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: 1609
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: 47
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: 1609
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: 7228

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: 1609
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 Moving a PD to PD spoorni DFSORT/ICETOOL 8 Fri Oct 07, 2016 9:52 pm
No new posts Format to pipe delimited with variabl... pshongal SYNCSORT 6 Wed Sep 14, 2016 2:48 pm
No new posts Variable for cursor names ravikumar15 DB2 5 Sun Jul 17, 2016 7:08 am
No new posts Moving character data to smallint in db2 rikdeb DB2 5 Thu Jul 14, 2016 12:38 am
No new posts OPC JCL Variable passion_sujesh IBM Tools 5 Fri Jul 01, 2016 4:21 am


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