cancel
Showing results for 
Search instead for 
Did you mean: 

Data not getting inserted in R/3 System from Webdynpro

Former Member
0 Kudos

Hi,

We were trying to insert some data into r/3 z-table using a Custom BAPI using RFC.

But the data is not getting inserted.

Through I commit is being performed explicity.

Please help:

Below is the code :

Controllor code :

public void wdDoInit()

{

//@@begin wdDoInit()

try{

Z_Bapi_Rfq_Test_Input objStatus = new Z_Bapi_Rfq_Test_Input();

wdContext.nodeZ_bapi_rfq_test().bind(objStatus);

// Create a new element in node Bapi_Transaction_Commit_Input

Bapi_Transaction_Commit_Input inputCommit =

new Bapi_Transaction_Commit_Input();

wdContext.nodeBAPI_TRANSACTION_COMMIT()

.bind(inputCommit);

//Bapi_Transaction_Commit_Input obj;

// wdContext.nodeZ_Bapi_Quo_Salesrep_Status_Input().invalidate();

//wdContext.nodeOutput().invalidate();

//wdContext.nodeRfq_Status().invalidate();

} catch(Exception rfqException){

wdComponentAPI.getMessageManager().reportException("rfqException="+rfqException.getMessage(),true);

}

//@@end

}

public void executeBapi( )

{

//@@begin executeBapi()

try{

Z_Bapi_Rfq_Test_Input obj = wdContext.currentZ_bapi_rfq_testElement().modelObject();

AbstractList objAbBapiPartner = new Bapiparnr.Bapiparnr_List();

Bapiparnr objBapiPartner = new Bapiparnr();

objBapiPartner.setPartn_Numb("0000001046");

objBapiPartner.setPartn_Role("AG");

//obj.addPartner(objBapiPartner);

objAbBapiPartner.add(objBapiPartner);

obj.setPartner(objAbBapiPartner);

Bapisdhd1 objBapisdhd1 = new Bapisdhd1();

objBapisdhd1.setSales_Org("2500");

objBapisdhd1.setDistr_Chan("30");

objBapisdhd1.setDivision("20");

objBapisdhd1.setDoc_Type("ZRFQ");

obj.setHeader(objBapisdhd1);

obj.execute();

// Synchronise the data in the context with the data in the model

wdContext.nodeZ_bapi_rfq_test().invalidate();

wdContext.nodePartner().invalidate();

wdContext.nodeHeader().invalidate();

wdContext.nodeOutput().invalidate();

wdContext.nodeReturn().invalidate();

// Z_Bapi_Quo_Salesrep_Status_Output outPut= obj.getOutput();

//

// if(outPut!=null){

// List materialList=outPut.getRfq_Status();

// if(materialList!=null){

// wdComponentAPI.getMessageManager().reportSuccess("materialList="+materialList.size());

// }

// }

} catch(Exception rfqException){

wdComponentAPI.getMessageManager().reportException("rfqException="+ rfqException.toString(),true);

}

//@@end

}

public void executeBapi_Commit( )

{

//@@begin executeBapi_Commit()

try {

// Calls remote function module BAPI_Transaction_Commit

wdContext.currentBAPI_TRANSACTION_COMMITElement().modelObject().execute();

wdContext.nodeBAPI_TRANSACTION_COMMIT().invalidate();

wdContext.nodeOutput1().invalidate();

wdContext.nodeReturn().invalidate();

wdContext.nodeReturn1().invalidate();

} catch (WDDynamicRFCExecuteException ce) {

wdComponentAPI.getMessageManager().reportException(ce.getMessage(), false);

}

//@@end

}

View Controlloer Code:

public void wdDoInit()

