Skip to Content
0

BAPI_PERSDATA_CHANGE to update user data using SAP JCo 3

Jan 04 at 04:29 PM

82

avatar image
Former Member

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.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Richard Zhao
Jan 08 at 05:08 AM
0

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

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

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

0
Raymond Giuseppi
Jan 17 at 11:58 AM
0

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.

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

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

0