project BLF > class Session > method GetCompanyListForUserAndDomain

Description

GetCompanyListForUserAndDomain: method that returns a comma-separated list with the available company-codes for a certain user and a certain domain.
Note that the user and the domnain are mandatory as input for this method.


Parameters


icUserLogininputcharacterUserLogin (mandatory)
iiDomainIDinputintegerDomainID (mandatory)
ocCompanyCodeListoutputcharacterocCompanyCodeList: Comma-seprated list with the available company-codes
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BAPMatching.AddAPMatchingLn
method BAPMatching.GetPendingVouchers
method BAPMatching.ValidateComponentPost


program code (program7/session.p)

/* ================================================================================================================= */
    /* GetCompanyListForUserAndDomain: method that returns a comma-separated list with the available company-codes for a */ 
    /* certain  user and a certain domain. Note that the user and the domnain are mandatory as input for this method.    */
    /* ================================================================================================================= */
    
    /* =========================== */
    /* Exception handling          */
    /* =========================== */
    assign oiReturnStatus = -98.
    
    /* =========================== */
    /* Input parameter validations */
    /* =========================== */
    if icUserLogin = ? or
       icUserLogin = "":U
    then do :
        assign oiReturnStatus = -1
               vcMessage      = trim(#T-6'The User-login is a mandatory parameter to get the list of accessible companies.':255(8859)T-6#) + chr(10) + 
                                trim(substitute(#T-7'Technical Error Information: location: &1.':255(8860)T-7#,"Session:GetCompanyListForUserAdnDomain":U)).
        <M-4 run SetMessage
           (input  vcMessage (icMessage), 
            input  '':U (icArguments), 
            input  '':U (icFieldName), 
            input  '':U (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  '':U (icRowid), 
            input  'BLF-401':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '' (icFcIdentification), 
            input  '' (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in Session>
        Return.
    end. /* if */
    if iiDomainID = ? or
       iiDomainID = 0
    then do :
        assign oiReturnStatus = -1
               vcMessage      = trim(#T-9'The Domain is a mandatory parameter to get the list of accessible companies.':255(8861)T-9#) + chr(10) + 
                                trim(substitute(#T-10'Technical Error Information: location: &1.':255(8860)T-10#,"Session:GetCompanyListForUserAdnDomain":U)).
        <M-8 run SetMessage
           (input  vcMessage (icMessage), 
            input  '':U (icArguments), 
            input  '':U (icFieldName), 
            input  '':U (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  '':U (icRowid), 
            input  'BLF-402':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '' (icFcIdentification), 
            input  '' (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in Session>
        Return.
    end. /* if */
    
    /* ============================================================== */
    /* Get all companies linked to the user & the domain : UsrCompany */
    /* ============================================================== */
    <Q-1 run UserCompanies (all) (Read) (NoCache)
       (input icUserLogin, (UserLogin)
        input ?, (CyId)
        input iiDomainID, (DomainId)
        output dataset tqUserCompanies) in BUser >
    
    /* ==================================================================================== */
    /* Get all domains linked to the user : UsrDomain                                       */       
    /* ==================================================================================== */
    find first tqUserCompanies 
               no-lock no-error.
    if available tqUserCompanies
    then do :
        for each tqUserCompanies 
                 no-lock : 
            assign ocCompanyCodeList = (if ocCompanyCodeList = "":U 
                                        then tqUserCompanies.tcCompanyCode
                                        else ocCompanyCodeList + ",":U + tqUserCompanies.tcCompanyCode).
        end. /* for each tqUserCompanies */
        assign oiReturnStatus = 0.
        Return.
    end. /* if available tqUserCompanies */    
    
    /* =========================== */
    /* Exception handling          */
    /* =========================== */
    if oiReturnStatus = -98
    then assign oiReturnStatus = 0.