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

Need a help to read last 3 bytes from a field


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

New User


Joined: 16 Feb 2006
Posts: 14

PostPosted: Thu Jun 08, 2006 11:04 am
Reply with quote

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
View user's profile Send private message
Aji

New User


Joined: 03 Feb 2006
Posts: 53
Location: Mumbai

PostPosted: Thu Jun 08, 2006 3:54 pm
Reply with quote

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
View user's profile Send private message
prasadvrk

Active User


Joined: 31 May 2006
Posts: 200
Location: Netherlands

PostPosted: Fri Jun 09, 2006 6:16 pm
Reply with quote

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
View user's profile Send private message
shreevamsi

Active User


Joined: 23 Feb 2006
Posts: 305
Location: Hyderabad,India

PostPosted: Fri Jun 09, 2006 7:35 pm
Reply with quote

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
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Sun Jun 11, 2006 8:48 pm
Reply with quote

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
View user's profile Send private message
prasadvrk

Active User


Joined: 31 May 2006
Posts: 200
Location: Netherlands

PostPosted: Mon Jun 12, 2006 11:59 am
Reply with quote

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
View user's profile Send private message
shreevamsi

Active User


Joined: 23 Feb 2006
Posts: 305
Location: Hyderabad,India

PostPosted: Mon Jun 12, 2006 12:11 pm
Reply with quote

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
View user's profile Send private message
prasadvrk

Active User


Joined: 31 May 2006
Posts: 200
Location: Netherlands

PostPosted: Mon Jun 12, 2006 12:18 pm
Reply with quote

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
View user's profile Send private message
maheshurstd

New User


Joined: 16 Feb 2006
Posts: 14

PostPosted: Thu Jun 15, 2006 11:32 am
Reply with quote

Hi friends,

Thanks for your suggessions,

It is working fine, Thanks to every one

Regards

Mahesh
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 Error to read log with rexx CLIST & REXX 11
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Random read in ESDS file by using RBA JCL & VSAM 6
No new posts Join 2 files according to one key field. JCL & VSAM 3
No new posts VSAM return code 23 - for a Random read COBOL Programming 4
Search our Forums:

Back to Top