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



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

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

Postby sange-sherin » Mon Dec 09, 2013 5:42 pm

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?
sange-sherin
 
Posts: 25
Joined: Thu Nov 21, 2013 6:56 pm
Has thanked: 0 time
Been thanked: 0 time

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

Postby Robert Sample » Mon Dec 09, 2013 6:44 pm

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.
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

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

Postby dick scherrer » Mon Dec 09, 2013 8:00 pm

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).
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

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

Postby sange-sherin » Tue Dec 10, 2013 10:58 am

Hi Dick scherrer,

How to keep track of the length and store it in WS-LENGTH-OUT?
sange-sherin
 
Posts: 25
Joined: Thu Nov 21, 2013 6:56 pm
Has thanked: 0 time
Been thanked: 0 time

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

Postby dick scherrer » Tue Dec 10, 2013 10:42 pm

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.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post