cancel
Showing results for 
Search instead for 
Did you mean: 

SAP BAPI access using JAVA ( BAPI - OpenInfoWarehouse)

Former Member
0 Kudos

Hi,

please help me i want to access the sap standrad table data from java using Jco and transfer to MySQL database then how can i do that. I already tried BAPI but i don't know how to create BAPI in SAP system by using java program.

So i tried for BAPI OpenInfoWarehouse but I don't know how to use this BAPI that is how to give Import parameter for GetData() method and how to extract data.

Please help me

U can send me mail also : sandy.24065@gmail.com

Thanku in advance

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

use SAP JCo

http://service.sap.com/connectors.

after you install NWDS, you should have the files in your system.

· sapjco.jar

· librfc32.dll

· sapjcorfc.dll

this is an example:

public class Example1 {

public static void main(String[] argv)

{

JCO.Client client = null;

try {

// Print the version of the underlying JCO library

System.out.println("

Version of the JCO-library:

" +

"----

-


" + JCO.getMiddlewareVersion());

// Create a client connection to a dedicated R/3 system

client = JCO.createClient( "400", // SAP client

"tomfu", // userid

"hellotom", // password

"EN", // language

"10.56.91.121", // host name

"05" ); // system number

// Open the connection

client.connect();

// Get the attributes of the connection and print them

JCO.Attributes attributes = client.getAttributes();

System.out.println("Connection attributes:

" +

"----

-


" + attributes);

boolean is_backend_unicode = attributes.getPartnerCodepage().equals("4102") ||

attributes.getPartnerCodepage().equals("4103");

// Create metadata definition of the input parameter list

JCO.MetaData input_md = new JCO.MetaData("INPUT");

input_md.addInfo("REQUTEXT", JCO.TYPE_CHAR, 255, 255 * (is_backend_unicode? 2 : 1 ),

-1, 0, null, null, 0, null, null);

// Create the input parameter list from the metadata object

JCO.ParameterList input = JCO.createParameterList(input_md);

// Set the first (and only) input parameter

input.setValue("This is my first JCo example.", "REQUTEXT");

// Create metadata definition of the output parameter list

JCO.MetaData output_md = new JCO.MetaData("OUTPUT");

// Specify the parameters types of the function will be returned

output_md.addInfo("ECHOTEXT", JCO.TYPE_CHAR, 255, 255 * (is_backend_unicode? 2 : 1 ),

-1, 0, null, null, 0, null, null);

output_md.addInfo("RESPTEXT", JCO.TYPE_CHAR, 255, 255 * (is_backend_unicode? 2 : 1 ),

-1, 0, null, null, 0, null, null);

// Create the output parameter list from the metadata object

JCO.ParameterList output = JCO.createParameterList(output_md);

// Call the function

client.execute("STFC_CONNECTION", input, output);

// Print the result

System.out.println("The function 'STFC_CONNECTION' returned the following parameters:

" +

"----

-


");

for (int i = 0; i < output.getFieldCount(); i++) {

System.out.println("Name: " + output.getName(i) + " Value: " + output.getString(i));

}//for

// All done

System.out.println("

Congratulations! It worked.");

}

catch (Exception ex) {

System.out.println("Caught an exception:

" + ex);

}

finally {

// do not forget to close the client connection

if (client != null) client.disconnect();

}

}

}

Answers (0)