Page 1 of 2

BPXWDYN ERRORs TO S99MSG.

PostPosted: Tue Nov 12, 2013 4:02 pm
by Steve Coalbran
Hi
    I've scanned this and many other fora for this and got nowhere.
    I've RTFMd too and there's no depth in any examples.
    I've tried various different approaches...

I want to call BPXWDYN to ALLOC/FREE/unameit and trap the error messages.
s99msg. never has anything, whatever weird errors I try to simulate, here the '.' instead of a ',' in the ALLOC.
Anyone got a nice little bit of working code that does this?
Here's my last futile attempt in function "BPX"...
(Details and comments removed for clarity.
The ABEXIT routine is just a standard error routine to ISPEXEC SETMSG the short&long messages)

-  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  2 Line(s) not Displayed
sm = "BPXWDYN ERROR"                                                   
-  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  2 Line(s) not Displayed
ADDRESS TSO                                                             
CALL SYSCALLS "ON"                                                     
PARSE VALUE "" WITH cdd edd                                             
CALL BPX "ALLOC NEW REUSE",                                             
         "LRECL(255) RECFM(VB) DSORG(PS) BLKSIZE(32720)",               
         "RTDDN(SDD) RTDSN(SDS) SPACE(3.3)CYL RELEASE MSG(WTP)"         
-  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  8 Line(s) not Displayed
EXIT                                                                   
BPX:                                                                   
ARG __cmd                                                               
s99msg. = 0                                                             
retc = BPXWDYN(__cmd)                                                   
IF( retc<>0 )THEN DO                                                   
   lm = "CALL BPXWDYN:" __cmd,                                         
       "§ENDED RC="retc "X'"C2X(retc)"'"                               
   IF( s99msg.0<>0 )THEN DO                                             
      DO i = 1 TO s99msg.0                                             
         lm = lm"§"s99msg.i                                             
      END                                                               
      END                                                               
   ELSE NOP                                                             
   CALL ABEXIT sm,lm                                                   
   END                                                                 
ELSE NOP                                                               
RETURN                                                                 
-  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - 34 Line(s) not Displayed

Thanks in advance.

Re: BPXWDYN ERRORs TO S99MSG.

PostPosted: Tue Nov 12, 2013 5:05 pm
by enrico-sorichetti
my understanding of the manual tells that You got what You asked for :D
"RTDDN(SDD) RTDSN(SDS) SPACE(3.3)CYL RELEASE MSG(WTP)"   


MSG(WTP|default.S99MSG.|stemname|fdnum)
Direct allocation messages to your job log (WTP), a REXX stem, or a file identified by a file descriptor number. If this key is not specified, messages will be returned in the S99MSG. stem, if possible. If the program was not called by a REXX exec, the messages will be lost.


MSG(WTP) instructs the BPX... powers to write the messages to the JOB LOG

try without using the MSG key

Re: BPXWDYN ERRORs TO S99MSG.

PostPosted: Tue Nov 12, 2013 6:16 pm
by Steve Coalbran
Hi Enrico
I Tried MSG(WTP) already.
I couldn't see any message in SDSF for my session and got nothing visible anywhere I could see.
I want to trap it in the steminside the subroutine. That's the point.
The error is deliberately to cause an error.

Re: BPXWDYN ERRORs TO S99MSG.

PostPosted: Tue Nov 12, 2013 6:47 pm
by Robert Sample
Did you not read the quote enrico posted? Here is the relevant portion again:
If this key is not specified, messages will be returned in the S99MSG. stem, if possible.
In other words, as long as you have MSG in your code, you will NOT be able to access the errors via S99MSG -- period.

Re: BPXWDYN ERRORs TO S99MSG.

PostPosted: Tue Nov 12, 2013 10:30 pm
by Steve Coalbran
Hi Robert
Yes, I read it... many times.
It is exactly the s99msg. stem that I want loaded with the message lines. That is why I DO NOT NOW have MSG(stem) in my call - I just tried that along the way.
Do you have a working example?

Re: BPXWDYN ERRORs TO S99MSG.

