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
 
Need a help to read last 3 bytes from a field

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Need a help to read last 3 bytes from a field
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    Post subject: Re: Need a help to read last 3 bytes from a field
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    Post subject: Re: Need a help to read last 3 bytes from a field
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    Post subject:
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: 1243
Location: Israel

PostPosted: Sun Jun 11, 2006 8:48 pm    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject: Re: Need a help to read last 3 bytes from a field
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    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 sort records based on length exceeds ... maxsubrat DFSORT/ICETOOL 7 Wed Oct 04, 2017 4:48 pm
No new posts Partial color change of a field in CI... waseem0424 CICS 5 Fri Sep 29, 2017 7:56 pm
No new posts how to see when the last read access ... Mike 1304 DB2 1 Tue Sep 12, 2017 7:52 pm
No new posts Error in SQL-PLIST3 'Above value tru... rikdeb DB2 4 Wed Sep 06, 2017 1:34 pm
No new posts Remove leading spaces from numeric field rexx77 SYNCSORT 6 Wed Sep 06, 2017 2:15 am

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