View previous topic :: View next topic
|
Author |
Message |
maheshurstd
New User
Joined: 16 Feb 2006 Posts: 14
|
|
|
|
Hi
My requirement is that i have a field in VSAM file, that field is pic X(17) length & it contains values e.g
AMAP14325NBVkL
AMBP1423VB
BXCV657U
would it be possible for to read only the last 3 values i.e VKL, 3VB, 57U from this field.if any one has the code please send it or tell me a way to do it.
thanks in advance
regards
Mahesh |
|
Back to top |
|
|
Aji
New User
Joined: 03 Feb 2006 Posts: 53 Location: Mumbai
|
|
|
|
Hi
Please try out the code below. (I didn't test the code, correct me if I am wrong)
INSPECT FUNCTION REVERSE(TEXT1) TALLYING
L FOR LEADING SPACE
compute l = length of text1 - l
if l > 3
subtract 3 from l
move text1(l:3) to new_char
else
move text1 to new_char
end-if
regards
Aji Cherian |
|
Back to top |
|
|
prasadvrk
Active User
Joined: 31 May 2006 Posts: 200 Location: Netherlands
|
|
|
|
maheshurstd wrote: |
Hi
My requirement is that i have a field in VSAM file, that field is pic X(17) length & it contains values e.g
AMAP14325NBVkL
AMBP1423VB
BXCV657U
would it be possible for to read only the last 3 values i.e VKL, 3VB, 57U from this field.if any one has the code please send it or tell me a way to do it.
thanks in advance
regards
Mahesh |
You can as well try the following code to get the last three chars.
WS-VAR((LENGTH OF WS-VAR-3):3)
Hope this meets your requiement. |
|
Back to top |
|
|
shreevamsi
Active User
Joined: 23 Feb 2006 Posts: 305 Location: Hyderabad,India
|
|
|
|
Could you plz allobrate on this prasadvrk.
maheshurstd want the last non space chars from the field.
I couldn't understand
Quote: |
WS-VAR((LENGTH OF WS-VAR-3):3) |
|
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
Three lines solution:
1 line in WORKING-STORAGE SECTION:
Code: |
01 WS-VAR PIC X(20) JUST RIGHT. |
2 lines in PROCEDURE DIVISION:
Code: |
UNSTRING VSAM-FIELD DELIMITED BY ALL ' ' INTO WS-VAR
MOVE WS-VAR(18:3) TO HERE-IT-IS |
|
|
Back to top |
|
|
prasadvrk
Active User
Joined: 31 May 2006 Posts: 200 Location: Netherlands
|
|
|
|
If WS-VAR is the VSAM field then the following code will get you the last three chars of that field.
WS-VAR((LENGTH OF WS-VAR-3):3)
If you still have doubts please post your doubts again |
|
Back to top |
|
|
shreevamsi
Active User
Joined: 23 Feb 2006 Posts: 305 Location: Hyderabad,India
|
|
|
|
Quote: |
WS-VAR((LENGTH OF WS-VAR-3):3) |
Consider the follwoing:
77 WS-VAR PIC X(20) VALUE SPACES.
MOVE 'VAMSI KRISHNA' TO WS-VAR.
LENGHT OF WA-VAR RETURNS 20 ONLY BUT NOT 13.
Similarly in ur case WS-VAR((LENGTH OF WS-VAR-3):3) will return spaces only but nor HNA.
Hope u got what i mean.
~Vamsi |
|
Back to top |
|
|
prasadvrk
Active User
Joined: 31 May 2006 Posts: 200 Location: Netherlands
|
|
|
|
You are right Vamshi I did not pay attentio to the non space aspect.
Yes you have unstring the VSAM field into WS-VAR delimited by space and then only you can use this |
|
Back to top |
|
|
maheshurstd
New User
Joined: 16 Feb 2006 Posts: 14
|
|
|
|
Hi friends,
Thanks for your suggessions,
It is working fine, Thanks to every one
Regards
Mahesh |
|
Back to top |
|
|
|