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
 

 

finding the length of a variable record in cobol

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions
View previous topic :: :: View next topic  
Author Message
subramanyamg5

New User


Joined: 13 Jun 2006
Posts: 5

PostPosted: Fri Jun 16, 2006 1:46 pm    Post subject: finding the length of a variable record in cobol
Reply with quote

How to find the length of a variable record in cobol file.
Back to top
View user's profile Send private message

subramanyamg5

New User


Joined: 13 Jun 2006
Posts: 5

PostPosted: Fri Jun 16, 2006 2:12 pm    Post subject: Re: finding the length of a variable record in cobol
Reply with quote

If the question is not clear then

how can we find the actual length of a record in a variable length file
Back to top
View user's profile Send private message
prasadvrk

Active User


Joined: 31 May 2006
Posts: 200
Location: Netherlands

PostPosted: Fri Jun 16, 2006 2:53 pm    Post subject:
Reply with quote

You must have a layout for the record where you will find the length
Back to top
View user's profile Send private message
subramanyamg5

New User


Joined: 13 Jun 2006
Posts: 5

PostPosted: Fri Jun 16, 2006 4:22 pm    Post subject:
Reply with quote

prasadvrk wrote:
You must have a layout for the record where you will find the length


Prasad i think you did not get my question.

I am asking for the actual length of a record in the case of a variable record length file.

The layout will be there but how can you get the actual length of a record.
Do not tell me to count the number of characters in the length by looking into each record. That is not the correct process

In the layout also how can you get the actual length
Back to top
View user's profile Send private message
aroraranjan22

New User


Joined: 16 Oct 2006
Posts: 3

PostPosted: Fri Oct 20, 2006 11:25 am    Post subject: Re: finding the length of a variable record in cobol
Reply with quote

Hi Subramanyam

Move your record to a variable say WS-REC1 having length as the maximum length of the variable record file say 250.

01 WS-REC1 PIC X(250).


Now define an array with occurs as the max length of the file, in this case, it will be 250.

01 WS-ARRAY.
05 WS-REC2 PIC X(1) OCCURS 250 times.


Define another variable to be used as subscript for WS-REC2.

01 ws-counter PIC 9(3) VALUE ZEROES.



Now, the logic of the code will be something like this :

Move 250 to WS-COUNTER.

Move WS-REC1 to WS-ARRAY.

Perform para 2000-check-spaces THRU 2000-EXIT.

Display 'length of the record is : ' WS-COUNTER.
STOP rUN.


2000-check-spaces.

IF WS-REC2(WS-COUNTER) NOT = SPACES
GO TO 2000-EXIT
ELSE
WS-COUNTER = WS-COUNTER - 1
GO TO 2000-CHECK-SPACES.

2000-EXIT.
EXIT.


By this logic, you will get the actual length of the record in the variable WS-COUNTER itself.

Please let me know if I'm not able to explain it clearly.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sat Oct 21, 2006 4:41 am    Post subject:
Reply with quote

Hi Sub,

In your FD code the following along w/whatever other clauses you want:

RECORD VARYING FROM 1 TO whatever DEPENDING ON WS-LEN-FLD

Define the field in WS as PIC 9(004).

After each read WS-LEN-FLD will contain the length of the rec just read. If you want to write a rec mo0ve the desired len to WS-LEN-FLD before the WRITE.
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 -> Mainframe Interview Questions All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts XML Parse for COBOL 5.2 Bhanu Praveen COBOL Programming 1 Sat Jul 08, 2017 8:58 pm
No new posts Dynamic output file creation in cobol... smileheal COBOL Programming 7 Thu Jun 15, 2017 10:53 pm
No new posts Search utility(3.14) using JCl and Cobol RKS3 COBOL Programming 12 Sat Jun 10, 2017 10:24 pm
No new posts Need to write record of PS File in ex... Chandan1993 JCL & VSAM 1 Wed Jun 07, 2017 1:35 am
No new posts Can I traverse a STEM variable? chong.zhou CLIST & REXX 5 Wed May 31, 2017 3:54 pm


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