cancel
Showing results for 
Search instead for 
Did you mean: 

Is RFC destination is required for accessing BAPI from java/VB program.

Former Member
0 Kudos

I am not able to understant that all BAPI are Remote enabled ,but no where I observed that RFC destination is required.

Can any body tell me exact flow and things step by step.

Any example/full source code so that I can call from java program.

I have tried some java code posted here but not able to understand ..

please provide me setttings also in SAP and java system

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Amit,

To connect the SAP Systems (ABAP Systems) from NON-ABAP Systems (for instance java), we will use SAP Connectors.

JCO API is used to connect to SAP Systems from JAVA Programming.

RFCs are exposed to the out side from the SAP Systems will allow another NON-SAP Systems to connect with SAP Systems.

RFC destintation is not required for plain JCO programming in java. but you can use RFCDestinations for connection pooling and the good practoce.

so using rfc destinations is not mandatory to connect RFC. RFC Destinations will be created in SAP WEbAS.

http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/85a483cb-0d01-0010-2990-c5168f01ce8a

Regards,

Naga

Former Member
0 Kudos

hi,

thank u for ur reply.

But can u provide me exact step by step source code( plane java) that will call any standard BAPI.

Is it like that i have to create program in webdynpro java.

I need a simple program so that I can execute directly from command prompt.

My requirement is just to see how java program will bring SAP screen and connect to SAP and than call BAPI API method.

thanks in advance.

Former Member
0 Kudos

Hi,

The Sample program to run via command prompt is :http://www.sapdev.co.uk/java/jco/jco_callfunc.htm

Explanation:http://www.blogjava.net/drmagic/archive/2005/12/06/22764.html

The required jars : sapjco.jar,SAPmdi.jar,aii_proxy_rt.jar,aii_util_misc.jar

To consume RFC in webdynpro java : you must have to create RFC Destinations in WebAS:

To create RFC Destination:http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/526bd490-0201-0010-038e-d3ff7eb1d16e&overridelayout=true

Call RFC in WDJ: http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/10c2c440-7f8c-2b10-7db0-dce34360f118&override...

Regards,

Nagaraju

Former Member
0 Kudos

Hi Nagaraju,

Thank you very much. your post resolve one of my basic need .really appreciate your post.

I was not able to execute bapi BAPI_MATERIAL_GETLIST but I executed BAPI_PO_GETDETAIL succesfully.

Still I have 2 doubt.

[1]. I called BAPI function module(BAPI_PO_GETDETAIL) from simple java program,But I need to call API method ( GETDETAIL) created for this BAPI not direct BAPI function module.

[2] this is something apart from original topic.

I have tested your java code in java as well as similar in ECC 6.0

But I am not getting any output in JAVA program.

I am getting output in ECC6.0 only when I will take internal table lt_mara[] with header line.

if I will take separate workarea output is not coming. I think this is the problem in JAVA also.

Please see the code and tell me where I am wrong.

REPORT ZTEST1.

types: begin of ty_mara .

include STRUCTURE BAPIMATRAM.

TYPES: END OF ty_mara.

types: begin of ty_list .

include STRUCTURE BAPIMATLST.

TYPES: END OF ty_list.

data: lt_mara type STANDARD TABLE OF ty_mara with HEADER LINE.

data: lt_list type STANDARD TABLE OF ty_list,

ls_list like LINE OF lt_list.

START-of-SELECTION.

lt_mara-SIGN = 'I'.

lt_mara-option = 'EQ'.

lt_mara-matnr_low = '000000000000000088'. "'P1001087'.

lt_mara-matnr_high = ''.

APPEND lt_mara.

lt_mara-SIGN = 'I'.

lt_mara-option = 'EQ'.

lt_mara-matnr_low = '000000000000000089'. "'P1001087'.

lt_mara-matnr_high = ''.

APPEND lt_mara.

CALL FUNCTION 'BAPI_MATERIAL_GETLIST'

TABLES

MATNRSELECTION = lt_mara

MATNRLIST = lt_list[] .

WRITE / 'output: '.

LOOP AT lt_list into ls_list .

write: ls_list .

ENDLOOP.

- - - - - - - - - - - - - - - -- - - - - - -- - - -

REPORT ZTEST2.

types: begin of ty_mara .

include STRUCTURE BAPIMATRAM.

TYPES: END OF ty_mara.

types: begin of ty_list .

include STRUCTURE BAPIMATLST.

TYPES: END OF ty_list.

data: lt_mara type STANDARD TABLE OF ty_mara, ">> Without header line

ls_mara like line of lt_mara.

data: lt_list type STANDARD TABLE OF ty_list,

ls_list like LINE OF lt_list.

START-of-SELECTION.

ls_mara-SIGN = 'I'.

ls_mara-option = 'EQ'.

ls_mara-matnr_low = '000000000000000088'. "'P1001087'.

ls_mara-matnr_high = ''.

APPEND ls_list to lt_mara.

ls_mara-SIGN = 'I'.

ls_mara-option = 'EQ'.

ls_mara-matnr_low = '000000000000000089'. "'P1001087'.

ls_mara-matnr_high = ''.

APPEND ls_list to lt_mara.

CALL FUNCTION 'BAPI_MATERIAL_GETLIST'

TABLES

MATNRSELECTION = lt_mara

MATNRLIST = lt_list[] .

WRITE / 'output: '.

LOOP AT lt_list into ls_list .

write: ls_list .

ENDLOOP.

Former Member
0 Kudos

Done