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
 

 

Determining the Lenght of a Record

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

New User


Joined: 26 Jan 2014
Posts: 2
Location: USA

PostPosted: Mon Sep 08, 2014 10:17 am    Post subject: Determining the Lenght of a Record
Reply with quote

Hi All,

I am writing a subroutine that will accept record formats from one or more callers. Since the record format can be any length or layout the subroutine will be responsible for providing the correct data to the caller.

My questions are:
1. Is there a simple way to dynamically determine the record length?
2. For development purposes, is there a way to display the record layout?

I have a working example that demonstrates the general concept using only one caller to the generic subroutine. This example only works because I know the length of data to return to the caller, I would like to dynamically determine the length of a record.

Any suggestions?

Caller:
Code:

000010 IDENTIFICATION DIVISION.
000020 PROGRAM-ID.        RECDRV.
000030
000040  ENVIRONMENT DIVISION.
000050
000060  DATA DIVISION.
000070
000080  WORKING-STORAGE SECTION.
000090
000100 01  CUSTOMER-RECORD.
000110     03  ACCT-NUMBER              PIC 9(09).
000120     03  FIRST-NAME               PIC X(20).
000130     03  LAST-NAME                PIC X(20).
000140     03  HOME-ADDRESS             PIC X(20).
000150***************************************
000160  PROCEDURE DIVISION.   
000170
000180     CALL 'RECLEN' USING CUSTOMER-RECORD.   
000190*
000200     DISPLAY 'Account Number  -> ',  ACCT-NUMBER.
000210     DISPLAY 'First Name      -> ',  FIRST-NAME.
000220     DISPLAY 'Last Name       -> ',  LAST-NAME.
000230     DISPLAY 'Home Address    -> ',  HOME-ADDRESS.
000240
000250      STOP RUN.
000260
000270**  END OF Caller


SubRoutine:

Code:

000010 IDENTIFICATION DIVISION.
000020 PROGRAM-ID.        RECLEN.
000030
000040  ENVIRONMENT DIVISION.
000050
000060  DATA DIVISION.
000070
000080  WORKING-STORAGE SECTION.
000090
000100  01 WS-SIMPLE-DATA .
000110     03 RECORD-FIELDS         PIC X(256) .
000120***************************************
000130  LINKAGE SECTION.
000140
000150  01 LS-GENERIC-RECORD-AREA.
000160     03 LINK-RECORD               PIC X(4096).
000170***************************************
000180   PROCEDURE DIVISION USING LS-GENERIC-RECORD-AREA.
000190   
000200*  Build a Record
000210   
000220     STRING "123123123"             DELIMITED BY SIZE
000230            "First Name          "  DELIMITED BY SIZE
000240            "Last Name           "  DELIMITED BY SIZE
000250            "Home Address        "  DELIMITED BY SIZE
000260       INTO RECORD-FIELDS.
000270
000280     DISPLAY "SIMPLE DATA -> ", WS-SIMPLE-DATA.
000290
000300     MOVE RECORD-FIELDS(1:69) TO LINK-RECORD(1:69).
000310
000320*    What I would like to use is:
000330*    MOVE RECORD-FIELDS(1:record-length)
000340                             TO LINK-RECORD(1:record-length).
000350
000360     EXIT PROGRAM.
000370
000380**  END OF SubRoutine
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Mon Sep 08, 2014 12:12 pm    Post subject: Re: Determining the Lenght of a Record
Reply with quote

Quote:

1. Is there a simple way to dynamically determine the record length?

No, not from a CALLed program. The CALLer can know. Why not provide it to the CALLed program?


Quote:

2. For development purposes, is there a way to display the record layout?

The particular record-layout of the record from an unknown file which has been passed to you by an unknown CALLer when the only place that the record-layout exists is in the COBOL program before it is compiled and the copybook library? No. Why do you need to do this?


[quote]
I have a working example that demonstrates the general concept
[quote]

It is unclear to me what it is that you are trying to do. If you can make a better description, we may have some ideas.
Back to top
View user's profile Send private message
K Newman

