project QadFinancials > class BPosting > method ApiStdMaintainMultiTT

Description

ApiStdMaintainMultiTT: Same as ApiStdMaintainTT except that all input main-tables are handled in a single transaction.
Note that the Remoting-flag has been turned on because this method is called from the JE-ExcelIntegration on the client.


Parameters


tApiPostinginputtemp-tableInput table containing the postings
tApiPostingLineinputtemp-tableInput table containing the posting-lines
tApiPostingSafinputtemp-tableInput table containing the posting-safs of a posting-line
tApiPostingVatinputtemp-tableInput table containing the PostingVat
tApiPostingVatDelayinputtemp-tableInput table containing the PostingVatDelay
icActioninputcharacterSAVE
SAVESTORE
STORE
VALIDATE
ocLstPrimKeyoutputcharacterLstPrimKey
Char4 separated list with the primary keys of the newly created main-table records. The fields of a primkey are separated with Char2.
E.g. 1<Char2>2002<Char2>100<Char4>1<Char2>2002<Char2>101
ocLstReturnoutputcharacterLstReturn
Char4 separated list with the return-status of the newly created main-table records. Zero means no errors occured.
E.g. 0<Char4>-1<Char4>-504<Char4>1<Char4>0
ocLstRowidoutputcharacterLstRowid
Char4 separated list with the temporarely rowids (negative for new ones) of the newly created main-table records. .
E.g.
-1<Char2>aox00098001<Char2>-26
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BCInvoiceJournalEntry.ApiStdMaintainTTV01
method BDInvoiceMultiCy.UpdateDeductionDetailCy
method BDInvoiceMultiCy.UpdateDeductionDetailCyV01
method BJournalEntryMultiCy.CreateMultiCyPostings


program code (program9/bposting.p)

