on 09-25-2008 8:24 AM
Hi,
Can this function module be used to insert a record to a customized infotype. If not, which is the best method to insert a record to a customized infotype.
Please find below the code .
This code is running for a long time and going for short dump.
DATA: l_bapireturn LIKE bapireturn1.
DATA: bapipakey_tab LIKE bapipakey OCCURS 0 WITH HEADER LINE.
DATA: l_p0169 LIKE p9007.
PARAMETERS: p_pernr LIKE p9007-pernr DEFAULT '00900014'.
START-OF-SELECTION.
CALL FUNCTION 'BAPI_EMPLOYEE_ENQUEUE'
EXPORTING
number = p_pernr
IMPORTING
return = l_bapireturn.
IF l_bapireturn-id NE space.
WRITE: / l_p0169-pernr, 'Enqueue failed'.
EXIT.
ENDIF.
*-- Suported operations:
*-- change (operation = 'MOD')
*-- Create (operation = 'INS')
*-- DELETE (operation = 'DEL')
*-- CREATESUCCESSOR (operation = 'COP')
.
l_p0169-mandt = sy-mandt.
l_p0169-pernr = p_pernr.
l_p0169-begda = '20021001'.
l_p0169-endda = '99991231'.
l_p0169-
l_p0169-
l_p0169-zz_sec_costcent = '0000100002'.
l_p0169-zz_strt_seccostc = '24.09.2008'.
l_p0169-zz_end_seccostc = '31.12.9999'.
CALL FUNCTION 'HR_INFOTYPE_OPERATION'
EXPORTING
infty = '9007'
subty = ''
number = p_pernr
recordnumber = '024'
record = l_p0169
validitybegin = '20021001'
validityend = '99991231'
operation = 'INS'
dialog_mode = '1' "Use default
nocommit = '1' "Use default
IMPORTING
return = l_bapireturn
key = bapipakey_tab.
IF l_bapireturn-id NE space.
WRITE: / p_pernr,
20 'Create was unsuccessful',
l_bapireturn-id,
l_bapireturn-message+0(40).
ELSE.
WRITE: / p_pernr,
20 'Create was successful',
l_bapireturn-id,
l_bapireturn-message+0(40).
ENDIF.
Use 'BAPI_EMPLOYEE_DEQUEUE' to un-lock the employee before updating
CALL FUNCTION 'BAPI_EMPLOYEE_DEQUEUE'
EXPORTING
number = l_p0169-pernr
IMPORTING
return = l_bapireturn.
Yes, HR_INFOTYPE_OPERATION function module can be used to create a record for a custom infotype.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi,
kindly go through below demo program..
it will resolve your problem.
DATA : return1 TYPE bapireturn1.
DATA : return2 TYPE bapireturn1.
DATA : it_0050 TYPE STANDARD TABLE OF p0050 WITH HEADER LINE,
wa_0050 TYPE p0050.
data var_50 TYPE begda .
wa_0050-pernr = wa_ztime-empno.
wa_0050-zausw = wa_ztime-ZCARDNO.
wa_0050-infty = '0050'.
wa_0050-begda = w_date.
wa_0050-endda = '99991231'.
wa_0050-aedtm = sy-datum.
wa_0050-uname = sy-uname.
var_operation = 'INS'.
PERFORM store_it50_data.
FORM STORE_IT50_DATA .
CALL FUNCTION 'BAPI_EMPLOYEET_ENQUEUE'
EXPORTING
number = wa_ztime-empno
validitybegin = sy-datum
IMPORTING
return = return1.
if return1 IS INITIAL.
CALL FUNCTION 'HR_INFOTYPE_OPERATION'
EXPORTING
infty = '0050'
number = wa_0050-pernr
subtype = wa_0050-subty
objectid = wa_0050-objps
lockindicator = wa_0050-sprps
validityend = '99991231'
validitybegin = wa_0050-begda
RECORDNUMBER =
record = wa_0050
operation = var_operation
VIEW_IDENTIFIER =
SECONDARY_RECORD =
IMPORTING
return = return2.
if return2 is INITIAL.
WRITE : / sy-tabix,
'Employee successfully uploaded ', wa_0050-pernr.
v_count = v_count + 1.
ENDIF.
CALL FUNCTION 'BAPI_EMPLOYEET_DEQUEUE'
EXPORTING
number = wa_ztime-empno
validitybegin = sy-datum
IMPORTING
return = return1.
endif.
CLEAR : return1,return2.
ENDFORM. " STORE_IT50_DATA
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
DATA : return1 TYPE bapireturn1.
DATA : return2 TYPE bapireturn1.
DATA : it_0050 TYPE STANDARD TABLE OF p0050 WITH HEADER LINE,
wa_0050 TYPE p0050.
data var_50 TYPE begda .
wa_0050-pernr = wa_ztime-empno.
wa_0050-zausw = wa_ztime-ZCARDNO.
wa_0050-infty = '0050'.
wa_0050-begda = w_date.
wa_0050-endda = '99991231'.
wa_0050-aedtm = sy-datum.
wa_0050-uname = sy-uname.
var_operation = 'INS'.
PERFORM store_it50_data.
FORM STORE_IT50_DATA .
CALL FUNCTION 'BAPI_EMPLOYEET_ENQUEUE'
EXPORTING
number = wa_ztime-empno
validitybegin = sy-datum
IMPORTING
return = return1.
if return1 IS INITIAL.
CALL FUNCTION 'HR_INFOTYPE_OPERATION'
EXPORTING
infty = '0050'
number = wa_0050-pernr
subtype = wa_0050-subty
objectid = wa_0050-objps
lockindicator = wa_0050-sprps
validityend = '99991231'
validitybegin = wa_0050-begda
RECORDNUMBER =
record = wa_0050
operation = var_operation
VIEW_IDENTIFIER =
SECONDARY_RECORD =
IMPORTING
return = return2.
if return2 is INITIAL.
WRITE : / sy-tabix,
'Employee successfully uploaded ', wa_0050-pernr.
v_count = v_count + 1.
ENDIF.
CALL FUNCTION 'BAPI_EMPLOYEET_DEQUEUE'
EXPORTING
number = wa_ztime-empno
validitybegin = sy-datum
IMPORTING
return = return1.
endif.
CLEAR : return1,return2.
ENDFORM. " STORE_IT50_DATA
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
DATA : return1 TYPE bapireturn1.
DATA : return2 TYPE bapireturn1.
DATA : it_0050 TYPE STANDARD TABLE OF p0050 WITH HEADER LINE,
wa_0050 TYPE p0050.
data var_50 TYPE begda .
wa_0050-pernr = wa_ztime-empno.
wa_0050-zausw = wa_ztime-ZCARDNO.
wa_0050-infty = '0050'.
wa_0050-begda = w_date.
wa_0050-endda = '99991231'.
wa_0050-aedtm = sy-datum.
wa_0050-uname = sy-uname.
var_operation = 'INS'.
PERFORM store_it50_data.
FORM STORE_IT50_DATA .
CALL FUNCTION 'BAPI_EMPLOYEET_ENQUEUE'
EXPORTING
number = wa_ztime-empno
validitybegin = sy-datum
IMPORTING
return = return1.
if return1 IS INITIAL.
CALL FUNCTION 'HR_INFOTYPE_OPERATION'
EXPORTING
infty = '0050'
number = wa_0050-pernr
subtype = wa_0050-subty
objectid = wa_0050-objps
lockindicator = wa_0050-sprps
validityend = '99991231'
validitybegin = wa_0050-begda
RECORDNUMBER =
record = wa_0050
operation = var_operation
VIEW_IDENTIFIER =
SECONDARY_RECORD =
IMPORTING
return = return2.
if return2 is INITIAL.
WRITE : / sy-tabix,
'Employee successfully uploaded ', wa_0050-pernr.
v_count = v_count + 1.
ENDIF.
CALL FUNCTION 'BAPI_EMPLOYEET_DEQUEUE'
EXPORTING
number = wa_ztime-empno
validitybegin = sy-datum
IMPORTING
return = return1.
endif.
CLEAR : return1,return2.
ENDFORM. " STORE_IT50_DATA
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
H Kiran,
Either use the function module 'ABAP4_COMMIT_WORK' after the FM "HR_INFOTYPE_OPERATION "
CALL FUNCTION 'ABAP4_COMMIT_WORK'.
OR
in the FM HR_INFOTYPE_OPERATION use
nocommit = '0'
Goodluck,
Bhumika
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
100 | |
12 | |
11 | |
6 | |
6 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.