project QadFinancials > class BJournalEntry > method GetPostingLineByGL

Description

This method retrieves PostingLine RowId of first row with required G/L account


Parameters


icPostingRowIdinputcharacter
iiPostingIDinputinteger
icGLCodeinputcharacter
ocPostingLineRowIdoutputcharacter
oiPostingLineIDoutputinteger
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BCInvoice.ReplaceCInvoicePosting
method BCInvoice.ReverseCInvoicePosting


program code (program6/bjournalentry.p)

/* =================================================================================================== */
/* Method      :  GetPostingLineByGL                                                                   */
/* Desc        :  This method retrieves RowId of posting line with certain G/L account                 */
/* --------------------------------------------------------------------------------------------------- */
/* Params:  (I)  PostingRowId         RowId of posting                                                 */
/*          (I)  PostingID            ID of posting                                                    */
/*          (I)  GLCode               Code of G/L account                                              */
/*          (O)  PostingLineRowId     Row id of posting line with G/L account                          */
/*          (O)  PostingLineId        ID of posting line with G/L accouint                             */
/* =================================================================================================== */

assign oiReturnStatus = -98.

/* =================================================================================================== */
/* Default output values                                                                               */
/* =================================================================================================== */
assign ocPostingLineRowId = ?
       oiPostingLineID    = ?.

/* =================================================================================================== */
/* Normalize input parameters                                                                          */
/* =================================================================================================== */
if icPostingRowId = "":U then assign icPostingRowId = ?.
if iiPostingID    = 0    then assign iiPostingID    = ?.
if icGLCode       = "":U then assign icGLCode       = ?.
   
/* =================================================================================================== */
/* Validate input parameters                                                                           */
/* =================================================================================================== */
if icPostingRowId = ? and
   iiPostingID    = ? or
   icGLCode       = ?
then do:
    assign vcContext = "icPostingRowId=&1|iiPostingID=&2|icGLCode=&3":U
           vcContext = substitute(vcContext, icPostingRowId, iiPostingID, icGLCode)
           vcContext = replace(vcContext, "|":U, chr(2)).
    <M-1 run SetMessage
       (input  #T-1'You have not entered all the mandatory values.':255(63250)t-1# (icMessage), 
        input  '':U (icArguments), 
        input  '':U (icFieldName), 
        input  '':U (icFieldValue), 
        input  'S':U (icType), 
        input  '':U (iiSeverity), 
        input  '':U (icRowid), 
        input  'QadFin-8173':U (icFcMsgNumber), 
        input  '':U (icFcExplanation), 
        input  '':U (icFcIdentification), 
        input  vcContext (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
    assign oiReturnStatus = -1.
    return.
end.

/* =================================================================================================== */
/* Find posting line                                                                                   */
/* =================================================================================================== */
for each tPosting where
         tPosting.Posting_ID = (if iiPostingID <> ? then iiPostingID else tPosting.Posting_ID) and
         tPosting.tc_Rowid   = (if icPostingRowId <> ? then icPostingRowId else tPosting.tc_Rowid),
    each tPostingLine where
         tPostingLine.tcGLCode = icGLCode:
    
    assign ocPostingLineRowId = tPostingLine.tc_Rowid
           oiPostingLineID    = tPostingLine.PostingLine_ID.
    leave.
end.

/* =================================================================================================== */
/* Return                                                                                              */
/* =================================================================================================== */
if oiReturnStatus = -98 then assign oiReturnStatus = 0.