Dynamic file buffer size declaration in Cobol



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

Dynamic file buffer size declaration in Cobol

Postby Sivapradeep » Sun May 06, 2012 1:33 pm

hi,
i want to know how to dynamically change the file buffer variables in cobol based on the data that i get from REXX.
My requirement is like this:
i have a cobol program that is getting executed from REXX. all the logical DD name were allocated in rexx itself. the DD name for the PS files that i'm assigning were dynamic with various RECL values everytime. Now, after assigning DD name i called COBOL for File handling operations on that PS file. when i tried to open the file i'm getting error in cobol with status code - 39.

below is snapshot of error.
 MQCONN SUCCESFUL                                                               
 MFRIVSRBS SUCCESFUL                                                           
 IGZ0201W A file attribute mismatch was detected. File INFILE in program DLVSPSQC  had a record length of 4088 and the file specified in the ASSIGN clause had a record length of 110.       
 INPUT FILE NOT OPENED                                                         
 ERROR CODE : 39                                                               
 MQDISC SUCCESFUL                                                               


the rexx i wrote for calling this cobol is shown below.
   "ALLOC DA('"INPUT"') DD(INF) SHR"                           
     "ALLOCATE DSN('XXXXX.TOOLS.PS1') RECFM(F B) DSORG(PS) TR
     LRECL("RECL")  SP(5 5) NEW "                             
         
  "ALLOC DA('XXXXX.TOOLS.PS1') DD(INFILE) MOD"               
   SAY RC                                                     
   "REPRO IFILE(INF) OFILE(INFILE)"                           
    SAY RC                                                     
 /*CALLING PUT MESSAGE AND TRANSFERRING PS CONTENT TO QUEUE*/ 
    "CALL 'OPERN.TEST.LOADLIB(DLVSPSQC)'"                     

Here INPUT is a VSAM and RECL is a dynamic value generated based on VSAM LRECL.

i want to declare file buffer size based on this RECL variable in rexx.
Sivapradeep
 
Posts: 35
Joined: Mon Mar 26, 2012 2:09 pm
Has thanked: 1 time
Been thanked: 1 time

Re: Dynamic file buffer size declaration in Cobol

 

Re: Dynamic file buffer size declaration in Cobol

Postby BillyBoyo » Sun May 06, 2012 3:23 pm

It won't solve your problem.

Please show your ASSIGN and FD for the file. Also a LISTCAT of the VSAM file.

What type of OPEN and READ are you wanting in the Cobol program?
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Dynamic file buffer size declaration in Cobol

Postby Robert Sample » Sun May 06, 2012 6:21 pm

You ARE aware, I hope, that COBOL requires the record length of each file to be known at COMPILE time not RUN time? In other words, unless you recompile the COBOL program every time you want a different LRECL for your file, the approach you are using cannot and will not work -- EVER. COBOL supports dynamic file allocation using BPXWDYN but the record length for the dynamically allocated file must still have been placed in the program when it was compiled.
Robert Sample
Global moderator
 
Posts: 3367
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 222 times

Re: Dynamic file buffer size declaration in Cobol

Postby Sivapradeep » Mon May 07, 2012 12:07 pm

hI BillyBoyo,
HERE IS ASSIGN AND FD OF MY COBOL
ENVIRONMENT DIVISION.                         
INPUT-OUTPUT SECTION.                           
FILE-CONTROL.                                   
               SELECT INFILE ASSIGN TO INFILE               
                  ORGANIZATION IS SEQUENTIAL     
                  ACCESS MODE IS SEQUENTIAL     
                  FILE STATUS IS WS-STATUS.     
DATA DIVISION.                                   
FILE SECTION.                                   
                                                 
FD  INFILE                                       
                                                 
     RECORD IS VARYING IN SIZE                   
     FROM 1 TO 220 CHARACTERS                   
     DEPENDING ON WS-REC-LEN-FD.                 
                                                 
01  FS-INFILE-REC.                               
    05  FS-DATA                 PIC  X(220).     
                                                 

From the data that i got from REXX i passed to WS-REC-LEN-FD.
LINKAGE SECTION.                       
01 LS-PARM.                           
   05  LS-PARM-LENGTH PIC S9(4) COMP. 
   05  LS-PARM-DATA   PIC X(10).       
                                       
PROCEDURE DIVISION USING LS-PARM.     
                                       
    MOVE LS-PARM-DATA TO WS-REC-LEN-FD


in REXX side i called COBOL using "CALL 'TEST.LOADLIB(DLVSPSQC)' '"RECL"'" Here RECL is record length of PS file that i wish to pass to FD section of COBOL.

i understood that During COmpilation time itself all the variable declarations happens in COBOL. I want to know if is there any other way available during runtime ?? if not, what can be the best alternative for solving my problem ??

These users thanked the author Sivapradeep for the post:
BillyBoyo (Mon May 07, 2012 1:04 pm)
Sivapradeep
 
Posts: 35
Joined: Mon Mar 26, 2012 2:09 pm
Has thanked: 1 time
Been thanked: 1 time

Re: Dynamic file buffer size declaration in Cobol

Postby BillyBoyo » Mon May 07, 2012 1:04 pm

The code you show does not match the message.

You may find this topic helpful. http://ibmmainframes.com/about38465.html You need to keep reading until the 2nd page and Jasorn's post.

If it doesn't help to conclusion, come back, with the code that matches any messages.

Thanks for using the Code tags.

These users thanked the author BillyBoyo for the post:
Sivapradeep (Mon May 07, 2012 6:55 pm)
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Dynamic file buffer size declaration in Cobol

Postby Robert Sample » Mon May 07, 2012 4:59 pm

Your post has INFILE defined with a fixed LRECL of 220 (RECORD IS VARYING does NOT cause the file to be variable length). Even if you made the record in the FD varying, you STILL only have a file with an LRECL of 224 (220 maximum bytes plus 4 bytes for the RDW). And whichever one it is, you are not going to change the record length at run time -- it was fixed when you compiled the program.

When I've worked on systems in the past that required using files where the LRECL was not known in advance, Assembler was used for all file access. The Assembler program was called from the COBOL program to open the file, read / write / etc each record, then called to close the file.
Robert Sample
Global moderator
 
Posts: 3367
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 222 times

Re: Dynamic file buffer size declaration in Cobol

Postby Sivapradeep » Mon May 07, 2012 6:58 pm

BillyBoyo, thanks alot. the link which you gave is very helpful. it solved my problem.

i changed my FD part from VARYING to RECORD CONTAINS 0 and used proper reference modifier in READ verb as specified by Jasorn in that link.
Sivapradeep
 
Posts: 35
Joined: Mon Mar 26, 2012 2:09 pm
Has thanked: 1 time
Been thanked: 1 time


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post