project QadFinancials > class BCountry > method ApiStdMaintainTTDetail


Parameters


icActioninputcharacterThis input parameter defines what should happen with the input data: - SAVE: Save the data if there were no errors. - SAVESTORE: Save the data if there were no errors. If there were, save as draft. - STORE: Save the data as draft. - VALIDATE: Validate the input data, but do not save the data.
bcLstReturninput-outputcharacterChar4 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
bcLstPrimKeyinput-outputcharacterChar4 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
bcLstRowidinput-outputcharacterChar4 separated list with the temporarely rowids (negative for new ones) of the newly created main-table records. . E.g. -1<Char2>aox00098001<Char2>-26
blSaveAsDraftinput-outputlogicalSave As Draft or not
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BCountry.ApiStdMaintainTT


program code (program7/bcountry.p)

/*==========================================================*/
/* create/modify CountryVatFormat records                   */
/*==========================================================*/
for each tApiCountryVatFormat where
         tApiCountryVatFormat.tc_ParentRowid = tApiCountry.tc_Rowid
         by tApiCountryVatFormat.tc_Rowid :
    
    /* ==================================== */
    /* Find the appropriate exsiting record */
    /* ==================================== */
    find tCountryVatFormat where         
         tCountryVatFormat.tc_ParentRowid   = tCountry.tc_Rowid and
         tCountryVatFormat.CountryVatFormat = tApiCountryVatFormat.CountryVatFormat         
         no-error.
    if not avail tCountryVatFormat
    then find tCountryVatFormat where         
              tCountryVatFormat.tc_ParentRowid      = tCountry.tc_Rowid and
              tCountryVatFormat.CountryVatFormat_ID = tApiCountryVatFormat.CountryVatFormat_ID         
              no-error.
    
    /* ================================= */
    /* Check for Create / Update         */
    /* ================================= */
    if available tCountryVatFormat
    then do:
        assign tCountryVatFormat.tc_Status = '':U.
        buffer-compare tApiCountryVatFormat except 
            CountryVatFormat_ID
            Country_ID         
            tc_Rowid      
            tc_ParentRowid
            tc_Status     
            to tCountryVatFormat save vlBufferCompareResult.
        if vlBufferCompareResult = true
        then next.
        assign tCountryVatFormat.tc_Status = 'C':U.
    end. /* if available tCountryVatFormat */
    else do:
        <M-3 run AddDetailLine (input  'CountryVatFormat':U (icTable), 
                        input  tCountry.tc_rowid (icParentRowid), 
                        output viFcReturnSuper (oiReturnStatus)) in BCountry>
        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 tCountryVatFormat */
    buffer-copy tApiCountryVatFormat except 
        CountryVatFormat_ID
        Country_ID         
        tc_Rowid      
        tc_ParentRowid
        tc_Status     
        to tCountryVatFormat.

end. /* for each tApiCountryVatFormat where */

/* =============================================== */
/* Remove the longer used Vatformat of the Country */
/* =============================================== */
for each tCountryVatFormat where
         tCountryVatFormat.tc_ParentRowid = tCountry.tc_Rowid :
    /* Check if the record still exists */
    find first tApiCountryVatFormat where                                                   
               tApiCountryVatFormat.tc_ParentRowid      = tApiCountry.tc_Rowid  AND
               tApiCountryVatFormat.CountryVatFormat_ID = tCountryVatFormat.CountryVatFormat_ID         
               no-error.
    if not available  tApiCountryVatFormat
    then find first tApiCountryVatFormat where            
                    tApiCountryVatFormat.tc_ParentRowid      = tApiCountry.tc_Rowid  AND
                    tApiCountryVatFormat.CountryVatFormat    = tCountryVatFormat.CountryVatFormat
                    no-error.
    if not available tApiCountryVatFormat
    then if tCountryVatFormat.tc_Status = "N":U 
         then delete tCountryVatFormat.
         else assign tCountryVatFormat.tc_Status = "D":U.
end. /* for each tApiCountryVatFormat where ... */