project QadFinancials > class BMfgSupplier > method UpdateSupplierLanguageSearchName

Description

Method to update supplier record in mfgpro when business relation language is changed in financials


Parameters


iiBusinessRelation_IDinputinteger
icLngCodeinputcharacter
icSearchNameinputcharacter
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BBusinessRelation.AdditionalUpdates


program code (program1/bmfgsupplier.p)

/* ============================================================================================ */
/* This method will update the language code of the supplier for a business relation language   */
/* change                                                                                       */
/* =============================================================================================*/
assign oiReturnStatus      = -98
       vcListVdMstr        = ''
       vcvd_lang           = <M-28 GetMfgLanguage  (input  icLngCode (icFinancialLanguage)) in BMfgSupplier>.

if icLngCode             = ? then assign icLngCode      = "":U.
if icSearchName          = ? then assign icSearchName   = '':U.
if iiBusinessRelation_ID = ? then assign iiBusinessRelation_ID = 0.

if iiBusinessRelation_ID = 0
then do:
    assign oiReturnStatus = 0.
    return.
end.

/* ======================================================================================= */
/* Retrieve all the vd_mstr records linked to the BusinessRelation                         */
/* BusinessRelation --> Creditor --> SharedSet --> Domains --> DomainSharedSet --> vd_mstr */
/* ======================================================================================= */
<Q-831 run GetvdmstrByBusinessRelation (all) (Read) (NoCache)
   (input iiBusinessRelation_ID, (BusinessRelation_ID)
    input ?, (CompanyId)
    output dataset tqGetvdmstrByBusinessRelation) in BMfgSupplierQuery>

/* Build up the list fo all records that need to be changed */
for each tqGetvdmstrByBusinessRelation where
         tqGetvdmstrByBusinessRelation.tiBusinessRelation_ID = iiBusinessRelation_ID and
         (tqGetvdmstrByBusinessRelation.tcLngCode <> icLngCode or
          tqGetvdmstrByBusinessRelation.tcvd_sort <> icSearchName)
         :
                
    assign vcListVdMstr = vcListVdMstr + 
                           (if vcListVdMstr = '':U
                            then '':U
                            else chr(4)) +
                            tqGetvdmstrByBusinessRelation.tcvd_domain +
                            chr(2) +
                            tqGetvdmstrByBusinessRelation.tcvd_addr.

end. /* for each tqGetvdmstrByBusinessRelation */

/* Do the DayaLoad */
if vcListVdMstr <> ? and vcListVdMstr <> "":U
then do:   
    /* ========================= */
    /* Load the tvd_mstr records */
    /* ========================= */
    <M-13 run DataLoad
       (input  '':U (icRowids), 
        input  vcListVdMstr (icPkeys), 
        input  '':U (icObjectIds), 
        input  '':U (icFreeform), 
        input  false (ilKeepPrevious), 
        output viFcReturnSuper (oiReturnStatus)) in BMfgSupplier>
        
    if viFcReturnSuper <> 0
    then do:
        assign oiReturnStatus = viFcReturnSuper.
        if viFcReturnSuper < 0 
        then return.
    end. /* if viFcReturnSuper <> 0 */   

end. /* if vcListVdMstr <> ? */         

/* Change the instance data */
for each tvd_mstr:

    assign tvd_mstr.tc_Status = "C":U
           tvd_mstr.vd_lang   = vcvd_lang
           tvd_mstr.vd_sort   = icSearchName.
        
end. /* for each tvd_mstr */
                

/* ========== */
/* ValidateBC */
/* ========== */
<M-14 run ValidateBC  (output viFcReturnSuper (oiReturnStatus)) in BMfgSupplier>

if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.

/* ================== */
/* Additional Updates */
/* ================== */
<M-15 run AdditionalUpdates  (output viFcReturnSuper (oiReturnStatus)) in BMfgSupplier>

if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.

/* ======== */
/* DataSave */
/* ======== */
<M-16 run DataSave  (output viFcReturnSuper (oiReturnStatus)) in BMfgSupplier>

if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.

if oiReturnStatus = -98 then
assign oiReturnStatus = 0.