cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to save records into R/3 table

Former Member
0 Kudos

Hi All,

For one of the requriements, I am passing data into RFC. The data is from excel sheet and the data is 33 columns currently and n number of records, which I am able to save into Attributes. After doing so, I have to execte one RFC to upload the data and to check whether the data already exists.. and after that one more RFC to save the uploaded data.

I am unable to execute the RFC, when there are multiple records. Please find my code below:

Z_Rfc_Qm_Procert_Import_Check_Input checkInp = new Z_Rfc_Qm_Procert_Import_Check_Input();

wdContext.nodeZ_Rfc_Qm_Procert_Import_Check_Input().bind(checkInp);

AbstractList AbsList = new Zqm_Procert_Import.Zqm_Procert_Import_List();

for(int j=0; j<wdContext.nodeVn_XL_Data().size(); j++)
{
          Zqm_Procert_Import checkImport = new Zqm_Procert_Import();

          checkImport.set1(SOME VALUE);
          checkImport.set2(SOME VALUE);
          checkImport.set3(SOME VALUE);
          ...................................................
          checkImport.set33(SOME VALUE);

AbsList.add(checkImport);

}//ends for loop

checkInp.setI_Data(AbsList);
wdComponentAPI.getMessageManager().reportSuccess("Abslist size outside: "+AbsList.size());

This gives me size as 4 which is correct as my sheets has 4 records.

The next line dosent executes, where I am trying to execute the RFC below:

checkInp.execute();

So I am unable to print the below messages. I am able to print the data inside the for loop. All looks okay all 33 columns with 4 records.

wdComponentAPI.getMessageManager().reportSuccess("Execute operation...");

wdContext.nodeOutput().invalidate();

This gives no error but doesnu2019t execute the RFC as well.

I have tried printing the values which it prints fine. Previously I tried executing without abstract list but then it saved only one record that too the last one (when it was being set outside the for loop. inside it never executes).

I think the code should work, as technically I see no issues. Please advice me further, if there's anywhere I am wrong.

Regards,

Gaurav

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi,

Try this code,

Z_Rfc_Qm_Procert_Import_Check_Input checkInp = new Z_Rfc_Qm_Procert_Import_Check_Input();

wdContext.nodeZ_Rfc_Qm_Procert_Import_Check_Input().bind(checkInp);

for(int j=0; j<wdContext.nodeVn_XL_Data().size(); j++)

{

Zqm_Procert_Import checkImport = new Zqm_Procert_Import();

checkImport.set1(SOME VALUE);

checkImport.set2(SOME VALUE);

checkImport.set3(SOME VALUE);

...................................................

checkImport.set33(SOME VALUE);

checkInp.add(checkImport);

}//ends for loop

Kind regards,

Saravanan K

Former Member
0 Kudos

Hi,

Set the abstractlist like below and execute the bapi.

wdContext.currentZ_Rfc_Qm_Procert_Import_Check_InputElement().modelObject().setI_Data(AbsList);

And to execute the bapi

try{
wdContext.currentZ_Rfc_Qm_Procert_Import_Check_Input().modelObje().execut();
wdContext.nodeOutput().invalidate();
 }
catch(WDDynamicRFCExecuteException e)
    {
      manager.reportException(e.getMessage(), false);
    }

Regards,

srikanth

Former Member
0 Kudos

Hi Nishi,

Thanks for your kind inputs.

As per your suggestion, I have implemented the code and it executes the RFC. But the RFC gets a blank data with no values

Please find my code below:

Iside the for loop

AbsList.add(checkImport);
checkInp.setI_Data(AbsList);
AbsList.clear();
wdContext.nodeZ_Rfc_Qm_Procert_Import_Check_Input().currentZ_Rfc_Qm_Procert_Import_Check_InputElement().modelObject().execute();

@ROHIT: Thanks buddy for you inputs, but that also dosen't actually solves the problem.

Waiting for responses...

Regards,

Gaurav

former_member40425
Contributor
0 Kudos

Hi,

Are you sure that your BAPI is getting executed successfully at R/3 end i.e. if you execute your BAPI in R/3 then values are getting reflacted in table.

If yes then try executing your BAPI in try catch block and in finally block use disconnectIfAlive() method.

You can refer following code.

checkInp.setI_Data(AbsList);
try{
wdContext.nodeZ_Rfc_Qm_Procert_Import_Check_Input().Z_Rfc_Qm_Procert_Import_Check_InputElement().modelObject().execute();
//invalidating the output node
wdContext.nodeOutput().invalidate();

}
	catch (Exception e)
	{
		
		wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess("Exception");
	}
	finally
	{ 
		//disconnecting the model of bapi
		checkInp.modelInstance().disconnectIfAlive();
	}

Regards,

Rohit

Former Member
0 Kudos

Hi,

Clear the abstract list after the execute is done and add the execute statement in the for loop.

hope it solves ur problem .Revert back if any issues

Thanks and Regards,

Nishita Salver

former_member40425
Contributor
0 Kudos

Hi,

Try to execute BAPI using following code.


wdContext.nodeZ_Rfc_Qm_Procert_Import_Check_Input().Z_Rfc_Qm_Procert_Import_Check_InputElement().modelObject().execute();
//invalidating the output node
wdContext.nodeOutput().invalidate();

I hope it helps.

Regards,

Rohit