project QadFinancials > class BBankPayFormat > method ApiMaintainStdTT

Description

This method can create new instances based on the content of the input temp-table.


Parameters


oiReturnStatusoutputintegerReturn status of the method.
tApiBankPayFormatinputtemp-table


Internal usage


unused


program code (program3/bbankpayformat.p)

IF oiReturnStatus = 0
THEN oiReturnStatus = -98.
<M-1 run ClearData (output viFcReturnSuper (oiReturnStatus)) in BBankPayFormat>
IF viFcReturnSuper <> 0
THEN oiReturnStatus = viFcReturnSuper.
IF viFcReturnSuper < 0
THEN RETURN.

<Q-6 run BankNumberPrim  (Start) in BBankNumber >
<Q-7 run GLPrim  (Start) in BGL >
<Q-15 run PayFormatTypeByType  (Start) in BPaymentFormat >

FOR EACH tApiBankPayFormat ON ERROR UNDO, RETURN:
    /* Resolve ParentObject_ID as GL's ID */
    <Q-11 run GLPrim (all) (Read) (NoCache)
       (input viCompanyId, (CompanyId)
        input tApiBankPayFormat.tcGLCode, (GLCode)
        input ?, (GLId)
        output dataset tqGLPrim) in BGL >
    for first tqGLPrim where
         tqGLPrim.tcGLCode = tApiBankPayFormat.tcGLCode:
        tApiBankPayFormat.tiParentObject_ID = tqGLPrim.tiGL_ID.
    end.

    /* Resolve BankNumber_ID from bank's business key values */
    if(tApiBankPayFormat.tcBankNumberExtension = '') then
        tApiBankPayFormat.tcBankNumberExtension = ?.
    <Q-10 run BankNumberPrim (all) (Read) (NoCache)
       (input ?, (BankNumberId)
        input tApiBankPayFormat.tiParentObject_ID, (ParentObjectId)
        input tApiBankPayFormat.tcBankNumber, (BankNumber)
        input tApiBankPayFormat.tcBankNumberExtension, (BankNumberExtension)
        input 0, (BankPayFormatID)
        output dataset tqBankNumberPrim) in BBankNumber >
    for first tqBankNumberPrim where
        tqBankNumberPrim.tiParentObject_ID = tApiBankPayFormat.tiParentObject_ID and
        tqBankNumberPrim.tcBankNumber = tApiBankPayFormat.tcBankNumber and
        (tApiBankPayFormat.tcBankNumberExtension = ? or
         tqBankNumberPrim.tcBankNumberExtension = tApiBankPayFormat.tcBankNumberExtension):
        tApiBankPayFormat.tiBankNumber_ID = tqBankNumberPrim.tiBankNumber_ID.
    end.

    if(tApiBankPayFormat.tiParentObject_ID = 0 or
       tApiBankPayFormat.tiParentObject_ID = ?) then do:
        assign
            vcMessage1 = trim(substitute(#T-12'The GL account &1 cannot be found.':200(1317)t-12#,tApiBankPayFormat.tcGLCode))
            oiReturnStatus = -1.
         <M-19 run SetMessage
            (input  vcMessage1 (icMessage), 
             input  '' (icArguments), 
             input  '' (icFieldName), 
             input  '' (icFieldValue), 
             input  'E':U (icType), 
             input  3 (iiSeverity), 
             input  '' (icRowid), 
             input  'QadFin-7131':U (icFcMsgNumber), 
             input  '' (icFcExplanation), 
             input  '' (icFcIdentification), 
             input  '' (icFcContext), 
             output viFcReturnSuper (oiReturnStatus)) in BBankPayFormat>
    end. /* if(tApiBankPayFormat.tiParentObject_ID = 0 */

    if(tApiBankPayFormat.tiBankNumber_ID = 0 or
       tApiBankPayFormat.tiBankNumber_ID = ?) then do:
        assign
            vcMessage1 = trim(substitute(#T-13'Bank account number &1 not found for this entity.':255(17148)T-13#,
                tApiBankPayFormat.tcBankNumber + '/':U + 
                if(tApiBankPayFormat.tcBankNumberExtension = ?) then '' else tApiBankPayFormat.tcBankNumberExtension))
            oiReturnStatus = -1.
         <M-20 run SetMessage
            (input  vcMessage1 (icMessage), 
             input  '' (icArguments), 
             input  '' (icFieldName), 
             input  '' (icFieldValue), 
             input  'E':U (icType), 
             input  3 (iiSeverity), 
             input  '' (icRowid), 
             input  'QadFin-7132':U (icFcMsgNumber), 
             input  '' (icFcExplanation), 
             input  '' (icFcIdentification), 
             input  '' (icFcContext), 
             output viFcReturnSuper (oiReturnStatus)) in BBankPayFormat>
    end. /* if(tApiBankPayFormat.tiBankNumber_ID = 0 */

    /* Verify that payment format type exists */
    <Q-16 run PayFormatTypeByType (all) (Read) (NoCache)
        (input tApiBankPayFormat.tcPayFormatTypeCode, (PayFormatTypeCode)
         output dataset tqPayFormatTypeByType) in BPaymentFormat >
    find tqPayFormatTypeByType where tqPayFormatTypeByType.tcPayFormatTypeCode = tApiBankPayFormat.tcPayFormatTypeCode no-error.
    if(not available(tqPayFormatTypeByType)) then do:
        assign
            vcMessage1 =  #T-17'The specified payment format $1 is not found in the system.':100(2979)t-17#
            oiReturnStatus = -1.
         <M-21 run SetMessage
            (input  vcMessage1 (icMessage), 
             input  tApiBankPayFormat.tcPayFormatTypeCode (icArguments), 
             input  '' (icFieldName), 
             input  '' (icFieldValue), 
             input  'E':U (icType), 
             input  3 (iiSeverity), 
             input  '' (icRowid), 
             input  'QadFin-7133':U (icFcMsgNumber), 
             input  '' (icFcExplanation), 
             input  '' (icFcIdentification), 
             input  '' (icFcContext), 
             output viFcReturnSuper (oiReturnStatus)) in BBankPayFormat>
    end.

    if(oiReturnStatus <> -1) then do:
        <M-2 run AddDetailLine (input  'BankPayFormat':U (icTable), 
                            input  ? (icParentRowid), 
                            output viFcReturnSuper (oiReturnStatus)) in BBankPayFormat>
        IF viFcReturnSuper <> 0
        THEN oiReturnStatus = viFcReturnSuper.
        IF viFcReturnSuper < 0
        THEN RETURN.
        ASSIGN
            tBankPayFormat.BankNumber_ID = tApiBankPayFormat.tiBankNumber_ID
            tBankPayFormat.tcBankNumber = tApiBankPayFormat.tcBankNumber
            tBankPayFormat.tcBankNumberExtension = tApiBankPayFormat.tcBankNumberExtension
            tBankPayFormat.tcParentCode = tApiBankPayFormat.tcGLCode
            tBankPayFormat.tcParentType = {&BANKNUMBERPARENTTYPE-GL}
            tBankPayFormat.tiParentObject_ID = tApiBankPayFormat.tiParentObject_ID
            tBankPayFormat.tcCompanyCode = vcCompanyCode
            tBankPayFormat.BankPayFormatIsActive = true
            tBankPayFormat.PayFormatTypeCode = tApiBankPayFormat.tcPayFormatTypeCode.
    END. /* if(oiReturnStatus <> -1) */
end. /* FOR EACH tApiBankPayFormat */

<Q-8 run GLPrim  (Stop) in BGL >
<Q-9 run BankNumberPrim  (Stop) in BBankNumber >
<Q-18 run PayFormatTypeByType  (Stop) in BPaymentFormat >

if(oiReturnStatus = -1) then return.

<M-3 run ValidateBC (output viFcReturnSuper (oiReturnStatus)) in BBankPayFormat>
IF viFcReturnSuper <> 0
THEN oiReturnStatus = viFcReturnSuper.
IF viFcReturnSuper < 0
THEN RETURN.
<M-4 run AdditionalUpdates (output viFcReturnSuper (oiReturnStatus)) in BBankPayFormat>
IF viFcReturnSuper <> 0
THEN oiReturnStatus = viFcReturnSuper.
IF viFcReturnSuper < 0
THEN RETURN.
<M-5 run DataSave (output viFcReturnSuper (oiReturnStatus)) in BBankPayFormat>
IF viFcReturnSuper <> 0
THEN oiReturnStatus = viFcReturnSuper.
IF viFcReturnSuper < 0
THEN RETURN.
IF oiReturnStatus = -98
THEN oiReturnStatus = 0.


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 = "BBankPayFormat".
create ttContext.
assign ttContext.propertyName = "methodName"
       ttContext.propertyValue = "ApiMaintainStdTT".
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/bbankpayformat.apimaintainstdtt.i.xsd", ?).
vhParameter = vhInputDS:get-buffer-handle("tApiBankPayFormat").
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.