on 07-08-2009 1:37 PM
Hi all ..can anybody plz tell how to use JCo through WebService Navigator ?
I want to call BAPI through JCO code in EJB perspective to create a WebService Model,so as to acess fast the BAPIs result from R3,etc...
Waiting for reply..
Regards:
Hanif
closing
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Refer this link to create JCO connections and get the values from the FM to your ejb.
http://www.apentia-forum.de/viewtopic.php?t=1962&sid=9ac1506bdb153c14edaf891300bfde25
https://wiki.sdn.sap.com/wiki/display/Snippets/AutomatedBackupMonitoringSystem-ImplementingJCobasedapplications.
Refer this link to expose your ejb as a web service.
https://wiki.sdn.sap.com/wiki/display/Java/ExcelcreationusingApachePOIAPIsinEJBandexposingitasweb+service.
Best Wishes
Idhaya R
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Please use the below sample Standalone program
Hi,
Use this sample standalone program and convert it to your EJB.
package SalesOrderJCO;
import java.math.BigDecimal;
import java.sql.Date;
import java.sql.Time;
import java.util.Calendar;
import java.util.StringTokenizer;
import com.sap.mw.jco.IFunctionTemplate;
import com.sap.mw.jco.IRepository;
import com.sap.mw.jco.JCO;
import com.sap.mw.jco.JCO.Function;
import com.sap.mw.jco.JCO.ParameterList;
import com.sap.mw.jco.JCO.Structure;
import com.sap.mw.jco.JCO.Table;
// method starting
Time t = new Time(1);
System.out.println("Time:"+t);
JCO.Client objClient = null;
IRepository objIRepository = null;
objClient = JCO.createClient("800","SAPUSER","india123","EN","sapserver","01");
objClient.connect();
objIRepository = JCO.createRepository("myrep",objClient);
IFunctionTemplate objFunctionTemplate = objIRepository.getFunctionTemplate("BAPI_SALESORDER_CREATEFROMDAT2");
Function objFunction = objFunctionTemplate.getFunction();
ParameterList objImpParameterList = objFunction.getImportParameterList();
Structure objHeaderStructure =objImpParameterList.getStructure("ORDER_HEADER_IN");
ParameterList objParameterList = objFunction.getTableParameterList();
Table objItemsTable = objParameterList.getTable("ORDER_ITEMS_IN");
Table objPartnersTable = objParameterList.getTable("ORDER_PARTNERS");
Table objOrderSchedulesTable = objParameterList.getTable("ORDER_SCHEDULES_IN");
objHeaderStructure.setValue("","DOCTYPE");
objHeaderStructure.setValue("","SALES_ORG");
objHeaderStructure.setValue("","DISTR_CHAN");
objHeaderStructure.setValue("","DIVISION");
objHeaderStructure.setValue("","PMNTTRMS");
objHeaderStructure.setValue("","INCOTERMS1");
objHeaderStructure.setValue("","INCOTERMS2");
objHeaderStructure.setValue("","ORD_REASON");
objHeaderStructure.setValue("","PURCH_NO_C");
objItemsTable.appendRow();
objItemsTable.setValue("00010","ITM_NUMBER");
objItemsTable.setValue("PK-100","MATERIAL");
objItemsTable.setValue("1000","PLANT");
objItemsTable.setValue("ST","SALES_UNIT");
objOrderSchedulesTable.appendRow();
objOrderSchedulesTable.setValue("00010","ITM_NUMBER");
String ReqQuty = "10";
BigDecimal reqqty = new BigDecimal(ReqQuty.trim());
objOrderSchedulesTable.setValue(reqqty,"REQ_QTY");
Date reqdate = getDate("29.07.2008");
objOrderSchedulesTable.setValue(reqdate,"REQ_DATE");
Regards,
Jaya.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Continuing the code..........
objPartnersTable.appendRow();
objPartnersTable.setValue("CASHMAN","PARTN_ROLE");
objPartnersTable.setValue("123","PARTN_NUMB");
objPartnersTable.setValue("00010","ITM_NUMBER");
//method end
private static Date getDate(String date)
{
java.sql.Date sqlDate = null;
try
{
StringTokenizer st = new StringTokenizer(date, ".");
String strdate = st.nextToken();
String strmonth = st.nextToken();
String stryear = st.nextToken();
int intdate = Integer.parseInt(strdate);
int intmonth = Integer.parseInt(strmonth);
int intyear = Integer.parseInt(stryear);
Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR, intyear);
cal.set(Calendar.MONTH, intmonth - 1);
cal.set(Calendar.DATE, intdate);
long l = cal.getTimeInMillis();
sqlDate = new java.sql.Date(l);
}
catch (Exception e)
{
return null;
}
return sqlDate;
}
}
Regards,
Jaya
Hi jaya i am using the below code to acess the data from BAPI_SALESORDER_GETSTATUS through JCo connection and displaying it through wsnavigator...<br>
But after deploying i am getting error i.e..excetion in JCo......<br>
Kindly confirm me were i am going wrong...in the below EJB method....<br>
public String[] getJCObapi() <br>
{ <br>
String[] JcoBapi = null;<br>
ArrayList arrayval=new ArrayList();<br>
String SID = "JCObapiWS"; //system ID used throughout the example <br>
com.sap.mw.jco.IRepository rep = null; //the repository we gonna be using<br>
JCO.Client mc = null;<br>
try<br>
{ <br>
//Add a connection pool for the specified system<br>
JCO.addClientPool ( SID , //alias for this pool <br>
, //max. number of connections<br>
"***" , //SAP client<br>
"****" , //userid<br>
"****" , //password <br>
"**" , //language<br>
"*****" , //host name<br>
"**" //system number<br>
); <br>
rep = com.sap.mw.jco.JCO.createRepository("mrep", SID); <br>
}<br>
catch(JCO.Exception ex) <br>
{<br>
ex.printStackTrace();<br>
}<br>
try<br>
{<br>
IFunctionTemplate ft = rep.getFunctionTemplate("BAPI_SALESORDER_GETSTATUS");<br>
JCO.Function function = ft.getFunction();<br>
mc = JCO.getClient(SID); // Get a client from the pool <br>
JCO.ParameterList input = function.getImportParameterList();<br>
input.setValue("0*******", "SALESDOCUMENT");<br>
mc.execute(function);<br>
JCO.Structure ret = function.getExportParameterList().getStructure("RETURN"); <br>
// Print return message<br>
// Get table containing the orders<br>
JCO.Table STATUSINFO = function.getTableParameterList().getTable("STATUSINFO");<br>
// Print results<br>
if (STATUSINFO.getNumRows() > 0) <br>
{<br>
do <br>
{ <br>
// Loop over all columns in the current row<br>
for (JCO.FieldIterator e = STATUSINFO.fields(); e.hasMoreElements(); )<br>
{<br>
JCO.Field field = e.nextField();<br>
JcoBapi = new String[6];<br>
JcoBapi[0] = field.getString();<br>
}<br>
} while(STATUSINFO.nextRow());<br>
}<br>
}<br>
catch (Exception ex)<br>
{<br>
ex.printStackTrace();<br>
}<br>
// Releasing AND Removing JCO.Client Object of JCO CLIENT POOL<br>
JCO.releaseClient(mc);<br>
JCO.removeClientPool(SID);<br>
return JcoBapi;<br>
}<br>
Edited by: Shaikh Hanif on Jul 9, 2009 8:35 AM
Edited by: Shaikh Hanif on Jul 9, 2009 8:44 AM
User | Count |
---|---|
95 | |
11 | |
11 | |
10 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.