First need to fetch data from relationship table which is HRP1001.
All relationship object ( SOBID field ) description is available in HRP1000.
REPORT zchange_1001_pos_0001.
DATA : gt_1001 TYPE STANDARD TABLE OF hrp1001,
gs_1001 TYPE hrp1001,
gs_0001 TYPE pa0001,
gs_p0001 TYPE p0001,
lv_plans TYPE plans,
ls_return TYPE bapireturn1,
lv_hrobjid TYPE hrp1001-objid.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS s_objid FOR lv_hrobjid.
PARAMETERS : p_job RADIOBUTTON GROUP r1,
p_org RADIOBUTTON GROUP r1.
SELECTION-SCREEN END OF BLOCK b1.
START-OF-SELECTION.
IF p_job IS NOT INITIAL.
SELECT * FROM hrp1001 INTO TABLE gt_1001 WHERE objid IN s_objid
AND otype = 'S' AND sclas = 'C'
AND endda = '99991231' AND subty = 'B007'.
IF sy-subrc = 0.
LOOP AT gt_1001 INTO gs_1001.
CLEAR : lv_plans, gs_0001, gs_p0001.
lv_plans = gs_1001-objid.
SELECT SINGLE * FROM pa0001 INTO gs_0001 WHERE plans = lv_plans AND endda = '99991231'.
IF sy-subrc = 0.
MOVE-CORRESPONDING gs_0001 TO gs_p0001.
gs_p0001-infty = '0001'.
IF gs_p0001-stell NE gs_1001-sobid.
gs_p0001-stell = gs_1001-sobid.
CALL FUNCTION 'HR_EMPLOYEE_ENQUEUE'
EXPORTING
number = gs_0001-pernr
IMPORTING
return = ls_return.
IF ls_return IS INITIAL.
CALL FUNCTION 'HR_INFOTYPE_OPERATION'
EXPORTING
infty = '0001'
number = gs_0001-pernr
validityend = gs_0001-endda
validitybegin = gs_0001-begda
record = gs_p0001
operation = 'MOD'
IMPORTING
return = ls_return.
IF ls_return-type = 'E'.
WRITE : / gs_0001-pernr, '---Not Executed', ls_return-message.
ELSE.
WRITE : / gs_0001-pernr, '---Executed'.
ENDIF.
CALL FUNCTION 'HR_EMPLOYEE_DEQUEUE'
EXPORTING
number = gs_0001-pernr
IMPORTING
return = ls_return.
ELSE.
WRITE : / gs_0001-pernr, '--Locked'.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
ENDIF.
ELSEIF p_org IS NOT INITIAL.
SELECT * FROM hrp1001 INTO TABLE gt_1001 WHERE objid IN s_objid
AND otype = 'S' AND sclas = 'O'
AND endda = '99991231' AND subty = 'A003'.
IF sy-subrc = 0.
LOOP AT gt_1001 INTO gs_1001.
CLEAR : lv_plans, gs_0001, gs_p0001.
lv_plans = gs_1001-objid.
SELECT SINGLE * FROM pa0001 INTO gs_0001 WHERE plans = lv_plans AND endda = '99991231'.
IF sy-subrc = 0.
MOVE-CORRESPONDING gs_0001 TO gs_p0001.
gs_p0001-infty = '0001'.
IF gs_p0001-orgeh NE gs_1001-sobid.
gs_p0001-orgeh = gs_1001-sobid.
CALL FUNCTION 'HR_EMPLOYEE_ENQUEUE'
EXPORTING
number = gs_0001-pernr
IMPORTING
return = ls_return.
IF ls_return IS INITIAL.
CALL FUNCTION 'HR_INFOTYPE_OPERATION'
EXPORTING
infty = '0001'
number = gs_0001-pernr
validityend = gs_0001-endda
validitybegin = gs_0001-begda
record = gs_p0001
operation = 'MOD'
IMPORTING
return = ls_return.
IF ls_return-type = 'E'.
WRITE : / gs_0001-pernr, '---Not Executed', ls_return-message.
ELSE.
WRITE : / gs_0001-pernr, '---Executed'.
ENDIF.
CALL FUNCTION 'HR_EMPLOYEE_DEQUEUE'
EXPORTING
number = gs_0001-pernr
IMPORTING
return = ls_return.
ELSE.
WRITE : / gs_0001-pernr, '--Locked'.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
No comments:
Post a Comment