project QadFinancials > class BJournalEntry > method UpdateManualPostingProject

Description

Update the project code on a posting line that was created by manual input.


Parameters


icPostingLineRowidinputcharactertPostingLine.tc_Rowid
bcProjectCodeinput-outputcharacterproject
icGLCodeinputcharacter
icComponentListinputcharacterChr(2) separated list of extra components to check during SAF defaulting.
icComponentValueListinputcharacterChr(2) separated list of extra component values to check during SAF defaulting.
tUpdatePostingSafinput-outputtemp-tablesaf
tPostingLineSafStructuresoutputtemp-tableSAF Structures
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


unused


program code (program1/bjournalentry.p)

empty temp-table tPostingLineSafStructures.

if bcProjectCode = "":U or
   bcProjectCode = ?
then return.

/* Find posting line and posting header */
find tPostingLine where
     tPostingLine.tc_Rowid = icPostingLineRowid
     no-error.

if available tPostingLine
then find tPosting where
          tPosting.tc_Rowid = tPostingLine.tc_ParentRowid
          no-error.

if not available tPostingLine or
   not available tPosting
then do:
    assign oiReturnStatus = -1
           vcMsgJE        = trim(subst(#T-10'Internal error: cannot default the project information because the posting line cannot be found in the business instance based on its row ID &1.':255(17897)t-10#,icPostingLineRowid)).

    <M-9 run SetMessage
       (input  vcMsgJE (icMessage), 
        input  '':U (icArguments), 
        input  '':U (icFieldName), 
        input  '':U (icFieldValue), 
        input  'E':U (icType), 
        input  3 (iiSeverity), 
        input  '':U (icRowid), 
        input  'QadFin-5949':U (icFcMsgNumber), 
        input  '':U (icFcExplanation), 
        input  '':U (icFcIdentification), 
        input  '':U (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>

    return.
end.

/* Get project definition */

<Q-11 run ProjectBeginsCode (all) (Read) (NoCache)
   (input tPosting.Company_ID, (CompanyId)
    input bcProjectCode, (ProjectCode)
    output dataset tqProjectBeginsCode) in BProject >

find first tqProjectBeginsCode
     where tqProjectBeginsCode.tcProjectCode = bcProjectCode no-error.
if not available tqProjectBeginsCode
   then do:
       find tqProjectBeginsCode
            where tqProjectBeginsCode.tcProjectCode BEGINS bcProjectCode no-error.
        /* if there's only one record */
       if available tqProjectBeginsCode
       then assign bcProjectCode = tqProjectBeginsCode.tcProjectCode.
       /* Ambiguous records will not be found and available will be false */
       else do:
            oiReturnStatus = -4.
            return.                  
       end. 
end.


<M-8 run GetSafStructureForProject
   (input  tPosting.Company_ID (iiCompanyId), 
    input  ? (iiGLId), 
    input  icGLCode (icGLCode), 
    input  ? (iiProjectId), 
    input  bcProjectCode (icProjectCode), 
    output viDefaultSafStuctureId (oiSafStructureId), 
    output vcSafStructureCode (ocSafStructureCode), 
    output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>

if viDefaultSafStuctureId <> ? and
   viDefaultSafStuctureId <> 0 and
   vcSafStructureCode     <> ? and
   vcSafStructureCode     <> "":U
then do:
    create tPostingLineSafStructures.

    assign tPostingLineSafStructures.tcSafStructureCode = vcSafStructureCode
           tPostingLineSafStructures.tiSafStructureID   = viDefaultSafStuctureId
           tPostingLineSafStructures.tcParentType       = {&POSTINGSAFPARENTTYPE-PROJECT}.
end.

assign tPostingLine.tcProjectCode = bcProjectCode.

/* Delete Saf's before re-create */
for each tUpdatePostingSaf where
         tUpdatePostingSaf.tc_ParentRowid       = icPostingLineRowid              and
         tUpdatePostingSaf.PostingSafParentType = {&POSTINGSAFPARENTTYPE-PROJECT} and
         tUpdatePostingSaf.tc_status           <> "D":U:
    if tUpdatePostingSaf.tc_status = "N":U
    then delete tUpdatePostingSaf.
    else assign tUpdatePostingSaf.tc_status = "D":U.
end.

for each tPostingSaf where
         tPostingSaf.tc_ParentRowid       = icPostingLineRowid              and
         tPostingSaf.PostingSafParentType = {&POSTINGSAFPARENTTYPE-PROJECT} and
         tPostingSaf.tc_Status           <> "D":U:
    if tPostingSaf.tc_Status = "N":U
    then delete tPostingSaf.
    else assign tPostingSaf.tc_Status = "D":U.
end.

if viDefaultSafStuctureId > 0
then do:
    <M-2 run PostingLineSafs
       (input  viDefaultSafStuctureId (iiSafStructureID), 
        input  vcSafStructureCode (icSafStructureCode), 
        input  icPostingLineRowid (icPostingLineRowid), 
        input  {&POSTINGSAFPARENTTYPE-PROJECT} (icParentType), 
        input  icGLCode (icGLCode), 
        input  '':U (icCostCentreCode), 
        input  tPostingLine.tcProjectCode (icProjectCode), 
        input  icComponentList (icComponentList), 
        input  icComponentValueList (icComponentValueList), 
        output oiReturnStatus (oiReturnStatus)) in BJournalEntry>

    if oiReturnStatus <> 0
    then return.
end.