/* ============================================================================ */
/* Clear the instance:                                                          */
/* this will also clear the t_s tables that were filled in ApiMaintainByDataSet */
/* ============================================================================ */
<M-50 run ClearData  (output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper < 0
then do:
    assign oiReturnStatus = viFcReturnSuper.
    return.
end.

/* ============================================================== */
/* Call method that can extend the tApi-tables with some defaults */
/* ============================================================== */
<M-74 run ApiStdMaintainTTInitialDefaulting  (output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0
then return.

/* ==================================================================== */
/* Set Default Return and Parameter Validation                          */
/* Note: as this is a multi-instance method (multiple db-instances      */
/* with a single transaction) and as we do not have a multi-instance    */
/* UI, we won't allow the creation of drafts                            */
/* ==================================================================== */
assign oiReturnStatus         = -98.
if icAction = ? then assign icAction = "":U.
if icAction <> {&DAEMONACTION-SAVE}  and
   icAction <> {&DAEMONACTION-VALIDATE}
then do:
    assign vcMsgApi       = trim(subst(#T-5'Posting integration (multiple instances): the specified action (&1) should be &2 or &3.':255(72869653)T-5#,trim(icAction),{&DAEMONACTION-SAVE},{&DAEMONACTION-VALIDATE}))
           oiReturnStatus = -1.
    <M-2 run SetMessage
       (input  vcMsgApi (icMessage), 
        input  '':U (icArguments), 
        input  '':U (icFieldName), 
        input  '':U (icFieldValue), 
        input  'E':U (icType), 
        input  1 (iiSeverity), 
        input  '':U (icRowid), 
        input  'QADFIN-3267':U (icFcMsgNumber), 
        input  '' (icFcExplanation), 
        input  '' (icFcIdentification), 
        input  '' (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BPosting>
    return.
end. /* if icAction */

/* ======================== */
/* Count main-table records */
/* ======================== */
for each tApiPosting no-lock :
    assign viMainTableRecordCount = viMainTableRecordCount + 1.    
end. /* for each */

if viMainTableRecordCount = 0
then do:
    assign vcMsgApi       = trim(#T-6'Posting integration: no main table records (posting) found.':255(825519009)T-6#)
           oiReturnStatus = -1.
    <M-3 run SetMessage
       (input  vcMsgApi (icMessage), 
        input  '':U (icArguments), 
        input  '':U (icFieldName), 
        input  '':U (icFieldValue), 
        input  'E':U (icType), 
        input  1 (iiSeverity), 
        input  '':U (icRowid), 
        input  'QADFIN-3268':U (icFcMsgNumber), 
        input  '' (icFcExplanation), 
        input  '' (icFcIdentification), 
        input  '' (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BPosting>
    return.
end. /* if viMainTableRecordCount */

empty temp-table tApiSafFromPosting.

/* ================================ */
/* Start loop on main-table records */
/* ================================ */
for each tApiPosting 
    by tApiPosting.tc_Rowid: 
    
    /* ================================== */
    /* Initialise and Create new instance */
    /* ================================== */
    assign vcMsgApi         = "":U 
           vcRowID          = "":U
           vlWarningsFound  = false.
    
    /* ================================================================== */
    /* Company_id should belong to the same domain as the viCompanyID     */
    /* If not passed then assume local company                            */
    /* ================================================================== */
    if tApiPosting.Company_ID = ? or
       tApiPosting.Company_ID = 0
    then assign tApiPosting.Company_ID = viCompanyId.
    else
    if tApiPosting.Company_ID <> viCompanyId
    then do:
         <Q-44 run CompanyByDomain (all) (Read) (Cache)
            (input tApiPosting.Company_ID, (CompanyId)
             input viDomainID, (DomainId)
             input true, (Active)
             output dataset tqCompanyByDomain) in BCompany>
         find tqCompanyByDomain where
              tqCompanyByDomain.tiCompany_ID =  tApiPosting.Company_ID and
              tqCompanyByDomain.tiDomain_ID  = viDomainID
              no-error.
         if not available tqCompanyByDomain
         then do:
            assign vcMsgApi      = trim(substitute(#T-10'Company ID (&1) does not match the current domain.)':200(915904178)T-10#, trim(string(tApiPosting.Company_ID)) ))
                   ocLstReturn   = ocLstReturn  + chr(4) + (if viFcReturnSuper = 0 then "-3":U else string(viFcReturnSuper))
                   ocLstPrimKey  = ocLstPrimKey + chr(4) + "*":U
                   ocLstRowid    = ocLstRowid   + chr(4) + "*":U.
            <M-7 run SetMessage (input  vcMsgApi (icMessage), 
                          input  '':U (icArguments), 
                          input  '':U (icFieldName), 
                          input  '':U (icFieldValue), 
                          input  'E':U (icType), 
                          input  3 (iiSeverity), 
                          input  '':U (icRowid), 
                          input  'QADFIN-3269':U (icFcMsgNumber), 
                          input  '' (icFcExplanation), 
                          input  '' (icFcIdentification), 
                          input  '' (icFcContext), 
                          output viFcReturnSuper (oiReturnStatus)) in BPosting>
            next.
        end.
    end. /* tApiPosting.Company_ID <> viCompanyId */
    
    /* ============================================ */
    /* Create Posting (modification is not allowed) */
    /* ============================================ */
    <M-37 run AddDetailLine
       (input  'Posting':U (icTable), 
        input  '':U (icParentRowid), 
        output viFcReturnSuper (oiReturnStatus)) in BPosting> 
    if viFcReturnSuper >= 0 then do:
        <M-47 run SetRowidConvert
           (input  tApiPosting.tc_Rowid (icOldRowid), 
            input  tPosting.tc_Rowid (icNewRowid), 
            output viFcReturnSuper (oiReturnStatus)) in BPosting>
    end.
    if viFcReturnSuper < 0
    then do:
        assign vcMsgApi      = trim(substitute(#T-45'Internal error on the posting integration: unable to create a new instance. Error number: &1.':255(52826970)T-45#,string(viFcReturnSuper)))
               ocLstReturn   = ocLstReturn  + chr(4) + (if viFcReturnSuper = 0 then "-3":U else string(viFcReturnSuper))
               ocLstPrimKey  = ocLstPrimKey + chr(4) + "*":U
               ocLstRowid    = ocLstRowid   + chr(4) + "*":U.
        <M-9 run SetMessage (input  vcMsgApi (icMessage), 
                      input  '':U (icArguments), 
                      input  '':U (icFieldName), 
                      input  '':U (icFieldValue), 
                      input  'E':U (icType), 
                      input  3 (iiSeverity), 
                      input  '':U (icRowid), 
                      input  'QADFIN-3270':U (icFcMsgNumber), 
                      input  '' (icFcExplanation), 
                      input  '' (icFcIdentification), 
                      input  '' (icFcContext), 
                      output viFcReturnSuper (oiReturnStatus)) in BPosting>
        next.
    end. /* if vcMsgApi <> "":U */
    
    /* =========================================================================================== */
    /* Copy all data into the new posting                                                          */
    /* Before continuing, we copy the primary-key-fields of the main table to the input parameters */
    /* This is just to hold it there so it can be assigned to ocPrimKey if the save succeeds. This */
    /* is done because tPosting is no longer available after the save. We use vcRowID in stead  */
    /* of tApiPosting.tc_rowid because tApiPosting.tc_rowid is used as by-clause in the for each   */     
    /* and this would result in the fact that a single record is treated multiple times by the     */
    /* for-each                                                                                    */
    /* =========================================================================================== */           
    buffer-copy tApiPosting 
        except tApiPosting.Posting_ID 
               tApiPosting.tc_ParentRowid 
               tApiPosting.tc_rowid 
               tApiPosting.tc_status 
               tApiPosting.PostingSystemDate
            to tPosting.
    assign tApiPosting.Posting_ID = tPosting.Posting_ID /* Needed to set the prim-key after the save */
           vcRowID                = tPosting.tc_Rowid
           tPosting.PostingOriginIsExternal = (if tPosting.PostingOriginIsExternal = ?
                                               then false
                                               else tPosting.PostingOriginIsExternal)
           tPosting.PostingAddGLNbrDate = (if tPosting.PostingAddGLNbrDate = ?
                                           then tPosting.PostingDate
                                           else tPosting.PostingAddGLNbrDate).

    /* ============================================== */
    /* If PostingYear and PostingPeriod are not set,  */
    /* calculate from PostingDate                     */
    /* ============================================== */
    if (tPosting.PostingYear = 0 or tPosting.PostingYear = ?) or
       (tPosting.PostingPeriod = 0 or tPosting.PostingPeriod = ?)
    then do:   
        <I-30 {bFcOpenInstance
             &CLASS           = "BPeriod"}>
           
        <M-98 run ApiGetDefaultPeriodDate
           (input  ? (iiYearIn), 
            input  ? (iiPeriodIn), 
            input  tPosting.PostingDate (itDateIn), 
            input  ? (ilOpenForPurchase), 
            input  ? (ilOpenForSales), 
            input  ? (ilOpenForInventory), 
            output tPosting.PostingYear (oiYear), 
            output tPosting.PostingPeriod (oiPeriod), 
            output tPosting.PostingDate (otPostingDate), 
            output viExternalReturnStatus (oiReturnStatus)) in BPeriod>
            
            
        <I-87 {bFcCloseInstance
             &CLASS           = "BPeriod"}>                     
     
        if viExternalReturnStatus < 0
            then do :
                assign vcMsgApi       = trim(substitute(#T-80'Posting integration: an error (&1) occurred with Posting &2 while retrieving Year and Period from Posting Date (&3).':255(155751887)T-80#,string(viExternalReturnStatus), tPosting.PostingText, string(tPosting.PostingDate)))
                       ocLstReturn    = ocLstReturn  + chr(4) + string(viExternalReturnStatus)
                       ocLstPrimKey   = ocLstPrimKey + chr(4) + "*":U
                       ocLstRowid     = ocLstRowid   + chr(4) + "*":U.
                if (viFcReturnSuper  = 0)
                then assign viFcReturnSuper = viExternalReturnStatus.       
            next.
        end. /* if viExternalReturnStatus < 0 */
        else if viExternalReturnStatus > 0
             then assign vlWarningsFound = true.
     end. /* if (tPosting.PostingYear = 0 */
        
    /* ================= */
    /* Get a new Voucher */
    /* ================= */
    if tPosting.PostingVoucher = 0 or
       tPosting.PostingVoucher = ?
    then do:
        <M-12 run GetPostingNumber
           (input  tPosting.tc_Rowid (ictcRowid), 
            input  tPosting.PostingYear (iiYear), 
            input  tPosting.tcJournalCode (icJournalCode), 
            output tPosting.PostingVoucher (oiVoucher), 
            output viFcReturnSuper (oiReturnStatus)) in BPosting>
        if viFcReturnSuper < 0
        then do :
            assign vcMsgApi       = trim(substitute(#T-17'Posting integration: an error (&1) occurred while retrieving a new number for the posting.':255(583990505)T-17#,string(viFcReturnSuper)))
                   ocLstReturn    = ocLstReturn  + chr(4) + string(viFcReturnSuper)
                   ocLstPrimKey   = ocLstPrimKey + chr(4) + "*":U
                   ocLstRowid     = ocLstRowid   + chr(4) + "*":U.
            next.
        end. /* if viFcReturnSuper < 0 */
        else 
        if viFcReturnSuper > 0
        then assign vlWarningsFound = true.

        if not can-find (tCommitNumber where
                         tCommitNumber.tcNumberType   = {&COMMITNUMBERTYPE-POSTINGVOUCHER} and
                         tCommitNumber.tcPostingRowID = tPosting.tc_Rowid)
        then do :
            create tCommitNumber.
            assign tCommitNumber.tcNumberType   = {&COMMITNUMBERTYPE-POSTINGVOUCHER}
                   tCommitNumber.tcPostingRowID = tPosting.tc_Rowid.             
        end.     

    end. /* if tPosting.PostingVoucher = 0 */
    
    /* ======================================================================================= */
    /* Process posting-lines, posting-safs, posting-vats, posting-vat-delays and posting-xrefs */
    /* ======================================================================================= */
    <M-13 run ApiStdMaintainTTSub1
       (input  icAction (icAction), 
        input-output ocLstReturn (bcLstReturn), 
        input-output ocLstPrimKey (bcLstPrimKey), 
        input-output ocLstRowid (bcLstRowid), 
        input-output vlDummy (blSaveAsDraft), 
        input-output vlQStartedVatRuleByVatIDCode (blQStartedVatRuleByVatIDCode), 
        input-output vlQStartedGetSafConceptsForStr (blQStartedGetSafConceptsForStr), 
        output viFcReturnSuper (oiReturnStatus)) in BPosting>
    if viFcReturnSuper < 0
    then next.
    else if viFcReturnSuper > 0
         then assign vlWarningsFound = true.
    
    /* =========================================================== */
    /* Indicate the data is saved/stored correctly and set primkey */
    /* =========================================================== */
    assign ocLstReturn  = ocLstReturn  + chr(4) + (if vlWarningsFound = true then "1":U else "0":U)
           ocLstPrimKey = ocLstPrimKey + chr(4) + string(tApiPosting.Posting_ID)
           ocLstRowid   = ocLstRowid   + chr(4) + vcRowID.
    
end. /* for each tApiPosting */

/* ============= */
/* Stop Queries  */
/* ============= */
if vlQStartedVatRuleByVatIDCode = true
then do :
    <Q-20 run VatRuleByVatIDCode  (Stop) in BVAT >
end.
if vlQStartedGetSafConceptsForStr = true
then do :
    <Q-46 run GetSafConceptsForStructure  (Stop) in BSafStructure >
end.

/* ============================================================ */
/* Trim the first character of ocLstReturn and primkey          */
/* Check for correct number and format of the return-parameters */
/* ============================================================ */
if length(ocLstReturn,"CHARACTER":U)  > 1 then assign ocLstReturn  = substring(ocLstReturn,2,-1,"CHARACTER":U).
if length(ocLstPrimKey,"CHARACTER":U) > 1 then assign ocLstPrimKey = substring(ocLstPrimKey,2,-1,"CHARACTER":U).
if length(ocLstRowid,"CHARACTER":U)   > 1 then assign ocLstRowid   = substring(ocLstRowid,2,-1,"CHARACTER":U).
if num-entries(ocLstReturn,chr(4))  <> viMainTableRecordCount or
   num-entries(ocLstPrimKey,chr(4)) <> viMainTableRecordCount or
   num-entries(ocLstRowid,chr(4))   <> viMainTableRecordCount
then do :
    assign vcMsgApi       = trim(#T-39'Posting integration: incomplete information returned by an API method. See other messages for further details.':200(3206)T-39#) + chr(10) + 
                            trim(substitute(#T-40'Main table records: &1.':255(310)T-40#,string(viMainTableRecordCount))) + chr(10) + 
                            trim(substitute(#T-41'Return Statuses: &1.':255(311)T-41#,ocLstReturn))  + chr(10) +
                            trim(substitute(#T-42'Primary keys: &1.':255(312)T-42#,ocLstPrimKey)) + chr(10) +
                            trim(substitute(#T-43'Row IDs: &1.':255(313)T-43#,ocLstRowid)).
           oiReturnStatus = -3.
    <M-38 run SetMessage
       (input  vcMsgApi (icMessage), 
        input  '':U (icArguments), 
        input  '':U (icFieldName), 
        input  '':U (icFieldValue), 
        input  'E':U (icType), 
        input  1 (iiSeverity), 
        input  '':U (icRowid), 
        input  'QADFIN-3280':U (icFcMsgNumber), 
        input  '' (icFcExplanation), 
        input  '' (icFcIdentification), 
        input  '' (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BPosting>
    return.
end. /* if num-entries */

/* ================================================================================================= */
/* Note: from here onwards, every input main-table has a corresponding entry in the ocLst-parameters */
/* If any error/warning occurs after this point, then the ocLst-parameters will be overwritten.      */
/* ================================================================================================= */


/* ==================================================================================================================================================== */
/* Call a method that will create tApiSafFromPosting records for every Saf that is used in the postings and that does not exist as a SAF in the db yet. */
/* These tApiSafFromPosting records will be the basis for creating new SAF records in the db later on in this method.                                   */
/* With this mechanism we support an in-flight create of SAFs for external postings                                                                     */
/* ==================================================================================================================================================== */
<M-76 run ApiStdMaintainTTCreatetApiSafFromPosting  (output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper <> 0
then do :
    if index(ocLstReturn,"-":U) = 0 
    then assign ocLstReturn = fill(string(viFcReturnSuper) + CHR(4),viMainTableRecordCount).
    if viFcReturnSuper < 0
    then do :
        assign oiReturnStatus = viFcReturnSuper.
        Return.
    end. /* if viFcReturnSuper < 0 */ 
end. /* viFcReturnSuper < 0 */

/* =================================================== */
/* Create the SAFs based upon tApiSafFromPosting       */
/* =================================================== */
if can-find (first tApiSafFromPosting)
then do :
    if viBSafPostingID = ? or 
       viBSafPostingID  = 0
    then do:
        <I-53 {bFcStartAndOpenInstance
             &ADD-TO-TRANSACTION   = "false"
             &CLASS                = "BSaf"}>
    end.
    else do:
        <I-58 {bFcOpenInstance
             &CLASS           = "BSaf"}>
    end.
    <M-14 run ApiStdMaintainTT
       (input  tApiSafFromPosting (tApiSaf), 
        input  icAction (icAction), 
        output vcLstPrimKey (ocLstPrimKey), 
        output vcLstReturn (ocLstReturn), 
        output vcLstRowId (ocLstRowId), 
        output viBSafReturn (oiReturnStatus)) in BSaf>    
    /* ========================================================================================================= */
    /* Normally we would here close BSAF but we will not do it for performance                                   */
    /* reasons as this way the Commit of the transaction does not have to re-open the instance to commit it.     */
    /* And in all other scenario's the instance of the class ill be closed by the de-activiate procedure of the  */
    /* appserver that is executed after each call to the appserver                                               */
    /* ========================================================================================================= */
    assign viFcReturnSuper = viBSafReturn. 
    if viFcReturnSuper <> 0
    then do :
        if index(ocLstReturn,"-":U) = 0 
        then assign ocLstReturn = fill(string(viFcReturnSuper) + CHR(4),viMainTableRecordCount).
        if viFcReturnSuper < 0
        then do :
            assign oiReturnStatus = viFcReturnSuper.
            Return.
        end. /* if viFcReturnSuper < 0 */ 
    end. /* viFcReturnSuper < 0 */        
end. /* if can-find (first tApiSafFromPosting) */
    
/* =============================== */
/* Set Actvity                     */
/* =============================== */
if (vcActivityCode = "":U or
    vcActivityCode = ?) and 
   can-find (first tPosting where
                   tPosting.tc_Status = "N":U)
then assign vcActivityCode = "ExternalCreate":U.

/* ======================================================== */
/* Add method which can be implemented to set some defaults */
/* ======================================================== */
<M-31 run ApiStdMaintainTTDefaulting  (output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper <> 0
then do :
    if index(ocLstReturn,"-":U) = 0 
    then assign ocLstReturn = fill(string(viFcReturnSuper) + CHR(4),viMainTableRecordCount).
    if viFcReturnSuper < 0
    then do :
        assign oiReturnStatus = viFcReturnSuper.
        Return.
    end. /* if viFcReturnSuper < 0 */ 
end. /* viFcReturnSuper < 0 */

/* ============================================================================== */
/* Validate the data and Perform external updates (can also contain validations). */    
/* ============================================================================== */
<M-34 run ValidateBC (output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper <> 0
then do :
    if index(ocLstReturn,"-":U) = 0 
    then assign ocLstReturn = fill(string(viFcReturnSuper) + CHR(4),viMainTableRecordCount).
    if viFcReturnSuper < 0
    then do :
        assign oiReturnStatus = viFcReturnSuper.
        Return.
    end. /* if viFcReturnSuper < 0 */ 
end. /* viFcReturnSuper < 0 */
<M-35 run AdditionalUpdates (output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper <> 0
then do :
    if index(ocLstReturn,"-":U) = 0 
    then assign ocLstReturn = fill(string(viFcReturnSuper) + CHR(4),viMainTableRecordCount).
    if viFcReturnSuper < 0
    then do :
        assign oiReturnStatus = viFcReturnSuper.
        Return.
    end. /* if viFcReturnSuper < 0 */ 
end. /* viFcReturnSuper < 0 */

/* ================================================== */
/* Save the data                                      */
/* If only validation was asked then discard the save */
/* ================================================== */
if icAction <> {&DAEMONACTION-VALIDATE}
then do :      
    <M-36 run DataSave (output viFcReturnSuper (oiReturnStatus)) in BPosting>
    if viFcReturnSuper <> 0
    then do :
        if index(ocLstReturn,"-":U) = 0 
        then assign ocLstReturn = fill(string(viFcReturnSuper) + CHR(4),viMainTableRecordCount).
        if viFcReturnSuper < 0
        then do :
            assign oiReturnStatus = viFcReturnSuper.
            Return.
        end. /* if viFcReturnSuper < 0 */ 
    end. /* viFcReturnSuper < 0 */
end. /* if icAction = {&DAEMONACTION-VALIDATE} */

/* ===================================================== */
/* Set global return value based on the individual ones: */ 
/* assign it to zero if all individual ones are zero.    */
/* ===================================================== */
if ocLstReturn = substring(fill("0":U + CHR(4),viMainTableRecordCount),1,length(ocLstReturn,"CHARACTER":U),"CHARACTER":U)
then assign oiReturnStatus = 0.
else do :
    if index(ocLstReturn,"-":U) <> 0 
    then do :
        assign oiReturnStatus = -3
               vcMsgApi       = trim(#T-32'Posting integration: an error has occurred while running this API method. See other error messages for more details.':255(3207)T-32#).
        <M-22 run SetMessage
           (input  vcMsgApi (icMessage), 
            input  '':U (icArguments), 
            input  '':U (icFieldName), 
            input  '':U (icFieldValue), 
            input  'E':U (icType), 
            input  1 (iiSeverity), 
            input  '':U (icRowid), 
            input  'QADFIN-3273':U (icFcMsgNumber), 
            input  '' (icFcExplanation), 
            input  '' (icFcIdentification), 
            input  '' (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BPosting>
        return.
    end. /* if index(ocLstReturn,"-":U) <> 0  */
    else do : 
        assign vcMsgApi        = trim(#T-33'Posting integration: a warning has occurred while running this API method. See other error messages for more details.':255(14315)T-33#)
               oiReturnStatus  = +1.
        <M-23 run SetMessage
           (input  vcMsgApi (icMessage), 
            input  '':U (icArguments), 
            input  '':U (icFieldName), 
            input  '':U (icFieldValue), 
            input  'W':U (icType), 
            input  3 (iiSeverity), 
            input  '':U (icRowid), 
            input  'QADFIN-3274':U (icFcMsgNumber), 
            input  '' (icFcExplanation), 
            input  '' (icFcIdentification), 
            input  '' (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BPosting>
        return.
    end. /* not if lookup */
end. /* Not ocLstReturn = .... */


Sample code: how to call this method through RPCRequestService (QXtend Inbound)

define temp-table ttContext no-undo
    field propertyQualifier as character
    field propertyName as character
    field propertyValue as character
    index entityContext is primary unique
        propertyQualifier
        propertyName
    index propertyQualifier
        propertyQualifier.

define dataset dsContext for ttContext.

define variable vhContextDS as handle no-undo.
define variable vhExceptionDS as handle no-undo.
define variable vhServer as handle no-undo.
define variable vhInputDS as handle no-undo.
define variable vhInputOutputDS as handle no-undo.
define variable vhOutputDS as handle no-undo.
define variable vhParameter as handle no-undo.

/* Create context */
create ttContext.
assign ttContext.propertyName = "programName"
       ttContext.propertyValue = "BPosting".
create ttContext.
assign ttContext.propertyName = "methodName"
       ttContext.propertyValue = "ApiStdMaintainMultiTT".
create ttContext.
assign ttContext.propertyName = "applicationId"
       ttContext.propertyValue = "fin".
create ttContext.
assign ttContext.propertyName = "entity"
       ttContext.propertyValue = "1000".
create ttContext.
assign ttContext.propertyName = "userName"
       ttContext.propertyValue = "mfg".
create ttContext.
assign ttContext.propertyName = "password"
       ttContext.propertyValue = "".

/* Create input dataset */
create dataset vhInputDS.
vhInputDS:read-xmlschema("file", "xml/bposting.apistdmaintainmultitt.i.xsd", ?).
vhParameter = vhInputDS:get-buffer-handle("tParameterI").
vhParameter:buffer-create().
assign vhParameter::icAction = <parameter value>.

vhParameter = vhInputDS:get-buffer-handle("tApiPosting").
vhParameter:buffer-create().
assign vhParameter::<field-name-1> = <field-value-1>
       vhParameter::<field-name-2> = <field-value-2>
       ...

vhParameter = vhInputDS:get-buffer-handle("tApiPostingLine").
vhParameter:buffer-create().
assign vhParameter::<field-name-1> = <field-value-1>
       vhParameter::<field-name-2> = <field-value-2>
       ...

vhParameter = vhInputDS:get-buffer-handle("tApiPostingSaf").
vhParameter:buffer-create().
assign vhParameter::<field-name-1> = <field-value-1>
       vhParameter::<field-name-2> = <field-value-2>
       ...

vhParameter = vhInputDS:get-buffer-handle("tApiPostingVat").
vhParameter:buffer-create().
assign vhParameter::<field-name-1> = <field-value-1>
       vhParameter::<field-name-2> = <field-value-2>
       ...

vhParameter = vhInputDS:get-buffer-handle("tApiPostingVatDelay").
vhParameter:buffer-create().
assign vhParameter::<field-name-1> = <field-value-1>
       vhParameter::<field-name-2> = <field-value-2>
       ...

/* Connect the AppServer */
create server vhServer.
vhServer:connect("-URL <appserver-url>").

if not vhServer:connected()
then do:
    message "Could not connect AppServer" view-as alert-box error title "Error".
    return.
end.

/* Run */
assign vhContextDS = dataset dsContext:handle.

run program/rpcrequestservice.p on vhServer
    (input-output dataset-handle vhContextDS by-reference,
           output dataset-handle vhExceptionDS,
     input        dataset-handle vhInputDS by-reference,
     input-output dataset-handle vhInputOutputDS by-reference,
           output dataset-handle vhOutputDS).

/* Handle output however you want, in this example, we dump it to xml */
if valid-handle(vhExceptionDS)
then vhExceptionDS:write-xml("file", "Exceptions.xml", true).

if valid-handle(vhOutputDS)
then vhOutputDS:write-xml("file", "Output.xml", true).

/* Cleanup */
vhServer:disconnect().
assign vhServer = ?.

if valid-handle(vhInputDS)
then delete object vhInputDS.

if valid-handle(vhOutputDS)
then delete object vhOutputDS.

if valid-handle(vhExceptionDS)
then delete object vhExceptionDS.