As delivered, the system can automatically perform foreign key checks, which are especially simple either for personnel areas/subareas (derived from table T001P), personnel areas (derived from table T500P), and employee groups/subgroups (derived from table T503), or for the fields of your primary and secondary records, since these fields are hard-coded.
Example
The following three foreign key checks are delivered with the standard system.
t001p = cl_hr_t001p=>read( werks = p0001-werks btrtl = p0001-btrtl ).CALL METHOD a_foreign_key_check->add_foreign_keysEXPORTING foreign_key_structure = t001p.
t500p = cl_hr_t500p=>read( persa = p0001-werks ).CALL METHOD a_foreign_key_check->add_foreign_keysEXPORTING foreign_key_structure = t500p.
t503= cl_hr_t503=>read( persg = p0001-persg persk = p0001-persk ).CALL METHOD a_foreign_key_check->add_foreign_keysEXPORTING foreign_key_structure = t503.
However, if you need to perform checks in relation to other tables, then you must instruct the system accordingly; to this end, you re-define the
FOREIGN_KEY_ADDITIONAL_DATA
methods and implement these methods within the method
CHECK_FOREIGN_KEYS
.
Example
In the
Capital Formation
infotype (0010) in prior releases, a foreign key check is automatically performed for the
Currency Key
field (WAERS) in relation to the
Valid Country Currencies
table (T500W), using the following source code:
T500W-MANDT = SYST-MANDT,T500W-LAND1 = PSYST-LAND,T500W-WAERS = P0010-WAERS.
If you wish to perform exactly the same checks in this release, then the following source code is required in method
FOREIGN_KEY_ADDITIONAL_DATA
:
DATA p0010 TYPE p0010.DATA psyst TYPE psyst.DATA p0001 TYPE p0001.DATA t500p TYPE t500p.p0010 = pnnnn.p0001 = p0001( tclas = tclas pernr = p0010-pernr begda = p0010-begda ).t500p = cl_hr_t500p=>read( persa = p0001-werks ).psyst-land = t500p-land1.CALL METHOD a_foreign_key_check->add_foreign_keys EXPORTING foreign_key_structure = psyst.
This source code instructs the system to check the
Country Key
field (LAND1) in structure PSYST – rather than, as in prior releases, structure PSYST itself. No explicit instructions are required in this release to check the HR Master Record for the
Capital Formation
infotype (structure P0010) or the
Valid Country Currencies
table (T500W), since the system now does so automatically. Structure SYST also requires no explicit check, since the system can evaluate this structure without external input. In essence, you need only provide the structure(s) that are required for the check, not the contents of the corresponding table(s).