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
 

 

To get theSize of Cobol Field

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

New User


Joined: 04 Jul 2007
Posts: 3
Location: Bangalore

PostPosted: Mon Jul 09, 2007 7:51 pm    Post subject: To get theSize of Cobol Field
Reply with quote

Hi

I want to get the COBOL field size

Lets say I have filed defined in copy book

01 E-Name pic x(40).

move 'Vijay' to E-Name.

If i use the Length function it will always return me the actual length of field i.e, 40.

But i want get the variable size in program , in the above example it should be 5 ('V i j a y ' is 5 letters).

PS let me know is there any function available in COBOL
?

Thanks in Advance

Vijay Sharma
Back to top
View user's profile Send private message

William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Mon Jul 09, 2007 9:19 pm    Post subject:
Reply with quote

Sorry, the SIZE is 40 characters....
You want the length of valid data (and who is to say trailing blanks are not valid).
You will have to unstring the data or examine tallying the data with your own rules for defining 'what is valid data and where does it end' to determine the length.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Mon Jul 09, 2007 9:49 pm    Post subject:
Reply with quote

Hello,

One way to get what you want is to redefine the field as an array, point to the right-most character, and compare if a space. If it is a space, decrement the pointer and check again. When you come to the first non-blank byte, the value in the pointer is the "length" of the data. This will accomodate embedded spaces which is common in name fields.
Back to top
View user's profile Send private message
Mickeydusaor

Active User


Joined: 24 May 2006
Posts: 258
Location: Salem, Oregon

PostPosted: Mon Jul 09, 2007 11:02 pm    Post subject:
Reply with quote

You could use the cobol REVERSE FUNCTION and process this field
until you come to the first non blank.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Tue Jul 10, 2007 12:43 am    Post subject:
Reply with quote

A variation on Mickey D's solution:

INSPECT FUNCTION REVERSE(TEXT1) TALLYING L FOR LEADING SPACES
COMPUTE L = LENGTH OF TEXT1 - L
Back to top
View user's profile Send private message
vijaysharma

New User


Joined: 04 Jul 2007
Posts: 3
Location: Bangalore

PostPosted: Tue Jul 10, 2007 1:56 pm    Post subject: Thank You
Reply with quote

Hi All

Thank You For all Eur quick Response..


regards

Vijay Sharma
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
This topic is locked: you cannot edit posts or make replies. Full Time COBOL Software Development ... shally Mainframe Jobs 0 Fri Jan 20, 2017 5:24 am
This topic is locked: you cannot edit posts or make replies. COBOL Software Development Lead at Fi... shally Mainframe Jobs 0 Fri Jan 20, 2017 5:21 am
No new posts INVALID FIELD OR CONSTANT IN SORTOF ?? Ron Klop DFSORT/ICETOOL 8 Wed Jan 11, 2017 3:44 pm
No new posts Executing OO COBOL program invoking J... Virendra Shambharkar COBOL Programming 2 Tue Jan 10, 2017 6:37 pm
No new posts OO COBOL compile error Virendra Shambharkar COBOL Programming 3 Tue Jan 10, 2017 6:05 pm


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