cancel
Showing results for 
Search instead for 
Did you mean: 

BAPI_PERSDATA_CHANGE to update user data using SAP JCo 3

Former Member
0 Kudos
386

Hello i'm using the following code snippet. The goal is to update the user lastname firstname and co using the BAPI_PERSDATA_CHANGE bapi. But somehow it's not working, I tried a lot of possibilities but it's not working. The message to the function related to BAPI_PERSDATA_CHANGE is:

No data stored for 0002 in the selected period
public boolean writeData(long id, HashMap<String, String>  userData) throws Exception{
        String DST1 = "ABAP_AS";
        JCoDestination dest = JCoDestinationManager.getDestination(DST1);
        JCoFunctionTemplate template = dest.getRepository().getFunctionTemplate("BAPI_PERSDATA_CHANGE");
        JCoFunction jcoFunction = template.getFunction();
        jcoFunction.getImportParameterList().setValue("EMPLOYEENUMBER", id);
        //jcoFunction.getImportParameterList().setValue("SUBTYPE", "002");
        //jcoFunction.getImportParameterList().setValue("OBJECTID", "");
        //jcoFunction.getImportParameterList().setValue("LOCKINDICATOR", "");
        jcoFunction.getImportParameterList().setValue("VALIDITYBEGIN", "19570101"); //"1994-04-24");
        jcoFunction.getImportParameterList().setValue("VALIDITYEND", "99991231");
        jcoFunction.getImportParameterList().setValue("RECORDNUMBER", "000");
        jcoFunction.getImportParameterList().setValue("FIRSTNAME", "FOfie modifier");
        JCoFunction jCoFunction1 = dest.getRepository().getFunctionTemplate("BAPI_TRANSACTION_COMMIT").getFunction();
        JCoFunction BAPI_EMPLOYEE_DEQUEUE = dest.getRepository().getFunction("BAPI_EMPLOYEE_DEQUEUE");
        BAPI_EMPLOYEE_DEQUEUE.getImportParameterList().setValue("NUMBER", id);
        jcoFunction.execute(dest);
        jCoFunction1.execute(dest);
        BAPI_EMPLOYEE_DEQUEUE.execute(dest);
        JCoContext.end(dest);
        return false;
    }

Am i missing something ? Thanks for helping.

Accepted Solutions (0)

Answers (2)

Answers (2)

raymond_giuseppi
Active Contributor
0 Kudos

You could first call BAPI_PERSDATA_GETDETAILEDLIST and/or BAPI_PERSDATA_GETDETAIL to get actual current values, then depending on required changes, call BAPI_PERSDATA_CHANGE and/or other BAPI like DELIMIT or CREATE.

Former Member
0 Kudos

This is what i did, but unfortunately, it doesn't work! Still looking forward!

richard-zhao
Advisor
Advisor
0 Kudos

Hello, Delly. Could you refer the link below? It seems that It's the same issue. You could try to use the same solution. thanks.

https://archive.sap.com/discussions/thread/124203

Former Member
0 Kudos

I've already seen this link but unfortunately cannot use the answer provided.