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
 

 

Variable Formatting to append a 'Zero'

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Variable Formatting to append a 'Zero'
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7251

PostPosted: Thu Sep 08, 2011 7:46 pm    Post subject: Reply to: Variable Formatting - Need help
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    Post subject:
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    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7251

PostPosted: Fri Sep 09, 2011 1:56 am    Post subject: Reply to: Variable Formatting - Need help
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    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 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 OPC JCL Variable passion_sujesh IBM Tools 5 Fri Jul 01, 2016 4:21 am
No new posts JOINKEYs and Variable files migusd SYNCSORT 8 Fri Jun 17, 2016 3:16 am
No new posts File Manager with Variable Length File ahabib IBM Tools 10 Thu Mar 31, 2016 11:00 pm


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