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: 

join all 5 HR (pa0000,pa0001,pa0002,pa0007,pa0315) to update MASSN field?

jjay
Participant
0 Kudos

Hi Gurus,

Need some guide here on HR master data updates. I have a requirement here to update Action Type(MASSN) using these tables mentioned by using 'HR_EMPLOYEE_ENQUEUE' & 'HR_INFOTYPE_OPERATION'. Should I first do a join statements for all these tables and update the fields at the end of my program or should I use these fm as and when my requirement validation is done?Appreciate it alot for your guide to clear my confusion.

Thanks.

9 REPLIES 9

Former Member
0 Kudos

Hi,

The best part would be to write a program using LDB PNP and declare the said infotypes ,

read the corresponding structures after GET PERNR event and update the field accordingly using the FM

'HR_INFOTYPE_OPERATION'.

Look at the below ...

tables : pernr.

infotypes : 0000 , 0001 , 0002 , 0007 , 0315.

start-of-selection.

get pernr.

rp-provide-from-last p0000 space pn-begda pn-endda.

check PNP-SW-FOUND EQ '1'.

rp-provide-from-last p0001 space pn-begda pn-endda.

check PNP-SW-FOUND EQ '1'.

rp-provide-from-last p0002 space pn-begda pn-endda.

check PNP-SW-FOUND EQ '1'.

rp-provide-from-last p0007 space pn-begda pn-endda.

check PNP-SW-FOUND EQ '1'.

rp-provide-from-last p0315 space pn-begda pn-endda.

check PNP-SW-FOUND EQ '1'.

*now call the FM's to change the MASSN ..

Call 'HR_EMPLOYEE_ENQUEUE' to lock the pernr

call 'HR_INFOTYPE_OPERATION' to change the infotype PA0000.

Call 'HR_EMPLOYEE_DEQUEUE' to unlock the pernr

end-of-selection.

Regards,

Srini.

0 Kudos

But cant i achieve this by doing normal select statements?This sounds new to me

0 Kudos

I do not have much options on the selection scree, only to upload an excel file, from there onwards either test run or run background option.

Former Member
0 Kudos

Joining 5 tables at one time is creating code that is way too complex and an DB2 nightmare.

You say that you are uploading the information via a spreadsheet so I assume it has the PERNRS that you want to read and/or update. The best thing would be to read your spreadsheet into a table, loop this table and using a function module like HR_READ_INFOTYPE get the infotypes you want, then for the update part use the logic shown in the other post.

0 Kudos

Hello Experts,

Im stuck again right now

I have gathered all the 5 tables data into a itab, but then the tables are updated using the 3 FM

a) HR_EMPLOYEE_ENQUEE

b) HR_EMPLOYEE_OPERATION

c) HR_EMPLOYEE_DEQUEUE

But the thing is, it has to meet the conditon of action type (MASSN) before updating the tables, for my case i have 3 scenarios,

Change, Leave & Hire.

itab_final -pa0000: Hire -


>call 3 FMs to update?

:Change -


>call 3 FMs to update?

: Leave -


>call 3 FMs to update?

