Hello Fellow Users,
We are using infotype 0057 to store some Union Codes. The requirement is to delimit the records by subtypes.
i.e, when a new record for a new subtype is created in IT0057, the previous record should be delimited.
Since this cannot be done by configuration for Infotype 0057, I have implemented the method IF_EX_HRPAD00INFTY~AFTER_INPUT of BADI HRPAD00INFTY.
So in the BADI, I am checking if there is any record which is active as of the new record start date, if yes, then delimit that record - i.e change ENDDA = NEW_BEGDA-1. Update existing record in IT0057 and create new record with new dates.
Here is the code that I have written. When I use this code in a report program, the previous infotype record is correctly picked up and delimited.
But in the BADI, the current record does not get updated.
In debugging I have noticed that the BADI is called twice, once with new PA0057 values that I am trying to create and then with the existing PA0057 values saved in the infotype.
So that means my changes are not being written to the database. Do I need to do this operation IN_UPDATE?
When I tried to create a session breakpoint IN_UPDATE, it doesnt get triggered.
What is the issue?
*-- Adding time constraints to subtypes --*
DATA: wa_0071 TYPE pa0071,
wa_0057 TYPE pa0057,
wa_p0057 TYPE p0057,
wa_p0071 TYPE p0071,
lv_begda TYPE pa0071-begda,
lv_endda TYPE pa0071-endda.
DATA : return TYPE bapireturn1,
key TYPE bapipakey.
CLEAR : lv_begda, lv_endda.
IF new_innnn-infty = '0057' AND ipsyst-ioper NE 'DEL'.
SELECT SINGLE * FROM pa0057 INTO wa_0057
WHERE pernr = new_innnn-pernr AND
begda LE new_innnn-begda AND
endda GE new_innnn-begda AND
subty NE new_innnn-subty.
IF sy-subrc = 0.
MESSAGE ID 'PG' TYPE 'W' NUMBER 204 WITH wa_0057-begda wa_0057-endda.
IF ipsyst-ioper EQ 'COP' OR ipsyst-ioper EQ 'INS'.
MOVE-CORRESPONDING wa_0057 TO wa_p0057.
wa_p0057-infty = '0057'.
lv_endda = new_innnn-begda - 1.
CALL FUNCTION 'HR_EMPLOYEE_ENQUEUE'
EXPORTING
number = wa_0057-pernr.
CALL FUNCTION 'HR_INFOTYPE_OPERATION'
EXPORTING
infty = '0057'
number = wa_0057-pernr
subtype = wa_0057-subty
validityend = wa_0057-endda
validitybegin = wa_0057-begda
recordnumber = wa_0057-seqnr
record = wa_p0057
operation = 'MOD'
nocommit = ' '
tclas = 'A'
dialog_mode = '0'
IMPORTING
return = return
key = key.
CALL FUNCTION 'HR_EMPLOYEE_DEQUEUE'
EXPORTING
number = wa_0057-pernr.
ENDIF.
ENDIF.
ENDIF.