project QadFinancials > class BDebtor > method ApiStdMaintainTTDetail

Description

ApiStdMaintainTTDetail


Parameters


icActioninputcharacter
bcLstPrimKeyinput-outputcharacter
bcLstReturninput-outputcharacter
bcLstRowidinput-outputcharacter
blSaveAsDraftinput-outputlogicalSaveAsDraft
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BDebtor.ApiStdMaintainTT


program code (program6/bdebtor.p)

/* ======================================================== */
/* create/modify DebtorSafDefault records                   */
/* ======================================================== */
for each tApiDebtorSafDefault where
         tApiDebtorSafDefault.tc_ParentRowid = tApiDebtor.tc_Rowid
         by tApiDebtorSafDefault.tc_Rowid :
    
    /* ==================================== */
    /* Find the appropriate existing record */
    /* ==================================== */
    find tDebtorSafDefault where         
         tDebtorSafDefault.tc_ParentRowid   = tDebtor.tc_Rowid and
         tDebtorSafDefault.tcSafConceptCode = tApiDebtorSafDefault.tcSafConceptCode
         no-error.
    if not avail tDebtorSafDefault
    then find tDebtorSafDefault where         
              tDebtorSafDefault.tc_ParentRowid      = tDebtor.tc_Rowid and
              tDebtorSafDefault.DebtorSafDefault_ID = tApiDebtorSafDefault.DebtorSafDefault_ID         
              no-error.
    
    /* ================================= */
    /* Check for Create / Update         */
    /* ================================= */
    if available tDebtorSafDefault
    then do:
        assign tDebtorSafDefault.tc_Status = '':U.
        buffer-compare tApiDebtorSafDefault except 
            DebtorSafDefault_ID
            Debtor_ID         
            tc_Rowid      
            tc_ParentRowid
            tc_Status     
            to tDebtorSafDefault save vlBufferCompareResult.
        if vlBufferCompareResult = true
        then next.
        assign tDebtorSafDefault.tc_Status = 'C':U.
    end. /* if available tDebtorSafDefault */
    else do :
        <M-1 run AddDetailLine (input  'DebtorSafDefault':U (icTable), 
                        input  tDebtor.tc_Rowid (icParentRowid), 
                        output viFcReturnSuper (oiReturnStatus)) in BDebtor>
        if viFcReturnSuper <> 0
        then do :
            assign oiReturnStatus = viFcReturnSuper.
            if oiReturnStatus < 0
            then do: 
                assign blSaveAsDraft  = (icAction <> {&DAEMONACTION-SAVE} and icAction <> {&DAEMONACTION-VALIDATE})
                       bcLstReturn    = bcLstReturn  + chr(4) + string(viFcReturnSuper)
                       bcLstPrimKey   = bcLstPrimKey + chr(4) + "*":U
                       bcLstRowid     = bcLstRowid   + chr(4) + "*":U.
                return.
            end. /* if oiReturnStatus < 0 */
        end. /* if viFcReturnSuper <> 0 */
    end. /* NOT if available tDebtorSafDefault */
    buffer-copy tApiDebtorSafDefault except 
        DebtorSafDefault_ID
        Debtor_ID         
        tc_Rowid      
        tc_ParentRowid
        tc_Status     
        to tDebtorSafDefault.

end. /* for each tApiDebtorSafDefault where */

/* =============================================== */
/* Remove the longer used Vatformat of the Debtor */
/* =============================================== */
for each tDebtorSafDefault where
         tDebtorSafDefault.tc_ParentRowid = tDebtor.tc_Rowid :
    /* Check if the record still exists */
    find first tApiDebtorSafDefault where                                                   
               tApiDebtorSafDefault.tc_ParentRowid      = tApiDebtor.tc_Rowid  AND
               tApiDebtorSafDefault.DebtorSafDefault_ID = tDebtorSafDefault.DebtorSafDefault_ID         
               no-error.
    if not available  tApiDebtorSafDefault
    then find first tApiDebtorSafDefault where            
                    tApiDebtorSafDefault.tc_ParentRowid   = tApiDebtor.tc_Rowid  AND
                    tApiDebtorSafDefault.tcSafConceptCode = tDebtorSafDefault.tcSafConceptCode
                    no-error.
    if not available tApiDebtorSafDefault
    then if tDebtorSafDefault.tc_Status = "N":U 
         then delete tDebtorSafDefault.
         else assign tDebtorSafDefault.tc_Status = "D":U.
end. /* for each tApiDebtorSafDefault where ... */