cancel
Showing results for 
Search instead for 
Did you mean: 

calling BAPIs from Java

Former Member
0 Kudos

Hi all,

I just started developing an application that allows patient search (BAPI_PATIENT_SEARCH) and patient creation (BAPI_PATIENT_CREATE) via Java. The search works pretty fine, and the patient creation also, as I always get a new patient id back from SAP. BUT, the patient is never stored in the database. I call BAPI_TRANSACTION_COMMIT (where I set WAIT to X) immediately after the patient creation, but the patients are never visible in SAP?!

Anyone any idea what I am missing?!

By the way - the classes to access the BAPIs have been created by a tool called eclipsesap2java (from SourceForgeNet) - and they look really fine. Is there any other source for generators that build Java classes corresponding to SAP BAPIs?!

Thanks in advance

Bernhard Böhm

Accepted Solutions (0)

Answers (1)

Answers (1)

gregorw
Active Contributor
0 Kudos

Is the RFC Connection closed between the call of BAPI_PATIENT_CREATE and BAPI_TRANSACTION_COMMIT?

Former Member
0 Kudos

No it is not closed - the commit is done immediately after the patient create with the same connection object.

But, meanwhile, I discovered a strange behaviour of the BAPI_PATIENT_CREATE. When I create the patient I get back the new patientId, as mentioned before. BUT, in the NEW_PATIENT object that is returned from the BAPI there exists no more information than this new patientId. So, fields like lastName, firstName, birthDay,... everything that has been filled out before in order to create the patient is empty in the return object.

Is this the normal behaviour or should there be a data returned?! Maybe the problem is not the commit, but the BAPI_PATIENT_CREATE?!

Thanks for more help...

Bernhard Böhm

Former Member
0 Kudos

Hi Bernhard,

please have a look at the documentation of the BAPI in the BAPI Explorer (Transaction BAPI) in R/3. There should be a detailled documentation about the required filling of the parameter(s) and structure(s). For some BAPI interfaces there are structures, which require the setting of a "Field Changed" flag, which has the same name as the corresponding field (for example FIRSTNAME -> FIRSTNAME_X). This is normally not the case for BAPIs which create something, but who knows. Otherwise, any value changes made are not recognized unless you set these flags too.

Hope that helps.

Regards

Stefan

Former Member
0 Kudos

Hi again,

now I found the first problem with empty return structures that I got from the BAPIs. It was a wrong handling of data structures. Now, when I create a new patient, for instance, I get the correct patient structure back in the return object and so this looks really fine.

BUT - I still can not store the data. I call BAPI_TRANSACTION_COMMIT, but nothing is stored. And this is not only in the PatientCreate-BAPI, but also when I want to create a Case for an existing Patient. So the problem is not inside one of these BAPIs, but in the transaction mode.

Is it possible that a connection to SAP can be made in read-only mode and where could this be set?! Also there are no change indicator fields (like FIRSTNAME_X) - I know those, but they only exist in PatientUpdate-BAPIs.

Any idea how I can determine if my SAP connection is read-only???

Thanks and regards

Bernhard Böhm

Former Member
0 Kudos

Hi all,

I am still searching for my problem with the "read-only" session (previous post). Does anybody know this behaviour?

Please help...

Thanks and regards

Bernhard Böhm

Former Member
0 Kudos

OK, now I found my problem....

The framework I used to generate connections to SAP and exceute the BAPIs had the implicit behavior to disconnect as soon as a BAPI was executed, so it was a stateless connection.

Now I modified this source to keep up the connection until the commit is done - and everything works perfect.

Thanks for all input anyway

Bernhard Böhm

Benny
Product and Topic Expert
Product and Topic Expert
0 Kudos

what framework is that???

Former Member
0 Kudos

Hi Benny,

the name is eclipsesap2java. Have a look at http://sourceforge.net/projects/eclipsesap2java/

Regards

Stefan