I am having trouble using CL_HRPA_MASTERDATA_FACTORY for updating PA infotypes during IDOC processing.
The reason for trying to utilize this is primarily that I need to update Cost Allocation (CA), i.e. tables ASSHR and ASSOB. We have a scenario where another SAP system is master for certain infotypes, incl. the CA, and these infotypes are then transferred via ALE to the payroll system. But SAP doesn’t include CA for the infotypes, and note 310993 says that a customer will have to develop this functionality themselves.
HR_INFOTYPE_OPERATION and HR_CONTROL_INFTY_OPERATION are thus not suitable, due to not processing PREF, and at least the first one doesn’t mix well with IDOC’s.
My problem is that the framework already has been initialized when I want to do something. Function Module for IDOC processing is standard module IDOC_INPUT_HRMD, where I use EXIT_INBOUND_IDOC->PROCESS_IDOC to remove the ASSHR and ASSOB segments – otherwise SAP will choke on these. Later I then use EXIT_INBOUND_IDOC->POST_PROCESS_IDOC to try and update CA, and this is where it fails. This is due to calling IDOC_PROCESS_HRMD in between the two exits in the IDOC module, this then performs INITIALIZE_PS_ADAPTER in program SAPFP50P, and CL_HRPA_MASTERDATA_FACTORY=>SET_FRAMEWORK is executed, setting LEGACY_MODE = X. This last part is SAP standard.
Once executed SET_FRAMEWORK cannot be called again, A_IS_INITIALIZED has been set, and LEGACY_MODE also being set results in exception CX_HRPA_VIOLATED_PRECONDITION.
I have tried doing the recommended thing of executing PERFORM DO_NOTHING IN PROGRAM SAPFP50P, but this doesn’t work… I have tried doing it directly prior to CL_HRPA_MASTERDATA_FACTORY=>GET_BUSINESS_LOGIC, in the CLASS-CONSTRUCTOR of the class used for the EXIT_INBOUND_IDOC->PROCESS_IDOC and ->POST_PROCESS_IDOC, and I have tried making the latter method instantiate a new class where I PERFORM DO_NOTHING, but none of them seem to work.
I have also looked at http://scn.sap.com/people/aditya.palekar/blog/2010/01/19/uploading-a-pa-infotype-record-with-cost-assignment, this uses the same approach, but doesn’t seem to encounter the problem.
I have checked table T77S0, where CCURE switches MAINS and PC_UI are both not set (blank). As a matter of fact, all switches I have seen mentioned in this regard are not set (only CHGLP and GEMAN contain a value).
Checking table T582ITVCLAS for e.g. infotype 0014 I can see that the NITF_ADM switch is set to 0… This might raise an eyebrow, as this means not admissible, but the strange thing is that CL_HRPA_MASTERDATA_FACTORY doesn’t know which infotype I want to update, so this shouldn’t matter at this point? And I am actually working in two different SAP systems, one where I tested the update in a single program, and one where I have to implement the update in ALE - and the test went fine, infotype and CA were updated.
Is there any way to “destroy” the previous initialization of CL_HRPA_MASTERDATA_FACTORY=>LEGACY_MODE so that I may be allowed to use it? I have all of my code working in a single program, it’s only when inside the IDOC framework that it won’t work.
Kind regards
Kim