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

BPXWDYN - assembler dynamic allocation


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Pankaj Gupta
Currently Banned

New User


Joined: 07 May 2008
Posts: 50
Location: Bangalore

PostPosted: Mon Oct 13, 2008 4:44 pm
Reply with quote

Hello,
I am trying to dynamically allocating a file in assembler.

Here is another way:

Code:
         LINK  EP=BPXWDYN,PARAM=(PARM01),VL=1
PARM01   DC    CL36'ALLOC FI(DDNAME) DA(MY.FILE.NAME) SHR'       


But how then am I to use DDNAME so that I can be writing to it?
Back to top
View user's profile Send private message
Bill Dennis

Active Member


Joined: 17 Aug 2007
Posts: 562
Location: Iowa, USA

PostPosted: Mon Oct 13, 2008 9:13 pm
Reply with quote

You include a DCB and do an OPEN on the file.
Back to top
View user's profile Send private message
Pankaj Gupta
Currently Banned

New User


Joined: 07 May 2008
Posts: 50
Location: Bangalore

PostPosted: Mon Oct 13, 2008 9:24 pm
Reply with quote

It cannot be this simple. If I am doing that then the program simply thinks there shoul dbe a DD statement in the JCLs.

But I am dynamically allocating and so somehow I am needing to link the DD name in the OPEN with what BPXWDYN has been allocating.
Back to top
View user's profile Send private message
Bill Dennis

Active Member


Joined: 17 Aug 2007
Posts: 562
Location: Iowa, USA

PostPosted: Mon Oct 13, 2008 9:26 pm
Reply with quote

That is exactly what dynamic allocation is about. Allocating a file without JCL, but just as if it were in the JCL.
Back to top
View user's profile Send private message
Bill Dennis

Active Member


Joined: 17 Aug 2007
Posts: 562
Location: Iowa, USA

PostPosted: Mon Oct 13, 2008 9:28 pm
Reply with quote

I see in your other post you are confused on the DDNAME. In your example, change FI(DDNAME) to the ddname you wish to use, ex. FI(CARDIN)

You want to give a ddname, not let one be returned.
Back to top
View user's profile Send private message
Pankaj Gupta
Currently Banned

New User


Joined: 07 May 2008
Posts: 50
Location: Bangalore

PostPosted: Tue Oct 14, 2008 2:38 pm
Reply with quote

Yes, indeed, I am wanting to give a DD name. DDNAME is being a valid DD name. In fact in my program I am using a DD name other than DDNAME, I just changed it to DDNAME for the purpose of the posting.

the question is still remaining, hjow is the assembler program knowing that my OPEN (DDNAME) is the DDNAME I am providing to the BPXWDYN. The assembler program is naturally expecting DDNAME to being part of a DCB... and then when I am running it is expecting DDNAME to being in the JCLS.

In PL1 I have done this and it is working very perfectly.
Back to top
View user's profile Send private message
Bill Dennis

Active Member


Joined: 17 Aug 2007
Posts: 562
Location: Iowa, USA

PostPosted: Tue Oct 14, 2008 7:02 pm
Reply with quote

I don't know how else to explain this.

1. Do the dynamic allocation using your desired DDname, for ex. FI(CARDIN)
2. Your program includes a DCB macro INREC DCB DDNAME=CARDIN,.....
3. You do an OPEN for the DCB just as if the DD were in the JCL OPEN (INREC,(INPUT))
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: Tue Oct 14, 2008 7:18 pm
Reply with quote

Quote:
and then when I am running it is expecting DDNAME to being in the JCLS.
Why? Where did you get this idea? As long as the DDNAME is defined, whether by BPXWDYN or JCL or SVC 99, the Assembler program doesn't care when it does the OPEN on the DDNAME.
Back to top
View user's profile Send private message
Pankaj Gupta
Currently Banned

New User


Joined: 07 May 2008
Posts: 50
Location: Bangalore

PostPosted: Tue Oct 14, 2008 7:45 pm
Reply with quote

Bill and Robert,
What you are saying is what I would expect to be happening. But this is not what is happening. When I am running the program it is getting the SOC1 because the DD name is missing from the JCL.

Here is the small program:

