External functions in Rexx



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

External functions in Rexx

Postby LasseH » Mon Oct 28, 2019 1:38 pm

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
LasseH
 
Posts: 70
Joined: Mon Nov 08, 2010 2:51 pm
Has thanked: 7 times
Been thanked: 1 time

Re: External functions in Rexx

Postby LasseH » Mon Oct 28, 2019 2:05 pm

Forgot: got this in SDSF-log
IEA989I SLIP TRAP ID=X13E MATCHED.  JOBNAME=U39828  , ASID=00D3.  
LasseH
 
Posts: 70
Joined: Mon Nov 08, 2010 2:51 pm
Has thanked: 7 times
Been thanked: 1 time

Re: External functions in Rexx

Postby willy jensen » Mon Oct 28, 2019 2:42 pm

May we see what the failing program snippet looks like?
willy jensen
 
Posts: 455
Joined: Thu Mar 10, 2016 5:03 pm
Has thanked: 0 time
Been thanked: 69 times

Re: External functions in Rexx

Postby LasseH » Mon Oct 28, 2019 3:18 pm

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                                    
LasseH
 
Posts: 70
Joined: Mon Nov 08, 2010 2:51 pm
Has thanked: 7 times
Been thanked: 1 time

Re: External functions in Rexx

Postby willy jensen » Mon Oct 28, 2019 3:35 pm

Your parameter list is wrong, it should be like this:
CALL ISPLINK ('TBCREATE' , table-name , key-name-list, name-list, 'WRITE'|'NOWRITE', 'REPLACE'|' ', library)
willy jensen
 
Posts: 455
Joined: Thu Mar 10, 2016 5:03 pm
Has thanked: 0 time
Been thanked: 69 times

Re: External functions in Rexx

Postby LasseH » Mon Oct 28, 2019 3:56 pm

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?
LasseH
 
Posts: 70
Joined: Mon Nov 08, 2010 2:51 pm
Has thanked: 7 times
Been thanked: 1 time

Re: External functions in Rexx

Postby LasseH » Mon Oct 28, 2019 4:14 pm

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 <        
LasseH
 
Posts: 70
Joined: Mon Nov 08, 2010 2:51 pm
Has thanked: 7 times
Been thanked: 1 time

Re: External functions in Rexx

Postby willy jensen » Mon Oct 28, 2019 7:54 pm

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.
willy jensen
 
Posts: 455
Joined: Thu Mar 10, 2016 5:03 pm
Has thanked: 0 time
Been thanked: 69 times

Re: External functions in Rexx

Postby LasseH » Mon Oct 28, 2019 9:13 pm

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
LasseH
 
Posts: 70
Joined: Mon Nov 08, 2010 2:51 pm
Has thanked: 7 times
Been thanked: 1 time

Re: External functions in Rexx

Postby enrico-sorichetti » Mon Oct 28, 2019 9:38 pm

cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Next

Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post