Page 1 of 1

Dynamic file buffer size declaration in Cobol

PostPosted: Sun May 06, 2012 1:33 pm
by Sivapradeep
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.

Re: Dynamic file buffer size declaration in Cobol

PostPosted: Sun May 06, 2012 3:23 pm
by BillyBoyo
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?

Re: Dynamic file buffer size declaration in Cobol

PostPosted: Sun May 06, 2012 6:21 pm
by Robert Sample
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.

Re: Dynamic file buffer size declaration in Cobol

PostPosted: Mon May 07, 2012 12:07 pm
by Sivapradeep
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 ??

Re: Dynamic file buffer size declaration in Cobol

PostPosted: Mon May 07, 2012 1:04 pm
by BillyBoyo
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.

Re: Dynamic file buffer size declaration in Cobol

PostPosted: Mon May 07, 2012 4:59 pm
by Robert Sample
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.

Re: Dynamic file buffer size declaration in Cobol

PostPosted: Mon May 07, 2012 6:58 pm
by Sivapradeep
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.