Hi gurus,
I have just posted a SAP OSS note for wrong coding in method SPECIFIC_INITIAL_COMPUTATIONS of class CL_HRPA_INFOTYPE_0064.
It seems there is an error in the logic syntax in found at line 139 (index = sy-index - 1.) where an index value is being evaluated from sy-index value in a loop statement evaluating a
standard table in order to build names of variables (ORGxx and COTxx to be exact).
Inconsistent code within context:
LOOP AT tab_default_model INTO wa_default_model FROM 2. * Build names of variables ORGxx and COTxx. index = sy-index - 1. * Add leading zero. UNPACK index TO index. CONCATENATE c_generic_org index INTO organization. CONCATENATE c_generic_cot index INTO contribution. ASSIGN COMPONENT organization OF STRUCTURE <p0064> TO <organ>. ASSIGN COMPONENT contribution OF STRUCTURE <p0064> TO <contrib>. <organ> = wa_default_model-value1. <contrib> = wa_default_model-value2. ENDLOOP.
Now I think sy-index value has no relation to a table line in a loop statement. The LOOP AT statement sets system field sy-tabix to the table index of the current table line therefore leaving sy-index to its original value.
Is my original analysis wrong?
In my current case, value ended up equal to 0 causing a runtime error after trying to give a value to <organ> where there is no evaluation of success after instruction ASSIGN COMPONENT.
While reviewing standard code I also have found inconsistencies in reading infotype 0008 (with abap_false specified as subtype!!!) in the same method.
CALL METHOD a_read_infotype->read_single EXPORTING tclas = tclas pernr = <p0064>-pernr infty = '0008' subty = space objps = space sprps = if_hrpa_read_infotype=>unlocked begda = default_begda endda = high_date mode = if_hrpa_read_infotype=>first_intersecting_record no_auth_check = true IMPORTING pnnnn = p0008 data_exists = data_exists.
I fill coding is a bit poor so I am wondering how many clients are using this class out there in a productive environment? I also wonder if I have to expect the same code quality in other standard object (international and country specific) belonging to the decoupled infotype framework.
I have made a client copy of CL_HRPA_INFOTYPE_0064 class with the correct abap coding to solve my issue while SAP replies.
Cheers.