You can use FM HR_INFOTYPE_OPERATION for all types of infotype opertions.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
data : lv_begda type prelp-begda, lv_endda type prelp-endda, lv_pernr type prelp-pernr, lv_infty type prelp-infty, lt_p0021 type table of p0021, ls_p0021 type p0021, ls_bapiret type bapireturn1, ls_bapiret2 type bapireturn1, lv_operation type pspar-actio. . lv_pernr = 'PERNR'. lv_begda = sy-datum. lv_endda = sy-datum. lv_infty = '0021'. call function 'HR_READ_INFOTYPE' exporting * TCLAS = 'A' pernr = lv_pernr infty = lv_infty begda = lv_begda endda = lv_endda * BYPASS_BUFFER = ' ' * LEGACY_MODE = ' ' * IMPORTING * SUBRC = tables infty_tab = lt_p0021 exceptions infty_not_found = 1 others = 2 . if sy-subrc <> 0. * Implement suitable error handling here endif. loop at lt_p0021 into ls_p0021. write : ls_p0021-infty , ls_p0021-begda , ls_p0021-endda , / . clear ls_bapiret. call function 'BAPI_EMPLOYEE_ENQUEUE' exporting number = ls_p0021-pernr importing return = ls_bapiret. if ls_bapiret is not initial. endif. lv_operation = 'DEL'. call function 'HR_PSBUFFER_INITIALIZE'. call function 'HR_INFOTYPE_OPERATION' exporting infty = '0021' subtype = ls_p0021-subty number = ls_p0021-pernr recordnumber = ls_p0021-seqnr record = ls_p0021 validitybegin = ls_p0021-begda validityend = ls_p0021-endda operation = lv_operation nocommit = 'X' dialog_mode = '0' importing return = ls_bapiret2. if ls_bapiret2 is not initial. write 'Error Deleting Infotype 21'. else. commit work. write 'Delete operation...Success'. endif. call function 'BAPI_EMPLOYEE_DEQUEUE' exporting number = ls_p0021-pernr importing return = ls_bapiret. endloop. |