Search code examples
rpgle

Definition not found for symbol 'QMHSNDPM'


I am following Scott Klement's tutorials on IFS programming with RPGLE. I am facing the below issues. I have added the code snippets as well. Please assist.

Ownership of object WITHERRH in QTEMP type *MODULE changed.            
*SRVPGM object QZDMMDTA in library QSOC not found.                     
Definition not found for symbol 'QMHSNDPM'.                            
Definition not found for symbol 'QMHSNDPM'.                            
Program WITHERRH in library ABCLIBL not created.     

The PR were defined inside this copy source.

 /if not defined(ERRNO_H)                                          
D strerror        PR              *   extproc('strerror')          
D  errnum                       10I 0 value                        
 /define ERRNO_H                                                   
 /endif                                                            

 /if defined(ERRNO_LOAD_PROCEDURE)                                 
P die             B                                                
D die             PI              N                                
D  msg                         256A   const                        

D QMHSNDPM        PR                  extproc('QMHSNDPM')          
D  messageId                     7A   const                        
D  qualMsgF                     20A   const                        
D  msgData                     256A   const                        
D  msgDataLen                   10I 0 const                        
D  msgType                      10A   const                  
D  callSktEnt                   10A   const                  
D  callSktCnt                   10I 0 const                  
D  messageKey                    4A                          
D  errorCode                   256A                          

D dsEC            DS                                         
D  dsECBytesP             1      4I 0 inz(%size(dsEC))       
D  dsECBytesA             5      8I 0 inz(0)                 
D  dsECMsgId              9     15                           
D  dsECReserv            16     16                           
D  dsECMsgData           17    256                           
D msgLen          S             10I 0                        
D theKey          S              4A                          

       msgLen = %checkr(msg:' ');                            
       if msgLen < 1;                                        
          return *off;                                         
       endif;                                                  

       callP  QMHSNDPM('CPF9897':'QCPFMSG   *LIBL':msg:msgLen: 
                       '*ESCAPE':'*':3:theKey:dsEC);           
       return *off;                                            
P                 E                                            

The main program has QC2LE binding directory added; the 'die' procedure is invoked as below,

H dftactgrp(*no) actgrp(*new) bnddir('QC2LE')    

D/copy ABCLIBL/QIFSSRC,IFSIO_H                 
D/copy ABCLIBL/QIFSSRC,ERRNO_H               
.....
if write(fd:%addr(wrdata):%size(wrdata)) < 1; 
   errMsg = %str(strerror(errno));            
   callP close(fd);                           
   callP die('open(): ' + errMsg);            
endif;                                        

Solution

  • As @user2338816 said QMHSNDPM is a external program not a procedure:

    D QMHSNDPM        PR                  extpgm('QMHSNDPM')
    

    Most APIs are external programs and not procedures. And when they aren't external programs it's easy to see from the documentation.

    For example: Dump Module Variables

    With this API you would bind your program to the QTEDMPV service program and then use extproc to reference the procedure.

    D DumpVariables   PR                  extproc('QteDumpModuleVariables')