Use of JCo

Hello Everyone,
                       I m developing one portal application using NWDS. This application connects to backend SAP R/3 system & fetches the data in some table. i have decided to use JCo to connect to R/3 system. But in my code it gives me error at the import statement "import com.sap.mw.jco.JCO;". so my question is , Are there any configurations or any .JAR files need to be added for using JCo while developing portal application through NWDS?
Thanks,
Chetan

hi
try like that
import com.sap.mw.jco.IFunctionTemplate;
import com.sap.mw.jco.JCO;
import com.sapportals.htmlb.InputField;
import com.sapportals.htmlb.event.Event;
import com.sapportals.htmlb.event.TableNavigationEvent;
import com.sapportals.htmlb.page.DynPage;
import com.sapportals.htmlb.page.PageException;
import com.sapportals.portal.htmlb.page.JSPDynPage;
import com.sapportals.portal.htmlb.page.PageProcessorComponent;
import com.sapportals.portal.prt.component.IPortalComponentContext;
import com.sapportals.portal.prt.component.IPortalComponentProfile;
import com.sapportals.portal.prt.component.IPortalComponentRequest;
public class TableApp extends PageProcessorComponent {
      public DynPage getPage(){
              return new TableAppDynPage();
    public static JCO.Client mConnection;
    public static class TableAppDynPage extends JSPDynPage{
          private TableBean myTableBean = null;
          private int visibleRow = 1;
          int flag=0;
          String inf1,inf2;
          public static JCO.Client mConnection = null;
          public static JCO.Repository mRepository = null;
          public static JCO.Function function = null;
          private String name1,name2;
         public void doInitialization(){
                IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();
                IPortalComponentContext myContext = request.getComponentContext();
                myTableBean = new TableBean();
                myContext.putValue("myTableBean", myTableBean);
                mConnection = JCO.createClient("200",
                                                     "jbabu",
                                                     "sy5tech!",
                                                     "EN",
                                                     "10.5.5.33",
                                                     "00");
               mConnection.connect();
               mRepository = new JCO.Repository("myRep",mConnection);
               IFunctionTemplate ft = mRepository.getFunctionTemplate("BAPI_BANK_GETLIST");
               function = ft.getFunction();
               setJspName("Input.jsp");
    public void doProcessAfterInput() throws PageException {
                IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();
                IPortalComponentContext context = request.getComponentContext();
                     myTableBean = (TableBean) context.getValue("myTableBean");
               try{
                   InputField myInputField1 = (InputField) getComponentByName("inf1");
                    if (myInputField1 != null) {
                         this.name1 = myInputField1.getValueAsDataType().toString();
                    InputField myInputField2 = (InputField) getComponentByName("inf2");
                    if (myInputField2 != null) {
                         this.name2 = myInputField2.getValueAsDataType().toString();
               JCO.ParameterList imParam1 = function.getImportParameterList();
               imParam1.setValue(name1,"BANK_CTRY");
               JCO.ParameterList imParam2 = function.getImportParameterList();
               imParam2.setValue(name2,"MAX_ROWS");
               mConnection.execute(function);
               JCO.ParameterList exParam = function.getTableParameterList();
               JCO.Table table = exParam.getTable("BANK_LIST");
               myTableBean.setName(table);
                mConnection.disconnect();
          catch(Exception ex)
               ex.printStackTrace();
     public void doProcessBeforeOutput() throws PageException {
               if(flag == 1)
                  this.setJspName("OutputTable.jsp");
     public void onButtonClicked(Event event) throws PageException
                flag = 1;       
          public void onNavigation(Event event) throws PageException
                              TableNavigationEvent tne = (TableNavigationEvent) event;
                                   this.visibleRow = tne.getFirstVisibleRowAfter();
                                   myTableBean.setVisibleRow(new Integer(this.visibleRow).toString());

Similar Messages

  • How to use a JCO connection pool in an EJB?

    Hi *,
    I want to build a WebService using SAP Web AS (J2EE Engine) that connects to a R/3 ERP (release 4.7).
    I thought of building a stateless session bean that will be deployed as webservice. The session bean shall connect to the R/3 in order to call some BAPIs. I'd like to use a JCO connection pool. But I'm not sure, where I should create and destroy the connection pool. Are the EJB methods ejbCreate() and ejbRemove() the right ones? If so, my businness methods would just have to get a connection from the pool and call the BAPIs, right? If not, what do you suggest?
    Another question: I already deployed a bean as webservice. Since not really knowing how to use the connection pool, I created a bean with one business method that creates a connection pool whenever it gets called. But if I have to change something in the bean so that I have to redeploy the bean I can't call my business method anymore, because JCO cannot load a native library once again, as it is already loaded, This leads to an exception. So I have to restart the complete engine everytime I redeploy my bean. Are there any workarounds for this problem? I'm not sure whether this is connected to the wrong use of the JCO connection pool.
    Kind regards,
    Lars

    Hi *,
    I want to build a WebService using SAP Web AS (J2EE Engine) that connects to a R/3 ERP (release 4.7).
    I thought of building a stateless session bean that will be deployed as webservice. The session bean shall connect to the R/3 in order to call some BAPIs. I'd like to use a JCO connection pool. But I'm not sure, where I should create and destroy the connection pool. Are the EJB methods ejbCreate() and ejbRemove() the right ones? If so, my businness methods would just have to get a connection from the pool and call the BAPIs, right? If not, what do you suggest?
    Another question: I already deployed a bean as webservice. Since not really knowing how to use the connection pool, I created a bean with one business method that creates a connection pool whenever it gets called. But if I have to change something in the bean so that I have to redeploy the bean I can't call my business method anymore, because JCO cannot load a native library once again, as it is already loaded, This leads to an exception. So I have to restart the complete engine everytime I redeploy my bean. Are there any workarounds for this problem? I'm not sure whether this is connected to the wrong use of the JCO connection pool.
    Kind regards,
    Lars

  • How to query an Infoset using SAP JCO APIs

    Hi
    How can I  query an Infoset (on SAP ECC) using SAP JCO APIs?
    Thanks

    Hi,
    Please use the DDIF_FIELDINFO_GET (standard) Function Module to retireve the details which you have mentioned.
    Thanks,
    Arun

  • Attachments to an a/p invoice using a jco

    Hello,
    I am trying to add an attachment to an existing invoice using a jco, but couldn't find any useful info so far:
    First I am trying to retrieve the document and then attach the files, but i receive a null object in the doc value.
    doc = SBOCOMUtil.getDocuments(company,SBOCOMConstants.BoObjectTypes_Document_oPurchaseInvoices,inv_num);
    Is there anything wrong in retrieving the document?
    A sample code in dot net would be helpful too.
    Thanks
    Ramakanth

    Have you tried to visualize the Draft you have created with B1 application and save it as document by directly using B1? Do you have the same error?
    If you create the Draft with B1 and try to add it after that as document the DeliveryDate and TaxCode are missing, do you fill this information when adding your document?
    I think you should open a message for support in SMP, they will try to reproduce your problem.
    Regards
    Trinidad.

  • Retrieving System Name used in JCO connection ?

    Hi All,
    Do you know how to retrive the System Name paramer value used in JCO connection using Web Dynpro programe. If so can you please sen me how.
    I promise to award points for the correct answer.
    Thank you and Regards
    Maruti CR

    Hi Jennifer,
    Thank you for your reply. I am still trying to get the SAP system name for the model used. I trind to your your code but I am getting some compilation errors.
    Bapi_User_Get_Detail_Input iasmodel  = new Bapi_User_Get_Detail_Input();
    The code I used is
    Bapi_User_Get_Detail_Input iasmodel = (Bapi_User_Get_Detail_Input)WDModelFactory.getModelInstance(Bapi_User_Get_Detail_Input.class);
    IWDJCOClientConnection jcoClientConn = (IWDJCOClientConnection)iasmodel.modelInstance();
    I am getting compile errors..
    The type of model represented by class 'com.ias.Bapi_User_Get_Detail_Input' is not compatible for creation by WDModelFactory
    Can you please suggest?
    Thank you and Regards
    Maruti CR

  • How to retrieve ABAP query field metedata using SAP JCO?

    How can I retrieve all field details (such as field name, field description, output length field type) using SAP JCO for an ABAP Query?
    I have query name, user group, query area and infoset name with me.
    Thanks

    Hi,
    Please use the DDIF_FIELDINFO_GET (standard) Function Module to retireve the details which you have mentioned.
    Thanks,
    Arun

  • Transfering a bitmap using the Jco

    Hello all,
    I have to transfer a bitmap using a Jco-Server. It has to be uploaded to the BDS. I found one similar forum-post for that and programmed it in that way. Everything works fine when I'm using the GUI_UPLOAD-Function. If  I try it with the Jco SAP won't recognize the picture.
    I send it in a Table (one 128 RAW column). Unfortunatelly SAP somehow doubles the size of the picture. I think, that that's the Problem. It could be, because of our System. We're using an AS/400 with EBCDIC-Codepage and SAP 4.6C. Do I have to encode it to BASE64 first?
    Did anyone ever had a similar problem and nows how to fix it? Or does somebody has an example for that?
    Thanks a lot for your help!
    Regards
    Patrick

    Check out service.sap.com/connectors

  • Unable to create sales Order/Inquiry object using SAP JCo

    Hi All,
    Pls can you help me.
    I am using BAPI_INQUIRY_CREATEFROMDATA2 and BAPI_Trancation_commit to create Inquiry object.From my Client JCo code there is no error.I debugged the BAPI_Trasaction_commit, there is no error,  return code is 0.  But th system is not creating Inquiry object. When I try the same from SAP GUI client with exactly the same input parameters it works.
    Do I need to set any option/value to commit the Inquiry to the SAP database? How to maintain the same session between the different BAPI's. Is there any issue with Session maintainance? I would appreciate if you can provide me any sample SAP JCo code for creating a Sales Order/Inquiry.
    Thanks
    mars

    Can you put the part of your code that fill the ORDER_PARTNERS table, also you could compare your coding with [Sales order creation using BAPI|http://wiki.sdn.sap.com/wiki/display/Snippets/SalesordercreationusingBAPI] in [Community Code Gallery |http://wiki.sdn.sap.com/wiki/display/Snippets/CommunityCodeGallery] (don't forget that there is a conversion exit on the partner role, so use internal codes "AG" and "WE")
    Regards,
    Raymond

  • Lookup using RFC & JCO.

    Hi All,
    We are develloping Lookup logic using custom java code.
    Our Xi server is at SP12.The code is working fine in java IDE.
    But when I imported classes into Repository & tested its rebooting services of XI j2ee engine & I am getting message dispatcher running no server conncted the monitoring tool shows
    <SAP:Category>XIServer</SAP:Category>
      <SAP:Code area="MAPPING">JCO_SYSTEM_FAILURE</SAP:Code>
      <SAP:P1 />
      <SAP:P2 />
      <SAP:P3 />
      <SAP:P4 />
      <SAP:AdditionalText />
      <SAP:ApplicationFaultMessage namespace="" />
      <SAP:Stack>&quot;SYSTEM FAILURE&quot; during JCo call.</SAP:Stack>
      <SAP:Retry>N</SAP:Retry>
      </SAP:Error>
    Any idea what is going wrong ?
    Thanks,
    Tuhin

    Hi,
    Did u import the required java JCO libraries into imported archives...?
    Have u mentioned the same in imports of your advanced java function...?
    Look at "How to Perform SAP Data Lookups Within XI Mappings" by "Jerome Delune" in articles section to perform the lookup.
    But i personally recommend you to upgrade the server to SP13 and use the new lookup API's provided. U can refer to "XI Mapping lookups RFC API" article by "Michal" to perform the lookup.
    Cheers,
    Siva Maranani.

  • Do I need a destination for the use of JCo?

    Hi.
    I want to use JCo for a connection between EP7 and ECC6. What I want to do is to use JCo to create an IDoc.
    Should I use a destination when creating the JCo client and if so, how do I create the destination? In all examples I have found the destination is for the backend system to communicate with the portal, but I just want the portal to communicate with backend, nothing else.
    After logging in to Visual Admin going to "Server > Services" should I then go to "Destinations" or to JCo RFC Provider? I have most often seen the latter and to me that seems to be about a JCo in the other direction than I am interested in.
    "Destinations" seem to be the more proper one also regarding the attributes you set but I can't find any documentation for this.
    Does anyone know which one to use in the case portal to backend communication and how to configure it?
    Regards
    Benny

    Hi,
    you can create this kind of JCO connection in the Webdynpro Content Administrator. This is reachable from the j2ee startpage under "Web dynpro tools"
    Regards,
    Jozsef

  • Secure use of JCO

    Whatu2019s SAPu2019s u201Cbest practiceu201D in utilizing JCO?  A hacker only needs to know SAP host, system number, and the program ID. Then he can stand up a JCO server instance and start intercepting outbound calls.   Any suggestions to make it more secure?
    Not sure which forum to post this on, we are running 4.6C, so not using NetWeaver.

    > Yes we have tried it.   And if you attempt to diplay the target system in SM59, it displays first one server then at the next display it will show the other server, maybe at random. 
    Have you made any entries in your secinfo and reginfo files for the RFC gateway? Within the server network, you can control inbound and outbound connections this way - forcing inbound calls to the local SAP system context (USER_HOST parameter) and outbound to specific hosts (HOST parameter).
    > We saw similar results when running the outbound RFC function module.
    Are you using DNS name lists, maintaining the host name in Sm59?
    That your ABAP function module (you are already on the inside, and have access to SM59, SE37, SA38, can install software on a server, etc - but I know that is not the point you are wanting to make about the credentials presented...) is randomly attempting a connection is most likely some performance consideration, probably controlled via the message server.
    Have you looked into any config possibilities there? Have you tried this from "the outside"? How does the message server react? (tip: try to flood the message server with requests).
    Also, can I assume that this is within your server network? I think in this case you can mitigate the risk to some large extent by only allowing trusted admins into that zone...
    Cheers,
    Julius

  • Use of JCO ??? ...i need to pay to use this API ????

    Hi experts...
    Please ...SomeBody can help-me in this Questions ???
    I need to pay to use the API JCO to make integration with SAP Systems and NO-SAP Systems ????
    Or simply ....I enter in the marketPlace and download this API to use ???
    Only this Friends...
    Best Regards.
    MBoni

    Hi,
    Pls don't forget to reward points and close the question if you find the answers useful.
    Eddy

  • Use of JCo destinations with SAP Logon Ticket

    I would have got a precision about the use of a connection pool in a JCo destination using the SAP Logon Ticket connectivity: do i have got the same functionality around the pool connection if i use the SAP logon ticket instead of a user/password inside a JCo destination defined in the web dynpro content administrator ?
    Thank in advance,
    Regards,
    Eric.

    Hello Eric,
    There is only one difference in ticket and user/password authentification method:
    By using a ticket
    <i>For SSO specify the user to be $MYSAPSSO2$ and pass the base64 encoded ticket as as the passwd parameter.
    </i>
    and for user/password you are passing user and password.
    So, there us no difference from connection pool management or behavior perspective.
    Best regards, Maksim Rashchynski.
    P.S.
    Link to JCo javadoc, it can be useful:
    http://media.sdn.sap.com/html/submitted_docs/60_sp2_javadocs/sapjco/com/sap/mw/jco/JCO.html

  • IDOC data transfer SAP to Java using SAP JCo

    Dear Experts,
              The challenging requirement we are having is, we need to create the interface for data transfer between SAP system and the Java system. The data will be transferred from SAP to java and similarly once some processing done in Java again the details needs to be transferred from Java to SAP.
                 For this data transferred we are planning to use IDOC process and for interface "SAP Java connector" we are planning to use. In this case we are having some doubts.
    1. The data from SAP is going to be transfered from one Custom transaction (Z tcode). Once  "Outbound IDOC" will get triggered and will carry the details. Now the doubt is, whether the data / details will get transfered to JAVA system automatically or we need to perform any other steps from SAP ABAP coding...(like converting in to flat file, XML file and etc) ??
    2. We are planning to install "SAP Jco" in Java server. Is this correct...??
    3. Other than SAP Jco any other softwares needs to be installed or not..??
    4. Since we are going to trigger the "outbound IDOC" from custom transaction, we are planning to develope one program in SE37. Other than this any other program we need to develop or not..??
    If anybody has detailed steps or explanation please share it with us.
    Warm Regards,
    VEL

    Hi All,
      For the above mentioned issue, we implemented JCo software in JAVA system and created the JAVA program including SAP logon credential details like Client, User name, password and Language details.
    When this JAVA program was compiled successfully then, that non SAP system will appear in SAP gateway Tcode.
    Once non SAP system started appearing in SAP gateway that means, both SAP & Non SAP are connected automatically.
    Regards,
    Velmurugan P

  • Use WebDynpro JCO Destination in Abstract Portal Component

    Hello,
    I was wondering if it is possible to use a WebDynpro JCo Destination in an Abstract Portal Component? I have a portal component that make as JCO call to run an rfc. I get the MYSAPSSO2 ticket from the cookie and pass this in to the JCO client. This works fine. Now I need to be able to run this for anonymous users as well. I was hoping to be able to retrieve a WebDynpro JCo destination that is set up as a userid/password type and use this to make the connection to run my RFC. This way I could avoid having to store the userid and password somewhere and encrypt/decrypt  it etc...
    Thanks,
    Bert

    Yes Asusha
    You can use JSP , JSPDyn pages in Abstract portal component.
    You can call a Jsp file from the abstract portal component.
        public void doContent(IPortalComponentRequest request, IPortalComponentResponse response)
         com.sapportals.portal.prt.resource.IResource somePage =          
                   request.getResource("jsp", "pagelet/test.jsp");
                   response.include(request, somePage);
    Then you can made your desired UI in JSP.
    Hope this helps..
    Cheers
    Chinmaya
    Reward for helpful answers

Maybe you are looking for