project QadFinancials > class BEmployee > method GetAutoNumber

Description

This method will retrieve an automatic number for the employee (if an active automatic number record was created for employee - domain combination)


Parameters


icRowidinputcharacterRowid of the Employee you want to automatically fill the EmployeeCode for.
ocEmployeeCodeoutputcharacterAutomatically Generated Employee Code.
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BEmployee.PreValidateComponent


program code (program6/bemployee.p)

/* ===================================================================================== */
/* This method will retrieve an automatic number for the employee                        */
/* (if an active automatic number record was created for employee - domain combination)  */
/* ===================================================================================== */
assign oiReturnStatus      = -98
       viLocalReturnStatus = 0.

find tEmployee where
     tEmployee.tc_Rowid  = icRowid and
     tEmployee.tc_Status = 'N':U
     no-error.
if not available tEmployee
then do:
    assign vcMessage      = trim(#T-1'The system cannot find an employee record with status N for this row ID.':100(63932)t-1#) + chr(10) +
                            trim(substitute(#T-2'Row IDs: &1.':200(20468)T-2#, trim(icRowid)))
           oiReturnStatus = -3.
    <M-3 run SetMessage
       (input  vcMessage (icMessage), 
        input  '':U (icArguments), 
        input  '':U (icFieldName), 
        input  '':U (icFieldValue), 
        input  'E':U (icType), 
        input  3 (iiSeverity), 
        input  icRowid (icRowid), 
        input  'QadFin-6626':U (icFcMsgNumber), 
        input  '':U (icFcExplanation), 
        input  '':U (icFcIdentification), 
        input  '':U (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BEmployee>
    return.
end. /* if not available tDebtor */

if tEmployee.Company_ID = viCompanyId
then assign viAutoNumberDomainID = viDomainID.
else do:
    <Q-5 run CompanyByDomain (all) (Read) (NoCache)
       (input tEmployee.Company_ID, (CompanyId)
        input 0, (DomainId)
        input ?, (Active)
        output dataset tqCompanyByDomain) in BCompany >
    find tqCompanyByDomain where
         tqCompanyByDomain.tiCompany_ID = tEmployee.Company_ID
         no-lock no-error.
    if available tqCompanyByDomain
    then assign viAutoNumberDomainID = tqCompanyByDomain.tiDomain_ID.
end.

assign vhFcComponent = ?.
<M-4 run GetAutoNumber
   (input  viAutoNumberDomainID (iiDomainID), 
    input  '':U (icDomainCode), 
    input  0 (iiSharedSetID), 
    input  '':U (icSharedSetCode), 
    input  {&AUTONUMBERTYPE-EMPLOYEE} (icAutoNumberType), 
    output ocEmployeeCode (ocAutoNumberNextNumber), 
    output viFcReturnSuper (oiReturnStatus)) in BAutoNumber>
if viFcReturnSuper <> 0
then do:
    assign viLocalReturnStatus = viFcReturnSuper.
    if viFcReturnSuper < 0
    then do:
        assign oiReturnStatus = viLocalReturnStatus.
        return.
    end. /* if viFcReturnSuper < 0 */
end. /* if viFcReturnSuper <> 0 */

assign oiReturnStatus = viLocalReturnStatus.