‎2011 Feb 18 4:04 AM
Hii all,
I have develop a BDC for transaction pa30( for 2013 infotype ).
DATA: MODE1 TYPE C VALUE 'N',
UPDT1 TYPE C VALUE 'A'.
CALL TRANSACTION 'PA30' USING BDCDATA
MODE MODE1
UPDATE UPDT1
MESSAGES INTO MESSTAB.
If any one open pa30 for any employy and the same time if i run that bdc for that particular employee
it shows an error message.
Problem :If i try to upload data in pa30 for multiple employee and the first employee is lock by some other user then the erroe messege coming that all other employee also lock.
But if first employee is not locked but second employee locked then the the first employee's data update successfully,for second employee shows a message that the employee is locked by some other user.In the selection screen if there is 3rd employee that also update successfully.
plz help.
Edited by: sk2789 on Feb 18, 2011 5:07 AM
Moderator message: please use more descriptive subject lines for your posts.
Edited by: Thomas Zloch on Feb 18, 2011 3:23 PM
‎2011 Feb 18 4:38 AM
null
Edited by: davuluria on Feb 18, 2011 5:39 AM
Edited by: davuluria on Feb 18, 2011 5:40 AM
‎2011 Feb 18 9:00 AM
‎2011 Feb 18 9:06 AM
‎2011 Feb 18 4:51 AM
Hi Sk,
When you are uploading this data day time or night . If it is a night time just run a back ground in time .
Regards,
Madhu.
‎2011 Feb 18 9:09 AM
Hi,
How are you updating the records? Is it one by one or all employees at once? Do it in LOOP of employees so that if error comes for one record, it wont affect others.
LOOP AT employees
CALL BDC
ENDLOOP.
thanks,
Vinod.
‎2011 Feb 18 9:23 AM
Yes i have already use the loop statement.
This BDC update multiple employee's data at a time.
if the first employee has been locked by some one in the time of updation .Other employee's data not updated and showing
the message that othe employee also locked.
But if the first employee not locked then all other employee's data update successfully except the emloyee which is locked.
‎2011 Feb 18 9:49 AM
did you debug it and see whats happening , I mean when first employee is locked is the control coming out of loop?
‎2011 Feb 18 9:54 AM
Hi,
can you try with Synchronous update instead of asynchronous update?
DATA: MODE1 TYPE C VALUE 'N',
UPDT1 TYPE C VALUE 'S'. "change to S
CALL TRANSACTION 'PA30' USING BDCDATA
MODE MODE1
UPDATE UPDT1
MESSAGES INTO MESSTAB.
Thanks,
Vinod.
‎2011 Feb 18 10:17 AM
Yes i check in dibugg mode.
it's not come out from the loop.
BDCDATA table alyz hold the first employee.
‎2011 Feb 18 10:46 AM
Hi,
Search some table/FM to check that record is locked by other user.
LOOP.
Peform Check_lock_data.
if v_lock_data = 'X'.
continue.
else.
BDC
endif.
ENDLOOP.
Reagrds,
Prasoon
‎2011 Feb 18 10:52 AM
hi
send me code generated through recording.....
Edited by: Prabhakar.. on Feb 18, 2011 11:53 AM
‎2011 Feb 18 11:49 AM
<removed by moderator>
Moderator message: please post only relevant code parts, observe the maximum of 5000 characters per post to preserve formatting.
Edited by: Thomas Zloch on Feb 18, 2011 3:28 PM
‎2011 Feb 18 11:57 AM
LOOP AT employee.
PERFORM check_lock_data.
IF v_lock_flag = 'X'.
CONTINUE.
ELSE.
PERFORM bdc_upload.
ENDIF.
CLEAR v_lock_flag.
ENDLOOP.
FORM check_lock_data.
TABLES: rp50g.
rp50g-pernr = '00003'. "Your Pernr from LOOP
DATA message_handler TYPE REF TO if_hrpa_message_handler.
DATA message_list TYPE REF TO cl_hrpa_message_list.
DATA message_tab TYPE hrpad_message_tab.
DATA mess_wa TYPE hrpad_message.
DATA is_ok TYPE boole_d.
CREATE OBJECT message_list.
message_handler = message_list.
*ensure that sapfp50p is loaded
PERFORM do_nothing IN PROGRAM sapfp50p.
CALL METHOD cl_hrpa_masterdata_enq_deq=>enqueue_by_pernr
EXPORTING
tclas = 'A'
pernr = rp50g-pernr
message_handler = message_handler
IMPORTING
is_ok = is_ok.
IF is_ok NE 'X'.
Set your error flag
v_lock_flag = 'X'.
ENDIF.
ENDFORM.
Let me know if it works.
Thanks,
Prasoon Sahay
Edited by: Prasoon Sahay on Feb 18, 2011 5:30 PM
‎2011 Feb 19 6:42 AM
‎2011 Feb 19 9:18 AM
The logic goes like this -
1.First lock an employee record using FM BAPI_EMPLOYEE_ENQUEUE for update. Based on the return value you can perform the updation task. If employee record gets locked successfully, chances are that your update will be 99.99 % successful.
2. Then update the employee record either using BDC or the function module(recommended) HR_INFOTYPE_OPERATION.
3. After update to the DB table is done, unlock the employee using FM BAPI_EMPLOYEE_DEQUEUE.
Regards,
rumhat
‎2011 Feb 23 7:02 AM
‎2011 Feb 23 7:24 AM
Hi I'm giving some sample code to enqueue and dequeue for the particular employee
LOOP AT itab.
clear user.
CALL FUNCTION 'HR_EMPLOYEE_ENQUEUE'
EXPORTING
number = itab-pernr
IMPORTING
RETURN = return
LOCKING_USER = user
.
IF user is not INITIAL.
*skip the particular record and add the user name to the error list if required and skip this line.
continue.
ENDIF.
********your bdc code
perform bdc_Data. "etc.
****your bdc processing code
*after you complete the updation of the bdc i.e. after call transaction statement
*this is a must after you have done with your processing you have to dequeue the pernr so that other users can update
this particular user.
CALL FUNCTION 'HR_EMPLOYEE_DEQUEUE'
EXPORTING
number = itab-pernr
IMPORTING
RETURN =
.
ENDLOOP.
hope this works for you.
ragards
gnaneswar