Error in JCo while connecting BAPI SALES ORDER.

package com.sap;
import com.sap.mw.jco.JCO;
import com.sap.mw.jco.JCO.Exception;
import com.sapportals.portal.prt.component.AbstractPortalComponent;
import com.sapportals.portal.prt.component.IPortalComponentRequest;
import com.sapportals.portal.prt.component.IPortalComponentResponse;
public class DirectBAPI extends AbstractPortalComponent
    public void doContent(IPortalComponentRequest request,   
         IPortalComponentResponse response)
             JCO.Client mConnection;
              JCO.Repository mRep;
      response.write("Connecting..........");
    try
                                // Change the logon information to your own system/user
   mConnection =  JCO.createClient("<client number>",  "<user Id>",  "password",                             
          null,                 // language
     "application server number",                "<system no..>");       
           response.write("Reached");
         mConnection.connect();                // connecting JCo...
mRep = new JCO.Repository("SAPJCo", mConnection);   //use JCo    Repository....
     response.write("Connected Succesfully");
    //response.write( mConnection.getAttributes() );
   // mConnection.disconnect();
catch (Exception ex)
     ex.printStackTrace();
       response.write(ex.getMessage());
   JCO.Function function = null;
   JCO.FunctionTemplate ftp = null;        
   JCO.Table codes = null;
try
         ftp = mRep.getFunctionTemplate();
         function = ftp.getFunction();
         function = this.createFunction("BAPI_SALESORDER_GETSTATUS");   
                                         // Accessing SALES_ORDER_GETSTATUS.
         if (function == null)
             response.write("BAPI_COMPANYCODE_GETLIST"  +  " not found in SAP.");
   catch (Exception exx)
      response.write(exx.getmessage() );
   In the above code while while connecting to the BAPI SALES ORDER GET_STATUS an error is coming for JCO connection for the JCo Repository.
The method createFunction() is undefined for the type of Project.
plz guide how to rectify this so as to connect BAPI SALES ORDER thru JCo connection.
Thanx in advance.
Regards:
Hanif

