on 04-04-2015 7:26 AM
Hi SAP Community,
I am trying to update last name, email , phone etc of an employee using the BAPI (BAPI_PERSDATA_CHANGE). But this Bapi is asking for some mandatory value
like 1) Employee number - I am providing a valid value
2) SUBTYPE - What can be the possible value for this? I am giving 002
3) OBJECTID - What can be the possible value for this? I am giving O
4) LOCKINDICATOR - What can be the possible value for this? I am giving X
I am not aware what value I need to provide in these arguments, So i am getting an exception "009No data stroed for 002 in the selected period".
I dont want to update employee record using Transaction PA30. I only want to use BAPI.
The reason to use BAPI is , I want to call the same from JAVA code to update records.
Any help is highly appreciated.
Thanks
Riju Bhasker
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Soumyasanto,
Thanks for your reply. Actually i had gone through all these links already, but was of no help to me.
As the values are not getting changed, and I am getting error.
Is there a way to directly update records in database of hr? Or if you have any sample java code changing lastname, email , phone of records present in HR then it will be great help to me.
Thanks
Riju Bhasker
Hi Riju,
BAPI_PERSDATA_CHANGE is used for changing the infotype 002, where subtype parameter is used for any subtype used in 002 and may that's the reason you are getting that error. Also I think you store email, phone etc in 105 not in 002 but first you may try the below solution.
use BAPI_EMPLOYEE_GETDATA to first fetch the data and using those parameters then use your FM to update.
Reg
Soumya
Hi Soumya,
Thanks for your reply.
I will share my java code with you, I tried to change only last name of an employee.
Even the the things are not working.
In case of BAPI_PERSDATA_CHANGE the infotype is 0002 which dont have any subtype. Is my understnanding correct?
Also I am not providing any values for "OBJECTID","LOCKINDICATOR". Do we need to provide any value to them?
In the code below i tried to use 4 bapis in sequence
BAPI_EMPLOYEE_ENQUEUE
BAPI_PERSDATA_CHANGE
BAPI_TRANSACTION_COMMIT
BAPI_EMPLOYEE_DEQUEUE
This is giving no exceptions, even then the values are not getting changed on server.
My code below
/*****************************************************************************************************/
public void modifyRecordLastnameUsingBapiPersDataChange() throws Exception |
{
System.out.println("inside bapi pers data change"); | |
JCoDestination destination = JCoDestinationManager.getDestination(DESTINATION_NAME1); | |
JCoFunction bloqFunction = destination.getRepository().getFunction("BAPI_EMPLOYEE_ENQUEUE"); | |
bloqFunction.getImportParameterList().setValue("NUMBER", "00000003"); | |
JCoFunction cambFunction = destination.getRepository().getFunction("BAPI_PERSDATA_CHANGE");
System.out.println(cambFunction.getImportParameterList());
cambFunction.getImportParameterList().setValue("EMPLOYEENUMBER", "00000003");//EMPLOYEENUMBER//VALIDITYBEGIN//VALIDITYEND//LASTNAME
cambFunction.getImportParameterList().setValue("SUBTYPE", "");
cambFunction.getImportParameterList().setValue("OBJECTID", "");
cambFunction.getImportParameterList().setValue("LOCKINDICATOR", "");
cambFunction.getImportParameterList().setValue("VALIDITYBEGIN", "19830429");//ENDDA//BEGDA//PERNR//NACHN
cambFunction.getImportParameterList().setValue("VALIDITYEND", "99991231");
cambFunction.getImportParameterList().setValue("RECORDNUMBER", "000");
cambFunction.getImportParameterList().setValue("LASTNAME", "KURAANE");
JCoFunction transctFunction = destination.getRepository().getFunction("BAPI_TRANSACTION_COMMIT");
//transctFunction.execute(destination);
JCoFunction desbFunction = destination.getRepository().getFunction("BAPI_EMPLOYEE_DEQUEUE");
desbFunction.getImportParameterList().setValue("NUMBER", "00000003");
//desbFunction.execute(destination);
try {
JCoContext.begin(destination);
if (JCoContext.isStateful(destination))
System.out.println("doing commits");
bloqFunction.execute(destination);
cambFunction.execute(destination);
transctFunction.execute(destination);
desbFunction.execute(destination);
System.out.println("done commits");
} finally {
JCoContext.end(destination);
}
System.out.println("done changes");
}
//****************************************************************************************
Thanks
Riju Bhasker
Hi Vikas,
Can you set a external debugger inside the BAPI and try to find out what went wrong. As you said, there is no need of Object ID hence it is time constraint 1 and no sub types. No need of lock indicator if you havent locked the personnel number for the infotype.
With Regards,
Giriesh M
User | Count |
---|---|
110 | |
12 | |
11 | |
6 | |
5 | |
4 | |
4 | |
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.