Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Getting the length of a variable data string

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
LlewellynNaicker

New User


Joined: 22 Mar 2005
Posts: 5

PostPosted: Wed Sep 27, 2006 6:38 pm    Post subject: Getting the length of a variable data string
Reply with quote

Hi all

I have a problem where I am trying to get the length of a variable data string. Basically it is a group of fields but not a copybook and I need to calculate the length with out doing a perform and calculating byte by byte.

Can anyone give me an easier way to do it.


Your help is much appreciated.

Regards
Llewellyn Naicker
Back to top
View user's profile Send private message

MFRASHEED

Active User


Joined: 14 Jun 2005
Posts: 186
Location: USA

PostPosted: Wed Sep 27, 2006 8:12 pm    Post subject: Re: Getting the length of a variable data string
Reply with quote

If i understood issue correctly, here is what you can use.

You can move the group of fields under one level and get length of the whole level.

Example:
Code:

01  WS-fields.                       
    05  WS-FLD1               PIC X(6).
    05  WS-FLD2               PIC X(9).
    05  WS-FLD1               PIC X(8).

01 WS-FLD-LEN               PIC S9(3)




and use following code

Code:


MOVE LENGTH OF WS-FIELDS                 
                            TO WS-FLD-LEN

Back to top
View user's profile Send private message
LlewellynNaicker

New User


Joined: 22 Mar 2005
Posts: 5

PostPosted: Thu Sep 28, 2006 11:05 am    Post subject: Re: Getting the length of a variable data string
Reply with quote

Hi there thanx so much for your reply. I was not sure if that statement would work but will try it out. icon_biggrin.gif
Back to top
View user's profile Send private message
shreevamsi

Active User


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

PostPosted: Thu Sep 28, 2006 12:28 pm    Post subject:
Reply with quote

hi LlewellynNaicker,

If you are not sure...abt the lenght of the variable withut trailing spaces,
here is a method...you can follow.

1. Reverse the String
2. Search for the non space charecter from the begining of the reversed string. Get the No of trailing Spaces
3. Subtract the number of spaces from the lenght of the variable with spaces.

~Vamsi
Back to top
View user's profile Send private message
elangomvs

New User


Joined: 07 Apr 2006
Posts: 4

PostPosted: Tue Oct 17, 2006 4:10 pm    Post subject: Re: Getting the length of a variable data string
Reply with quote

LlewellynNaicker wrote:
Hi all

I have a problem where I am trying to get the length of a variable data string. Basically it is a group of fields but not a copybook and I need to calculate the length with out doing a perform and calculating byte by byte.

Can anyone give me an easier way to do it.


Your help is much appreciated.

Regards
Llewellyn Naicker


hi,

do like this

01 STR1 PIC X(80).
01 LEN PIC 99.


PROCEDURE DIVISION.

PERFORM VARYING I FROM 80 BY -1 UNTIL STR1(I:1) > SPACES
END-PERFORM.

MOVE I TO LEN.


now the data name LEN have the actual length.
Back to top
View user's profile Send private message
elangomvs

New User


Joined: 07 Apr 2006
Posts: 4

PostPosted: Tue Oct 17, 2006 4:15 pm    Post subject:
Reply with quote

hi,

do like this

01 STR1 PIC X(80).
01 LEN PIC 99.
01 I PIC 99.

PROCEDURE DIVISION.

PERFORM VARYING I FROM 80 BY -1 UNTIL STR1(I:1) > SPACES
END-PERFORM.

MOVE I TO LEN.


now the data name LEN have the actual length.


>>> ELANGO G
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 Storing huge volume of data, compare ... Pradeep K M All Other Mainframe Topics 3 Mon Jan 16, 2017 5:08 pm
No new posts how to recover an uncataloged VSAM da... archanamuthukrishnan All Other Mainframe Topics 3 Wed Jan 11, 2017 6:18 pm
No new posts HALDB data refresh/copy from producti... vineetanand2007 IMS DB/DC 0 Mon Jan 02, 2017 11:16 am
No new posts JES2 JEC: Use UNIX Pipes to Pass Data... Virendra Shambharkar JCL & VSAM 21 Tue Dec 20, 2016 6:55 pm
No new posts Is the 'prompt' data for the DSLIST p... Willy Jensen TSO/ISPF 2 Tue Dec 06, 2016 4:38 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us