View previous topic :: View next topic
|
Author |
Message |
abraralum
New User
Joined: 19 Dec 2010 Posts: 42 Location: Bangalore
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Ed Goodman
Active Member
Joined: 08 Jun 2011 Posts: 556 Location: USA
|
|
|
|
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 |
|
|
abraralum
New User
Joined: 19 Dec 2010 Posts: 42 Location: Bangalore
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
|