Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

BAPI programing

Former Member
0 Likes
782

Hi All,

Please let me know what the topics of java like Core Java, JSP or Servlets that are used in BAPI programing.

Thanks in advance,

Sriram.

Message was edited by: Sriram Ponna

Message was edited by: Sriram Ponna

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
760

Hello,

There are something called as JCO Function Calls that can be used from java to call BAPI or rfc.

<a href="http://www.huihoo.org/openweb/jco_api/com/sap/mw/jco/JCO.Function.html">Class Documentation</a>

<a href="http://www.sapdevelopment.co.uk/java/jco/jco_callfunc.htm">Java Program</a>

Hope this information is useful.

Regards,

Shekhar Kulkarni

6 REPLIES 6
Read only

Former Member
0 Likes
761

Hello,

There are something called as JCO Function Calls that can be used from java to call BAPI or rfc.

<a href="http://www.huihoo.org/openweb/jco_api/com/sap/mw/jco/JCO.Function.html">Class Documentation</a>

<a href="http://www.sapdevelopment.co.uk/java/jco/jco_callfunc.htm">Java Program</a>

Hope this information is useful.

Regards,

Shekhar Kulkarni

Read only

0 Likes
760

Correct... Java apps can call BAPI objects in SAP systems. But BAPI objects are built using SAP's own language - ABAP/4.

Read only

0 Likes
760

Hi John,

What i need is, in java programing what are the topics that are used in java programming like Core Java, JSP or Servlets.

Thanks,

Sriram.

Read only

0 Likes
760

<deleted>

Read only

0 Likes
760

hi here is the sample code..

it depends on your application ..(basic application need only core java) but you want to see the output in web then you need jsp or servelets.

import com.sap.mw.jco.*;

/**

  • @author Thomas G. Schuessler, ARAsoft GmbH

*/

public class TutorialBapi2 extends Object {

JCO.Client mConnection;

JCO.Repository mRepository;

public TutorialBapi2() {

try {

// Change the logon information to your own system/user

mConnection =

JCO.createClient("001", // SAP client

"<userid>", // userid

"****", // password

null, // language

"<hostname>", // application server host name

"00"); // system number

mConnection.connect();

mRepository = new JCO.Repository("ARAsoft", mConnection);

}

catch (Exception ex) {

ex.printStackTrace();

System.exit(1);

}

JCO.Function function = null;

JCO.Table codes = null;

try {

function = this.createFunction("BAPI_COMPANYCODE_GETLIST");

if (function == null) {

System.out.println("BAPI_COMPANYCODE_GETLIST" +

" not found in SAP.");

System.exit(1);

}

mConnection.execute(function);

JCO.Structure returnStructure =

function.getExportParameterList().getStructure("RETURN");

if (! (returnStructure.getString("TYPE").equals("") ||

returnStructure.getString("TYPE").equals("S")) ) {

System.out.println(returnStructure.getString("MESSAGE"));

System.exit(1);

}

codes =

function.getTableParameterList().getTable("COMPANYCODE_LIST");

codes.setRow(2);

codes.deleteRow();

codes.deleteRow(5);

codes.appendRow();

codes.setValue("XXXX", "COMP_CODE");

codes.setValue("Does not exist", "COMP_NAME");

codes.appendRows(2);

codes.setValue("YYYY", "COMP_CODE");

codes.setValue("Does not exist either", "COMP_NAME");

codes.nextRow();

codes.setValue("ZZZZ", "COMP_CODE");

codes.setValue("Nor does this", "COMP_NAME");

for (int i = 0; i < codes.getNumRows(); i++) {

codes.setRow(i);

System.out.println(codes.getString("COMP_CODE") + '\t' +

codes.getString("COMP_NAME"));

}

}

catch (Exception ex) {

ex.printStackTrace();

System.exit(1);

}

try {

codes.firstRow();

for (int i = 0; i < codes.getNumRows(); i++, codes.nextRow()) {

function = this.createFunction("BAPI_COMPANYCODE_GETDETAIL");

if (function == null) {

System.out.println("BAPI_COMPANYCODE_GETDETAIL" +

" not found in SAP.");

System.exit(1);

}

function.getImportParameterList().

setValue(codes.getString("COMP_CODE"), "COMPANYCODEID");

mConnection.execute(function);

JCO.Structure returnStructure =

function.getExportParameterList().getStructure("RETURN");

if (! (returnStructure.getString("TYPE").equals("") ||

returnStructure.getString("TYPE").equals("S") ||

returnStructure.getString("TYPE").equals("W")) ) {

System.out.println(returnStructure.getString("MESSAGE"));

}

JCO.Structure detail =

function.getExportParameterList().

getStructure("COMPANYCODE_DETAIL");

System.out.println(detail.getString("COMP_CODE") + '\t' +

detail.getString("COUNTRY") + '\t' +

detail.getString("CITY"));

}

}

catch (Exception ex) {

ex.printStackTrace();

System.exit(1);

}

mConnection.disconnect();

}

public JCO.Function createFunction(String name) throws Exception {

try {

IFunctionTemplate ft = mRepository.getFunctionTemplate(name.toUpperCase());

if (ft == null)

return null;

return ft.getFunction();

}

catch (Exception ex) {

throw new Exception("Problem retrieving JCO.Function object.");

}

}

public static void main (String args[]) {

TutorialBapi2 app = new TutorialBapi2();

}

}

regards

vijay

Read only

0 Likes
760

HI Sriram

You can write a BAPI using just Core JAVA,

BAPI's are Nothing but a RFC Which has certain Business Functionality....

By RFC I mean--Remote Enabled Function Module...

And for Writing an RFC you just need to have the BASIC PROGRAMMING Knowledge (Core JAVA)...

Cheers:-)

Mithlesh