Skip to Content
0
Former Member
Jan 04, 2018 at 04:29 PM

BAPI_PERSDATA_CHANGE to update user data using SAP JCo 3

217 Views Last edit Jan 14, 2018 at 12:52 PM 4 rev

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.