PostPosted: Tue Nov 12, 2013 10:41 pm
by Steve Coalbran
I had cut&pasted the code before into a NotePad - apologies, the MSG(WTP) was not included.
I put a TRACE "I" around the check get this...
36 *-*    IF( s99msg.0<>0 )
   >V>      "0"             
   >L>      "0"             
   >O>      "0" 
41 *-*    ELSE   
   *-*     NOP     

Re: BPXWDYN ERRORs TO S99MSG.

PostPosted: Tue Nov 12, 2013 11:03 pm
by Steve Coalbran
Try again, here's the latest version, I try passing a stem of my own...
sm = "BPXWDYN ERROR"
CALL SYSCALLS "ON"
CALL BPX "ALLOC NEW REUSE",
         "LRECL(255) RECFM(VB) DSORG(PS) BLKSIZE(32720)",
         "RTDDN(SDD) RTDSN(SDS) SPACE(3.3)CYL RELEASE "
EXIT
BPX: TRACE "I"
ARG __cmd
__msg. = 0
__msg = "MSG(__msg.)"
__rc = BPXWDYN(__cmd __msg)
IF( __rc<>0 )THEN DO
   retx = C2X(__rc)
   /*
   */
   __lm = "CALL BPXWDYN:" __cmd,
        "§ENDED RC="__rc "X'"retx"'"
   IF( __msg.0<>0 )THEN DO
      DO i = 1 TO __msg.0
         __lm = __lm"§"__msg.i
      END
      END
   ELSE NOP
   CALL ABEXIT __sm,__lm
   END
ELSE NOP
RETURN
giving a TRACE output of...
    22 *-*  ARG __cmd
       >>>    "ALLOC NEW REUSE LRECL(255) RECFM(VB) DSORG(PS) BLKSIZE(32720) RT
DDN(SDD) RTDSN(SDS) SPACE(3.3)CYL RELEASE "
    23 *-*  __msg. = 0
       >L>    "0"
    24 *-*  __msg = "MSG(__msg.)"
       >L>    "MSG(__msg.)"
    25 *-*  __rc = BPXWDYN(__cmd __msg)
       >V>    "ALLOC NEW REUSE LRECL(255) RECFM(VB) DSORG(PS) BLKSIZE(32720) RT
DDN(SDD) RTDSN(SDS) SPACE(3.3)CYL RELEASE "
       >V>    "MSG(__msg.)"
       >O>    "ALLOC NEW REUSE LRECL(255) RECFM(VB) DSORG(PS) BLKSIZE(32720) RT
DDN(SDD) RTDSN(SDS) SPACE(3.3)CYL RELEASE  MSG(__msg.)"
       >F>    "-930"
    26 *-*  IF( __rc<>0 )
       >V>    "-930"
       >L>    "0"
       >O>    "1"
       *-*   THEN
       *-*   DO
    27 *-*    retx = C2X(__rc)
       >V>      "-930"
       >F>      "60F9F3F0"
    28 *-*    /*
               */
    30 *-*    __lm = "CALL BPXWDYN:" __cmd,
                    "§ENDED RC="__rc "X'"retx"'"
       >L>      "CALL BPXWDYN:"
       >V>      "ALLOC NEW REUSE LRECL(255) RECFM(VB) DSORG(PS) BLKSIZE(32720)
RTDDN(SDD) RTDSN(SDS) SPACE(3.3)CYL RELEASE "
       >O>      "CALL BPXWDYN: ALLOC NEW REUSE LRECL(255) RECFM(VB) DSORG(PS) B
LKSIZE(32720) RTDDN(SDD) RTDSN(SDS) SPACE(3.3)CYL RELEASE "
       >L>      "§ENDED RC="
       >O>      "CALL BPXWDYN: ALLOC NEW REUSE LRECL(255) RECFM(VB) DSORG(PS) B
LKSIZE(32720) RTDDN(SDD) RTDSN(SDS) SPACE(3.3)CYL RELEASE  §ENDED RC="
       >V>      "-930"
       >O>      "CALL BPXWDYN: ALLOC NEW REUSE LRECL(255) RECFM(VB) DSORG(PS) B
