Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Update infotype using class method

Former Member
0 Kudos

Hi All,

I need to update an infotype using a Class method. I need to pass a file as input to the Class Structure.

How can we pas a file as input to the Class structure.

Any pointers on this would be really helpful.

Thanks,

Saher

1 REPLY 1

Former Member
0 Kudos

Hello,

You can update/insert records in Info type thru below code using FM: HR_INFOTYPE_OPERATION, but you need to get the data from the file to internal table for the same.

LOOP AT t_insert INTO w_insert.

w_pernr = w_insert-ownnum.

CALL FUNCTION 'HR_READ_INFOTYPE'

EXPORTING

pernr = w_pernr

infty = c_infty "'0105'

TABLES

infty_tab = t_0105

EXCEPTIONS

infty_not_found = 1

OTHERS = 2.

READ TABLE t_0105 INTO w_0105 WITH KEY pernr = w_insert-ownnum"#EC *

subty = c_subu.

IF sy-subrc = 0.

MOVE w_0105 TO w_p0105.

w_p0105-usrid = w_insert-lanid.

CLEAR w_0105.

ELSE.

w_p0105-pernr = w_pernr.

w_p0105-usrid = w_insert-lanid.

w_p0105-begda = sy-datum.

w_fnr = 'X'.

ENDIF.

CALL FUNCTION 'BAPI_EMPLOYEE_ENQUEUE'

EXPORTING

number = w_pernr.

w_p0105-pernr = w_pernr.

IF w_fnr = 'X'.

CALL FUNCTION 'HR_INFOTYPE_OPERATION'

EXPORTING

infty = c_infty "'0105'

number = w_p0105-pernr

subtype = c_subu "'0001'

validityend = w_p0105-endda

validitybegin = w_p0105-begda

record = w_p0105

operation = c_oprn "'INS'

tclas = 'A'

dialog_mode = '0'

IMPORTING

return = w_return.

ELSE.

CALL FUNCTION 'HR_INFOTYPE_OPERATION'

EXPORTING

infty = c_infty "'0105'

number = w_p0105-pernr

subtype = c_subu "'0001'

validityend = w_p0105-endda

validitybegin = w_p0105-begda

record = w_p0105

operation = 'MOD' "'MOD'

tclas = 'A'

dialog_mode = '0'

IMPORTING

return = w_return.

ENDIF.

CLEAR w_fnr.

CALL FUNCTION 'BAPI_EMPLOYEE_DEQUEUE'

EXPORTING

number = w_pernr.

endloop.

Hope it helps.

Thanks,

Jayant