Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Modify Infty 0057 using HR_INFOTYPE_OPERATION

Hi,

I am trying to update (MOD) an 0057-infotype record using HR_INFOTYPE_OPERATION. But no matter what I do, I cannot make it work. It works with INS and COP but then I get a new entry and the old entry is not delimited. When using MOD I receive the following message in RETURN (return_struct)

TYPE E

ID PG

NUMBER 009

MESSAGE No data stored for 0057 in the selected period

LOG_NO

LOG_MSG_NO 000000

MESSAGE_V1 0057

The code I am using look like this:

Do you please have any advices to give according to this?

*&---------------------------------------------------------------------*
*& Report  ZHR_ESS_UPDATE_INFTY_0057
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  zhr_ess_update_infty_0057.

PARAMETERS: p_pernr TYPE p0057-pernr,
            p_lgarto TYPE p0057-lgart,  "old lgart
            p_lgartn TYPE p0057-lgart.  "new lgart

CONSTANTS: change TYPE pspar-actio VALUE 'MOD'.

DATA: lt_p0057 TYPE TABLE OF p0057.
DATA: ls_current_p0057 LIKE LINE OF lt_p0057,
      ls_new_p0057 LIKE LINE OF lt_p0057.

DATA: l_p0057 LIKE p0057.

DATA: l_subrc LIKE sy-subrc.

DATA  return_struct LIKE bapireturn1.
DATA w_return TYPE  bapireturn1.

DATA: bapipakey_tab LIKE bapipakey OCCURS 0 WITH HEADER LINE.


DATA: validitybegin TYPE sy-datum,
      validityend   TYPE sy-datum.


CALL FUNCTION 'HR_PSBUFFER_INITIALIZE'.

CALL FUNCTION 'HR_READ_INFOTYPE'
  EXPORTING
    tclas           = 'A'
    pernr           = p_pernr
    infty           = '0057'
  IMPORTING
    subrc           = l_subrc
  TABLES
    infty_tab       = lt_p0057
  EXCEPTIONS
    infty_not_found = 1
    OTHERS          = 2.


* Enqueue personnel number
CALL FUNCTION 'BAPI_EMPLOYEE_ENQUEUE'
  EXPORTING
    number = p_pernr
  IMPORTING
    return = w_return.


READ TABLE lt_p0057 INTO ls_current_p0057 INDEX 1..


ls_new_p0057-begda = sy-datum.
ls_new_p0057-endda = '99991231'.
ls_new_p0057-subty = p_lgartn.
ls_new_p0057-lgart = p_lgartn.
ls_new_p0057-mgart = p_lgartn.

CALL FUNCTION 'HR_INFOTYPE_OPERATION'
  EXPORTING
    infty         = '0057'
    subtype       = ls_current_p0057-subty
    objectid      = ''
    lockindicator = ''
    number        = ls_current_p0057-pernr     "employeenumber
    validityend   = ls_current_p0057-begda
    validitybegin = ls_current_p0057-endda
    record        = ls_new_p0057
    recordnumber  = ls_current_p0057-seqnr
    operation     = change                     "MOD
    tclas         = 'A'
    nocommit      = '1'
    dialog_mode   = '0'
*   view_identifier  = '23'
  IMPORTING
    return        = return_struct
    key           = bapipakey_tab
  EXCEPTIONS
    OTHERS        = 0.


IF return_struct IS INITIAL.
  COMMIT WORK.
ENDIF.

* Enqueue personnel number
CALL FUNCTION 'BAPI_EMPLOYEE_DEQUEUE'
  EXPORTING
    number = p_pernr
  IMPORTING
    return = w_return.

Former Member
Former Member replied

check your begin and end dates you are passing them opposite

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question