New User


Joined: 26 Jan 2014
Posts: 2
Location: USA

PostPosted: Mon Sep 08, 2014 7:57 pm    Post subject: Re: Determining the Lenght of a Record
Reply with quote

Hi Bill,

I'm going to answer your questions n parts.

Bill Woodger wrote:

No, not from a CALLed program. The CALLer can know. Why not provide it to the CALLed program?


I can provide the length to the CALLed program using LENGTH OF if that's the only way to do it.

Quote:

The particular record-layout of the record from an unknown...


I'm writing a general purpose tool in which I want the CALLed program to know a little as possible about the CALLer.

Thanks.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Tue Sep 09, 2014 1:00 am    Post subject: Reply to: Determining the Lenght of a Record
Reply with quote

If it's a fixed-length VSAM file, a small Assembler sub-program, issuing a SHOWCB Macro, will work. For variable-length VSAM, the length value returned from a SHOWCB will be the maximum-length.

You can define the ACB to use a DD name, passed to the sub-program, allowing use for any VSAM file.

I can provide you with a sample, offline.

Send me a PM and give me time to put it together....

HTH....
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Tue Sep 09, 2014 2:56 am    Post subject: Reply to: Determining the Lenght of a Record
Reply with quote

For a fixed-length record, LENGTH OF is going to work. For variable-length records, I suggest RECORD VARYING DEPENDING ON ...

How will you know what record-layout to use? DDNAME in combination with program-name would probably allow you to build something that knew, but you don't want to know about the CALLer.

You could get hold of the DSN, and build a cross-reference on that, perhaps.

Still not clear what you want to actually do with the CALLed program.
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 1609
Location: NY,USA

PostPosted: Tue Sep 09, 2014 4:23 am    Post subject:
Reply with quote

Code:
MOVE FUNCTION REVERSE (RECORD-FIELDS))           
                              TO WS-REVERSE-REC
 INSPECT WS-REVERSE-REC TALLYING WS-BLANK-CTR   
                              FOR LEADING SPACES
 COMPUTE  WS-REC-LEN = length of (RECORD-FIELDS) - WS-BLANK-CTR     

MOVE RECORD-FIELDS(1:WS-REC-LEN)
                             TO LINK-RECORD(1:WS-REC-LEN).


Something like this you can try...
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Tue Sep 09, 2014 4:53 am    Post subject: Reply to: Determining the Lenght of a Record
Reply with quote

No, Rohit. Why would anything passed as a parameter conveniently be followed by a number of blanks which added up to the maximum definition used in the LINKAGE SECTION?

Your example is one way to count the actual bytes of data excluding trailing space in a field of a known length, but I don't think that is what the TS/OP wants.
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 1609
Location: NY,USA

PostPosted: Tue Sep 09, 2014 8:26 pm    Post subject:
Reply with quote

Quote:
No, Rohit. Why would anything passed as a parameter conveniently be followed by a number of blanks which added up to the maximum definition used in the LINKAGE SECTION?


Right, So he needs to correct the definition it looks. As then the below MOVE doesn't make any sense as he could directly move without ref. modification or may be I am getting it wrong.

Code:
000320*    What I would like to use is:
000330*    MOVE RECORD-FIELDS(1:record-length)
000340                             TO LINK-RECORD(1:record-length).
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 How to update a portion of text in a ... Bill Woodger DFSORT/ICETOOL 25 Wed Nov 09, 2016 9:41 pm
No new posts sort with previous record anatol DFSORT/ICETOOL 9 Thu Oct 06, 2016 2:36 am
No new posts Get Record count in summary record fo... Atul Banke DFSORT/ICETOOL 21 Fri Sep 23, 2016 4:17 pm
No new posts Change date (DD/MM/YY) in 2nd record ... uday kiran DFSORT/ICETOOL 12 Wed Sep 07, 2016 10:57 pm
No new posts Using 'parm' to vary SORTOUT record v... Sysaron DFSORT/ICETOOL 13 Wed Sep 07, 2016 9:24 pm


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