JCO-BAPI
HI,
I am trying to retrieve the customer master information by using JCO from BAPI call.
Interface between JAVA-JCo-BAPI. (Source JAVA - Target BAPI) . As per my understanding , i need to create BAPI ,Create API...
So 1. what are the things need to give to java person inorder to establish the connection.
2. Where do i instal JCo (in sap system or Java system )
3. Shall i need to provide .jar files, if yes, how can i get those ?
Please answer the above questions....
Are you retrieving this information from within a mapping?
SAP has brought out the mapping api for lookups which replaces the jco calls.
I would suggest you have a look at this document and see if your scenario can be altered to this.
https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/a03e7b02-eea4-2910-089f-8214c6d1b439
Similar Messages
-
JCo BAPI authorization question
We are developing web applications using Jco connector.
The default authentication approach is to use connection pooling where all different users access BAPI via default (generic) user name and password.
My question is how to authenticate current (specific) user whether he has valid permission rights for some particular transaction, because for SAP-BAPI they are all the
same user (they are establishing connection with the same user name and password.)
Are there some BAPIs for checking user permission for some transaction?
Example code are very welcome
Thanks
MarinoI believe there are BAPIs under the category security/user that will provide you with details of the user and you can always of course build your own authentication scheme on the java side based on what's on the R/3 side, but to be honest I would suggest not using a generic user if you wish to keep the current authorization structure in R/3. The R/3 structure for authorization is a maze of objects and tables - virtually a skill in itself, there are people who make a living on it and it is a constant headache on every R/3 installation and enrvironment causing many issues.
I would recommend to simply use the current logged on user details and log on to the backend. If your user is not authorized you will get an exception from JCo that you can handle in your application. Believe me, it would be a lot simpler than anything else you could implement to achieve your objective.
Cheers,
Dion -
Authentication Web Services for Java applications
Hi All,
We are building Java based SAP applications for mobile devices such as Blackberry, iPhone etc. The applications are browser based (thin client) to be deployed on SAP Netweaver WAS and would interface with SAP backends such as SAP ECC, SAP BW using SAP Web Services (converted from BAPIs).
For certain reasons we do not want to use Mobile Webdynpro Java using JCO/BAPIs as we would be using a Java based middleware which is built in-house for rendering on multiple devices and it does not go well with Mobile Webdynpro with Java. We are NOT using SAP Enterprise Portal as well.
What I would like to know is are there any standard Authentication Web Services that can be used to authenticate the user, when he tries to login to the application through the mobile browser. Also does SAP Netweaver WAS provide authentication mechanism for a Java based web application by default.
Any pointers would be appreciated and thanks in advance for the same.
SureshHi All,
We are building Java based SAP applications for mobile devices such as Blackberry, iPhone etc. The applications are browser based (thin client) to be deployed on SAP Netweaver WAS and would interface with SAP backends such as SAP ECC, SAP BW using SAP Web Services (converted from BAPIs).
For certain reasons we do not want to use Mobile Webdynpro Java using JCO/BAPIs as we would be using a Java based middleware which is built in-house for rendering on multiple devices and it does not go well with Mobile Webdynpro with Java. We are NOT using SAP Enterprise Portal as well.
What I would like to know is are there any standard Authentication Web Services that can be used to authenticate the user, when he tries to login to the application through the mobile browser. Also does SAP Netweaver WAS provide authentication mechanism for a Java based web application by default.
Any pointers would be appreciated and thanks in advance for the same.
Suresh -
How to retrieve all BAPIs through JCo
Hi All,
i'm currently using JCo to access an SAP server, and just wondering if there's a method to retrieve all BAPIs from the server. From the available online documents, i can only see methods that returns a specific BAPI with a given function name.
If we can't get all BAPIs through JCo, whether there're some system BAPIs that i can call on to process the searching? just like sys procedure in database's context.
Any helps are highly appreciated. ThanksWell, the Repository seems to only expose methods like
getFunctionInterface() & queryFunctionInterface(), both of which certainly don't serve my needs.
The reason why i expect JCo has such built-in "retrieving all func names" services is because i saw some tooling applications, purely written in Java, developed navigator to display all BAPIs of a SAP. I mean it could be some button say "search all BAPIs", and when the user gestures to hit that button, it just populates all BAPIs returned from server.
While since i can't find such methods from the JCO doc, does it mean it can't be achieved through JCo? -
Error while calling BAPI_PARTNEREMPLOYEE_CREATE BAPI using JCO
Hi All,
Our requirement is to create and update customer contact details from java application. For this purpose we are trying to call BAPI_PARTNEREMPLOYEE_CREATE BAPI for create contact and BAPI_PARTNEREMPLOYEE_EDIT for updating contact information. As these BAPIs are of online version, error is coming while calling these BAPIs.
So is there any way to call these BAPIs through JCO or are there any alternative BAPIs available for same purpose?
Thanks in advance,
Arati.Hi,
All the bapi or function module available in SAP to create contact person will internally do a call transaction to VAP1 and VAP2 tcodes in order to create or change contact person respectively.
We had a similar problem when we were creating and updating customer contact person using inbound idoc. We then created a bdc recording for the same and then created two function module with name Z_CREATE_CONTACT and Z_CHANGE_CONTACT. In your case you can make this function modules as RFC enabled FM and call them using JCO I guess.
KR Jaideep, -
Hi all,
Please share your views on the below scenario:
A WD Java app, deployed on WAS and an iView created in portal, is calling a BAPI and works fine when assigned to the role.
Now the same application when viewed directly using
http://<host>:<port>/webdynpro/dispatcher/local/<appname> does not execute the bapi and gives
com.sap.tc.webdynpro.modelimpl.dynamicrfc.WDDynamicRFCExecuteException: Error connecting using JCO.Client: null
The JCO are using a service user to connect to the backend, so SSO still exist.
Let me know what we could be doing wrong here.
Meanwhile I can check the connection pool to see the property value.
Thanks for your time
AvinashHi Prashant
Thanks for your quick response.
The application when accessed directly does not ask for user id/password.
If I set the application property 'authentication' as true, would this authentication be done against UME?
Also since there is no "SSO using logon tickets" why is there a need for issuing a logon ticket?
I will try what you suggested in the earlier post.
Thanks
Avinash -
Error in Connecting to BAPI (Error connecting using JCO.Client: null)
Hi,
I am trying to connect to a BAPI to extract data. However, I am getting this error
Error connecting using JCO.Client: null
Pls explain the meaning of the error and solution to the problem
TIA
HimanshuHi,
This means you are getting error while executing your model. its not able to use the JCO's.
as I asked previously check your JCO status... its up and running????
Here are some threads having same problem
URGENT :Error connecting using JCO.Client: null
Model and MetaData configarations in JCO Connection
Exception while executing
PradeeP
Edited by: pradeep bondla on Jul 31, 2008 11:53 AM -
Hi,
I am trying to access an BAPI which has an Import parameter as an Table "ORDERDATA". So i need to form the Table with the values entered in the textboxes in Portal to send the Import input Table while calling a BAPI.
Can someone help me out to Create an Table "Ord_Table" with 5 fields or more so that i can pass it as an import to the function module?
JCO.Function function = repository.getFunctionTemplate("Z_ORDER_CREATE").getFunction();
JCO.ParameterList input = function.getImportParameterList();
input.setValue(<b>Ord_Table</b> , "ORDERDATA");
client = JCO.getClient(SID);
client.execute(function);
JCO.Structure ret=function.getExportParameterList().getStructure("RETURN");
System.out.println("RETURN MESSAGE: " + ret.getString("MESSAGE"));
JCO.Table code=function.getTableParameterList().getTable("STATUS");
Thank you
arunHey Arun,
Tables are not quite treated the in the same manner that inputFields are. Check it out:
JCO.ParameterList importList = function.getImportParameterList();
// set import field and table
importList.setValue(myVariable, "SOME_SAP_ INPUT_FIELD");
// retrieve JCO.Table structure from backend
JCO.Table newDataTable = function.getTableParameterList().getTable("ORDERDATA");
// append data to Table
newDataTable.appendRow();
// these are the column names of the 'import' table
newDataTable.setValue(myVar1, "ORDERDATA_COLUMN_1");
newDataTable.setValue(myVar2, "ORDERDATA_COLUMN_2");
newDataTable.setValue(myVar5, "ORDERDATE_COLUMN_5");
// call the function module
client.execute(function);
Hopefully that helps,
Mike
P.S. if you are dev'ing for EP6.0 you should be using the JCA instead of the JCo. -
Hello guys,
I have an scenario R3 -> XI -> R3.
From the first R/3 we call a function in a program to execute a BAPI in the second R/3, so the BAPI doesn't exist in the R/3 that starts the interface.
We have configured the TCP/IP connection and with the same program ID in the Sender RFC adapter. All the connectios are running successfully but when we execute the program we have the error:
JCO.Server could not find server function 'Z_TEST'
Do you know if the BAPI has to be created in both systems, or it's only necessary in the R/3 destination to run.
All connections are running so the question is what we remarked before, the BAPI must be created in both R/3 systems?
Regards,
Xavier.Hi Xavier,
strange, i answered to a very similar question a hour before, there was no reaction by Gerardo Mondragon .
How can the sender adapter get the metadata? If the FM is just in the receiver system? Maintain the meta data connection at Communication Channel to the receiver system...
Regards,
Udo -
How can I retrieve a List of BAPIs with JCO?
Hello!
I want to retrieve a list of BAPIs in Java. Does anyone have a code sample how to do this with JCO and SWO_QUERY_API_METHODS?
Regards,
JanHi Diana,
I've written a small example here (refresh my rusty JCo!) which returns just the function names in a Vector.
Hope this helps,
Gregor
* Fetch a list of BAPIs
* @author Gregor Brett
import com.sap.mw.jco.*;
import java.util.*;
public class GetBapis
private JCO.Client client;
private JCO.Repository repository;
private Vector bapis;
public GetBapis()
try
client = JCO.createClient("CLIENT","USERNAME","PASSWORD","EN","SERVERNAME","00");
client.connect();
repository = new JCO.Repository("Gregor", client);
IFunctionTemplate ftemplate = repository.getFunctionTemplate("SWO_QUERY_API_METHODS");
JCO.Function function = ftemplate.getFunction();
client.execute(function);
JCO.Table table = function.getTableParameterList().getTable("API_METHODS");
bapis = new Vector();
do
JCO.Field functionName = table.getField("FUNCTION");
bapis.add(functionName.getString());
while(table.nextRow());
catch(Exception e)
System.out.println("Error: " + e.getMessage());
e.printStackTrace();
public Vector getBapiList()
return bapis;
public static void main(String[] args)
GetBapis gb = new GetBapis();
Vector v = gb.getBapiList();
System.out.println("Fetched " + v.size() + " BAPIs."); -
Standard BAPI for creating groups in SAP using JAVA and JCO
Hi,
I have a requirement for creating user groups in SAP from java using JCO but i am unable to find the standard BAPI name to creating user groups.
Can anyone let me know whats the bapi name for creating user groups in SAP?
Thanks in advance,
AniHi,
I think you can search for it or you can create a thread at ABAP section. -
Create a new routing with BAPI BAPI_ROUTING_CREATE via JCo
I try to create a new routing with BAPI BAPI_ROUTING_CREATE via JCo.
I filled all necessary parameters. I also realized a commit_work. I get in the RETURN parameter of the BAPI the Message "S 000 Routing N/50001641/01". But the routing isn't in the database. Other JCo programs I wrote (create material master or costumer order) are working very well.
Have anyone an idea?
Thanks Jörg
Here's my coding:
public void createArbeitsplan() {
doLogin();
// connectionAttributes();
Plan plan = new Plan();
for (int i = 0; i < planList.size(); i++)
plan = (Plan) planList.get(i);
//Ein Function-Objekt erzeugen
String bapi = "BAPI_ROUTING_CREATE";
JCO.Function savePlan = null;
try { savePlan = this.createFunction(bapi); }
catch(Exception ex) { ex.printStackTrace(); System.exit(1); }
if(savePlan == null) { System.err.println(bapi + " not found in SAP"); System.exit(1); }
//Import und Tabellen füllen
// Plankopf
JCO.Table headData = savePlan.getTableParameterList().getTable("TASK");
headData.appendRow();
headData.setValue(plan.kurztext,"DESCRIPTION");
headData.setValue("1","TASK_LIST_USAGE");
headData.setValue(werks,"PLANT");
headData.setValue("4","TASK_LIST_STATUS");
headData.setValue("ST","TASK_MEASURE_UNIT");
headData.setValue("001","RESP_PLANNER_GROUP");
headData.setValue("20070101","VALID_FROM");
headData.setValue("20991231","VALID_TO_DATE");
headData.setValue("1","LOT_SIZE_FROM");
headData.setValue("99999999","LOT_SIZE_TO");
// Materialzuordnung
JCO.Table materialAlloc = savePlan.getTableParameterList().getTable("MATERIALTASKALLOCATION");
materialAlloc.appendRow();
materialAlloc.setValue(plan.material,"MATERIAL");
materialAlloc.setValue(werks,"PLANT");
materialAlloc.setValue("20070101","VALID_FROM");
materialAlloc.setValue("20991231","VALID_TO_DATE");
materialAlloc.setValue("1","GROUP_COUNTER");
// Vorgänge
JCO.Table operationData = savePlan.getTableParameterList().getTable("OPERATION");
for (int j = 0; j < plan.getAnzahl(); j++) {
operationData.appendRow();
operationData.setValue(plan.getVorgang(j).vorgang,"ACTIVITY");
operationData.setValue(plan.getVorgang(j).steuschl,"CONTROL_KEY");
operationData.setValue(plan.getVorgang(j).arbplatz,"WORK_CNTR");
operationData.setValue("1111","WORK_CNTR");
operationData.setValue(plan.getVorgang(j).text,"DESCRIPTION");
operationData.setValue(plan.getVorgang(j).basismenge,"BASE_QUANTITY");
operationData.setValue(plan.getVorgang(j).vw1,"STD_VALUE_01");
operationData.setValue(plan.getVorgang(j).vw2,"STD_VALUE_02");
operationData.setValue(plan.getVorgang(j).vw3,"STD_VALUE_03");
operationData.setValue(plan.getVorgang(j).ze1,"STD_UNIT_01");
operationData.setValue(plan.getVorgang(j).ze2,"STD_UNIT_02");
operationData.setValue(plan.getVorgang(j).ze3,"STD_UNIT_03");
operationData.setValue("1","DENOMINATOR");
operationData.setValue("1","NOMINATOR");
operationData.setValue("20070101","VALID_FROM");
operationData.setValue("20991231","VALID_TO_DATE");
operationData.setValue("ST","OPERATION_MEASURE_UNIT");
// Testflag
JCO.Structure test = savePlan.getImportParameterList().getStructure("TESTRUN");
test.setValue(" ","BAPIFLAG");
//BAPI ausführen (incl. Commit)
mConnection.execute(savePlan);
JCO.Function commit = null;
try {commit = this.createFunction("BAPI_TRANSACTION_COMMIT"); }
catch (Exception ex) { ex.printStackTrace();System.exit(1); }
JCO.ParameterList input = commit.getImportParameterList();
input.setValue("X","WAIT");
mConnection.execute(commit);
//Messages vom SAP-System holen
JCO.Table jcoReturn = savePlan.getTableParameterList().getTable("RETURN");
for (int k = 0; k < jcoReturn.getNumRows(); k++)
jcoReturn.setRow(i);
// System.out.println(jcoReturn.getField("MESSAGE").getValue());
System.out.println(jcoReturn.getField("TYPE").getValue());
System.out.println(jcoReturn.getField("NUMBER").getValue());
System.out.println(jcoReturn.getField("MESSAGE_V1").getValue());
System.out.println(jcoReturn.getField("MESSAGE_V2").getValue());
System.out.println(jcoReturn.getField("MESSAGE_V3").getValue());
System.out.println(jcoReturn.getField("MESSAGE_V4").getValue());
JCO.Structure output = commit.getExportParameterList().getStructure("RETURN");;
System.out.println(output.getString("MESSAGE"));
System.out.println(output.getString("TYPE"));
System.out.println(output.getString("NUMBER"));
System.out.println(output.getString("MESSAGE_V1"));
closeConnectionToSAP();
System.exit(1);Hi,
perhaps you could use
BAPI_HRMASTER_SAVE_REPL_MULT
Regards
Bernd -
BAPI Transaction commit in JCo
Hi,
I am posting a GL document via JCo (Java Program ) into SAP using the BAPI_ACC_DOCUMENT_POST and then calling the BAPI_TRANSACTION_COMMIT to commit the transaction so that it gets updated in SAP system.
After i execute my program, i get the posting successful message and document number is returned to me. But when i look for this document in the SAP system, it is not found.
Any help will be appreciated.
Below is the piece of code where i execute the BAPI's in java after mapping the required data.
function.execute(destination);
System.out.println("Function BAPI_ACC_DOCUMENT_POST executed .");
commFunct.getImportParameterList().setValue("WAIT", "10");
commFunct.execute(destination);
System.out.println("Function BAPI_TRANSACTION_COMMIT executed .");
Regards,
Ganesh.Hi Ganesh,
With JCo3 the connections are no longer stateful by default, so each RFC call is executed within it's own context. In your case though, you want the commit to occur in the same context where you posted the document. You can do this by adding the following static method calls:
JCoContext.begin(destination);
// Execute both RFC functions here
JCoContext.end(destination);
You can also check the Java API help for JCoContext, which explains this in more detail. Once you added the two lines (ideally end the context in a finally block), you should see the document in SAP.
Cheers, harald -
Hello everybody,
I have an application which a call a BAPI in an ECC System. This BAPI is a specific one, and it is developed in Batch input to create a Billing document from a sales order.
This call take too much time and my java program don't wait for the answer of it. I have done some performance check on the program and this call take more of 1 minutes to finish.
Here is my program :
//-Fill the entry parameter-
//Import parameter
paramImport = function.getImportParameterList();
paramImport.setValue(SalesOrder, Constants.IV_VBELN);
//Define Export parameter list for the returning Data
paramExport = function.getExportParameterList();
//Execute the BAPI
client.execute(function.getName(), paramImport, paramExport);
The fact it is developped in Batch input could be a problem ? Tell me if there is a solution to speed up the process or to say to my java program to wait until the answer of the BAPI.
Thanks.Hello Sir,
I am a student who is pursuing a project that deals with JCo 3.
I read your question on the forum and think that you have done the JCo stuff and can answer my questions.
Kindly, try to shed some light on following question:
Q1: I simply want to start with connecting my SAP system. I have a user ID and password for the same.
I saw some examples where they use "JCo.createClient(....)" and "JCo.client.connect()" to simply connect the client but
when I type in the code it shows me an error, because they are using package "com.sap.mw.jco" but since I am using JCo3,
I don't have that package instead I have "com.sap.conn.jco" which do not have createClient function.
Q2: By setting the classpath for "sapjco.jar" I was able to compile one of the sample programs but could not run it. Do you
know how to run the SAP JCo program.
Your guidance will be highly appreciated
-Thanks
-Dmukhi -
hi guys,
i am using bapi via jco
i am retrieving data,appending data on standard funtional modules , ok, fine
how can i insert data into custom tables using bapi via jco...
plz give me some steps...............
thanks,
tonyHi,
Just to clarify (again) as far as I know yuo cannot directly access SAP tables via JCo calls from Java. JCo only allows you to call function modules on teh SAP system. Any database interaction (Select, Insert, etc.) has to be coded in ABAP inside the function module. You then call the function module (which must be RFC enabled) via JCo in your Java.
You can use standard function modules or you can create custom function modules if you need to acces custom tables or perform custom logic.
Hope this helps,
Gareth.
Maybe you are looking for
-
E-Mail Array - Showing Up As Blank.
Hey Again.. So I'm now trying to e-mail a log of some script actions, which include an array of data that was processed, however it seems that while I can display the data with a write-host command, I cannot e-mail it? In this one I am trying to load
-
Result set too large in BI report; Safety belt settings in WAD
Hello All, When we run a BI report, the error " Result set is too large; data retrieval restricted by configuration" appears. We did a search on SAP portal and found the SAP note 1127156, whics recommends the configuaration of safety belt to limit me
-
Hey there, Apple Support Communities. To start, I'm working on a MBP Retina 15" with a 2.3GHz i7 processor and 16 GB of RAM. 10GB free on a 256GB SS HD. Attached are two external HDs - one 1TB Western Digital portable drive from 2011, one 2TB Porsc
-
Question on best approach to create sales orders in R3
Hi We have a scenario wherein XI should read data for sales orders from a SQL server DB and then map this information onto an IDOC and post to R3. Now, there is some information needed to fill in some segments of the idoc - that has to be looked u
-
How do I find out what my online number is? I have...
how do I find out what my online number is? I have skype-pro