cancel
Showing results for 
Search instead for 
Did you mean: 

BAPI_FIXEDASSET_CREATE1 - Can't find created assets

Former Member
0 Kudos

Hello,

I'm using the BAPI BAPI_FIXEDASSET_CREATE1 to create assets. In return-message I get the asset and the subnumber of this asset. I'm also sending an commit, but after that I can't find the asset anymore.

Thanks for help,

Claudia Stephani

Accepted Solutions (1)

Accepted Solutions (1)

gregorw
Active Contributor
0 Kudos

Hello Claudia,

I think you must call BAPI_TRANSACTION_COMMIT to commit the creation to the database.

Regards

Gregor

p.s.: Hope you've received the JCo for linux .

Former Member
0 Kudos

Hi Gregor,

I'm already calling BAPI_TRANSACTION_COMMIT, if BAPI_FIXEDASSET_CREATE1 returns no errors. An the commit also returns no error.

here an extract of the code. the function "getReturnValue" is a function that reads the return structure

"setAusgaben" calls System.out.println();

String bapi_name = "BAPI_FIXEDASSET_CREATE1";

try {

IFunctionTemplate ftemplate = getRepository().getFunctionTemplate(bapi_name);

JCO.Function function = ftemplate.getFunction();

JCO.ParameterList input = function.getImportParameterList();

IMetaData smeta = getRepository().getStructureDefinition("BAPI1022_KEY");

JCO.Structure struct = new JCO.Structure(smeta);

struct.setValue(bk, "COMPANYCODE");

smeta = getRepository().getStructureDefinition("BAPI1022_FEGLG001");

struct = new JCO.Structure(smeta);

struct.setValue("00003200", "ASSETCLASS");

/* some other input */

JCO.Client client = getClient();

client.execute(function);

String[] ret = getReturnValue(function.getExportParameterList().getStructure("RETURN"), true);

if (!ret[0].equals("E")){

ftemplate = getRepository().getFunctionTemplate("BAPI_TRANSACTION_COMMIT");

}else{

ftemplate = getRepository().getFunctionTemplate("BAPI_TRANSACTION_ROLLBACK");

setAusgaben("Fehler beim Update.

Rollback wird durchgeführt.");

}

JCO.Function function2 = ftemplate.getFunction();

getClient().execute(function2);

ret = getReturnValue(function2.getExportParameterList().getStructure("RETURN"), true);

if (!ret[0].equals("E")){

struct = function.getExportParameterList().getStructure("ASSETCREATED");

setAusgaben("Folgende Anlage wurde angelegt: "struct.getString("ASSET")"_"+struct.getString("SUBNUMBER"));

}

releaseClient();

p.s.: Thanks for the JCo.

gregorw
Active Contributor
0 Kudos

Hello Claudia,

the problem is that you have a getClient() call for each function. You must do the commit with the client which was used to call the BAPI_FIXEDASSET_CREATE1 because you had to be in the same session. In your code you get a new client which terminates the first session without a commit. Just change the line

getClient().execute(function2);

to

client.execute(function2);

and it will work.

Regards

Gregor

Former Member
0 Kudos

Hi Gregor,

thanks, this helped. I don't know, why I used a new client. With other BAPIs I didn't make this mistake.

Many greetings,

Claudia

Answers (0)