Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Dynamic output file creation in cobol using BPXWDYN

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Dynamic output file creation in cobol using BPXWDYN
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: 8132
Location: East Dubuque, Illinois, USA

PostPosted: Thu Jun 15, 2017 11:47 pm    Post subject: Reply to: Dynamic output file creation in cobol using BPXWDYN
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    Post subject:
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: 1772
Location: Bloomington, IL

PostPosted: Fri Jun 16, 2017 12:23 am    Post subject:
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: 8132
Location: East Dubuque, Illinois, USA

PostPosted: Fri Jun 16, 2017 12:24 am    Post subject:
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    Post subject:
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: 8132
Location: East Dubuque, Illinois, USA

PostPosted: Fri Jun 16, 2017 6:01 pm    Post subject:
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: 546
Location: The Universe

PostPosted: Mon Jun 19, 2017 7:18 pm    Post subject:
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
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts ALPHABETIC check in COBOL vidyaa COBOL Programming 6 Thu Aug 17, 2017 7:13 pm
No new posts Multiple VSAM files single output fil... Mohan Kothakota DFSORT/ICETOOL 11 Wed Aug 09, 2017 7:57 pm
This topic is locked: you cannot edit posts or make replies. rexx code to create a ps file Bharath Vikraman CLIST & REXX 4 Mon Aug 07, 2017 10:30 am
No new posts Split file based on comparsion to 2 f... Div Grad DFSORT/ICETOOL 3 Thu Jul 27, 2017 9:16 pm
No new posts Read two inputs and write into output... murali.andaluri DFSORT/ICETOOL 6 Wed Jul 26, 2017 7:35 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us