Code:
ASS09    CSECT                                   
         STM   R14,R12,12(R13)                   
         BASR  R12,R0                             
         USING *,12                               
         ST    R13,SAVE+4                         
         LA    R13,SAVE                           
         L     R13,SAVE+4                         
                                                 
         LINK  EP=BPXWDYN,PARAM=(PARM01),VL=1     
         OPEN  (OUTREC,(OUTPUT))                 
         PUT   OUTREC,OUTLINE                     
         CLOSE (OUTREC)                           
*                                                 
         LM    R14,R12,12(R13)                   
         LA    R15,0                             
         BR    R14                               
*                                                 
SAVE     DS    18F                               
*                                                           
PARMLIST DC    A(PARM01)                                     
*                                                           
PARM01   DC    CL36'ALLOC FI(MYFILE) DA(DVDYC.ASS.FL) SHR'   
*                                                           
OUTLINE  DC    CL80'THIS IS AN OUTPUT LINE'                 
*                                                           
OUTREC   DCB   DSORG=PS,DDNAME=MYFILE,MACRF=PM,             
               RECFM=FB,LRECL=80,BLKSIZE=27920               
*                                                           
R0       EQU   0                                             
R1       EQU   1                                             
R2       EQU   2                                             
R3       EQU   3                                             
R4       EQU   4                                             
R5       EQU   5                                             
R6       EQU   6                                             
R7       EQU   7                                             
R8       EQU   8                                             
R9       EQU   9                                             
R10      EQU   10     
R11      EQU   11     
R12      EQU   12     
R13      EQU   13     
R14      EQU   14     
R15      EQU   15     
*                     
         END           


and here is this form the abendaid:

Code:
SPECIFIC INFORMATION                         
                                             
I/O INSTRUCTION ISSUED AGAINST DDNAME MYFILE 
WHICH IS MISSING FROM JCL.     
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: Tue Oct 14, 2008 7:58 pm
Reply with quote

Just for curiosity, where in your code are you checking the return code of the BPXWDYN link to ensure that BPXWDYN actually did allocate the DDNAME? If the LINK failed, the OPEN will fail and probably with an S0C1 since the link failing means there's probably no DDNAME defined to OPEN.

And Abend-Aid doesn't know you're doing a dynamic allocation, so it assumes your DDNAME will be in the JCL. It doesn't have to be; if the LINK to BPXWDYN is working, the OPEN will work even without a MYFILE DD statement.
Back to top
View user's profile Send private message
Pankaj Gupta
Currently Banned

New User


Joined: 07 May 2008
Posts: 50
Location: Bangalore

PostPosted: Tue Oct 14, 2008 8:03 pm
Reply with quote

Yes, that is being a good point re abendaid not knowing about the dynamic allocation.

The documentaiton for BPXWDYN is so poor that I am not sure where is being the return code or I would have checked. Would it perhaps be in R15?
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: Tue Oct 14, 2008 8:15 pm
Reply with quote

If you look in this ftp.software.ibm.com/s390/zos/tools/bpxwdyn/bpxwdyn.html you can find
Quote:
When called as a program, the return code is available in R15.

BPXWDYN returns the following codes:

0
Success
20
Invalid parameter list. See Calling Conventions for parameter list formats.
-21 to -9999
Key error
-100nn
Message processing error. IEFDB476 returned code nn.
>0
Dynamic allocation or dynamic output error codes
Back to top
View user's profile Send private message
Pankaj Gupta
Currently Banned

New User


Joined: 07 May 2008
Posts: 50
Location: Bangalore

PostPosted: Tue Oct 14, 2008 8:25 pm
Reply with quote

Oh well. R15 is seeming to have 0000FD9A after the call.

I might as well be giving up as there seems not much else I can be doing.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue Oct 14, 2008 8:29 pm
Reply with quote

if I remember correctly the format of the parameter list to be passed on a link macro id the same You would get at program initiation
something like

Code:

         L     R1,ALCPTR
         LINK  EP=BPXWDYN
         LTR   R15,R15
         BNZ   ALCERR
..... CONTINUE PROCESSING
ALCERR   DS    0H
... ERROR PROCESSING
...
...
ALCPTR   DC    A(ALCLIST)+X'80000000'
ALCLIST  DC    AL2(80)
ALCPAR   DC    CL80''ALLOC FI(MYFILE) DA(DVDYC.ASS.FL) SHR'


