project QadFinancials > class BBankImportLine > method ApiProcessBankImpLineNewBankEntry

Description

ApiProcessBankImpLineNewBankEntry:
This method creates a new banking entry with a single banking-entry-line and allocates that line to an existng supplier or customer payment.

The input-table of this method should just contain 1 record with these fields filled:

BankImpLineFileFormatCode: Bank-file-format
BankImpLineTransType: Transaction-type of the Bank-file-format
BankImpLineAction: This should either be "PAIDCDOCUMENT" for supplier-payments, either "PAIDDDOCUMENT" for customer-payments
BankImpLineOwnBankNumber: Bank-number of the Banking-Entry
BankImpLineBusRelType: This should either be "CREDITOR" for supplier-payments, either "DEBTOR" for customer-payments
BankImpLineDescription: Description of the Banking-Entry-line
BankImpLineInOut: Direction of the movement; when the action is "PAIDCDOCUMENT" then this will normally be "-" or "OUT", when the action is "PAIDDDOCUMENT" then this will normally be "+" or "IN"
BankImpLineAmountTC: Amount of the Banking-Entry-line
BankImpLineCurrencyCode: Currency of Bank-GL linked to the Bank-number of the Banking-Entry. This is also the currency of the amount on the Banking-Entry-line
BankImpLineExchangeRate: Exchange-rate used on the Banking-Entry-line
BankImpLineRateScale: Exchange-rate-scale used on the Banking-Entry-line (normally 1)
BankImpLineOrigTransDate: Transaction-date of the Banking-Entry
BankImpLineCreditorCode: Code of the supplier (only applicable for supplier-payments)
BankImpLineDebtorCode: Code of the customer (only applicable for customer-payments)
BankImpLineBankNumber: Bank-number of the supplier or customer
BankImpLinePaymentRef: Reference of the existing supplier-payment or customer-payment - note that this should exactly be the reference of the payment as this field is used to find the existing payment in the system
BankImpLineValueDate: Value-date of the Banking-Entr


Parameters


tApiBankImpLineinputtemp-tableTemp-table defined like BankImpLine.
This table can only contain a single record and following fields in this record should be filled;

BankImpLineFileFormatCode: Bank-file-format
BankImpLineTransType: Transaction-type of the Bank-file-format
BankImpLineAction: This should either be "PAIDCDOCUMENT" for supplier-payments, either "PAIDDDOCUMENT" for customer-payments
BankImpLineOwnBankNumber: Bank-number of the Banking-Entry
BankImpLineBusRelType: This should either be "CREDITOR" for supplier-payments, either "DEBTOR" for customer-payments
BankImpLineDescription: Description of the Banking-Entry-line
BankImpLineInOut: Direction of the movement; when the action is "PAIDCDOCUMENT" then this will normally be "-" or "OUT", when the action is "PAIDDDOCUMENT" then this will normally be "+" or "IN"
BankImpLineAmountTC: Amount of the Banking-Entry-line
BankImpLineCurrencyCode: Currency of Bank-GL linked to the Bank-number of the Banking-Entry. This is also the currency of the amount on the Banking-Entry-line
BankImpLineExchangeRate: Exchange-rate used on the Banking-Entry-line
BankImpLineRateScale: Exchange-rate-scale used on the Banking-Entry-line (normally 1)
BankImpLineOrigTransDate: Transaction-date of the Banking-Entry
BankImpLineCreditorCode: Code of the supplier (only applicable for supplier-payments)
BankImpLineDebtorCode: Code of the customer (only applicable for customer-payments)
BankImpLineBankNumber: Bank-number of the supplier or customer
BankImpLinePaymentRef: Reference of the existing supplier-payment or customer-payment - note that this should exactly be the reference of the payment as this field is used to find the existing payment in the system
BankImpLineValueDate: Value-date of the Banking-Entry
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


unused


