| icAction | input | character | This input parameter defines what should happen with the input data: - SAVE: Save the data if there were no errors. - SAVESTORE: Save the data if there were no errors. If there were, save as draft. - STORE: Save the data as draft. - VALIDATE: Validate the input data, but do not save the data. |
| bcLstReturn | input-output | character | Returns the list of returnvalues for all records that were processed. |
| bcLstPrimKey | input-output | character | Returns the list of IDs for all records that were processed. |
| bcLstRowid | input-output | character | Returns the list of Rowids for each records that was processed. |
| blSaveAsDraft | input-output | logical | Save as draft |
| oiReturnStatus | output | integer | Return status of the method. |
QadFinancials
/*==========================================================*/
/* create/modify CompanySharedSet records */
/*==========================================================*/
<Q-2 run DomainByDomainSharedSet (all) (Read) (NoCache)
(input tApiCompany.Domain_ID, (DomainID)
input ?, (SharedSetID)
input '':U, (SharedSetCode)
input '':U, (SharedSetType)
output dataset tqDomainByDomainSharedSet) in BDomain >
for each tqDomainByDomainSharedSet:
/* ==================================== */
/* Find the appropriate exsiting record */
/* ==================================== */
find tCompanySharedSet where
tCompanySharedSet.tc_ParentRowid = tCompany.tc_Rowid and
tCompanySharedSet.tcSharedSetCode = tqDomainByDomainSharedSet.tcSharedSetCode
no-error.
/* ================================= */
/* Check for Create / Update */
/* ================================= */
if available tqDomainByDomainSharedSet
then do:
assign tCompanySharedSet.tc_Status = "":U.
buffer-compare tqDomainByDomainSharedSet to tCompanySharedSet save vlBufferCompareResult.
if vlBufferCompareResult = true
then next.
assign tCompanySharedSet.tc_Status = "C":U.
end. /* if available tCompanySharedSet */
else do:
<M-1 run AddDetailLine (input 'CompanySharedSet':U (icTable),
input tCompany.tc_Rowid (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BCompany>
if viFcReturnSuper <> 0
then do:
assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0
then do:
assign blSaveAsDraft = (icAction <> {&DAEMONACTION-SAVE} and icAction <> {&DAEMONACTION-VALIDATE})
bcLstReturn = bcLstReturn + chr(4) + string(viFcReturnSuper)
bcLstPrimKey = bcLstPrimKey + chr(4) + "*":U
bcLstRowid = bcLstRowid + chr(4) + "*":U.
return.
end. /* if oiReturnStatus < 0 */
end. /* if viFcReturnSuper <> 0 */
end. /* NOT if available tCompanySharedSet */
buffer-copy tqDomainByDomainSharedSet to tCompanySharedSet.
end. /* for each tApiCompanySharedSet */
/* ====================================================== */
/* Remove the longer used CompanySharedSet of the Company */
/* ====================================================== */
for each tCompanySharedSet where
tCompanySharedSet.tc_ParentRowid = tCompany.tc_Rowid :
/* Check if the record still exists */
find first tqDomainByDomainSharedSet where
tqDomainByDomainSharedSet.tcSharedSetCode = tCompanySharedSet.tcSharedSetCode
no-error.
if not available tqDomainByDomainSharedSet
then if tCompanySharedSet.tc_Status = "N":U
then delete tCompanySharedSet.
else assign tCompanySharedSet.tc_Status = "D":U.
end. /* for each tApiCompanySharedSet where ... */
/* ================================================================================= */
/* create/modify CompanyProperty records */
/* Exceptional case because it is not sure whether the relation between Company and */
/* CompanyProperty is based on tc_rowid/tc_parentrowid or on Company_ID/CompanyCode */
/* ================================================================================= */
for each tApiCompanyPropertyRef where
tApiCompanyPropertyRef.tc_ParentRowid = tApiCompany.tc_Rowid
by tApiCompanyPropertyRef.tc_Rowid :
/* ==================================== */
/* Find the appropriate exsiting record */
/* ==================================== */
find first tCompanyPropertyRef where
tCompanyPropertyRef.tc_ParentRowid = tCompany.tc_Rowid and
tCompanyPropertyRef.CompanyPropertyCode = tApiCompanyPropertyRef.CompanyPropertyCode
no-error.
if not available tCompanyPropertyRef
then find first tCompanyPropertyRef where
tCompanyPropertyRef.tc_ParentRowid = tCompany.tc_Rowid and
tCompanyPropertyRef.Company_ID = tApiCompanyPropertyRef.Company_ID
no-error.
if not available tCompanyPropertyRef
then find tCompanyPropertyRef where
tCompanyPropertyRef.tc_ParentRowid = tCompany.tc_Rowid
no-error /* no first option because the find should only retrieve a single record by itself */.
if not available tCompanyPropertyRef
then find tCompanyPropertyRef where
tCompanyPropertyRef.Company_ID = tCompany.Company_ID
no-error /* no first option because the find should only retrieve a single record by itself */.
/* ======================================================== */
/* Check for Create / Update */
/* Note: Create is done ate the moment tCompany is created */
/* ======================================================== */
if available tCompanyPropertyRef
then do:
buffer-compare tApiCompanyPropertyRef except
CompanyProperty_ID
Company_ID
Currency_ID
tc_ParentRowid
tc_Status
to tCompanyPropertyRef save vlBufferCompareResult.
if vlBufferCompareResult = true
then next.
if tCompanyPropertyRef.tc_Status = "":U
then assign tCompanyPropertyRef.tc_Status = 'C':U.
buffer-copy tApiCompanyPropertyRef except
CompanyProperty_ID
Company_ID
Currency_ID
tc_ParentRowid
tc_Status
to tCompanyPropertyRef.
/* Get the currency from the domain */
<Q-3 run DomainPropertyByDomain (all) (Read) (NoCache)
(input tApiCompany.Domain_ID, (DomainID)
output dataset tqDomainPropertyByDomain) in BDomainProperty >
for first tqDomainPropertyByDomain:
assign tCompanyPropertyRef.Currency_ID = tqDomainPropertyByDomain.tiCurrency_ID
tCompanyPropertyRef.tcCurrencyCode = tqDomainPropertyByDomain.tcCurrencyCode.
end.
end. /* if available tCompanyPropertyRef */
end. /* for each tApiCompanyPropertyRef where */
/* ======================================================= */
/* Remove the longer used CompanyProperties of the Company */
/* ======================================================= */
/* NOTE: Removal is not supported as you cannot have a Company-record without a single */
/* underlaying CompanyProperty-record. We will not give any error here based on the input */