cancel
Showing results for 
Search instead for 
Did you mean: 

BAPI to update employee details in SAP HCM?

former_member567509
Participant
0 Kudos

Hello there.

I want to create or update an employee record in SAP HCM system with the below details:

First, Middle and Last Name, DOB, Email, Org ID, Position, Vendor ID, Personnel Area, Start Date and End Date.

Any idea about any BAPI?

Regards.

Accepted Solutions (1)

Accepted Solutions (1)

former_member567509
Participant
0 Kudos

Use Function Module 'HR_MAINTAIN_MASTERDATA' to create/update employee record.

CALL FUNCTION 'HR_MAINTAIN_MASTERDATA'
EXPORTING

massn = 'ZS'

actio = 'INS'
tclas = 'A'
begda = i_input_data-startdate
werks = lv_persa
persg = 'E'
persk = '51'
plans = i_input_data-positionno
IMPORTING
return1 = e_message
TABLES
proposed_values = lt_values
modified_keys = lt_modified_keys.

The infotypes which you want to update can be passed in proposed_values.

See below code example:

* Action type - Hiring non-payroll
ls_values-infty = '0000'.
ls_values-fname = 'P0000-MASSN'.
ls_values-fval = 'ZS'.
APPEND ls_values TO lt_values.
CLEAR ls_values.


* Action Reason
ls_values-infty = '0000'.
ls_values-fname = 'P0000-MASSG'.
ls_values-fval = '51'.
APPEND ls_values TO lt_values.
CLEAR ls_values.

* Action type - Termination non-payroll
ls_values-infty = '0000'.
ls_values-fname = 'Q0000-MASSN'.
ls_values-fval = 'ZU'.
APPEND ls_values TO lt_values.
CLEAR ls_values.

ls_values-infty = '0001'.
ls_values-fname = 'P0001-BTRTL'.
ls_values-fval = i_input_data-location.
APPEND ls_values TO lt_values.
CLEAR ls_values.

ls_values-infty = '0002'.
ls_values-fname = 'P0002-ANRED'.
ls_values-fval = i_input_data-title.
APPEND ls_values TO lt_values.
CLEAR ls_values.

ls_values-infty = '0002'.
ls_values-fname = 'P0002-NACHN'.
ls_values-fval = i_input_data-lname.
APPEND ls_values TO lt_values.
CLEAR ls_values.

ls_values-infty = '0002'.
ls_values-fname = 'P0002-VORNA'.
ls_values-fval = i_input_data-fname.
APPEND ls_values TO lt_values.
CLEAR ls_values.

ls_values-infty = '0002'.
ls_values-fname = 'P0002-MIDNM'.
ls_values-fval = i_input_data-mname.
APPEND ls_values TO lt_values.
CLEAR ls_values.

ls_values-infty = '0002'.
ls_values-fname = 'P0002-RUFNM'.
ls_values-fval = i_input_data-pname.
APPEND ls_values TO lt_values.
CLEAR ls_values.

ls_values-infty = '0002'.
ls_values-fname = 'P0002-GBDAT'.
ls_values-fval = i_input_data-birthdate.
APPEND ls_values TO lt_values.
CLEAR ls_values.

* Termination date
ls_values-infty = '0019'.
ls_values-fname = 'P0019-TERMN'.
ls_values-fval = i_input_data-enddate.
APPEND ls_values TO lt_values.
CLEAR ls_values.

ls_values-infty = '0315'.
ls_values-fname = 'P0315-ENDDA'.
ls_values-fval = i_input_data-enddate.
APPEND ls_values TO lt_values.
CLEAR ls_values.

ls_values-infty = '0315'.
ls_values-fname = 'P0315-LIFNR'.
ls_values-fval = i_input_data-vendor_id.
APPEND ls_values TO lt_values.
CLEAR ls_values.

ls_values-infty = '0105'.
ls_values-fname = 'P0105-SUBTY'.
ls_values-fval = '0010'.
APPEND ls_values TO lt_values.
CLEAR ls_values.

ls_values-infty = '0105'.
ls_values-fname = 'P0105-USRID_LONG'.
ls_values-fval = i_input_data-email.
APPEND ls_values TO lt_values.
CLEAR ls_values.

Regards.

ChrisSolomon
Active Contributor
0 Kudos

You need to be careful with this function. It is older and bypasses the newer DCIF. I believe there is a newer function for this if this is how you want to handle it.

Answers (1)

Answers (1)

ChrisSolomon
Active Contributor

First off, do you understand what BAPIs actually are and what "business objects" are? Second, do you understand functions, remote functions, and interfaces?.....if you answered "yes" to those questions....Have you even attempted to look?....Uhm...transaction BAPI? And then under Personnel Management - > Personnel Administration there are a TON of "employee" business objects. There is even documentation on each one. I suggest you go look there.

TheGokke
Active Participant

I see you still got it, this pleases me a lot 😄

former_member567509
Participant
0 Kudos

Thanks for kind suggestion, Christopher.

First off. i do understand BAPIs, Business Objects, Functions, remote functions and interfaces. and i did attempt to look for that. I did not find any BAPI but found certain FMs which by using in combination could solve my problem but i wanted to check if someone have handled the same requirement and knew any FM or BAPI ( a remote enabled FM registered in Business object) which could be used to update different infotypes in one call.

ChrisSolomon
Active Contributor
0 Kudos

Ok...so you understand "objects"....then you should understand "separation of concerns" and why there isn't ONE that just does everything at once. Glad you figured it out and have a plan of attack/design now. Good luck!

ChrisSolomon
Active Contributor
0 Kudos

I have my moments. haha.....looks like you have been getting to do all the "fun" stuff...Fiori/Odata.....hope all is well!

TheGokke
Active Participant

Yes, all is well. Fiori is fun indeed but I had my share of "crying in the corner" because the sh*t doesn't work or I didn't know javascript anymore. Still better than FPM and Proc. and Forms, am I right? 😉

ChrisSolomon
Active Contributor
0 Kudos

HCM P&F is fun now, cause I can do it in my sleep. haha I have to keep my "other" skills sharp.....doing FreeCodeCamp courses, doing Laracast/Laravel tutorials, doing Fiori and SAPUI5 tutorials (for the 5th time haha).....or I feel like I am becoming ancient. haha