{

//@@begin wdDoInit()

wdThis.wdGetCControllerController().executeBapi();

wdThis.wdGetCControllerController().executeBapi_Commit();

IWDApplication wedDynApplication=wdComponentAPI.getApplication();

IWDApplicationInfo applicationInfo=wedDynApplication.getApplicationInfo();

Collection collection=applicationInfo.getApplicationProperties();

//@@end

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Aditya,

I am not ABAP expert but clearly the transaction is not being propagated in case when you invoke BAPI through Web Dynpro. But the transaction is propagated when you run in SAPGUI workbench.

I am not aware whether the transaction behaviour can be configurable in JCo connection. I think no.

But if you implicitly commit the transaction without calling the 'BAPI_TRANSACTION_COMMIT' in your custom RFC BAPI, things will start working I guess.

Hope this helps.

Thanks and Regards,

Rohit Jaiswal

Former Member
0 Kudos

Hi Aditya,

IMHO Web Dynpro is not transaction scope aware and do not call the second explicit commit call in the same transaction scope as the first call.

You should commit in the BAPI RFC and make one call from Web Dynpro so the commit is called in the same transaction scope.

Can you try the same.

Thanks and Regards,

Rohit Jaiswal

Former Member
0 Kudos

Hi Rohit,

The transaction is ended by calling the special service BAPI BapiService.TransactionCommit in BAPI RFC.

But still the data i not getting inserted.

Rgds,

Aditya

Former Member
0 Kudos

Hi Aditya,

I think what Rohit means is that you should execute the execute of the BAPI together with the commit, i.e. in the same request. It looks as if you are using two separate requests. Is that right?

Regards

Markus

Former Member
0 Kudos

Hi Markus,

what Rohit meant was to commit in RFC-bapi end as well as at the webydynpro end. It is done but still the data is not getting inserted.

And commit in RFC-BAPI is done using

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

and the same is being used in webdynpro.

If you see the code, the commit performed is in the same transaction scope of the request. they are not separate requests.

Thanks,

Rgds,

Aditya

Former Member
0 Kudos

Hi Aditya,

My point was to have just single BAPI which calls commit implicitly, so that you need not call commit explicitly from the Web Dynpro application because AFAIK it does not run in the same transaction scope.

By having single BAPI, you can run the same in the R/3 system and see the data is being entered. Then you can call the single call from Web Dynpro which should definitely work.

Hope this helps.

Thansk and Regards,

Rohit Jaiswal

Former Member
0 Kudos

Hi Rohit,

From R/3 system data is getting inserted. No problems from there.

Only problem is from Webdynpro.

Data is not coming into r/3 system.

Thanks,

Rgds,

Aditya

Former Member
0 Kudos

Hi Aditya,

Your code above(on top) is not running in the same request / transaction context. Have you tried using just invoking single BAPI and not 2 BAPI's, implicitly committing in the single BAPI.

If the single BAPI is working at R/3 side and not running in Web Dynpro then I don't know what the problem is?

Thanks and Regards,

Rohit Jaiswal

Former Member
0 Kudos

Hi Rohit,

First I tried invoking single BAPI , data was not getting inserted.

Then I tried explicity calling BAPI_COMMIT RFC, still the data was not getting inserted.

Rgds,

Aditya

Former Member
0 Kudos

Hi Aditya,

And is it the same when you do it at R/3 side, you call both the BAPIs or single Bapi inserts the data?

Thanks and Regards,

Rohit Jaiswal

Former Member
0 Kudos

Hi Rohit,

R/3 Custom RFC Bapi is internally calling

'CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' to commit the data.

So executing this Custom RFC BAPI @ SAPGUI workbench, inserts the data.

But when I try to invoke this single bapi in webdynpro, data is not getting inserted. So i thought of externally calling the BAPI_COMMIT BAPI through webdynpro, but still its not working.

Do you think it might be because of any version problem ?

The current setup is :

NWDS SP15

EP 6.40 SP16

sap R/3 4.6C

Thanks,

Rgds,

Aditya Metukul

Former Member
0 Kudos

Hi,

So you have a custom RFC module that performs your logic and then performs a BAPI_TRANSACTION_COMMIT - is this all inside 1 custom function module? Do you set the WAIT flag as well to ensure it commits?

If this is working ok when tested in SE37 then you need to make sure your Web Dynpro is definitely calling your RFC and passing the correct data.

Do yuo get any exceptions raised or any return messages back from your RFC?

There is nothing obvious that would cause your RFC to work differently when called from Web Dynpro so it must be a problem with the connection/calling of the RFC.

Have you tried using the FBGENDAT functionality on R3 to check your RFC is being called correctly?

Hope this helps,

Gareth.

Former Member
0 Kudos

Hi Gareth,

I was not getting enough time to reply, so replying late.

Actaully the problem was with r/3 BAPI Code itself.

There was condition in the begining of the code to check the data in the workare of R/3, so this condition was failing here.

But when we try to invoke that bapi from r/3 workbench it works fine because the data first comes to R/3 workarea then to R/3 Tables.

But when we insert data from Webdynpro framework , the data directly goes to R/3 Tables rather than the R/3 Workarea. So in Bapi the first condition was failing and no data was getting inserted.

So this was the problem, and we solved it.

Thanks,

Regards,

Aditya metukul

Former Member
0 Kudos

Hi,

Was it something like

if table is initial

instead of

if table[] is initial

?

I've done that a few times and spent ages trying to find the problem!!

Gareth.