-pa0001 (same scenario's as above)

-pa0002

-pa0007

-pa0315

So in this case, i will be calling the function modules 15 times and its gonna create a haewok...but wat is the best way to do this update??please advice

if not gt_itabfinal[] is initial.

sort gt_itabfinalby recty.

loop at gt_itabfinalinto wa_updtab where recty eq 'H'.

"table pa0000

wa_pa0000-pernr = wa_gt_itabfinal-pernr.

wa_pa0000-begda = wa_gt_itabfinal-begda.

wa_pa0000-massn = wa_gt_itabfinalb-massn.

if not wa_updtab-endda eq ''.

wa_pa0000-endda = gt_itabfinal-endda.

else.

"do nothing.

endif.

append wa_pa0000 to gt_pa0000.

clear wa_pa0000.

endloop.

CALL FUNCTION 'HR_EMPLOYEE_ENQUEUE'

EXPORTING

NUMBER = gt_pa0000-pernr

  • IMPORTING

  • RETURN =

  • LOCKING_USER =

.

CALL FUNCTION 'HR_INFOTYPE_OPERATION'

EXPORTING

INFTY = 0000

NUMBER = gt_pa0000-pernr

  • SUBTYPE =

  • OBJECTID =

  • LOCKINDICATOR =

  • VALIDITYEND =

  • VALIDITYBEGIN =

  • RECORDNUMBER =

RECORD = gt_pa0000

OPERATION = 'INS'

TCLAS = 'A'

DIALOG_MODE = '0'

  • NOCOMMIT =

  • VIEW_IDENTIFIER =

  • SECONDARY_RECORD =

  • IMPORTING

RETURN = return

KEY = key

.

CALL FUNCTION 'HR_EMPLOYEE_DEQUEUE'

EXPORTING

NUMBER = gt_pa0000-pernr.

endif.

Really appreciate your kind help

former_member226519
Active Contributor
0 Kudos

usually different action types require different infotypes in different order.

So you will have to handle the different action types in different modules.

One valid option to upload data is LSMW.

if you are not allowed to use LSMW you could use fm HR_MAINTAIN_MASTERDATA. See documentation .

Former Member
0 Kudos

I'm totally confused on what you are trying to do, but unless you are updating thousands of records each night there should be no issue with what you are doing. I run a job every night that has the potential of inserting 8 new Infotypes for an employee and I use HR_INFOTYPE_OPERATION. I lock the PERNR using ENQUE then do all my updates then unlock it with DEQUE.

As best i can tell you will only perform the updates on employees who are: Hired, Changed, or Terminated so you should only be executing these updates once for a given employee.

There is also another Function Module that you need to execute before each HR_INFOTYPE_OPERATION and that is the following:

CALL FUNCTION 'HR_PSBUFFER_INITIALIZE'.

0 Kudos

Hi Richard,

Is there any sample program tht I can refer to? The gt_finaltab[] contains all data from 5 tables, how should I loop it and update the SAP tables using these 3 function modules?

0 Kudos

Hi Guys,

I am facing issues now using the FM HR_INFOTYPE_OPERATION as it returns me the message "Personal Number not yet assigned". I am not sure what I am missing because this is a new hire and am trying to update all the infortypes from a upload file.

LOOP AT gt_tempout INTO wa_tempout WHERE status EQ 'I'.

wa_ip0000-pernr = wa_tempout-pernr.

wa_ip0000-endda = wa_tempout-endda.

wa_ip0000-begda = wa_tempout-begda.

wa_ip0000-massn = wa_tempout-massn.

IF NOT wa_ip0000 IS INITIAL.

CALL FUNCTION 'HR_EMPLOYEE_ENQUEUE'

EXPORTING

number = wa_ip0000-pernr

IMPORTING

RETURN = return2

  • LOCKING_USER =

.

CALL FUNCTION 'HR_INFOTYPE_OPERATION'

EXPORTING

infty = '0000'

number = wa_ip0000-pernr

  • SUBTYPE =

  • OBJECTID =

  • LOCKINDICATOR =

  • VALIDITYEND =

  • VALIDITYBEGIN =

  • RECORDNUMBER =

record = wa_ip0000

operation = 'INS'

TCLAS = 'A'

DIALOG_MODE = '1'

NOCOMMIT = ''

  • VIEW_IDENTIFIER =

  • SECONDARY_RECORD =

IMPORTING

RETURN = return1

"KEY = key

.

CALL FUNCTION 'HR_EMPLOYEE_DEQUEUE'

EXPORTING

number = wa_ip0000-pernr

  • IMPORTING

  • RETURN =

.

  • updated record

IF return2 IS INITIAL.

IF return1 IS INITIAL.

wa_i_udata-pernr = wa_ip0000-pernr.

wa_i_udata-message = c_updated.

APPEND wa_i_udata TO gt_i_udata.

CLEAR wa_i_udata.

ELSE.

wa_i_undata-pernr = wa_ip0000-pernr.

wa_i_undata-message = return1-message.

APPEND wa_i_undata TO gt_i_undata.

ENDIF.

CLEAR wa_i_undata.

ELSE.

  • not updated record - BAPI_ENQUEUE failed - Object locked

wa_i_undata-pernr = wa_ip0000-pernr.

wa_i_undata-message = c_oblck.

"object locked

APPEND wa_i_undata TO gt_i_undata.

ENDIF.

CLEAR wa_i_undata.

"endif.

ENDIF.