Description
Create a posting line and initialise the g/l account
Parameters
bcGLCode | input-output | character | GL code |
icProjectCode | input | character | |
icCostCentreCode | input | character | |
icPostingRowid | input | character | value of tPosting.tc_Rowid |
iiSequence | input | integer | posting line sequence number (0 = add at end of journal entry) |
itPostingDate | input | date | posting date |
icComponentList | input | character | Chr(2) separated list of extra components to check during SAF defaulting. |
icComponentValueList | input | character | Chr(2) separated list of extra component values to check during SAF defaulting. |
icLayerTypeCode | input | character | |
tUpdatePostingLine | output | temp-table | posting line |
tUpdatePostingSaf | output | temp-table | saf |
tUpdatePostingLineEnabling | output | temp-table | enabling |
tPostingLineSafStructures | output | temp-table | SAF Structures |
iiBusinessRelation_ID | input | integer | Business Relation ID |
icCurrencyCode | input | character | |
icDivisionCode | input | character | Sub-Account Code |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
unused
program code (program6/bjournalentry.p)
assign oiReturnStatus = -98
viLocalReturn = 0.
empty temp-table tUpdatePostingLine.
empty temp-table tUpdatePostingSaf.
/* Get Posting Header of line to be created */
find first tFcRowidConvert where
tFcRowidConvert.tcFcOldRowid = icPostingRowid and
tFcRowidConvert.tlFcOk no-error.
if available tFcRowidConvert
then assign icPostingRowid = tFcRowidConvert.tcFcNewRowid.
find tPosting where
tPosting.tc_Rowid = icPostingRowid
no-error.
if not available tPosting
then do:
assign vcMsgJE = #T-4'Internal error: cannot create manual posting.':255(59276)T-4#.
<M-5 run SetMessage
(input vcMsgJE (icMessage),
input '':U (icArguments),
input 'icPostingRowid':U (icFieldName),
input icPostingRowid (icFieldValue),
input 'S':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-5952':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
assign oiReturnStatus = -1.
return.
end.
POSTING_LINE_BLOCK:
do:
/* Create new posting line row*/
<M-1 run AddDetailLine
(input 'PostingLine':U (icTable),
input icPostingRowid (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper < 0 or
viFcReturnSuper > 0 and viLocalReturn = 0
then assign viLocalReturn = viFcReturnSuper.
if viFcReturnSuper < 0
then leave POSTING_LINE_BLOCK.
/* Assign posting line sequence, change sequence of highers */
if iiSequence <> 0
then do:
for each bline where
bline.PostingLineSequence >= iiSequence and
bline.PostingLineSequence < tPostingLine.PostingLineSequence:
assign bline.PostingLineSequence = bline.PostingLineSequence + 1.
if bline.tc_Status = ""
then assign bline.tc_Status = "C":U.
end.
assign tPostingLine.PostingLineSequence = iiSequence.
end.
/* Create output record for update of UI */
create tUpdatePostingLine.
raw-transfer tPostingLine to tUpdatePostingLine.
assign tUpdatePostingLine.tcGLCode = bcGLCode
tUpdatePostingLine.tcDivisionCode = icDivisionCode.
if bcGLCode <> "":U
then do:
<Q-7 run GLBeginsUnitOnGLChange (all) (Read) (NoCache)
(input tPostingLine.Company_ID, (CompanyID)
input bcGLCode, (GLCode)
output dataset tqGLBeginsUnitOnGLChange) in BGL >
/* Try exact match of G/L account */
find tqGLBeginsUnitOnGLChange where
tqGLBeginsUnitOnGLChange.tcGLCode = bcGLCode no-error.
/* Try if there is only one account beggining with enetered value */
if not available tqGLBeginsUnitOnGLChange
then find tqGLBeginsUnitOnGLChange where
tqGLBeginsUnitOnGLChange.tcGLCode BEGINS bcGLCode no-error.
/* If still there is not any account -> Error */
if not available tqGLBeginsUnitOnGLChange
then do:
assign viLocalReturn = -4.
leave POSTING_LINE_BLOCK.
end.
assign bcGLCode = tqGLBeginsUnitOnGLChange.tcGLCode
tUpdatePostingLine.tcUnitCode = tqGLBeginsUnitOnGLChange.tcUnitCode
tUpdatePostingLine.tcGLCode = bcGLCode.
<M-2 run PostingLineGLUpdate
(input itPostingDate (itPostingDate),
input icProjectCode (icProjectCode),
input icCostCentreCode (icCostCentreCode),
input icComponentList (icComponentList),
input icComponentValueList (icComponentValueList),
input icLayerTypeCode (icLayerTypeCode),
input iiBusinessRelation_ID (iiBusinessRelation_ID),
input icCurrencyCode (icCurrencyCode),
input icDivisionCode (icDivisionCode),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
if viFcReturnSuper < 0 or
viFcReturnSuper > 0 and viLocalReturn = 0
then assign viLocalReturn = viFcReturnSuper.
if viFcReturnSuper < 0
then leave POSTING_LINE_BLOCK.
end.
end. /* POSTING_LINE_ROW: */
/* If there was any error, delete created posting line */
if viLocalReturn < 0
then do:
for each tPostingSaf where
tPostingSaf.tc_ParentRowid = tPostingLine.tc_Rowid:
delete tPostingSaf.
end.
delete tPostingLine.
empty temp-table tUpdatePostingSaf.
delete tUpdatePostingLine.
end.
/* Return handling */
assign oiReturnStatus = viLocalReturn.