LKSIZE(32720) RTDDN(SDD) RTDSN(SDS) SPACE(3.3)CYL RELEASE  §ENDED RC=-930"
       >L>      "X'"
       >O>      "CALL BPXWDYN: ALLOC NEW REUSE LRECL(255) RECFM(VB) DSORG(PS) B
LKSIZE(32720) RTDDN(SDD) RTDSN(SDS) SPACE(3.3)CYL RELEASE  §ENDED RC=-930 X'"
       >V>      "60F9F3F0"
       >O>      "CALL BPXWDYN: ALLOC NEW REUSE LRECL(255) RECFM(VB) DSORG(PS) B
LKSIZE(32720) RTDDN(SDD) RTDSN(SDS) SPACE(3.3)CYL RELEASE  §ENDED RC=-930 X'60F
9F3F0"
       >L>      "'"
       >O>      "CALL BPXWDYN: ALLOC NEW REUSE LRECL(255) RECFM(VB) DSORG(PS) B
LKSIZE(32720) RTDDN(SDD) RTDSN(SDS) SPACE(3.3)CYL RELEASE  §ENDED RC=-930 X'60F
9F3F0'"
    32 *-*    IF( __msg.0<>0 )
       >V>      "0"
       >L>      "0"
       >O>      "0"
    37 *-*    ELSE
       *-*     NOP
    38 *-*    CALL ABEXIT __sm,__lm
       >L>      "__SM"
       >V>      "CALL BPXWDYN: ALLOC NEW REUSE LRECL(255) RECFM(VB) DSORG(PS) B
LKSIZE(32720) RTDDN(SDD) RTDSN(SDS) SPACE(3.3)CYL RELEASE  §ENDED RC=-930 X'60F
9F3F0'"
    71 *-*     ABEXIT:
       *-*     PROCEDURE
       *-*     TRACE "O"
***
Spot the mistake? I can't. It's probably blindingly obvious?!

Re: BPXWDYN ERRORs TO S99MSG.

PostPosted: Wed Nov 13, 2013 1:10 am
by enrico-sorichetti
see here for a handy tool to display the names of the variables active in Your REXX
http://ibmmainframes.com/about59657.html

Re: BPXWDYN ERRORs TO S99MSG.

PostPosted: Wed Nov 13, 2013 1:14 am
by Pedro
This works for me:
/* rexx */                                             
trace('r')                                             
parse UPPER arg dsn                                     
                                                       
ZZ =  BPXWDYN("ALLOC FI(TEMP1) DSN("dsn")     REUSE")   
say  zz s99msg.0                                       
                                                       
If s99msg.0 ¬= 'S99MSG.0' Then                         
  Do idx = 1 to s99msg.0                               
   say idx s99msg.idx                                   
  End                                                   
Address TSO "LISTDD TEMP1"                             

It results in four messages being shown. The problem is that 'duplicate name exists in catalog'.

I found it unforgiving in:
1. does not support dataset prefix. I had to fully qualify in parameter.
2. did not like REU. I had to specify REUSE.
3. needed to specify OLD to not get a message.

Your exec does not work because of this:
 SPACE(3.3)CYL

It should use a comma. Add a blank for readability.

It seems to have various return codes for syntax errors but does not provide messages for those. You will likely get messages when it is syntactically correct, but some error occurs when it tries to execute it.

Re: BPXWDYN ERRORs TO S99MSG.

PostPosted: Wed Nov 13, 2013 10:19 am
by Steve Coalbran
Pedro wrote: Your exec does not work because ...
It should use a comma. ...

Thanks Pedro - the whole point of the dot instead of comma was to generate an error, __ I got the syntax down. :D
OK,
So, could you(/anyone) please let me know of a situation that will generate 'error messages' in the 'msg' stem/whatever?
Just to check the syntax.
BTW: Yes, I changed my check to be IF( DATATYPE(s99msg.0,"N") )THEN ...

Please excuse my REXX writing standard which can be accused of "over-bracketing"?
I like all REXX keywords & labels in uppercase, OK, weird or...? :?