program code (program6/bbankimportline.p)

    
    
    /* ====================================================================================================== */
    /* Method      : ApiProcessBankImpLineNewBankEntry                                                        */
    /* Desc        : This method is just a wrapper around method ProcessBankImpLineNewBankEntry and will      */
    /*               create a BankEntry with one banking-line and allocate that banking-line to a single      */
    /*               document (supplier or curstomer). The input of this method is a temp-table that is       */
    /*               defined like class-table tBankImpLine and this temp-table should contain just one record */
    /* Notes:      : This method has to be in the same segment as method ProcessBankImpLineNewBankEntry (6)   */
    /*               This method will not save anything in this class - it will just save data in class       */
    /*               BBankEntry and its sub-classes                                                           */
    /* ====================================================================================================== */
    
    
    /* ============================== */
    /* Exception handling - Use block */
    /* ============================== */
    assign oiReturnStatus      = -98
           viLocalReturnStatus = 0.
    APIBEBLOCK: DO : 
        
        /* ========================= */
        /* Validate input parameters */
        /* ========================= */
        Find tApiBankImpLine no-lock no-error.
        if ambiguous tApiBankImpLine or 
           not available tApiBankImpLine 
        then do:
            assign vcMessage           = trim(#T-35'The Api-method for the creation of an allocated banking-entry expects exactly one record in its input table.':255(315287869)T-35#)
                   viLocalReturnStatus = -1.
            <M-43 run SetMessage
               (input  vcMessage (icMessage), 
                input  '':U (icArguments), 
                input  '':U (icFieldName), 
                input  '':U (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  '':U (icRowid), 
                input  'qadfin-403965':U (icFcMsgNumber), 
                input  '':U (icFcExplanation), 
                input  '':U (icFcIdentification), 
                input  '':U (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BBankImportLine>
            Leave APIBEBLOCK.
        end. /* if ambiguous tApiBankImpLine or */
        
        /* ================================================================================================ */
        /* Stop all external instances to make sure we start from scratch                                   */
        /* Clear the instance-table and than create a record in there (manualy and not via AddDetailLine    */
        /* as we just need this record temporarely when method ProcessBankImpLineNewBankEntry is executed)  */
        /* We will store the single input record in this manualy create record in the instance-table.       */
        /* Note that once everything is processed by sub-method ProcessBankImpLineNewBankEntry, we will     */
        /* empty the instance-table again as we do not want to save anything in this class                  */
        /* ================================================================================================ */
        <M-59 run StopAndCloseExternalInstances
           (input  false (ilIsCloseOnly), 
            output viFcReturnSuper (oiReturnStatus)) in BBankImportLine>
        if viFcReturnSuper <> 0 then assign viLocalReturnStatus = viFcReturnSuper.
        if viFcReturnSuper < 0 then Leave APIBEBLOCK.
        <M-15 run ClearData  (output viFcReturnSuper (oiReturnStatus)) in BBankImportLine>
        if viFcReturnSuper <> 0 then assign viLocalReturnStatus = viFcReturnSuper.
        if viFcReturnSuper < 0 then Leave APIBEBLOCK.
        Create tBankImpLine.
        Buffer-copy tApiBankImpLine to tBankImpLine.
        
        /* =============================================================== */
        /* Set the amount to negative in case the direction is OUT and the */
        /* other way around - The InOut states the sign of the amount      */
        /* =============================================================== */
        if (tBankImpLine.BankImpLineAmountTC > 0 and 
            (tBankImpLine.BankImpLineInOut = {&TRANSDIRECTION-OUT} or
             tBankImpLine.BankImpLineInOut = "-":U))                   OR
           (tBankImpLine.BankImpLineAmountTC < 0 and 
            (tBankImpLine.BankImpLineInOut = {&TRANSDIRECTION-IN} or
             tBankImpLine.BankImpLineInOut = "+":U                or
             tBankImpLine.BankImpLineInOut = "":U))
        then assign tBankImpLine.BankImpLineAmountTC = tBankImpLine.BankImpLineAmountTC * -1.
        
        /* ======================================================================================================== */
        /* Run method ProcessBankImpLineNewBankEntry that will do the real processing:                              */
        /* Create BBankEntry-instance, call methods in there to create the bank-header, bank-line and allocation    */
        /* of the line, call the validation and AddUpd in the BBankEntry-instance and close the BBankEntry-instance */
        /* ======================================================================================================== */
        <M-81 run ProcessBankImpLineNewBankEntry
           (input  false (ilIsBatchProcessing), 
            output viFcReturnSuper (oiReturnStatus)) in BBankImportLine>
        if viFcReturnSuper <> 0 then assign viLocalReturnStatus = viFcReturnSuper.
        if viFcReturnSuper < 0 then Leave APIBEBLOCK.
        
        /* ================================================================================================ */
        /* Clear the instance-table that was created manually previously in this method - the record        */ 
        /* can just be deleted without using a ClearData as it was created manualy as well                  */
        /* ================================================================================================ */
        Delete tBankImpLine.
        
        /* ================================================================================= */
        /* Save the data                                                                     */
        /* Note that this method will not save anything in this class as the instance tables */
        /* are all empty. So we do not need to Validate the data in this class.              */
        /* Calling DataSave will just save data in class BBankEntry and its sub-classes      */
        /* Note that BBankEntry:ValidateBCAndAdditionalUpdates() was already called from     */
        /* submethod ProcessBankImpLineNewBankEntry                                          */
        /* ================================================================================= */
        <M-64 run DataSave  (output viFcReturnSuper (oiReturnStatus)) in BBankImportLine>
        if viFcReturnSuper <> 0 then assign viLocalReturnStatus = viFcReturnSuper.
        if viFcReturnSuper < 0 then Leave APIBEBLOCK.
        
    END. /* APIBEBLOCK */
        
    /* ============================== */
    /* Exception handling             */
    /* ============================== */
    assign oiReturnStatus = viLocalReturnStatus.
    
    
    


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 = "BBankImportLine".
create ttContext.
assign ttContext.propertyName = "methodName"
       ttContext.propertyValue = "ApiProcessBankImpLineNewBankEntry".
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/bbankimportline.apiprocessbankimplinenewbankentry.i.xsd", ?).
vhParameter = vhInputDS:get-buffer-handle("tApiBankImpLine").
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.