How to access SAP database tables with Java (Jco)

Hi!
I need to develop a Java Client for SAP with access to the SAP database. Is there a way to do this directly in Java (the db access) or do I have to use some ABAP logic in between to get the information to the java client? If so, are there any existing ABAP functions to read AND write db tables? Or do I have to create my own wrappers for each table I need to read and write?
Thanks,
Konrad

hi,
i am sending code .i think it will help u
     try {
               // Add a connection pool to the specified system
               //    The pool will be saved in the pool list to be used
               //    from other threads by JCO.getClient(SID).
               //    The pool must be explicitely removed by JCO.removeClientPool(SID)
                    this.objClient = JCO.createClient(strClient, // SAP client
                    strUserID, // userid
                    strPwd, // password
                    strLang, // language
                    strHost, // host name
                    strSysNr);
               this.objClient.connect();
               // Create a new repository
               //    The repository caches the function and structure definitions
               //    to be used for all calls to the system SID. The creation of
               //    redundant instances cause performance and memory waste.
               this.objIRepository =
                    JCO.createRepository("MYRepository", this.objClient);
          } catch (JCO.Exception ex) {
               System.out.println("Caught an exception: \n" + ex);
          JCO.Function objFunction =
               this
                    .objIRepository
                    .getFunctionTemplate("BAPI_MATERIAL_AVAILABILITY")
                    .getFunction();
          objFunction.getImportParameterList().setValue(strPlant, "PLANT");
          objFunction.getImportParameterList().setValue(strMaterial, "MATERIAL");
          objFunction.getImportParameterList().setValue(strQuantity, "UNIT");
          this.objClient.execute(objFunction);
          JCO.Structure ret =
               objFunction.getExportParameterList().getStructure("RETURN");
          String strRetMsg = ret.getString("MESSAGE");
          if (strRetMsg.equals("Unit  is not created in language")) {
               arrResult.add("error");
               return arrResult;
          } else {
               String strQty1 =
                    objFunction.getExportParameterList().getString("AV_QTY_PLT");
               if (strQty1.equals("0"))
                    result = "no";
               else
                    result = "yes";
               arrResult.add(result);
               return arrResult;

Similar Messages

  • Sap database tables with adobe forms

    Hai all,
      I am new to adobe forms...Can anyone explain me how to link sap database with adobe forms....
    Any documents regarding tht will be helpful.....
    Thanks in advance....

    Hi,
    Check these:
    https://www.sdn.sap.com/irj/sdn/adobe
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/2a8a0a37-0301-0010-f794-aecd1bb426e0
    http://help.sap.com/saphelp_nw2004s/helpdata/en/37/47a2be350c4ac8afe36b691203971f/frameset.htm
    Regards,
    Subramanian

  • Access SAP database table from different SAP server

    Hi,
    May i know is that possible to access the SAP database table from server A to server B without write a program on server A? Is it possible for direct access the SAP database table.
    Best regards,
    Gan

    Hello,
    you could use the RFC-Modules RFC_READ_TABLE or RFC_GET_TABLE_ENTRIES on server A.
    Precondition: you need a RFC-Destination from B to A.
    And a little drawback: you get only the first 512 byte of each table entry.
    Regards Wolfgang

  • How to access the database tables from application

    Hii all,
    The information in webcenter content, such as meta data fields, users, security groups etc are stored in
    database tables like-      Revisions, SecurityGroups, Users, DocType etc..
    Can we access this tables from an adf application or any webcenter application..
    If yes, then what can be the approach for that..??
    Another things, how can we create custom tables just like the predefined tables...??
    Any information regarding this.??
    Thanks

    Can we access this tables from an adf application or any webcenter application.Yes, you can - like to any other existing database. But I would strongly discourage you from any, but read-only access, or you can easily end up with inconsistent data.
    If yes, then what can be the approach for that..??Just create a database connection and define in your model what tables you want to access.
    Another things, how can we create custom tables just like the predefined tables...
    Actually, WebCenter Content provides functionality of creation of custom tables (see http://docs.oracle.com/cd/E23943_01/doc.1111/e10978/c04_metadata.htm#autoId2 ) and these are probably the only good candidates for read-write access. See further in the manual what use cases are supported. Of course, you could do this even externally, but rather than Data Definition Language, I'd use services (if there are some).

  • Hello Anybody, I have a question. Can any of you please suggest me how to make an xml file from the database table with all the rows? Note:- I am having the XSD Schema file and the resulted XML file should be in that XSD format only.

    Hello Anybody, I have a question. Can any of you please suggest me how to make an xml file from the database table with all the records?
    Note:- I am having the XSD Schema file and the resulted XML file should be in that XSD format only.

    The Oracle documentation has a good overview of the options available
    Generating XML Data from the Database
    Without knowing your version, I just picked 11.2, so you made need to look for that chapter in the documentation for your version to find applicable information.
    You can also find some information in XML DB FAQ

  • How to access Portal Database ( ORACLE) through webdynpro  java

    Hello experts,
    I  want to <b>access portal database tables</b> ( WCR_USERSTAT,WCR_WEBCONTENTSTAT,WCR_USERFIRSTLOGON )<b> using</b> <b>webdynpro  java</b> application/service . Our portal DB is Oracle , so please tail me some solution for this asap. I had tried using   <u>Portal Activity Report</u> iViews  but that no fulfill  our requirment.
    Regads,
    Laxmi..

    Hi,
    You can use the following link which will help you to resolve the problem:
    /thread/100181 [original link is broken]
    thanks & regards,
    Manoj

  • How to enter values to a database table with data type 'LCHR'?

    Hello All,
    I have created a database table with five fields, of which the last field is 'Value' field in which i have to enter text with a maximum of 1000characters. I have also specified a 'Length' field preceding the 'Value' field.
    The datatype specified for the 'Length' field is 'INT2' and for the value field is 'LCHR' with length 1000.
    When i tried inserting values to the table through a report, the report is giving an error that 'Literals that take up more than one line are not permitted', which means 255characters.
    Also, when i entered a short text which is less than 250 characters to the 'Value' field,, the report is working fine and the table entry is visible.
    Can anyone help me in this?
    It would be really helpful if you explain how to use 'LCHR' data type in tables and how to enter values to such a field with more than 255characters.
    Thanks in Advance,
    Shino

    Hi shino,
    Alternatively,
    you can use STRING instead of LCHR.
    I too have tried with LCHR and am facing the same issue.. i am not sure why its coming..
    i have tried STRING and its working perfectly.
    wa-key_field = 'IN4'.
    CONCATENATE  'Long text over 200 chars length '
                  'another Long text over 200 chars length '
                  'another Long text over 200 chars length '
                  INTO wa-long_text.
      wa-len = strlen( wa-long_text ).
      INSERT zshino_table from wa.
      SELECT * FROM zshino_table INTO table it.
      clear wa.
      LOOP AT it INTO wa.
          WRITE:/ wa-len, '  ' , wa-long_text.
      ENDLOOP.
    Also, remember to set the type of the database field as String.
    hope this was of some help,
    thanks and regards,
    Sagar.

  • How to update database table with key field?

    Hello Experts,
    I have a database table with following fields
    MATNR   - Key
    SSOUR  -  Key
    KUNNR   - Key
    MENG1 
    MENG2
    MENG3
    And this table contains records like...
    MSD50001     R      1000001     5.30    2.30    5.25
    MSD50002     R      1000002     5.30    2.30    5.25
    MSD50003     R      1000003     5.30    2.30    5.25
    MSD50005     R      1000004     5.30    2.30    5.25
    MSD50004     R      1000005     5.30    2.30    5.25
    I have an internal table with same fields of above database table.
    MSD50001     A      1000001     5.30    2.30    5.25
    MSD50002     A      1000002     5.30    2.30    5.25
    MSD50003     A      1000003     5.30    2.30    5.25
    MSD50005     A      1000004     5.30    2.30    5.25
    MSD50004     A      1000005     5.30    2.30    5.25
    MSD50006     A      1000006     5.30    2.30    5.25
    I want to update the DB table with following internal table records.
    If internal table records = db table records are same then Update....else insert from internal table to db table.
    But here, SSOUR is key field so i am not able to use
    MODIFY dbtab from itab.
    It results me , entries in internal table are inserted into db table.
    So i have double records.
    Is there any statement which updates the key field? and if no fields in db table then insert it?
    Regards
    RH

    hi,
    u cannot update akey field.u can update only non key fields by using key field as a selection criteria.For example if u go to sm30 if u enter any table for inserting values, the key field will always be greyed out it is not succumbed to chnges.but u can insert value into ,if ur inserting and in the insert staemnet if  u have key field which is already present in the table it will return sy-subrc = 4 otherwise it will insert the record and return 0.
    eg for update :
    UPDATE zdm_wtyprof  SET upload_status = 'S'
                             WHERE spart = wa_upd-spart.
    here spart is the key field and it will update the status field in the table as S.
    if updated succesfully it will return 0.
    SIMILARLY U CAN USE select.

  • SAP database updations through Java program

    Hi All,
    From Java program, I want to access SAP database batch RFC
    Please tell me which batch RFC's I have to use for read and update of a table.
    Please also tell me how to find out a batch RFC for a particular table.Is there any way to find it out like BAPI.
    What are the steps and settings ?
    Detailed steps help the requirement.
    Thanks,
    Giri

    Giri,
    Ya...Java APP sents data to XI and XI needs to insert the data into the database.
    Before the next round of data is sent by the Application, Xi should sent back info on the status of the records.
    Is this what you want?
    This will be like I have pointed earlier possible without a BPM. But, make the call from the sending application Synchronous. And then map the JDBC response to the calling aplication.
    But this updation is only possible through XI.
    If i got the requirement wrong can you let me know in more detail, what is it that you are trying?
    Reward if solved

  • How to call SAP Webservice in standalone java program

    Hi,
    In our Java application, we want to use the SAP Webservices. I dont know much about authentication mechanism used by SAP. Can any one please help me with any sample code how to Call SAP webservice in Standalone Jave Program. I searched alot on the web regarding this, but helpless. Please help me.
    Thanks,
    Mohan

    Hi Mohan,
    You need an account for the ES Workplace. I'm afraid this is not free, e.g. check [SAP NetWeaver, Composition Subscription|https://www.sdn.sap.com/irj/sdn/subscriptions/composition].
    But I thought you wanted to play with a WSDL [you already had at hand|Sample code to access BAPI Web services from JAVA required;?

  • Database table with potentially millions of records

    Hello,
    We want to keep track of user's transaction history from the performance database.  The workload statistics contain the user transaction history information, however since the workload performance statistics are intended for temporary purposes and data from these tables are deleted every few months, we loose all the user's historical records.
    We want to keep track of the following in a table that we can query later:
    User ID      - Length 12
    Transaction  - Length 20
    Date         - Length 8
    With over 20,000 end users in production this can translate into thousands of records to be inserted into this table daily.
    What is the best way to store this type of information?  Is there a specific table type that is designed for storing massive data quantity?  Also, over time (few years) this table can grow into millions or hundreds of millions of records.  How can we manage that in terms of performance and storage space?
    If anyone has worked with database tables with very large amounts of records, and would like to share your experiences, please let us know how we could/should structure this function in our environment.
    Best Regards.

    Hi SS
    Alternatively, you can use a <u>cluster table</u>. For more help refer to F1 help on <b>"IMPORT TO / EXPORT FROM DATABASE"</b> statements.
    Or you can store data as a <u>file</u> on the application server using <b>"OPEN DATASET, TRANSFER, CLOSE DATASET"</b> statements.
    You can also select to archieve data of older than some definite date.
    You can also mix your alternatives for the recent and archieve data.
    *--Serdar <a href="https://www.sdn.sap.com:443http://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=qbk%2bsag%2bjiw%3d">[ BC ]</a>

  • Logical database vs direct access of database table

    Hi
    I have created a FI report.    I am trying to get data from large FI tables like BSAK, BSEG, BKPF, RSEG.  eventhough there are 10 records as per my criteria, system is taking morethan an hour time even in background processing.  This may be becaz of lot of conditions that I am applying to filter the data.  But still trying to improve the performance
    For fetching data which is the better way for getting optimum performance of the report.
    a) directly fetching data from database tables
    b) using logical database collecting data into an itab
    regards,
    mallik

    Hi,
    If you are accessing the database tables more than once with different criteria then definetly it will take more time. In such case write only one Select statement on the table and get all the required data into an internal table and then process this internal table as per your logic.
    Use of LDBs is definetly faster but filter conditions might not match with your filter conditions. In such case direct access of database table is preferable but as i said in above paragraph.
    thanks,
    sksingh

  • Populating SAP Database table using JDBC adapter

    Hi Folks,
        I have a requirement to populate a SAP database table say ZTABLE using XI. The Model is the table has to be populated through a file which will be processed by SAP XI. Basically this is a File to JDBC scenario. The database used is ORACLE. Kindly provide me some idea to go ahead.

    I tried to place the MS access table in the shared folder of the Application server system but still it seems the table is not being populated.
    did you check the log in your receiver channel? (/people/sameer.shadab/blog/2005/10/24/connecting-to-ms-access-using-receiver-jdbc-adapter-without-dsn)
    The requirement is to update the tables directly as those are the custom tables.
    i would still say that do not update SAP tables directly from XI/ PI.....this is not a standard architecture/ solution....

  • How to Access the  XI_AF_MSG table

    Hi Experts,
    I request you to please let meknow that how can I access the different JAVA tables like XI_AF_MSG table or the AUDIT tables.
    Actualy my requirement is to trace the audit log for a  particular message ID in the Adapter Engine.This audit trace is not same as the audit log that found in the PI7.0  Runtime WorkBench.For exmaple.--
    a message failed in the adapter engine after successfuly processed from PI Integration Engine. Now I want to trace the USERID by whom the message is resent or canceled.
    please let me know how can I achive this and how can I access the different tables in JAVA layer.
    Thanks
    Sugata Bagchi Majumder

    These 3 are the tables that are for XI Adapter in ABAP Stack.
    SWFRXICNT
    SWFRXIHDR
    SWFRXIPRC
    You can also try the following tables.
    SXMSAEADPMOD                   XI: Adapter and Module Information
    SXMSAEADPMODCHN                XI: Adapter Module Chains
    SXMSAEAGG                      XI: Adapter Runtime Data (Aggregated)
    SXMSAERAW                      XI: Adapter Runtime Data (Raw Data)
    Cheers,
    Sarath.
    Award if helpful.

  • Select data from database tables with high performance

    hi all,
    how to select data from different database tables with high performance.
    im using for all entries instead of inner joins, even though burden on data base tables is going very high ( 90 % in se30)
    hw to increase the performance.
    kindly, reply.
    thnks

    Also Check you are not using open sql much like distict order by group by , use abap techniques on internal table to acive the same.
    also Dont use select endselect.
    if possible use up to n rows claus....
    taht will limit the data base hits.
    also dont run select in siode any loops.
    i guess these are some of the trics oyu can use to avoid frequent DATA BASE HITS AND ABVOID THE DATA BASE LAOD.

Maybe you are looking for

  • How to change the email in the link where we can reset passwords.

    I want to reset my security questions but unfortunately I forgot my password. However, I've been clicking the reset link to email but it's not sending. And I realized the email is not my primary email. Not even my alternative email. So what can I do?

  • Page flipping with Volatile Image.  Need help :)

    Hello all, Could someone point me to a nice tutorial which specifically addresses setting up page flipping with Volatile Images as the buffer? I haven't had any trouble with the generic BufferStrategy way of doing things, but it looks like the absolu

  • Render Files Are Being Saved onto My Mac Book Hard Drive...?

    Hi All - So, I was highly curious as to why I have such little disk space on the hard drive on my Mac Book Pro and discovered that there is a file called "Render Files" on my hard drive which contains an enormous amount of video footage from movies I

  • Can't remove duplicates in Address Book

    Have lots of duplicates in Address Book since moving to iCloud. Went to Card>Look for Duplicate. It found a few and so merged them but there are still lots of identical cards that are not recognized as duplicates. Is there a simple, easy way to remov

  • Defult document type in FV60

    Dear gurus, Does anybody know about how I can default the document type on the FV60 nsaction? I tried to create validation but realised if I validated, I would have to validate all FI documents as there is no way to isolate the transaction....So that