project QadFinancials > class BPaymentFormat > method ApiStdMaintainTT

Description

With this method a Payment Format can be added, modified or deleted.


Parameters


t_sApiPayFormatTypeinputtemp-table
icActioninputcharacter
t_sApiPayFormatCodeinputtemp-table
t_sApiPayFormatGroupinputtemp-table
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


unused


program code (program3/bpaymentformat.p)

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

if oiReturnStatus < 0
then return.
/* ==================== */
/* Set Default Return   */
/* ==================== */
assign oiReturnStatus         = -98.

if icAction = ? then assign icAction = "":U.
if icAction <> {&DAEMONACTION-SAVE}      and
  icAction <> {&DAEMONACTION-VALIDATE}
then do:
    assign vcMsgApi       = trim(subst(#T-1'A Payment Format Integration error occurred. The specified action (&1) must be in the list: &2.':255(60867)t-1#,trim(icAction),"{&DAEMONACTION-SAVE},{&DAEMONACTION-VALIDATE}":U))
           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-6162':U (icFcMsgNumber), 
        input  '':U (icFcExplanation), 
        input  '':U (icFcIdentification), 
        input  '':U (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BPaymentFormat>
   
    return.
end. /* if icAction */

/* ================================================================= */
/* Check the main table record                                       */
/* ================================================================= */
find first t_sApiPayFormatType no-error.

if not available t_sApiPayFormatType
then do:
    assign
        vcMsgApi = #T-4'A Payment Format Integration error occurred. The system cannot find the main table record (PaymentFormatType).':255(60868)t-4#
        oiReturnStatus = -1.
     <M-5 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-6164':U (icFcMsgNumber), 
         input  '':U (icFcExplanation), 
         input  '':U (icFcIdentification), 
         input  '':U (icFcContext), 
         output viFcReturnSuper (oiReturnStatus)) in BPaymentFormat>
    return.
end.

for each t_sApiPayFormatType:    
    <M-6 run AddDetailLine
       (input  'PayFormatType':U (icTable), 
        input  '':U (icParentRowid), 
        output viFcReturnSuper (oiReturnStatus)) in BPaymentFormat>
        
        if viFcReturnSuper < 0
        then do:
            assign vcMsgApi = #T-7'An internal error occurred with the payment format integration. The system cannot create a new instance (PayFormatType).':220(60870)t-7#.
            <M-8 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-6166':U (icFcMsgNumber), 
                input  '':U (icFcExplanation), 
                input  '':U (icFcIdentification), 
                input  '':U (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BPaymentFormat>
             next.
        end. 
        buffer-copy t_sApiPayFormatType
            except t_sApiPayFormatType.tc_ParentRowid
                   t_sApiPayFormatType.tc_Rowid
                   t_sApiPayFormatType.tc_Status
            to tPayFormatType.
        
    for each t_sApiPayFormatGroup 
        where t_sApiPayFormatGroup.tc_ParentRowid = t_sApiPayFormatType.tc_Rowid
        by t_sApiPayFormatGroup.tc_Rowid:
       <M-9 run AddDetailLine
           (input  'PayformatGroup':U (icTable), 
            input  tPayFormatType.tc_Rowid (icParentRowid), 
            output viFcReturnSuper (oiReturnStatus)) in BPaymentFormat>
            
            if viFcReturnSuper < 0
            then do:
            assign vcMsgApi = #T-11'An internal error occurred with the payment format integration. The system cannot create a new instance (payment format group).':220(60871)t-11#.
            <M-10 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-6167':U (icFcMsgNumber), 
                input  '':U (icFcExplanation), 
                input  '':U (icFcIdentification), 
                input  '':U (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BPaymentFormat>

                next.
            end.
            buffer-copy t_sApiPayformatGroup
                except t_sApiPayFormatGroup.PayFormatGroup_ID
                       t_sApiPayFormatGroup.tc_ParentRowid
                       t_sApiPayFormatGroup.tc_Rowid
                       t_sApiPayFormatGroup.tc_Status
                to tPayFormatGroup.
        for each t_sApiPayformatCode 
            where t_sApiPayFormatCode.tc_ParentRowid = t_sApiPayFormatGroup.tc_Rowid
            by t_sApiPayFormatCode.tc_Rowid:
           
            <M-12 run AddDetailLine
               (input  'PayFormatCode':U (icTable), 
                input  tPayFormatGroup.tc_Rowid (icParentRowid), 
                output viFcReturnSuper (oiReturnStatus)) in BPaymentFormat>

                if viFcReturnSuper < 0
            then do:
            assign vcMsgApi = #T-14'An internal error occurred with the payment format Integration. The system cannot create a new instance (PayFormatCode)':220(60892)t-14#.
            <M-13 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-6168':U (icFcMsgNumber), 
                input  '':U (icFcExplanation), 
                input  '':U (icFcIdentification), 
                input  '':U (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BPaymentFormat>

                next.
            end.
            buffer-copy t_sApiPayformatcode
                except t_sApiPayFormatCode.PayFormatCode_ID
                       t_sApiPayFormatCode.PayFormatGroup_ID
                       t_sApiPayFormatCode.tc_ParentRowid
                       t_sApiPayFormatCode.tc_Rowid
                       t_sApiPayFormatCode.tc_Status
                to tPayformatCode.

        end. /* for each t_sApiPayformatCode */
    end. /*for each t_sApiPayFormatGroup */
end. /*for each t_sApiPayFormatType:*/

<M-15 run ValidateBC
   (output viFcReturnSuper (oiReturnStatus)) in BPaymentFormat>
if viFcReturnSuper < 0
then do:
    assign
        oiReturnStatus = viFcReturnSuper.

    return.
end.

<M-16 run AdditionalUpdates
   (output viFcReturnSuper (oiReturnStatus)) in BPaymentFormat>
if viFcReturnSuper < 0
then do:
    assign
        oiReturnStatus = viFcReturnSuper.
    return.
end.

<M-17 run DataSave
   (output viFcReturnSuper (oiReturnStatus)) in BPaymentFormat>
if viFcReturnSuper < 0
then do:
    assign
        oiReturnStatus = viFcReturnSuper.
    return.
end.

if oiReturnStatus = -98
then assign oiReturnStatus = 0.
return.


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 = "BPaymentFormat".
create ttContext.
assign ttContext.propertyName = "methodName"
       ttContext.propertyValue = "ApiStdMaintainTT".
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/bpaymentformat.apistdmaintaintt.i.xsd", ?).
vhParameter = vhInputDS:get-buffer-handle("tParameterI").
vhParameter:buffer-create().
assign vhParameter::icAction = <parameter value>.

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

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

vhParameter = vhInputDS:get-buffer-handle("tApiPayFormatGroup").
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.