Page 1 of 1

Have to find the output record length to assign to output fd

PostPosted: Mon Dec 09, 2013 5:42 pm
by sange-sherin
Hi,

Below is the my requirement:

I need to find the record length of my output since i need to declare in the FD section.
My output record length may vary from input record length.Input and output are VB.

For example
FILE SECTION.                               
FD  DATA-FILE                               
    RECORDING MODE IS V                     
    RECORD IS VARYING FROM 1 TO 32696       
     DEPENDING ON WS-LENGTH.                 
01  INPUT-REC                   PIC X(32696).
FD  OUTPUT-FILE                             
    RECORDING MODE IS V                     
    RECORD IS VARYING FROM 1 TO 32696       
     DEPENDING ON WS-LENGTH-OUT.                 
01  OUTPUT-REC                  PIC X(32696).


The working storage variable WS-LENGTH-OUT should be calculated from my output.

How can i calculate it?

Re: Have to find the output record length to assign to outpu

PostPosted: Mon Dec 09, 2013 6:44 pm
by Robert Sample
As you build your output data, you will need to keep track of the length and store it in WS-LENGTH-OUT. How you do this will, of course, depend upon your code and while we can provide some general guidelines, the specifics will be up to you.

Re: Have to find the output record length to assign to outpu

PostPosted: Mon Dec 09, 2013 8:00 pm
by dick scherrer
Hello,

How is WS-Length determined for each read? Ususally, input VB files have common info as the first part of the record - a field of which is the record length or a repitition factor for some repeating group(s).

Re: Have to find the output record length to assign to outpu

PostPosted: Tue Dec 10, 2013 10:58 am
by sange-sherin
Hi Dick scherrer,

How to keep track of the length and store it in WS-LENGTH-OUT?

Re: Have to find the output record length to assign to outpu

PostPosted: Tue Dec 10, 2013 10:42 pm
by dick scherrer
Hello,

You have to calculate the length of the various output records. The is often done by summing the lengths of the fields for this particular output record.
Say there are 15 bytes of control (sort key) data, a record type (not mandadory, but quite useful, the record length (the value from WS-LENGTH-OUT, and the variable data. Your record definition might be:
01  my-var-rec.
  05  mvr-key.
    10  mvr-key-1        pic x(10).
    10  mvr-key-2        pic x(5).
  05  mvr-rec-typ        pic x.
  05  mvr-rec-lth        pic 9(4) comp.
  05  filler             pic x(....)  - the lenth of the longest variable data.
*
01  my-var-reca.
  05  mvr-keya.
    10  mvr-key-1a.        pic x(10).
    10  mvr-key-2a.        pic x(5).
  05  mvr-rec-typa         pic x.
  05  mvr-rec-ltha         pic 9(4) comp.
  05  mvr-dataa            pic(s) whatever.
*
01  my-var-recb.
  05  mvr-keyb.
    10  mvr-key-1b.        pic x(10).
    10  mvr-key-2b.        pic x(5).
  05  mvr-rec-typb         pic x.
  05  mvr-rec-lthb         pic 9(4) comp.
  05  mvr-datab            pic(s) whatever.


The first part of each record is the same. The last part (mvr-data+) is the variable content.

The length is recalculated for each output record and must include the common first part.