the load could be a load address, in two runs You can find which is the good instruction
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Oct 14, 2008 11:41 pm
Reply with quote

Hello,

Quote:
It cannot be this simple.
Actually, it can. . .

Quote:
The documentaiton for BPXWDYN is so poor

If is not good form to blame the documentation for one's inexperience.

Quote:
I might as well be giving up as there seems not much else I can be doing.
If you come back to this after you gain considerably more experience, it will not appear so difficult.
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: Tue Oct 14, 2008 11:46 pm
Reply with quote

I've gotten BPXWDYN running from Assembler. This program uses standard linking conventions and returns a condition code of zero in the JCL. The code is:
Code:
ASMTEST  CSECT
         REGEQU
         STM   R14,R12,12(R13)
         LR    R12,R15
         USING ASMTEST,R12
         LA    R15,SAVEAREA
         ST    R13,4(R15)
         ST    R15,8(R13)
         LR    R13,R15
         OPEN  (SYSPRINT,(OUTPUT))
         PUT   SYSPRINT,=CL133'HELLO WORLD'
         LINK  EP=BPXWDYN,PARAM=(P1ADDR),VL=1
         LTR   R15,R15
* TEST FOR GOOD RETURN -- IF SO, JUMP OVER MOVE OF R15 TO OUTPUT
*        BZ    DYNWRITE
         CVD   R15,R15CVD
         UNPK  BPXM1R15(8),R15CVD+4(4)
         CLI   BPXM1R15+7,C'J'
         BL    BPXPLUS
         MVI   BPXMSG1+14,C'-'
         B     PUTCODE
BPXPLUS  EQU   *
         MVI   BPXMSG1+14,C'+'
PUTCODE  EQU   *
         OI    BPXM1R15+7,X'F0'
         PUT   SYSPRINT,BPXMSG1
DYNWRITE EQU   *
         OPEN  (DDN,(OUTPUT))
         PUT   DDN,BPXMSG2
         CLOSE (DDN)
         LINK  EP=BPXWDYN,PARAM=(P2ADDR),VL=1
         CLOSE (SYSPRINT)
         L     R13,SAVEAREA+4
         XR    R15,R15
         RETURN (14,12),RC=(15)
SAVEAREA DS    18F
DDN      DCB   DDNAME=MYFILE,BLKSIZE=27920,DSORG=PS,MACRF=(PM),        X
               LRECL=80
SYSPRINT DCB   DDNAME=SYSPRINT,BLKSIZE=133,DSORG=PS,MACRF=(PM)
         DC    C'SYSSNAP DCB FOUNDATION.'
         CNOP  0,4                 FULLWORD ALIGNMENT.
P1ADDR   DC    H'54'
PARM01   DC    CL54'ALLOC DD(MYFILE) DA(''TTSSRS0.BPXWDYN.FILE.DATA'') X
               SHR'
         CNOP  0,4                 FULLWORD ALIGNMENT.
P2ADDR   DC    H'16'
PARM02   DC    CL16'FREE  DD(MYFILE)'
R15CVD   DS    D
BPXMSG1  DC    0CL133
BPXMSG2  DC    0CL80
         DC    CL15'BPXWDYN R15 =  '
BPXM1R15 DS    CL8
         DC    CL110' '
FINAL    EQU   *
         END   ASMTEST

The JCL that runs this program does not include DDNAME MYFILE but is:
Code:
//STEP1     EXEC PGM=MF0027
//STEPLIB   DD   DISP=SHR,DSN=TTSSRS0.COMPILES.LOADLIB
//SYSABEND  DD   SYSOUT=*
//SYSPRINT  DD   SYSOUT=*
//

and the output file is:
Code:
 ISRBROBA DSLIST 0.BPXWDYN.FILE.DATA
 Command ===>
********************************* Top of Data
BPXWDYN R15 = +00000000

And SYSPRINT looks like:
Code:
----+----1----+----2----+----3
HELLO WORLD
BPXWDYN R15 = +00000000
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: Tue Oct 14, 2008 11:58 pm
Reply with quote

