View previous topic :: View next topic
|
Author |
Message |
ojdiaz
New User
Joined: 19 Nov 2008 Posts: 98 Location: Spain
|
|
|
|
Hi
It's been a long long while since I had to do something in COBOL. In this installation the version used is Enterprise COBOL for z/OS 4.2.0.
I need to process an imput variable from the front UI with a variable length which format might be like this:
Code: |
-999,9999
-99,9999
-9,9999
9999,9999
999,9999
99,9999
9,9999 |
It is a % value that could be negative or positive.
My program receives this variable in the Transaction Linkage area in a PIC X(20) variable, aligned to the rigth.
I need to be able to move that variable to a PIC S9(4)V9(8) variable, in order to perform some calculations, and finally, i have to move it to a PIC X(20) varibale and pass it to a routine, which needs it to be formated like (-9999,99999999) format, aligned to the right. The sign could be optional if the value es positive.
I've been trying to move the input variable to edit variables, like this:
Code: |
10 WS-FOR-RAR PIC -9999,99999999.
10 WS-FOR-RAR2 PIC ---9,99999999.
10 WS-RAR PIC X(11).
10 WS-RAR-RED REDEFINES WS-RAR.
15 WS-NUM-RAR PIC S9(3)V9(6).
15 FILLER PIC X(2). |
But I still I'm not able to do this.
Any help Please?
Thanks a lot
Oliver. |
|
Back to top |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
|
|
Have you looked into the NUMVAL function? |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
You first need to right-align it, using a "Goldilocks" field:
Code: |
01 a-nice-descriptive-name PIC X(10)
JUSTIFIED RIGHT.
....
UNSTRING input-data
DELIMITED BY ALL SPACE
INTO a-nice-descriptive-name |
Then do your de-edit:
Code: |
01 a-nice-descriptive-name PIC X(10)
JUSTIFIED RIGHT.
01 FILLER
REDFINES a-nice-descriptive-name.
05 another-nice-name PIC -(4)9.9999.
....
MOVE another-nice-name TO where-it-is-needed |
I assume you have DECIMAL POINT IS COMMA.
FUNCTION NUMVAL is a more resource-intensive (but less code) alternative.
You could also count the trailing spaces and use reference-modification or variable-length fields. |
|
Back to top |
|
|
ojdiaz
New User
Joined: 19 Nov 2008 Posts: 98 Location: Spain
|
|
|
|
Bill and Terry, Thanks for the reply. I Haven't looked at the NUMVAL function, but I'm pretty much sure that I won't be able to use it in this installation since there are a lot of instructions that are "forbidden" just for that, resource intensive usage.
Also, yes, the program has DECIMAL POINT IS COMMA.
I'll try your suggestion Bill. Thanks a lot
Oliver |
|
Back to top |
|
|
|