QMHSNDPM API in RPG

      //*-----------------------------------------------------------------------
      //* LogMessage - Write message to job log
      //*
      //* Parameter       ATR      I/O       Description
      //* ----------      ---      ---       -----------
      //* textToSend      132a     I         Text message for job log
      //*-----------------------------------------------------------------------

     p LogMessage...
     p                 b
     d LogMessage...
     d                 pi
     d TextToSend                   132a   CONST

     **-- Api error data structure:
     D APIerr          Ds                  Qualified
     D  BytPro                       10i 0 Inz( %Size( APIerr ))
     D  BytAvl                       10i 0 Inz
     D  MsgId                         7a
     D                                1a
     D  MsgDta                      100a

     D QMHSNDPM        pr                  extpgm('QMHSNDPM')
     D  MsgID                         7a   Const
     D  MsgFName                     20a   Const
     D  MsgDta                    32767a   Const Options(*Varsize)
     D  MsgDtaLength                  9b 0 Const
     D  MsgType                      10a   Const
     D  CallStackE                   10a   Const Options(*Varsize)
     D  CallStackC                   10i 0 Const
     D  MsgKey                        4a
     D  Error                     32767a         Options(*Varsize)
      *  Optional Parameter Group 1
     D  CallStackEL                   9b 0 Const Options(*Nopass)
     D  CallStackEQ                  20a   Const Options(*Nopass)
     D  DspPgmMsgWait                 9b 0 Const Options(*Nopass)
      *  Optional Parameter Group 2
     D  CallStackEDT                 10a   Const Options(*Nopass)
     D  MsgCCSID                      9b 0 Const Options(*Nopass)

    	D  MsgID          s              7a
    	D  MsgFil         s             10a
    	D  MsgLib         S             10a
    	D  MsgDta         S          32767a
    	D  MsgDtaLen      S             10i 0
    	D  MsgTyp         S             10a
    	D  PgmMsgF        S             20a
    	D  MsgFName       S             10a
    	D  MsgTypInfo     S             10a
    	D  MsgKey         S              4a
    	D  Error          S          32767a
    	D  PgmMsgDta      S                   Like(MsgDta)
    	D  PgmDtaLen      S                   Like(MsgDtaLen)
    	D  MsgKeyA        S              4a
    	D  PgmCllStck     S             10a   inz(*blanks)
    	D  PgmCllStckC    S             10i 0 inz(0)
    	 *  Optional Parameter Group 1
    	D  CallStackEL    s             10i 0 inz(10)
    	D  CallStackEQ    s             20a   inz('*NONE')
    	D  DspPgmMsgWait  s             10i 0 inz(*zeros)
    	 *  Optional Parameter Group 2
    	D  CallStackEDT   s             10a   inz('*CHAR')
    	D  MsgCCSID       s             10i 0 inz(0)
      /free

         RESET APIerr;
         pgmCLLStck = '*'                                            ; // program of procedure
         msgDta    = textToSend                                      ; // Text length
         msgDtaLen = %len(%trim(MsgDta))                             ; // Text length

         msgID = 'CPF9897'                                           ; // Message ID is CPF9897
         pgmMsgf  = 'QCPFMSG'                                        ; // From QCPFMSG
         %subst(pgmMsgF:11) = '*LIBL'                                ; // library qualifier
         PgmMsgDta = MsgDta                                          ; // Message data
         PgmDtaLen = MsgDtaLen                                       ; // Data length
    	    msgTypInfo= '*INFO'                                         ; // Message type
    	
    	    QMHSNDPM( MsgId
    	              : pgmMsgF
    	              : PgmMsgDta
    	              : PgmDtaLen
    	              : msgtypinfo
    	              : PgmCllStck
    	              : 0
    	              : MsgKeyA
    	              : APIerr
                 ) ;
    	    return;

      /end-free

     P                 e