Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 7315

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: 7315

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 Moving values to a variable of copybo... Vignesh Sid COBOL Programming 6 Wed Sep 06, 2017 1:04 pm
No new posts Updating the Trailer count in variabl... satheshbabur DFSORT/ICETOOL 6 Wed Aug 30, 2017 9:49 pm
No new posts Move from Comp3 variable to Edited Va... sreekusr COBOL Programming 8 Thu Aug 10, 2017 4:20 pm
No new posts Can I traverse a STEM variable? chong.zhou CLIST & REXX 5 Wed May 31, 2017 3:54 pm
No new posts Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us