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
 

 

Procesing a String Variable

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

New User


Joined: 19 Nov 2008
Posts: 90
Location: Spain

PostPosted: Mon Aug 17, 2015 6:52 pm    Post subject: Procesing a String Variable
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: 1238
Location: Richfield, MN, USA

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

Have you looked into the NUMVAL function?
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7225

PostPosted: Mon Aug 17, 2015 7:08 pm    Post subject: Reply to: Procesing a String Variable
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: 90
Location: Spain

PostPosted: Mon Aug 17, 2015 7:59 pm    Post subject:
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    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
This topic is locked: you cannot edit posts or make replies. Checking wether a string starts from ... sundaram.naveen CLIST & REXX 9 Thu Oct 06, 2016 11:56 am
No new posts Format to pipe delimited with variabl... pshongal SYNCSORT 6 Wed Sep 14, 2016 2:48 pm
No new posts Random Password (in string format) ge... ezhavendhan COBOL Programming 10 Mon Aug 29, 2016 3:18 pm
No new posts How to insert a lengthy string havin... vidyaa DB2 7 Thu Aug 25, 2016 5:20 pm
No new posts Which function does the Ampersand (&a... Andi1982 PL/I & Assembler 3 Wed Aug 24, 2016 2:05 pm


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