Hi,
The below Code is helpful for Calling BAPI's Using JCO .
public class TestJCO {
     JCO.Client mConnection;
      JCO.Repository mRepository;
      public TestJCO() {
        try {
           // Change the logon information to your own system/user
//           mConnection =
//             JCO.createClient("800", // SAP client
//                "USERID",           // userid
//                "password",               // password
//                null,                 // language
//                "appserver hostname",         // application server host name
//                "00");                // system number
          mConnection =
            JCO.createClient("002", // SAP client
               "userid",           // userid
               "password",               // password
               null,                 // language
               "app server host name",         // application server host name
               "00");                // system number
           mConnection.connect();
           mRepository = new JCO.Repository("companyname", 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");
           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");
             function.getExportParameterList().setActive(false, "COMPANYCODE_ADDRESS");
             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) {
          TestJCO app = new TestJCO();
Please Check your code with above code.
Thanks,
SubbaRao Chinta

Similar Messages

  • Error while Saving Service Sales order.

    Hi..
    Please help me for resolving below error..
    While saving service sales order error is coming as-
    Invalid account assignment category...
    Detailed Error-
    "Assign components to a/c assignment category & Account Assigmnet Category not defined.
    In customisining a/c assgnment cate for ser & mainta order .In standard define the following values for the order category 30.A/c Asd type general F,
    A/c *** type Project Q,A/c assigment type Sales Order E,Sales Doc Project D".
    Awaiting for your inputs....
    Thanks
    Manoj Mahajan

    Hi Manoj,
    Account Key assigned to the pricing condition hasn't been configured completely.
    Please check the appropriate account key and speak to your FI team.
    Pl award me points if it is helpful.
    Let me know if you need more details.
    Thanks,
    Ramesh

  • Error while saving the Sales Order

    Hi experts,
        i am getting a runtime error while saving a sales order stating: SAPSQL_EMPTY_TABNAME. It says the field T681-KOTAB could be empty. I would give in more inputs. Someone plz help.
    Thanks.

    I would expect that KOTN521 would be a Database table defined in the ABAP Dictionary that relates to the condition implemented in 521 for the usage specified in that record.
    You should be able to go into the info system, SE84, and search under ABAP Dictionary / Database Tables to see what KOTN521 is.
    Also, since the only Keys to T681 are KVEWE and KOTABNR, and there are two KOTABNR entries with a value of 521, then there must be two different usages (KVEWE) associated with that table.
    If you see what they are, you can check to see what the usages represent.   Based on a lookup, it appears that a usage of N is for Free Goods, A is for Pricing etc.   In our system, we only have A entries.
    What are the usages for the 521 entries?  Do they relate to Free Goods/Pricing???
    Does the table KOTN521 exist in the ABAP Dictionary?
    Answering these questions may get you closer to the answer.
    Can you compare the values in these entries to what you have in different SIDs?
    Is this problem happening in Production, or is it still in a development or Quality Assurance client?
    If it is still in development or Q, then it may be that a recent customization change was made.
    Compare the entries across your systems, if possible.
    Good luck
    Brian

  • RunTime Error while saving a Sales Order

    Hi All,
    When i am saving a Sales Order, the system is throwing a Runtime Error.
    The ABAP Code in the Runtime Error screen as follows.
              select * from (t681-kotab) appending table <cond_tab>
                     up to 1 rows
                     where kappl  = se_kappl
                     and   kschl  = se_kschl
                     and   datbi >= se_date
                     and   datab <= se_date
                     and   (coding_tab).
    Till these days, there was no such error while saving a Sales Order.
    How to resolve this issue?
    Regards
    Pavan

    Hi,
    The below piece of code is trying to get the contents of the table mentioned in T681-KOTAB.
    select * from (t681-kotab) appending table <cond_tab>
    up to 1 rows
    where kappl = se_kappl
    and kschl = se_kschl
    and datbi >= se_date
    and datab <= se_date
    and (coding_tab).
    The reason could be is someone has screwed up the entries in T681 table. Check that out.
    Try to put a break point on this SELECT query and see what the value of T681-KOTAB holds before the SELECT query. Check whether such a table entry exists in DB.
    Let me know if you are still stuck up.
    If you can send me the ST22 dump of the run time error, i might be able to help you more  on this.
    Hope this helps.
    Thanks,
    Balaji

  • Error while saving a Sales Order in the CRM Mobile Application

    Hi,
    I am facing issues while saving a Sales Order in the CRM Mobile Application. I am getting the error message "Value Field KvLangu is not valid (Error: 236 / 1102)".
    I would be very grateful if somebody had faced this issue before and this way could help me with some information.
    Best Regards,
    Rogerio Prado.

    Hi Rogerio,
    You should put mobile sales related messages in the forum "CRM Mobile applications"
    This error message is coming because the language table SMOT002 might be empty in your mobile client OR it does not have all the values which have been customized in the system.
    You need to have subscription based on publication "customizing objects" assigned to your site.
    Regards
    Vivek

  • WHILE DELETING A SALE ORDER GETTING A RUNTIME ERROR " Screen: Illegal message"

    Hi Experts,
    While deleting a sales order giving run time error.  PFB runtime error details.
    If you know any OSS message, please let m know. I tried, but there is no luck.
    Short text
        Screen: Illegal message
    What happened?
        The current screen processing action was terminated since a situation
        occurred where the application could not continue.
        This is probably due to an error in the ABAP program or in the current
        screen.
    What can you do?
        Note which actions and input led to the error.
        For further help in handling the problem, contact your SAP administrator.
        You can use the ABAP dump analysis transaction ST22 to view and manage
        termination messages, in particular for long term reference.
    Error analysis
        The program attempted to issue a " " message during "Exit Command" processing.
        This is an illegal operation.
        The program was terminated.
        Screen name.............. "SAPMV45A"
        Screen number............ 4001
    How to correct the error
        The program must be modified to correct the error.
        The modification must be made in "Exit Command" processing.
        If you cannot solve the problem yourself and want to send an error
        notification to SAP, include the following information:
        1. The description of the current problem (short dump)
           To save the description, choose "System->List->Save->Local File
        (Unconverted)".
        2. Corresponding system log
           Display the system log by calling transaction SM21.
           Restrict the time interval to 10 minutes before and five minutes
        after the short dump. Then choose "System->List->Save->Local File
        (Unconverted)".
    Source Code Extract
    Line  SourceCde
        1 *---------------------------------------------------------------------*
        2 *       FORM YVBEP_LESEN                                              *
        3 *---------------------------------------------------------------------*
        4 *       Lesen der Tabelle YVBEP (nicht sortiert)                      *
        5 *---------------------------------------------------------------------*
        6 FORM YVBEP_LESEN USING US_POSNR
        7                        US_ETENR
        8               CHANGING CH_TABIX.
        9
       10   YVBEP = SPACE.
       11   YVBEP-MANDT = VBAK-MANDT.
       12   YVBEP-VBELN = VBAK-VBELN.
       13   YVBEP-POSNR = US_POSNR.
       14   YVBEP-ETENR = US_ETENR.
       15   READ TABLE YVBEP.
       16   IF SY-SUBRC > 0.
       17     MESSAGE E506 WITH US_POSNR US_ETENR.
       18   ENDIF.
    >>>>>   CH_TABIX = SY-TABIX.
       20
       21 ENDFORM.
    Could you please help on this issue.
    Thanks
    Srinu

    Hi Srinu,
    it looks like you got the error message Schedule line &1 &2 is missing in table YVBEP while deleting the sales order.
    It seems, that there are no SAP notes regarding this issue. Do you have this issue with all orders or with a single order?
    If only a single order causes this issue, maybe something was wrong during an update.
    If you get this error for many orders, then custom code (modification, enhancement, user exit in MV45AFZZ, ...) may be the reason for it.
    If you have no custom code in module pool SAPMV45A, then contact SAP for this issue.
    Regards,
    Klaus

  • Material Listing Error while creating the sales order

    Hi Guru's
    I have mantained a material in the lisitng for A002 combiantion for SO/DC/Pric. ref. material
    While creating the sales order is throwing an error as material is not listed so the transaction is not possible.
    I have done the basic invetingation on the folowing aspects
    1)checking the material in the listing
    2)Validity periods
    3)Material not blcoked
    4)Mateial is extened for the respective sales org
    Kindly help ASAP.
    Thanks & Regards
    Tarakaram

    Dear SAP SD 007
    I can confidently tell that an enhancement or an user exit has been applied in your scenario
    You have to check that
    Normally when creating a sales order with respect or referring billing documents the qty will be in editable mode and it is standard problem
    Your people has solved the standard problem by enhancement
    Usually OR--LF-PGI----F2 (SAY THE QTY IS 25 UNITS)
    Now you are creating returns order with reference to F2 in the return order type Re there is a standard issue that user can edit the qty to 30 from the original 25
    To solve this only your people have used userexit
    Line items and qty greyed out means definately there is some enhancement or user exit applied
    You have to check that
    Regards
    Raja

  • Error while creating the sales order with billing reference

    hi alll
    i am getting error while creating the sales order with billing reference.The line items are coming in grey.I am not able to change the items as well as the quantity field.Can u guide me
    cheers
    shalsa007........

    Dear SAP SD 007
    I can confidently tell that an enhancement or an user exit has been applied in your scenario
    You have to check that
    Normally when creating a sales order with respect or referring billing documents the qty will be in editable mode and it is standard problem
    Your people has solved the standard problem by enhancement
    Usually OR--LF-PGI----F2 (SAY THE QTY IS 25 UNITS)
    Now you are creating returns order with reference to F2 in the return order type Re there is a standard issue that user can edit the qty to 30 from the original 25
    To solve this only your people have used userexit
    Line items and qty greyed out means definately there is some enhancement or user exit applied
    You have to check that
    Regards
    Raja

  • Interesting scenario- user facing error while deleting a sales order

    Hello All,
    I have one interesting scenario and want feedback from your side as soon as possible
    Scenario-
    One of my clients is facing a problem while deleting a sales order.
    the sales order he is trying to delete is the old order created in 2007.
    when i see the document flow the user has created the export order, then delivered it, invoiced and sent it to accounting, accounting document is also cleared. then he cancelled the invoice, reverse PGI and deleted the delivery. the status of the sales order system is showing is being processed. but please note in this case after reversing PGI and deleting a delivery the delivery document disappears from the document flow.
    document flow looks like this
    Order - 200004715                     Being processed
    invoice- 700005310                    completed
    accounting 700005311                 cleared
    Cancel Invoice 700005315            completed
    Accounting 700005316                 cleared
    Now, in 2008 user is trying to delete the sales order but he is unable to do the same. system is giving him message "unable to delete sales order because of subsequent document 70005310 (which is invoice number)"
    Can somebody please throw some light on this problem.
    Thanks in advance.

    Hi,
    As fas as I know, this is standard system behaviour. The reason - you have done PGI (which has created a material document as well as accounting doc) and invoiced & reversed (which again has created accounting documents & rversal documents). All these documents are referencing the sales order.
    If you delete sales order, sales order number gets deleted from VBAK /VBAP tables.
    Hence, in relational data base scenario (meanin SAP in this context), deletion of sales order after creation of subsequent documents is not feasible.
    Hope it clarifies the issue.
    Regards
    Murali

  • SAP Note 144253 For error Enter valid delivery plant in sales order

    Hi all,
    I am getting the error "Enter valid delivery plant" while creating the sales order . This is due to Customer and plant are same .
    For that I got one SAP Note 144253.
    If anyone implimented this SAP note Could you please share is there any impact of this note after implimenting.
    Thanks
    CM

    Hi,
    Go to bellow links,
    http://help.sap.com/saphelp_nw04/helpdata/en/60/8def3981fe5d7de10000000a114084/content.htm
    http://www.sap-basis-abap.com/bc/steps-to-install-sap-note.htm
    Thanks,
    Raviteja

  • Change Request demanded while creating a Sales Order

    Dear All,
    I am creating a Sales Order. The solution is using user exits to communicate between SD and TEM.
    Whenever we create a Sales Order its corresponding sales order and line item is updated in TEM table HRVPAD25.
    While saving the Sales Order, its asking for a Change Request which is by default the Customizing Request created for functional configuration of that particular solution.
    Sales orders however are created successfully.
    Can anyone throw some light on the issue?
    regards,
    Prosenjit.

    Solved

  • Credit Check while creation of Sales Order for Item Category Purchase Req

    Hi Experts,
    We are creating Sales Order using an Order Type ABCD for a material 1000. While creating Sales Order, we use Item categories (ZOVD, ZOVB,ZOST,ZOVP and ZOBO).
    Credit Check settings are there at Order Type ABCD as well as all the Item Categories (ZOVD, ZOVB,ZOST,ZOVP and ZOBO). We are trying to test a scenario where a customer does not have enough credit limit while creating a sales order.
    When we create a sales order for Item Categories (ZOVD, ZOVB,ZOST,ZOVP), credit check fails because our customer does not have enough credit limit, so that Sales Order gets created and Delivery does not get created (This is what we want), then we go into VKM1 manually and relase the sales order and then if we go to VA02 and check the status of the Sales Order, it says sales order status is complete. My Sales Team is saying here also Purchase Requisition is getting created.
    When we create a sales order for Item category ZOBO, it is going into Purchase Requisition screen. Once we give another plant in the create purchase requisition screen and save it we are getting a message that cannot create Purchase Requisiton because of Credit Block.
    The settings were same for all the Item categories.
    1) What made difference to complete Purchase Requisition for Item Categories (ZOVD, ZOVB,ZOST,ZOVP) and not for Item Category ZOBO when my customer is not having enough credit Limit.
    2) Why Purchase Requisition screen is not coming for us when we create an Sales Order for Item Categories (ZOVD, ZOVB,ZOST,ZOVP). We only get Create Purchase Requisiton Screen for Item Category ZOBO.
    Thanks
    Rajanikanth

    Hi,
    None of the Item Categories has Create PO Automatically.
    Thanks
    Rajanikanth

  • I keep getting this message An unknown error (-15006) occurred while connecting to the AirPlay device " AirPort Express".

    Please help. I have been having major difficulties with my Airport Express. It used to work fine but for the last year or so it continually disconnects, skips and ultimately drops out and itunes gives me this message "An unknown error (-15006) occurred while connecting to the AirPlay device “AirPort Express”. I keep resetting, unplugging, restarting Itunes, or my computer. It works for a couple of hours and then I get the message again. It's making me nuts and was a bummer at last week's party when we had no music, yet again. I have looked up the support discussions, but there is no answer as to how I can fix it. I am currently using Mt Lion OS. Does this have anything to do with it? Checked for software updates, but nada.
    Any suggestions.

    It may be possible the where you have the AX located may just be in a spot where it does not get a good signal even it is only 8 feet away.
    I suggest that you download and install iStumbler. You will use it to determine the signal quality by making Signal-to-Noise Ratio (SNR) measurements. This will be easiest if your Mac is a laptop ... or you can borrow one. When taking the measurements, you only want your "main" AirPort running as this is what we want to measure at the location of the AX.
    SNR (in dB) = Signal (in dBm) - Noise (in dBm)
    You can easily find the Signal and Noise value using System Profiler on your Mac laptop.
    ref: Click on the Apple icon on the menu bar > About This Mac > More Info... > Contents > Network > AirPort > Interfaces > en1 > Current Network Information > Find your wireless network > Signal / Noise
    While your still in the System Profiler, note the value for Transmit Rate.
    These values should be negative numbers. For example, mine currently read: -67 dBm / -95 dBm, with a transmit rate of 27 (Mbps). Plugging in these numbers yield: SNR = -67 - (-95) = 28. My Mac Mini is about four rooms away from my AEBS with about five walls between them. As you can see, the signal is still quite useable ... but the bandwidth is minimal, especially for streaming.
    SNR Guideline
    40dB+ SNR = Excellent signal
    25dB to 40dB SNR = Very good signal
    15dB to 25dB SNR = Low signal
    10dB to 15dB SNR = Very low signal
    5dB to 10dB SNR = No signal
    Please post back your results.

  • HT204291 at times error 6722 appears while connecting to airplay device "apple tv"

    at times error 6722 appears while connecting to airplay device "apple tv".  i have restarted the apple tv several times but it keeps doing the same thing, at times the pictures appears without sound from my sound system. what is the  problem, my apple tv and macbook pro is new?

    As an update, tried to connect from a Macbook Pro with an older ITunes and all devices show up, connect and work fine.

  • Mapping datas from idoc while creating a sales order.

    Hi Friends,
    From the idoc i want to fill the field 'YOUR REFERNCE' in the tag ORDER DATA at header level while creating a sales order. From which segment i can find the datas for that field.
    Your answers will be valuable.
    Thanks,
    Bestin
    Edited by: Be$t!N on Aug 26, 2009 4:41 PM

    Hi,
    You can find the Your Reference field in the segment E1EDKA1 and the field name is IHREZ.  This Your reference field is at the Partner level. This is a standard field.
    If you can let me know at which place you want this field to be populated then we can find another suitable field in the IDOC.
    Thanks,
    Mahesh.

Maybe you are looking for