Page 1 of 2

External functions in Rexx

PostPosted: Mon Oct 28, 2019 1:38 pm
by LasseH
Writing a function that reads DB2 and leaving result in a ISPF-table.
Abends when I do a TBCREATE (first ISPF-command)

Start function this way

Call Rexx:
res = SQL2TABT(restab,sql,max)

SQL2TABT(rexx):
1. Writing the 3 arguments to a dataset (shall be accept:ed in Cobol-program, much easier to parse)
2. call DB2STRT SQL2TAB

DB2STRT (rexx):
program = strip(arg(1))                    
plan    = program                          
ssid    = 'DB2U'                          
parms   = ''                              
                                           
newstack                                  
queue "RUN PROGRAM("program")" ,          
      "    PLAN("plan")"    ,              
      "    PARMS("parms")"                
queue "END"                                
queue ""                                  
address TSO "DSN SYSTEM("ssid")"          
dsnrc = rc                                
if dsnrc <> 0 then                        
   say 'DSN command failed. rc='dsnrc      
delstack                                  
return 0                                  


Doing a couple of DB2-commands and then...
Everything works until my Cobol-program trying to issue a ISPF-command.

SQL2TAB  09:04:09,09 ta-tbcreate                                
Trying TBCREATE                                                
                                                               
System abend code 0C4, reason code 00000016.                    
Abend in host command DSN or address environment routine TSO.  
System abend code 0C4, reason code 00000016.                    
Abend in external subroutine DB2STRT.                          
System abend code 0C4, reason code 00000016.                    
Abend in external function SQL2TABT.                            
***                                                            


Recommendation of how to run this
//Lasse

Re: External functions in Rexx

PostPosted: Mon Oct 28, 2019 2:05 pm
by LasseH
Forgot: got this in SDSF-log
IEA989I SLIP TRAP ID=X13E MATCHED.  JOBNAME=U39828  , ASID=00D3.  

Re: External functions in Rexx

PostPosted: Mon Oct 28, 2019 2:42 pm
by willy jensen
May we see what the failing program snippet looks like?

Re: External functions in Rexx

PostPosted: Mon Oct 28, 2019 3:18 pm
by LasseH
The cobol-program.
We have done some DB2-stuff before this ISPF-command

01          ispf-service    pic  x(08).                  
01          ispf-key-list.                              
    05      ispf-key-count  pic  9(06)    binary.        
    05      filler          pic  9(06)    binary.        
    05      ispf-key        pic  x(08)    occurs 30.    
01          ispf-name-list.                              
    05      ispf-name-count pic  9(06)    binary.        
    05      filler          pic  9(06)    binary.        
    05      ispf-name       pic  x(08)    occurs 30.    
                                                         
01          ispf-table-name pic  x(08).                  
01          ispf-option1    pic  x(08).                  
01          ispf-option2    pic  x(08).                  


*    ----------------------------------          
*    create the result ISPF-table using          
*    collected column-names                      
*    ----------------------------------          
     display 'Trying TBCREATE'                    
     move 'TBCREATE'         to  ispf-service    
     move w-ispftab          to  ispf-table-name  
     move 00                 to  ispf-key-count  
     move 'NOWRITE '         to  ispf-option1    
     move 'REPLACE '         to  ispf-option2    
     call 'isplink'          using                
                             ispf-service        
                             ispf-table-name      
                             ispf-key-list        
                             ispf-name-list      
                             ispf-option1        
                             ispf-option2        
     end-call                                    

Re: External functions in Rexx

PostPosted: Mon Oct 28, 2019 3:35 pm
by willy jensen
Your parameter list is wrong, it should be like this:
CALL ISPLINK ('TBCREATE' , table-name , key-name-list, name-list, 'WRITE'|'NOWRITE', 'REPLACE'|' ', library)

Re: External functions in Rexx

PostPosted: Mon Oct 28, 2019 3:56 pm
by LasseH
Sorry but I'm not seeing any difference

Service = TBCREATE
Table-name = name coming from "accept"
Key-list = put zero in key-count (don't use keys)
Name-list = already populated from DB2.
Option1 = NOWRITE
Option2 = REPLACE
Not using "library

What am I missing?

Re: External functions in Rexx

PostPosted: Mon Oct 28, 2019 4:14 pm
by LasseH
Now I've put in some 'displays' in the program

display 'Trying TBCREATE'                      
move 'TBCREATE'         to  ispf-service      
move w-ispftab          to  ispf-table-name    
move space              to  ispf-key-list      
move 00                 to  ispf-key-count    
move 'NOWRITE '         to  ispf-option1      
move 'REPLACE '         to  ispf-option2      
display 'service >' ispf-service '<'          
display 'Table   >' ispf-table-name '<'        
display 'Key cont>' ispf-key-count '<'        
display 'Key 1   >' ispf-key (1) '<'          
display 'nme cont>' ispf-name-count '<'        
display 'nme 1   >' ispf-name (1) '<'          
display 'nme 2   >' ispf-name (2) '<'          
display 'nme 3   >' ispf-name (2) '<'          
display 'option1 >' ispf-option1 '<'          
display 'option2 >' ispf-option2 '<'          
call 'isplink'          using                  
                        ispf-service          
                        ispf-table-name        
                        ispf-key-list          
                        ispf-name-list        
                        ispf-option1          
                        ispf-option2          
end-call                                                                     

Trying TBCREATE          
service >TBCREATE<        
Table   >LASSE   <        
Key cont>000000<          
Key 1   >        <        
nme cont>000003<          
nme 1   >TYPNR   <        
nme 2   >TYPNAMN <        
nme 3   >TYPNAMN <        
option1 >NOWRITE <        
option2 >REPLACE <        

Re: External functions in Rexx

PostPosted: Mon Oct 28, 2019 7:54 pm
by willy jensen
I'm not a COBOL person so forgive me if I am talking rubbish. But the definition section looks a lot like PL/I (which I have done some time ago), so I assume that the structure

01 ispf-name-list.
05 ispf-name-count pic 9(06) binary.
05 filler pic 9(06) binary.
05 ispf-name pic x(08) occurs 30.

will generate 2 binary fields followed by the character field holding the name list. That is not the valid parameter format. I found a COBOL sample at https://www.ibm.com/support/knowledgece ... spsg30.htm

WORKING-STORAGE SECTION.
77 SERVIS PICTURE A(8) VALUE 'LMOPEN '.
77 DATAID PICTURE A(8).
77 OPTSHUN PICTURE A(8) VALUE 'INPUT '.
?
PROCEDURE DIVISION.
CALL 'ISPLINK' USING SERVIS DATAID OPTSHUN.

which uses strict character fields, no counts or fillers in front.

It would also be more useful if your displays showed the 'ispf-name-list' and 'ispf-key-list' fields.

Re: External functions in Rexx

PostPosted: Mon Oct 28, 2019 9:13 pm
by LasseH
Thanks, You got me on the right track.

I did spaced out the following definition:
move space              to  ispf-key-list
move space              to  ispf-name-list


01          ispf-key-list.                              
    05      ispf-key-count  pic  9(06)    binary.        
    05      filler          pic  9(06)    binary [b]Value Zero[/b].        
    05      ispf-key        pic  x(08)    occurs 30.    
01          ispf-name-list.                              
    05      ispf-name-count pic  9(06)    binary.        
    05      filler          pic  9(06)    binary [b]Value Zero[/b].       
    05      ispf-name       pic  x(08)    occurs 30.


But the 2 'fillers' has to have a value of ZERO

Re: External functions in Rexx

PostPosted: Mon Oct 28, 2019 9:38 pm
by enrico-sorichetti