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

Procesing a String Variable


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ojdiaz

New User


Joined: 19 Nov 2008
Posts: 98
Location: Spain

PostPosted: Mon Aug 17, 2015 6:52 pm
Reply with quote

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
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Mon Aug 17, 2015 7:03 pm
Reply with quote

Have you looked into the NUMVAL function?
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 17, 2015 7:08 pm
Reply with quote

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
View user's profile Send private message
ojdiaz

New User


Joined: 19 Nov 2008
Posts: 98
Location: Spain

PostPosted: Mon Aug 17, 2015 7:59 pm
Reply with quote

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
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 Replace each space in cobol string wi... COBOL Programming 3
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts Variable Output file name DFSORT/ICETOOL 8
Search our Forums:

Back to Top