To add to what Dick said (I didn't see his post before putting my code up), the use of the LINK assembler macro requires use of certain standard calling conventions, which you chose to ignore (or didn't know about). The program I posted follows the LINK calling conventions and wrote to a DDNAME that was not defined in JCL. 55 lines of Assembler to start up, call BPXWDYN, and exit is not a large program. Getting so frustrated on such a simple task is not a good indicator for future success -- perhaps you need to reconsider an IT career???
Back to top
View user's profile Send private message
Pankaj Gupta
Currently Banned

New User


Joined: 07 May 2008
Posts: 50
Location: Bangalore

PostPosted: Tue Oct 28, 2008 12:05 am
Reply with quote

Now I am back from my holiday I have revied your fine code Mr Robert and I am seeing that my code was nearly right, missing only the 2 lines. Now my code is working well. Thank you for your help Mr Robert.

Mr Dick, I must say that I am in fact having 20 years of the informations technology experience. In fact, here on my desk they have been putting a sign which is saying "IT Guru", which I think is speaking for itself.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Oct 28, 2008 1:13 am
Reply with quote

Quote:
they have been putting a sign which is saying "IT Guru", which I think is speaking for itself.
Opinions vary. . .

Quote:
I must say that I am in fact having 20 years of the informations technology experience
Apparently not with this type of beginning assembler code (standard linkage should be the first discipline learned and understood with assembler - imho). Also, with 2 decades experience, one should surely have learned that "guru"s do not blame the documentation when they do not understand something.

d
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue Oct 28, 2008 1:31 am
Reply with quote

Quote:
The documentaiton for BPXWDYN is so poor that I am not sure where is being the return code or I would have checked. Would it perhaps be in R15?


to confirm that Your judgement is unfair ( I went thru the issue as a beginner would )

a stupid search with "bpxwdyn assembler samples" brought up ...

ftp.software.ibm.com/s390/zos/tools/bpxwdyn/bpxwdyn.html

with the important info

Code:

      *-*------------------*     *-------*---------------------*
 R1-->|1| parm string addr *---->| length| parameter string    |
      *-*------------------*     *---*---*---------------------*


the docs cannot be blaimed, they rather should be read
and once in a while the IBM explanation is very clear
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: Tue Oct 28, 2008 3:38 am
Reply with quote

Quote:
PostPosted: Tue Oct 14, 2008 9:45 am Post subject:
Reply with quote
If you look in this ftp.software.ibm.com/s390/zos/tools/bpxwdyn/bpxwdyn.html you can find
Early on in this document you can read:
Quote:
Calling Conventions

BPXWDYN is designed to be called from REXX, but may also be called by any program. Three parameter list forms are supported.

REXX External Function Parameter List

This parameter list allows REXX programs to call the BPXWDYN programs as a function or subroutine. They must be called with a single string parameter:

if BPXWDYN("alloc dd(sysin) da('my.dataset') shr")<>0 then
call allocfailed

Conventional MVS Variable Length Parameter String

This is the same parameter list as is generated by ADDRESS LINKMVS with one parameter and JCL with EXEC PGM=,PARM=. This parameter list form is simple to use by any program. Note that this is a single item variable length parameter list. The high bit is on in the parameter address word and length is a half word.


Figure 1.


*-*------------------*
R1-->|1| parm string addr *---*
*-*------------------* |
*-----------------------*
| *-------*---------------------*
*---->| length| parameter string |
*---*---*---------------------*


Now, I can only conclude that one of three possibilities occurred:
1. You did not read the material you were referred to. "Guru"s read documentation, especially when told it can solve their problem.
2. You read this document but did not comprehend it. Since this is basic, elementary Assembler coding conventions, not comprehending this material is not a good indicator for a "Guru".
3. You read this document, comprehended it, but did not follow the coding conventions. A "Guru" would not ignore coding conventions and then complain about the quality of the documentation. Coding conventions may sound optional but they are not -- you disregard them at the peril of your program. Your program problems were entirely caused by your not following the requirements of the called subroutine.
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 -> PL/I & Assembler

 


Similar Topics
Topic Forum Replies
No new posts CLIST - Virtual storage allocation error CLIST & REXX 5
No new posts Using Dynamic file handler in the Fil... COBOL Programming 2
No new posts JCL Dynamic System Symbols JCL & VSAM 3
No new posts Build dataset list with properties us... PL/I & Assembler 4
No new posts Synctool-dynamic split job for varyin... JCL & VSAM 7
Search our Forums:

Back to Top