| opPrimeKey | output | longchar | Primary Key field value of loaded record(s). Keys are chr(4) separated. Key fields are chr(2) separated. |
| oiReturnStatus | output | integer | Return status of the method. |
if oiReturnStatus = 0
then oiReturnStatus = -98.
PROCESSBLOCK:
for each t_sCountry:
/* ================================================================= */
/* Lookup object by logical key */
/* When in create mode, skip lookup. */
/* ================================================================= */
if vcActivityCode <> "Create":U
then do:
vcFreeform = "for each Country where Country.CountryCode = '":U + t_sCountry.CountryCode + "'":U.
<M-2 run DataLoad (input '' (icRowids),
input '' (icPkeys),
input '' (icObjectIds),
input vcFreeform (icFreeform),
input yes (ilKeepPrevious),
output viFcReturnSuper (oiReturnStatus)) in BCountry>
if viFcReturnSuper >= 0
then find first tCountry where tCountry.CountryCode = t_sCountry.CountryCode no-error.
end.
/* ================================================================= */
/* When in delete mode, ignore input data. */
/* When object not found, do not return an error. */
/* ================================================================= */
if vcActivityCode = "Delete":U
then do:
if viFcReturnSuper = -4
then delete t_sCountry.
else do:
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
/* ================================================================= */
/* Update input to allow correct matching */
/* ================================================================= */
assign t_sCountry.tc_Rowid = tCountry.tc_Rowid
t_sCountry.tc_ParentRowid = ""
opPrimeKey = (if opPrimeKey = "" then "" else opPrimeKey + chr(4))
+ string(tCountry.Country_ID).
end.
next.
end.
if vcActivityCode = "Create":U
or viFcReturnSuper = -4
then do:
/* ================================================================= */
/* When object not found and in modify only mode, return an error. */
/* ================================================================= */
if vcActivityCode = "Modify":U
then do:
assign
vcMessage = trim(#T-1'Object with key $1 does not exist.':100(48021)T-1#).
<M-3 run SetMessage (input vcMessage (icMessage),
input t_sCountry.CountryCode (icArguments),
input 'tCountry.CountryCode':U (icFieldName),
input t_sCountry.CountryCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sCountry.tc_Rowid (icRowid),
input 'QadFin-5161':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCountry>
assign oiReturnStatus = -1.
return.
end.
/* ================================================================= */
/* When object not found or in create mode, create it. */
/* ================================================================= */
<M-4 run AddDetailLine (input 'Country':U (icTable),
input '' (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BCountry>
/* ================================================================= */
/* Update input to allow correct matching */
/* ================================================================= */
assign t_sCountry.tc_Status = "N":U.
end.
else do:
/* ================================================================= */
/* Update input to allow correct matching */
/* ================================================================= */
assign t_sCountry.tc_Status = "C":U.
end.
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
/* insert code for subtables here */
/* ================================================================= */
/* Delete existing detail */
/* ================================================================= */
for each tCountryVatFormat where
tCountryVatFormat.tc_ParentRowid = tCountry.tc_Rowid:
assign tCountryVatFormat.tc_Status = "D":U.
end.
/* ================================================================= */
/* Update / add detail */
/* ================================================================= */
for each t_sCountryVatFormat where
t_sCountryVatFormat.tc_ParentRowid = t_sCountry.tc_Rowid:
find first tCountryVatFormat where
tCountryVatFormat.tc_ParentRowid = tCountry.tc_Rowid and
tCountryVatFormat.CountryVatFormat = t_sCountryVatFormat.CountryVatFormat no-error.
if available tCountryVatFormat
then assign t_sCountryVatFormat.tc_Status = "C":U.
else do:
<M-5 run AddDetailLine (input 'CountryVatFormat':U (icTable),
input tCountry.tc_Rowid (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BCountry>
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
assign t_sCountryVatFormat.tc_Status = "N":U.
end.
/* ================================================================= */
/* override value for identity fields in input */
/* ================================================================= */
assign t_sCountryVatFormat.CountryVatFormat_ID = tCountryVatFormat.CountryVatFormat_ID
/* ================================================================= */
/* Update input to allow correct matching */
/* ================================================================= */
t_sCountryVatFormat.Country_ID = tCountryVatFormat.Country_ID
t_sCountryVatFormat.tc_Rowid = tCountryVatFormat.tc_Rowid
t_sCountryVatFormat.tc_ParentRowid = tCountry.tc_Rowid.
end. /* for each t_sCountryVatFormat */
<I-46 {UpdateTransString
&TABLE = "Country"}>
/* ================================================================= */
/* override value for identity fields in input */
/* ================================================================= */
assign t_sCountry.Country_ID = tCountry.Country_ID
/* ================================================================= */
/* Update input to allow correct matching */
/* ================================================================= */
t_sCountry.tc_Rowid = tCountry.tc_Rowid
t_sCountry.tc_ParentRowid = ""
opPrimeKey = (if opPrimeKey = "" then "" else opPrimeKey + chr(4))
+ string(tCountry.Country_ID).
end.
if oiReturnStatus = -98
then oiReturnStatus = 0.