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

Variable Formatting to append a 'Zero'


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

New User


Joined: 19 Dec 2010
Posts: 42
Location: Bangalore

PostPosted: Thu Sep 08, 2011 7:01 pm
Reply with quote

Hi,

I am trying to format the input varaible with PIC X. The data is as below:

Input:
11
1
Spaces (bb)

Expected Output:
11
01
Spaces (bb)

Trying to do define a single variable say In-ID PIC X(2).
However when I move to Out-ID PIC 9(2) - (since I have to append a 'Zero', if it is single alphanumeric in my case above it is '1'). But getting problem at my third record i.e,spaces.

Please can you suggest me effective way so that I can do it easily ...
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: Thu Sep 08, 2011 7:46 pm
Reply with quote

Your input is

11
1b
bb

Your desired output is

11
01
bb


Code:
01  RECEIVING-FIELD.
    05  RF-BYTE-1 PIC X.
    05  RF-BYTE-2 PIC X.


Code:
move input-filed to RECEIVING-FIELD.
if RF-BYTE-2 equal to space
    if (  RF-BYTE-1 not equal to space )
        move RF-BYTE-1 to RF-BYTE-2
        move zero to RF-BYTE-1   
    end-if
end-if
.


Can you get b1?
Back to top
View user's profile Send private message
Ed Goodman

Active Member


Joined: 08 Jun 2011
Posts: 556
Location: USA

PostPosted: Thu Sep 08, 2011 10:30 pm
Reply with quote

See if the NUMVAL function would help. It can work with this kind of data and produce good results.

I can't remember what it does with an input that is all spaces though, you'll have to check.
Back to top
View user's profile Send private message
abraralum

New User


Joined: 19 Dec 2010
Posts: 42
Location: Bangalore

PostPosted: Thu Sep 08, 2011 10:47 pm
Reply with quote

Thanks Bill. I was thinking we might do it using string functions with out if logic ...

Thanks Ed. I will get into on Numval an try at wrk.
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: Fri Sep 09, 2011 1:56 am
Reply with quote

If your field is actually two bytes long, I'm not sure I see the need beyond the most simple.

The longer the field is, the less sense in coding out an if/evaluate.

If you want to avoid the simple, I think your task will be easier as Ed has suggested.
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 How to append a PS file into multiple... JCL & VSAM 3
No new posts Need help to append a date&tsp at... DFSORT/ICETOOL 9
No new posts Need help on formatting a report DFSORT/ICETOOL 14
No new posts Variable Output file name DFSORT/ICETOOL 8
Search our Forums:

Back to Top