Description
Updates the contents of the class dataset.
When requested, the input data will be validated first, and the class dataset will only be updated when the input data is correct.
When no validation is requested, the input data is written to the class dataset unconditionally, but this data cannot be written to the database (method DataSave will return an error). The data can only be saved as a draft instance.
Parameters
il_Validate | input | logical | validate input data |
BDDocument | input | dataset | class dataset |
oiReturnStatus | output | integer | error status |
program code (program/bddocument.p)
for each t_sDDocument:
if t_sDDocument.tc_Status = "D":U
then do:
run gipr_Delete_sDDocumentInvoiceXref (input t_sDDocument.tc_Rowid).
run gipr_Delete_sDDocumentPostingLine (input t_sDDocument.tc_Rowid).
end.
find first tFcRowidConvert where
tFcRowidConvert.tcFcOldRowid = t_sDDocument.tc_Rowid and
tFcRowidConvert.tlFcOk no-error.
if available tFcRowidConvert
then assign t_sDDocument.tc_Rowid = tFcRowidConvert.tcFcNewRowid.
end.
for each t_oDDocument where
not can-find (t_sDDocument where t_sDDocument.tc_Rowid = t_oDDocument.tc_Rowid):
create t_sDDocument.
raw-transfer t_oDDocument to t_sDDocument.
end.
for each t_sDDocumentInvoiceXref:
if t_sDDocumentInvoiceXref.tc_Status = "D":U
then do:
run gipr_Delete_sDDocInvoiceXrefStage (input t_sDDocumentInvoiceXref.tc_Rowid).
end.
find first tFcRowidConvert where
tFcRowidConvert.tcFcOldRowid = t_sDDocumentInvoiceXref.tc_ParentRowid and
tFcRowidConvert.tlFcOk no-error.
if available tFcRowidConvert
then assign t_sDDocumentInvoiceXref.tc_ParentRowid = tFcRowidConvert.tcFcNewRowid.
find first tFcRowidConvert where
tFcRowidConvert.tcFcOldRowid = t_sDDocumentInvoiceXref.tc_Rowid and
tFcRowidConvert.tlFcOk no-error.
if available tFcRowidConvert
then assign t_sDDocumentInvoiceXref.tc_Rowid = tFcRowidConvert.tcFcNewRowid.
end.
for each t_oDDocumentInvoiceXref where
not can-find (t_sDDocumentInvoiceXref where t_sDDocumentInvoiceXref.tc_Rowid = t_oDDocumentInvoiceXref.tc_Rowid) and
not can-find (t_sDDocument where t_sDDocument.tc_Rowid = t_oDDocumentInvoiceXref.tc_ParentRowid and t_sDDocument.tc_Status = "D":U):
create t_sDDocumentInvoiceXref.
raw-transfer t_oDDocumentInvoiceXref to t_sDDocumentInvoiceXref.
end.
for each t_sDDocInvoiceXrefStage:
find first tFcRowidConvert where
tFcRowidConvert.tcFcOldRowid = t_sDDocInvoiceXrefStage.tc_ParentRowid and
tFcRowidConvert.tlFcOk no-error.
if available tFcRowidConvert
then assign t_sDDocInvoiceXrefStage.tc_ParentRowid = tFcRowidConvert.tcFcNewRowid.
find first tFcRowidConvert where
tFcRowidConvert.tcFcOldRowid = t_sDDocInvoiceXrefStage.tc_Rowid and
tFcRowidConvert.tlFcOk no-error.
if available tFcRowidConvert
then assign t_sDDocInvoiceXrefStage.tc_Rowid = tFcRowidConvert.tcFcNewRowid.
end.
for each t_oDDocInvoiceXrefStage where
not can-find (t_sDDocInvoiceXrefStage where t_sDDocInvoiceXrefStage.tc_Rowid = t_oDDocInvoiceXrefStage.tc_Rowid) and
not can-find (t_sDDocumentInvoiceXref where t_sDDocumentInvoiceXref.tc_Rowid = t_oDDocInvoiceXrefStage.tc_ParentRowid and t_sDDocumentInvoiceXref.tc_Status = "D":U):
create t_sDDocInvoiceXrefStage.
raw-transfer t_oDDocInvoiceXrefStage to t_sDDocInvoiceXrefStage.
end.
for each t_sDDocumentPostingLine:
find first tFcRowidConvert where
tFcRowidConvert.tcFcOldRowid = t_sDDocumentPostingLine.tc_ParentRowid and
tFcRowidConvert.tlFcOk no-error.
if available tFcRowidConvert
then assign t_sDDocumentPostingLine.tc_ParentRowid = tFcRowidConvert.tcFcNewRowid.
find first tFcRowidConvert where
tFcRowidConvert.tcFcOldRowid = t_sDDocumentPostingLine.tc_Rowid and
tFcRowidConvert.tlFcOk no-error.
if available tFcRowidConvert
then assign t_sDDocumentPostingLine.tc_Rowid = tFcRowidConvert.tcFcNewRowid.
end.
for each t_oDDocumentPostingLine where
not can-find (t_sDDocumentPostingLine where t_sDDocumentPostingLine.tc_Rowid = t_oDDocumentPostingLine.tc_Rowid) and
not can-find (t_sDDocument where t_sDDocument.tc_Rowid = t_oDDocumentPostingLine.tc_ParentRowid and t_sDDocument.tc_Status = "D":U):
create t_sDDocumentPostingLine.
raw-transfer t_oDDocumentPostingLine to t_sDDocumentPostingLine.
end.
if il_Validate
then do:
{ includes/bfcrun.i
&procedure = "CheckValidationExceptionList"
¶meters = "input true, output vl_validate" }
end.
if vl_Validate
then do:
{ includes/bfcrun.i
&procedure = "gipr_CompleteSTables" }
{ includes/bfcrun.i
&procedure = "ValidateComponent"
¶meters = "output oiReturnStatus" }
end.
if oiReturnStatus >= 0
then do:
{ includes/bfcrun.i
&procedure = "gipr_SetTables"
¶meters = "output viFcReturnSuper" }
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
end.
if il_Validate
and oiReturnStatus >= 0
then do:
{ includes/bfcrun.i
&procedure = "AdditionalUpdates"
¶meters = "output viFcReturnSuper" }
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
end.
if oiReturnStatus >= 0
then assign vlFcDataValidated = il_Validate.