IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Dynamic output file creation in cobol using BPXWDYN


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
smileheal
Warnings : 1

New User


Joined: 22 Jul 2013
Posts: 4
Location: india

PostPosted: Thu Jun 15, 2017 10:53 pm
Reply with quote

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


JCL:
Code:

STEP01 EXEC PGM=ABC
SYSOUT  DD SYSOUT=*
DD1          DD DSN=ABC.DD1
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Thu Jun 15, 2017 11:47 pm
Reply with quote

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.
Back to top
View user's profile Send private message
smileheal
Warnings : 1

New User


Joined: 22 Jul 2013
Posts: 4
Location: india

PostPosted: Fri Jun 16, 2017 12:16 am
Reply with quote

Hi Robert, thanks for the feedback.

I called BPXWDYN in my pgm. Apology 4 the typo.

I had set the RC from the call and following is the display.

77 WS-DYN-RC PIC S9(08) COMP-5.
CALL BPXWDYN USING WS-ALLOC-STRING RETURNING WS-DYN-RC.

RC1 :- 000000002N
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Fri Jun 16, 2017 12:23 am
Reply with quote

And what does that tell you?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Fri Jun 16, 2017 12:24 am
Reply with quote

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.
Back to top
View user's profile Send private message
smileheal
Warnings : 1

New User


Joined: 22 Jul 2013
Posts: 4
Location: india

PostPosted: Fri Jun 16, 2017 3:38 pm
Reply with quote

Hi Robert, thanks 4 the valuable feedback.

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.

It is working fine now with expected result.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Fri Jun 16, 2017 6:01 pm
Reply with quote

Good to hear you got it working.
Back to top
View user's profile Send private message
steve-myers

Active Member


Joined: 30 Nov 2013
Posts: 917
Location: The Universe

PostPosted: Mon Jun 19, 2017 7:18 pm
Reply with quote

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.
Back to top
View user's profile Send private message
jasorn
Warnings : 1

Active User


Joined: 12 Jul 2006
Posts: 191
Location: USA

PostPosted: Fri Aug 10, 2018 4:35 am
Reply with quote

steve-myers,

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?

www.ibm.com/support/knowledgecenter/en/SSLTBW_2.1.0/com.ibm.zos.v2r1.bpxb600/wdyn.htm
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Access to non cataloged VSAM file JCL & VSAM 18
Search our Forums:

Back to Top