Hi, i am trying to create multiple output files dynamically from a Cobol pgm using BPXWDYN routine.
But when i ran the compiled load in JCL, the files are not created after the successful job run.
Below the Cobol logic.
Code:
SELECT OP-FILE ASSIGN TO DD1
FD OP-FILE
RECORDING MODE IS F
LABEL RECORDS ARE STANDARD.
01 OP-REC PIC X(10).
PROCEDURE DIVISION.
MOVE 'ABC.BAR.DD01' TO FN.
STRING 'ALLOC DD(DD1) DSN('FN') NEW '
'CATALOG' 'LRECL(10) RECFM(F,B)'
DELIMITED BY SIZE INTO WS-ALLOC-STRING
CALL 'BPXDWYN' USING WS-ALLOC-STRING
OPEN OUTPUT OP-FILE
MOVE '123' TO OP-REC.
WRITE OP-REC.
CLOSE OP-FILE
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
How do you know BPXWDYN worked correctly? Try
Code:
DISPLAY RETURN-CODE
after the call to BPXWDYN. If it is not zero, then the call did NOT work and (most likely) your allocated data set wasn't allocated. And since you didn't bother with file status (which should be a mortal sin for professional COBOL programmers such as those posting on this web site), you have no idea if the OPEN worked or not, if the WRITE worked or not, and if the CLOSE worked or not.
In other words, by your lack of error checking you have no way of knowing whether ANYTHING you did worked. If you decide to post anything else, we'll want to see RETURN-CODE after the call to BPXWDYN as well as the file status code for the OPEN, WRITE, and CLOSE statements. And if any of the four values are not zero, then you CANNOT tell us you have a "successful job run".
And, by the way, either the code you posted has a typo (BPXDWYN is what you are calling whereas BPXWDYN is the name of the IBM module) or the explanation for your results is calling the wrong program and NOT doing any error checking.
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
The return code is -25, which means the fifth key failed the parse. So you need to display WS-ALLOC-STRING and find out what is wrong with the fifth key. Since the code you posted didn't have a space after CATALOG and before LRECL(10), the system is probably telling you CATALOGLRECL(10) Is invalid but you need to display WS-ALLOC-STRING to be sure.
And the fact you got a non-zero return code from BPXWDYN means that your statement about the job successfully running in your first post is rubbish -- the dynamic allocation failed so everything after that failed.
Have corrected the string command to lave space between Catlog & LRECL.
Also used FREE Command before allocating the same DD Name to the subsequent files.
Joined: 30 Nov 2013 Posts: 917 Location: The Universe
I have no idea what the designers of OS/360 were actually thinking, but I suspect they were thinking they did not want application programmers to run into the problems the topic starter had when they did not provide dynamic allocation in OS/360.
As most of us know, TSO for OS/360 had a primitive dynamic allocation. There were a multitude of problems, most of them because TSO dynamic allocation was serialized using the same locks as JCL allocation, so if JCL allocation was working it blocked TSO allocation. This meant a TSO user had to wait for JCL allocation to complete.
The ALLOCATE and FREE commands, with their multitude of options illustrate the problems. TSO ALLOCATE and FREE, though they have been enhanced over the years, are little changed from the ALLOCATE and FREE commands for OS/360 TSO. The enhancements since OS/360 TSO are rarely used.
MVS, of course, has had dynamic allocation from the beginning, but it's mainly targeted at Assembler programmers. Most Assembler programmers find it difficult to use. Quite honestly, having observed its use over the years, I find dynamic allocation misused rather than properly used. The biggest problem is message support when a problem is encountered. It's usually done poorly; all too often mysterious error codes from dynamic allocation are presented to the end user, and even then presented in a fashion that make it difficult to use the available documentation.
The BPXWDYN function gives some clues.
First, BPXWDYN has never been part of the mainline z/OS product. Its documentation, such as it is, is not in any mainline z/OS document. I suspect most BPXWDYN users would not know where its documentation is located, much less actually use its documentation. I can recall, some years ago, spending several hours trying to find its documentation. Few people would guess where its documentation is hidden, much less deduce the rational that placed the documentation where it is.
Second, the character strings used with BPXWDYN are loosely based on the ALLOCATE and FREE TSO commands. I suppose this is a complement to the designers of the ALLOCATE command in 1970 or so. BPXWDYN does not use the sophisticated string parser used by TSO to examine the ALLOCATE and FREE commands so its message support when there is a syntax error is non-existent; this is a problem the topic starter encountered. The parser used in BPXWDYN seems to acknowledge many alternates accepted in TSO and commonly used by users of the TSO ALLOCATE and FREE commands, but these seemed to be programmed into the parser rather than unintentioned byproducts of the TSO parser. An example: the official syntax in TSO is FILE(xxx), but many TSO users found the OS/360 TSO parser accepted F(xxx) because there were no other keywords in the OS/360 ALLOCATE command that started with F, and lazy bums that we are we still use F(xxx) Eventually, of course, TSO ALLOCATE was changed to accept the more correct DDNAME(xxx) syntax. Regardless, BPXWDYN appears to use FI(xxx) and DD(xxx) as its official short cuts.
Third, the official documentation does not say BPXWDYN can be used in Cobol, though we all know, as does the topic starter, that it can be used in Cobol and some other high level languages such as C, as documented.
I suppose I'm missing the meaning of 'any mainline z/OS document' but when I first started using it, 10+ years ago I think, I don't remember having a hard time finding documentation. Actually, I think I learned about it by reading documentation on IBM's site. There were some quirks I had to get used to, however.
There are some pages dedicated to it now which look like mainline z/OS documentation to me now. Or, is there better documentation which you're referring to?