Problem in calling BAPI on HTML screen

Hi all,
i have an input tag on the html screen and ~event linked to the form is say Confirm.
so when anyone clicks on button so it calls BAPI for the online form. it is making the server slow and after some time it gives the internal server error.
say
     <event name="Confirm" next_state="Confirm"/>
     <state name="Confirm">
          <module name="ZV_FUNC_CCK_CONFIRM_ORDER" type="RFC" stateful="1">
               <result next_template="ZV_CCO_CONFIRMED_ORDER">
                    <expr>RET == ""</expr>
               </result>
               <inputmapping source="Contract" target="CONTRACT"/>
               <inputmapping source="SHIP_TO" target="CUSTOMER"/>
               <inputmapping source="CONT_ITEM" target="ITEM"/>
               <inputmapping source="RET" target="RET"/>
               <inputmapping source="TRANSPORT" target="TRANSPORT"/>
               <outputmapping source="ITEM" target="CONT_ITEM"/>
               <outputmapping source="RET" target="RET"/>
               <outputmapping source="SALESORDER" target="SALESORDER"/>
          </module>
     </state>
thanks
ekta

Thanks
Ekta

Similar Messages

  • Problem in calling bapi

    hi
    i developed one report and one bapi (to create sale order with ref to contract) every thing working fine.
    now my client asked he want to call bapi program from report because my report output is input to bapi for this i maintained check box for every row in report and in application tool bar i maintained one key , suppose he selected one record and press on that key it should move to bapi up to this working fine .for this my logic is
    SET PF-STATUS 'ZCON'.
    At USER-COMMAND.
    CASE SY-UCOMM.
    WHEN 'BAPI'. "this is key
    CALL TRANSACTION 'ZBC'. "zbc = my bapi tcode
    endcase.
    now i have to pass selected record values to bapi input automatically so what i have to write .
    please share information
    thanks in advance
    Moderator message : Duplicate post locked. Continue with the original thread.
    Edited by: Vinod Kumar on Sep 7, 2011 10:32 AM

    Hello Bhavin,
    you have marked your question an self solved. Would be fine if you post your solution.
    Regards
    Gregor

  • Calling BAPI from java screen

    Hi All
    I want to develop Order entry form in PDK, in that i need to call BAPI...namely "BAPI_SALESORDER_CREATEFROMDAT2".
    Can anybody send me the sample code...
    [email protected]
    Thanks for ur help
    Pradeep

    In PDK you can import RFC modules. For that you have to create a jco connection. The code for calling an simple rfc ....
    package com.satyam.callrfc;
    import com.sap.mw.jco.JCO;
    import com.sapportals.portal.prt.component.*;
    public class rfc extends AbstractPortalComponent
         private JCO.Client jcoClient;
    // proxy for rfc you already assigned...     
         Insert_pgm_PortType insFunc=new Insert_pgm_PortType();
         Zinsert_Pgm_Input ip=new Zinsert_Pgm_Input();
         Zinsert_Pgm_Output op=new Zinsert_Pgm_Output();
        public void doContent(IPortalComponentRequest request, IPortalComponentResponse response)
        this.connect();
         insFunc.messageSpecifier.setJcoClient(jcoClient);
    //setting input params
         ip.setAssociate_Id1("44");
         ip.setCourse_Objt1(2);
         ip.setQlty_Content1(5);
         ip.setSeq_Content1(2);
         ip.setTraining_Id1("22");
         try{
    //calling rfc
         op=insFunc.zinsert_Pgm(ip);
         }catch(Exception e){}
    //display output
              response.write(op.getMessage());
              this.disconnect();
         private void connect() {
                   try {
                        jcoClient =
                             JCO.createClient("client","userid","password","EN","application_system","system_no");
                             jcoClient.connect();
                   } catch (Exception e) {
                        System.out.println("Error connecting to SAP ::" + e.getMessage());
                        e.printStackTrace();
         private void disconnect() {
                   try {
                        jcoClient.disconnect();
                   } catch (Exception e) {
                        System.out.println(
                             "Error dis-connecting to SAP ::" + e.getMessage());
                        e.printStackTrace();
    Hope this helps
    gEorgE

  • Locking Problem while calling BAPI

    Hi ,
    I am calling a BAPI in my wd appln . if there is some problem while executing the bapi like posting period not open then i am displaying the error of the BAPI . but after that i see in the locked tables through SM12 some tables gets locked .
    so when i call the BAPI again it gives me error like the following tables are locked by the user... so is there any way by which i can release the locks hold by the bapi if problems occurs.
    Regards
    Yash

    Hi Yash,
    Try the command ROLLBACK WORK if the error occurs.
    This will remove all locks set by the BAPI.
    Regards,
    Jos

  • Problem of calling BAPI to release transport request

    Dear Friends,
    I want to automatically release Transport Request using BAPI (BAPI_CTREQUEST_RELEASE), but I met a difficult during the process that only TR TYPE 'K'or 'W' can be release using this BAPI, if I create an addon program which TR Type is 'S' (stand for Development/Correction), then this BAPI does not work. 
    BTW, you can refer table E070.
    Could you please kindly give me some idea to solve this problem?
    Thank you in advance.
    Best regards,
    Nick

    Dear Li Nick,
    The reason that you cannot release a request of type 'S' is that type 'S' names a local correction, which cannot not be transported (and therefore of course not released).
    Regards, Tino

  • Problem with CALL TRANSACTION  SKIP FIRST SCREEN

    Hi Experts,
    I am having a functionality where in if i click the hotspot i go the specified transaction..I am able to do that using --
    CALL TRANSACTION 'CAA3' AND SKIP FIRST SCREEN
    Now if i press the back button on the standard transaction i am coming to the first screen of the CAA3 transaction..
    Can i come back to my original ALV display instead of coming to the first screen of the CAA3 transaction which i have skipped while going there..
    I have searched in all forums. But i couldn't get the proper solution.
    Please Help me !!!
    Regards,
    Rajesh

    Hi friends,
    What do you think the results?
    I used alv hotspot.
    FORM user USING  r_ucomm LIKE sy-ucomm rs_selfield
                              TYPE slis_selfield .
       READ TABLE gt_alv INTO gs_alv INDEX rs_selfield-tabindex.
       IF rs_selfield-fieldname EQ 'BELGE'.
         SET PARAMETER ID '80B' FIELD gs_alv-belge.
         CALL TRANSACTION 'FPE3' AND SKIP FIRST SCREEN.
       ELSEIF rs_selfield-fieldname EQ 'GPART'.
         SET PARAMETER ID 'BPA' FIELD gs_alv-gpart.
         CALL TRANSACTION 'FPP3' AND SKIP FIRST SCREEN.
       ELSEIF rs_selfield-fieldname EQ 'VKONT'.
         SET PARAMETER ID 'KT0' FIELD gs_alv-vkont.
         CALL TRANSACTION 'CAA3' AND SKIP FIRST SCREEN.
       ENDIF.
    FPE3 and FPP3 is running. But CAA3 is incorrect.
    is the correct answer enhancement ?

  • Problem with Call Screen and Leave Screen !

    Hi,
    I am calling Modal screen (Dialog Pop up screen) from my first screen by 'Leave to Screen 'nbr' ' then once user enter the value in the pop up screen then I haveto display value with TABLE in Final screen as 'Normal screen'  here I am  using LEAVE to SCREEN, but after this call - my new final screen is not displaying as noraml screen it also displaying like 'Modal Screen' Like big pop scrren.!!
    When I tried final CALL by using CALL SCREEN instead of LEAVE screen the final screen with  table is dispalying fine as Normal screen but its returning control to pop-up screen which I dont want.
    I like Screen flow as 1>2>3--->1
    Help me to solve this Problem.
    Regards
    James

    Hi,
    Check the below thread,
    Unable to close Modal dialog box
    1) 1st screen--> 2nd screen --> Use CALL SCREEN.(This is Modal Screen)
    2) 2nd Screen-->(ModalScreen so you need come back) use the above thread
    3) Still on 1st screen--> Use CALL SCREEN --> To 3rd Screen
    4) 3rd Screen back to First Screen -> use LEAVE TO SCREEN First_Screen_NO.
    Cheerz
    Ram

  • Problem with mutiple BAPI calls during the commit

    Hi all,
    I am trying to create accounts for a given partner i the transaction F9K1 using the BAPI BAPI_BKK_ACCNT_CREATE. After calling the BAPI I am committing it too.
    The problem is if I try to create multiple accounts like RCA, ACA, MCA, IOE and so on, the first time the BAPI is called to create RCA account it is successful an it is even committing. When I call the BAPI to create the the ACA account the return table from the BAPI shows success message but the commit fails. If I restart the program and try creation of accounts now the RCA will throw a error msg saying account already exist, ACA account will be created and then the MCA account creation fails in the same manner explained above.
    I see the issue is with multiple BAPI calls and I tried using all sort of methods like clearing buffers, start new task in local and wait command and all.  But none of them seems to be working for me.
    Can anyone please guide me on how I can overcome this problem.
    Thanks.

    BAPI :
    BAPI BAPI_BKK_ACCNT_CREATE
    Functionality
    Use this method to create an account in Bank Customer Accounts. This method returns the following values:
    Identification details for the newly created account such as the internal and the external account number, and the bank area details
    A table containing error messages
    To create an account by using this method, you must specify values for the import parameters Bank Area (BANKAREA) and Product (PRODUCTNAME).
    Note: You must also specify a value in the External Account Number (EXTERNALACCOUNTNR) parameter if you have defined an external number range for the bank .
    REgards,
    Jayan.

  • There is a problem with the phone app. When I want to call somebody the phone screen come too late. This will cause a problem if I call the wrong number

    There is a problem with the phone app. When I want to call somebody the phone screen come too late. This will cause a problem if I call the wrong number.  Apple please please please fix it as soon as possible and also check why the phone is always restart. I prefer to let us use the iOS 7 until you finished from the IOS 8 because Ios 8 still under construction  there is a tones problems in the system.  And this Will cause undirect problem for the iPhone 6

    There is no apple here in this user to user technical forum.
    Do this Use iTunes to restore your iOS device to factory settings

  • Calling report with parameter screen from form using frmrwinteg

    Hi,
         I am calling a report with a parameter screen from a form and am using the frmrwinteg bean. This works fine on our test application server but, when moved onto our production application server, the database logon screen is presented after pressing the submit button on the parameter screen. The cause of the problem seems to be the html generated to simulate the parameter screen. The html on the test application server contains a BASE tag in the HEAD section with an href starting "http:/servername.companyname.com". However, the same tag in the html generated on the production application server is missing the ".companyname.com", causing the cookie produced by the frmrwinteg bean to not be found. Does anyone know how the BASE href tag is generated and what I need to change to get the correct BASE href value? I am using Forms/Reports 10g R2 and Application Server 10.1.2.
    Cheers.....

    Appendix "A" of this document describes how cookie_domain works:
    http://otn.oracle.com/products/forms/pdf/10g/frmwebshowdoc_rep.pdf

  • Any program for calling bapi from ABAP step by step

    any program for calling bapi from ABAP step by step
    points will be rewarded,
    thank you,
    Jagrut BharatKumar Shukla

    Hi Jagrut,
    BAPI stands for Business API(Application Program Interface).
    A BAPI is remotely enabled function module ie it can be invoked from remote programs like standalone JAVA programs, web interface etc..
    You can make your function module remotely enabled in attributes of Function module but
    A BAPI are standard SAP function modules provided by SAP for remote access. Also they are part of Businees Objest Repository(BOR).
    BAPI are RFC enabled function modules. the difference between RFc and BAPI are business objects. You create business objects and those are then registered in your BOR (Business Object Repository) which can be accessed outside the SAP system by using some other applications (Non-SAP) such as VB or JAVA. in this case u only specify the business object and its method from external system in BAPI there is no direct system call. while RFC are direct system call Some BAPIs provide basic functions and can be used for most SAP business object types. These BAPIs should be implemented the same for all business object types. Standardized BAPIs are easier to use and prevent users having to deal with a number of different BAPIs. Whenever possible, a standardized BAPI must be used in preference to an individual BAPI.
    The following standardized BAPIs are provided:
    Reading instances of SAP business objects
    GetList ( ) With the BAPI GetList you can select a range of object key values, for example, company codes and material numbers.
    The BAPI GetList() is a class method.
    GetDetail() With the BAPI GetDetail() the details of an instance of a business object type are retrieved and returned to the calling program. The instance is identified via its key. The BAPI GetDetail() is an instance method. BAPIs that can create, change or delete instances of a business object type
    The following BAPIs of the same object type have to be programmed so that they can be called several times within one transaction. For example, if, after sales order 1 has been created, a second sales order 2 is created in the same transaction, the second BAPI call must not affect the consistency of the sales order 2. After completing the transaction with a COMMIT WORK, both the orders are saved consistently in the database.
    Create( ) and CreateFromData! ( )
    The BAPIs Create() and CreateFromData() create an instance of an SAP business object type, for example, a purchase order. These BAPIs are class methods.
    Change( )
    The BAPI Change() changes an existing instance of an SAP business object type, for example, a purchase order. The BAPI Change () is an instance method.
    Delete( ) and Undelete( ) The BAPI Delete() deletes an instance of an SAP business object type from the database or sets a deletion flag.
    The BAPI Undelete() removes a deletion flag. These BAPIs are instance methods.
    Cancel ( ) Unlike the BAPI Delete(), the BAPI Cancel() cancels an instance of a business object type. The instance to be cancelled remains in the database and an additional instance is created and this is the one that is actually canceled. The Cancel() BAPI is an instance method.
    Add<subobject> ( ) and Remove<subobject> ( ) The BAPI Add<subobject> adds a subobject to an existing object inst! ance and the BAPI and Remove<subobject> removes a subobject from an object instance. These BAPIs are instance methods.
    ex BAPI:
    API_SALESORDER_CREATEFROMDAT1
    BAPI_SALESORDER_CREATEFROMDAT2
    You can get good help form the following links,
    BAPI-step by step
    http://www.sapgenie.com/abap/bapi/example.htm
    list of all bapis
    http://www.planetsap.com/LIST_ALL_BAPIs.htm
    for BAPI's
    http://www.sappoint.com/abap/bapiintro.pdf
    http://www.sappoint.com/abap/bapiprg.pdf
    http://www.sappoint.com/abap/bapiactx.pdf
    http://www.sappoint.com/abap/bapilst.pdf
    http://www.sappoint.com/abap/bapiexer.pdf
    http://service.sap.com/ale
    http://service.sap.com/bapi
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCMIDAPII/CABFAAPIINTRO.pdf
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/CABFABAPIREF/CABFABAPIPG.pdf
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCFESDE8/BCFESDE8.pdf
    http://www.planetsap.com/Bapi_main_page.htm
    http://www.topxml.com/sap/sap_idoc_xml.asp
    http://www.sapdevelopment.co.uk/
    http://www.sapdevelopment.co.uk/java/jco/bapi_jco.pdf
    Also refer to the following links..
    www.sappoint.com/abap/bapiintro.pdf
    www.sap-img.com/bapi.htm
    www.sap-img.com/abap/bapi-conventions.htm
    www.planetsap.com/Bapi_main_page.htm
    www.sapgenie.com/abap/bapi/index.htm
    Checkout !!
    http://searchsap.techtarget.com/originalContent/0,289142,sid21_gci948835,00.html
    http://techrepublic.com.com/5100-6329-1051160.html#
    http://www.sap-img.com/bapi.htm
    http://www.sap-img.com/abap/bapi-conventions.htm
    http://www.sappoint.com/abap/bapiintro.pdf
    http://sap-img.com/bapi.htm
    <b>EG::</b>
    <b>Here is the step by step procedure for creating BAPIs.</b>
    There are 5 different steps in BAPI.
    - Create BAPI Structure
    - Create BAPI Function Module or API Method.
    - Create BAPI object
    - Release BAPI Function Module.
    - Release BAPI object.
    Step1. Creating BAPI Structure:
    - Go to <SE11>.
    - Select Data Type & Enter a name.
    - Click on Create.
    - Note: Always BAPI should be in a development class with request number (Not Local Object).
    - Select Structure & hit ENTER.
    - Enter the fields from your database. Make sure that the first field is the Primary Key Field.
    - Then SAVE & ACTIVATE.
    Step 2. Creating BAPI module:
    - Enter TR.CODE <SE37>.
    - Before entering any thing, from the present screen that you are in, select the menu
    Goto -> Function Groups -> Create Group.
    Enter a name (Note: This name Must start with ZBAPI)
    Let this screen be as it is and open another window and there, enter TR.CODE <SE80).
    Click on the Third ICON that says Inactive Objects.
    Select the group that you just created and click on Activate.
    Notice that the group you created will disappear from the list of inactive objects.
    - Go back to ><SE37> screen and enter a name and hit <ENTER>. Then enter the group name that you just created and activated.
    NOTE: When you release a function module the respective group will be attached to that particular application. It cannot be used for any other application. NEVER include an already existing group that is attached to another module.
    Now click on the first Tab that says [ATTRIBUTES] and select the radio button that says remote-enabled module since we will be accessing this from any external system.
    Then click on the second tab that says [IMPORT].
    Enter a PARAMETER NAME, TYPE and the structure you created in the first step. Also select the check box ‘Pa’. All remotely enabled functional modules MUST be Pa enabled, where Pa means ‘Passed by Value’ and if you don’t select ‘Pa’, then that means it will be passed by reference..
    Then click on tab that says [EXPORT].
    Enter the following as is in the first three fields
    RETURN TYPE BAPIRETURN (These 3 field values are always same)
    Here also select ‘Pa’ meaning Pass by value.
    Note: BAPIRETURN contains structure with message fields.
    Then SAVE and ACTIVATE.
    Step 3. Creating BAPI object:
    - Enter Tr.Code <SWO1> (Note. It is letter ‘O’ and not Zero).
    - Enter a name and then click on create. Enter details.
    NOTE: Make sure that that Object Type and Program name are SAME.
    - Enter Application ‘M’, if you are using standard table Mara. If you are using your own database then select ‘Z’ at the bottom.
    - Then hit <ENTER>.
    - Now we have to add ‘Methods’. High light METHODS and then select the following from the menu:
    Goto Utilities -> API Methods -> Add Methods.
    - Enter function Module name and hit <ENTER>.
    - Select the second FORWARD ARROW button (>)to go to next step.
    - Check if every thing looks ok and again click on FORWARD ARROW button (>).
    - Then select ‘YES’ and click on <SAVE>.
    - Now on a different screen goto TR.CODE <SE37>. Enter Function Module name and select from the top menu Function Module -> Release -> Release.
    - Goback to TR.CODE <SWO1>.
    Here select the menu combination shown below in the same order.
    - Edit -> Change Release Status -> Object Type Component -> To Implemented.
    - Edit -> Change Release Status -> Object Type Component -> To Released.
    - Edit -> Change Release Status -> Object Type -> To Implemented.
    - Edit -> Change Release Status -> Object Type -> To Released.
    - Then click on <SAVE>.
    - Then click on Generate Button (4th button from left hand side looks like spinning wheel).
    - Then Click on the button that says ‘PROGRAM’ to see the source code.
    To check if this is present in work flow goto TR.CODE <BAPI>.
    Here it shows business object repository.
    - First click on the middle button and then select “ALL” and hit ENTER.
    - Goto tab [ALPHABETICAL] and look for the object that you created. This shows that the BAPI object has been created successfully
    <b>Reward pts if found usefull :)</b>
    regards
    Sathish

  • JCo Calling BAPI and generate htm and xml page in output

    Friends,
            I am developing an Application in Java using JCO. The requirement there is a list of BAPI's are available for the selection, once the user select the BAPI , it will dynamically generates the screen of input parameters and than result will be stored in .htm and .xml file. It works for many BAPI's, but for few of that it won't work. Will you help me out why its gng to create problem for other BAPI's.
    e.g.
    BAPI_SALESORDER_GETLIST
    BAPI_PO_GETITEMS
    BAPI_MATERIAL_GET_DETAIL and few more...
    It doesn't generate the proper output of these BAPI's.
    Thanks.
    HItesh Shah

    Tanveer,
    There are many files so i wont be able to put the codes but let me tell u how i m doing.
    1) Giving the options to user in which server they want to connect.
    2) After connection has been established there is a plain text file available which consists the list of BAPI's which will be displayed in the list box.
    3) After user select any BAPI and press a button named 'DETAILS' it will display the Import/Export/Tables list.
    4) After clicking on Next , i m generating a dynamic screen for input parameters.
    5)Here is this step also one problem is that i have to write all the zeros, can u tell me if i want to pad the zeroes automatically what i will do.Becz every time the input parameters of each BAPI would be different.
    6) After getting input parameters i will generate the .htm and .xml file using writeXML and writeHTML function.
    7) I want to show them generated xml and html file in iexplore using clicking button...Can u tell me how to achieve that.
    Here is the code through which my xml and htm file will be generated.
    import com.sap.mw.jco.*;
    import java.io.*;
    import java.util.*;
    import java.math.*;
    import java.util.Iterator;
    // Quick imports
    import com.jxml.quick.QDoc;
    import com.jxml.quick.Quick;
      class RFCG {
          static final String SID = "R3";
          String conDetails []=new String[6];
          String ErrorMsg;
          int i=0;
          String LogonDetail;
          int Rows;
          IRepository repository;
          String InputName[]=new String[200];
          String InputType[]=new String[200];
          String OutputName[]=new String[200];
          String OutputType[]=new String[200];
          String OutputINTTYPE[]=new String[200];
          String OutputField[]=new String[200];
          String TableName[]=new String[500];
          String TableType[]=new String[500];
          String TableINTTYPE[]=new String[500];
          String FIELDNAME[]=new String[500];
          //String FIELDNAME[]=new String[20];
          String FIELDINTTYPE[]=new String[500];
          String OutputFieldType[]=new String[200];
          String OutputFieldINTTYPE[]=new String[200];
          String InputParFieldName[][]=new String[200][200];
          String InputParFieldDatatype[]=new String[200];
          String InputParFieldIntType[]=new String[200];
          int l,j,k,m,n,o,t,q;
           /** public static void main(String [] args){
                  new RFCG("SAPR3.txt");
             public RFCG(String LogonDetail,String BAPI)
                      this.LogonDetail=LogonDetail;
                      cleanUp();
                      try {
                                 /* for xml */
                                 // Initialize Quick
                                  QDoc schema = PersonSchema.createSchema();
                              // Convert input XML to Java
                                  QDoc doc = Quick.parse(schema, "input.xml");
                             // Get the result
                                  Person person = (Person)Quick.getRoot(doc);
                               for (Iterator i = person.getClientList().iterator(); i.hasNext(); ) {
                                            Client number = (Client)i.next();
                                           // String type=number.getType();
                                            //System.out.println(type);
                                           // System.out.println(LogonDetail+"LOGO");
                                            if(LogonDetail.equals(number.getType())){
                                                   //conDetails[0]=number.getType();
                                                   conDetails[0]=number.getSapclient();
                                                   conDetails[1]=number.getUserid();
                                                   conDetails[2]=number.getPassword();
                                                   conDetails[3]=number.getLanguage();
                                                   conDetails[4]=number.getHostname();
                                                   conDetails[5]=number.getSystemnumber();
                                            //System.out.println("  Client Type(" + number.getType() + "):");
                                          //System.out.println("  Sapclient " + number.getSapclient());
                                          //System.out.println("  Userid  " + number.getUserid());
                                          //System.out.println("  Password " + number.getPassword());
                                          //System.out.println("  Language " + number.getLanguage());
                                          //System.out.println("  Hostname  " + number.getHostname());
                                          //System.out.println("  Systemnumber  " + number.getSystemnumber());
                                          //System.out.println("   \n  ");
                               } catch (Exception e) {
                                     e.printStackTrace();
                      Connect(LogonDetail);
                      zbapi(BAPI);
                      new BapiParameters1(InputName,InputType,OutputName,OutputType,TableName,TableType,BAPI,repository,OutputINTTYPE,FIELDNAME,FIELDINTTYPE,OutputField,OutputFieldType,OutputFieldINTTYPE,LogonDetail,InputParFieldName,InputParFieldDatatype,InputParFieldIntType);
                      for (int i = 0; i < 10; i++) {
                               //System.out.println("STRING***RFCG*******"InputName<i>'\t'+InputType<i>);
         public void Connect(String LogonDetail){
         //CustName=CustName;
      /** try{
           File myFile = new File(LogonDetail);
           FileReader fr= new FileReader(myFile);
           BufferedReader reader=new BufferedReader(fr);
           String line=null;
           while ((line=reader.readLine())!=null){
                     String[] result=line.split(":");
                     conDetails<i>=result[1];
                     System.out.println(conDetails<i>);
                     ++i;
                reader.close();
           }catch(Exception ex){
                ex.printStackTrace();
               try {
                 JCO.addClientPool( SID,           // Alias for this pool
                                    10,            // Max. number of connections
                                    conDetails[0], // SAP client
                                    conDetails[1], // userid
                                            conDetails[2], // password
                                    conDetails[3], // language
                                    conDetails[4], // host name
                                    conDetails[5] );
                 this.repository = JCO.createRepository("MYRepository", SID);
                 //System.out.println("Connected"+ repository);
               catch (JCO.Exception ex) {
                 //System.out.println("Caught an exception: \n" + ex);
                 ErrorMsg=ex.toString();
                 //new Error(ex);
                 if (ErrorMsg!=null){
                      new Error(ErrorMsg);
             protected void cleanUp() {
                           JCO.removeClientPool(SID);
    public void zbapi(String BAPI)
        JCO.Client client = null;
        JCO.Table codes = null;
        try {
          // Get a function template from the repository
          //FunctionTemplate ftemplate = repository.getFunctionTemplate(person.getRFCName());
             IFunctionTemplate ftemplate = repository.getFunctionTemplate("FUNCTION_GET");
          // if the function definition was found in backend system
          if(ftemplate != null) {
          // Create a function from the template
            JCO.Function function = ftemplate.getFunction();
            // Get a client from the pool
            client = JCO.getClient(SID);
            // Fill in input parameters
            JCO.ParameterList input = function.getImportParameterList();
            input.setValue(BAPI, "FUNCNAME");
            client.execute(function);
            // Print return message
            //JCO.Structure ret = function.getExportParameterList().getString("NAME1");
              codes = function.getTableParameterList().getTable("PRMTAB");
                 //System.out.println("ROWS:"+codes.getNumRows());
                 this.Rows=codes.getNumRows();
                 //System.out.println(this.Rows);
              //System.out.println("PTYPE" + '\t' + "PNAME" + '\t' + "FIELDNAME" + '\t' + "DATATYPE");
         for (int i = 0; i < codes.getNumRows(); i++, codes.nextRow()) {
                                  //System.out.println(codes.getString("PARAMTYPE")+ '\t' +
                                  //codes.getString("NAME") + '\t'codes.getString("FIELDNAME")
                                  //'t' +codes.getString("DATATYPE"));
                                  if (codes.getString("PARAMTYPE").equals("1")){
                                        InputName[j]=codes.getString("NAME");
                                        InputType[j]=codes.getString("INTTYPE");
                                        //InputINTTYPE[j]=codes.getString("INTTYPE");
                                        ++j;
                                  else if(codes.getString("PARAMTYPE").equals("2")){
                                             OutputName[k]=codes.getString("NAME");
                                             OutputType[k]=codes.getString("DATATYPE");
                                             OutputINTTYPE[k]=codes.getString("INTTYPE");
                                             ++k;
                                  else if(codes.getString("PARAMTYPE").equals("3")){
                                             TableName[l]=codes.getString("NAME");
                                             TableType[l]=codes.getString("DATATYPE");
                                             TableINTTYPE[l]=codes.getString("INTTYPE");
                                             ++l;
                                       /**else if(codes.getString("PARAMTYPE").equals("5")){
                                            //System.out.println("RFCGGGGG"+InputParFieldName[o]);
                                             InputParFieldName[q][o]=codes.getString("FIELDNAME");
                                             if(t==0){
                                                  t=1;
                                                  //System.out.println("RFCGGGGG"InputParFieldName[o]"           "+t);
                                                        InputParFieldDatatype[o]=codes.getString("NAME");
                                              else{
                                                   int w=o-1;
                                                   System.out.println("OoOoOooo"w"\t"+o);
                                                   if(InputParFieldDatatype[w].equals(InputParFieldDatatype[o])){
                                                  //System.out.println("RFCGGGGG"InputParFieldName[o]"           "+t);
                                                  System.out.println("yes");
                                                 else{
                                                   InputParFieldDatatype[o]=codes.getString("NAME");
                                                   ++q;
                                             InputParFieldIntType[o]=codes.getString("INTTYPE");
                                                                                ++o;
                                  else if(codes.getString("PARAMTYPE").equals("6")){
                                            if(!codes.getString("NAME").equals("RETURN")){
                                                  //if(codes.getString("NAME").equals(TableName[]))
                                                  OutputField[n]=codes.getString("FIELDNAME");
                                                  //OutputFieldType[n]=codes.getString("DATATYPE");
                                                  OutputFieldINTTYPE[n]=codes.getString("INTTYPE");
                                                  ++n;}
                                  else if(codes.getString("PARAMTYPE").equals("7")){
                                             FIELDNAME[m]=codes.getString("FIELDNAME");
                                             FIELDNAME[m]=codes.getString("DATATYPE");
                                             //System.out.println("TABLEFIELD"+FIELDNAME[m]);
                                             FIELDINTTYPE[m]=codes.getString("INTTYPE");
                                             ++m;
          else {
                //System.out.println("Function not found"  );
                   //new Error("Function not Found");
            //System.out.println("Function BAPI_SALESORDER_GETLIST not found in backend system.");
          }//if
        catch (Exception ex) {
         System.out.println("Caught an exception: \n" + ex);
         ErrorMsg=ex.toString();
              //System.out.println("2222Caught an exception: \n" + ErrorMsg);
                   if (ErrorMsg!=null)
                               new Error(ErrorMsg);
         //        new Error(ex);
        finally {
          // Release the client to the pool
                    //System.out.println("2222Caught an exception: \n" + ErrorMsg);
          JCO.releaseClient(client);
    /**protected void cleanUp() {
                  JCO.removeClientPool(SID);
    Thanks,
    Hitesh

  • Sample ABAP code for userexits, and calling bapi's

    Hi,
    Can someone please send me sample ABAP code
    1) to do extractor enhancement using user exit.
    2) ABAP program to call BAPI to read live cache order series data in SNP and write to Idocs through some ports.
    3) ABAP routine to generate file name (based on date/country)in the infopackage to upload flatfiles.
    Thank you very much in advance and appreciate any help.
    Regards
    Prasad

    hai ,
    check this code...
    *& Tables
    tables : tstc,     "SAP Transaction Codes
             tadir,    "Directory of Repository Objects
             modsapt,  "SAP Enhancements - Short Texts
             modact,   "Modifications
             trdir,    "System table TRDIR
             tfdir,    "Function Module
             enlfdir,  "Additional Attributes for Function Modules
             tstct.    "Transaction Code Texts
    *& Variables
    data : jtab like tadir occurs 0 with header line.
    data : field1(30).
    data : v_devclass like tadir-devclass.
    *& Selection Screen Parameters
    selection-screen begin of block a01 with frame title text-001.
    selection-screen skip.
    parameters : p_tcode like tstc-tcode obligatory.
    selection-screen skip.
    selection-screen end of block a01.
    *& Start of main program
    start-of-selection.
    Validate Transaction Code
      select single * from tstc
        where tcode eq p_tcode.
    Find Repository Objects for transaction code
      if sy-subrc eq 0.
        select single * from tadir
           where pgmid    = 'R3TR'
             and object   = 'PROG'
             and obj_name = tstc-pgmna.
        move : tadir-devclass to v_devclass.
        if sy-subrc ne 0.
          select single * from trdir
             where name = tstc-pgmna.
          if trdir-subc eq 'F'.
            select single * from tfdir
              where pname = tstc-pgmna.
            select single * from enlfdir
              where funcname = tfdir-funcname.
            select single * from tadir
              where pgmid    = 'R3TR'
                and object   = 'FUGR'
                and obj_name = enlfdir-area.
            move : tadir-devclass to v_devclass.
          endif.
        endif.
    Find SAP Modifactions
        select * from tadir
          into table jtab
          where pgmid    = 'R3TR'
            and object   = 'SMOD'
            and devclass = v_devclass.
        select single * from tstct
          where sprsl eq sy-langu
            and tcode eq p_tcode.
        format color col_positive intensified off.
        write:/(19) 'Transaction Code - ',
        20(20) p_tcode,
        45(50) tstct-ttext.
        skip.
        if not jtab[] is initial.
          write:/(95) sy-uline.
          format color col_heading intensified on.
          write:/1 sy-vline,
          2 'Exit Name',
          21 sy-vline ,
          22 'Description',
          95 sy-vline.
          write:/(95) sy-uline.
          loop at jtab.
            select single * from modsapt
            where sprsl = sy-langu and
            name = jtab-obj_name.
            format color col_normal intensified off.
            write:/1 sy-vline,
            2 jtab-obj_name hotspot on,
            21 sy-vline ,
            22 modsapt-modtext,
            95 sy-vline.
          endloop.
          write:/(95) sy-uline.
          describe table jtab.
          skip.
          format color col_total intensified on.
          write:/ 'No of Exits:' , sy-tfill.
        else.
          format color col_negative intensified on.
          write:/(95) 'No User Exit exists'.
        endif.
      else.
        format color col_negative intensified on.
        write:/(95) 'Transaction Code Does Not Exist'.
      endif.
    Take the user to SMOD for the Exit that was selected.
    at line-selection.
      get cursor field field1.
      check field1(4) eq 'JTAB'.
      set parameter id 'MON' field sy-lisel+1(10).
      call transaction 'SMOD' and skip first screen.

  • Calling EJB with HTML via SERVLET

    Hi,
    I used a writen example that calls EJB from HTML via SERVLET. Example name is Bonus. The problem I have is that the HTML throw error while calling SERVLET. I dont figure out what seams to be a problem. Someone know?
    I wonder if the problem is in servlet? The EJB is fine!
    christian
    HTML CODE:(bonus.html)
    <HTML>
    <HEAD>
    <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1250"/>
    <TITLE>untitled1</TITLE>
    </HEAD>
    <BODY BGCOLOR = "WHITE">
    <BLOCKQUOTE>
    <H3>Bonus Calculation</H3>
    <FORM METHOD="GET" ACTION="BonusAlias">
    <P>Enter social security Number:<P>
    <INPUT TYPE="TEXT" NAME="SOCSEC"></INPUT>
    </P>
    Enter Multiplier:
    <P>
    <INPUT TYPE="TEXT" NAME="MULTIPLIER"></INPUT>
    </P>
    <INPUT TYPE="SUBMIT" VALUE="Submit">
    <INPUT TYPE="RESET">
    </FORM>
    </BLOCKQUOTE>
    </BODY>
    </HTML>
    SERVLET CODE:(BonusServlet.java)
    package mypackage5;
    import mypackage5.Calc;
    import mypackage5.CalcHome;
    import mypackage5.impl.CalcBean;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import javax.naming.*;
    import javax.rmi.PortableRemoteObject;
    import java.beans.*;
    public class BonusServlet extends HttpServlet {
    CalcHome homecalc;
    public void init(ServletConfig config) throws ServletException{
    //Look up home interface
    try{
    //InitialContext ctx = new InitialContext();
    //Object objref = ctx.lookup("Calc");
    //homecalc = (CalcHome)PortableRemoteObject.narrow(objref, CalcHome.class);
    Context context = new InitialContext();
    CalcHome calcHome = (CalcHome)PortableRemoteObject.narrow(context.lookup("Calc"), CalcHome.class);
    Calc calc;
    catch (Exception NamingException) {
    NamingException.printStackTrace();
    public void doGet (HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    String socsec = null;
    int multiplier = 0;
    double calc = 0.0;
    PrintWriter out;
    response.setContentType("text/html");
    String title = "EJB Example";
    out = response.getWriter();
    out.println("<HTML><HEAD><TITLE>");
    out.println(title);
    out.println("</TITLE></HEAD><BODY>");
    try{
    Calc theCalculation;
    //Get Multiplier and Social Security Information
    String strMult = request.getParameter("MULTIPLIER");
    Integer integerMult = new Integer(strMult);
    multiplier = integerMult.intValue();
    socsec = request.getParameter("SOCSEC");
    //Calculate bonus
    double bonus = 100.00;
    theCalculation = homecalc.create();
    calc = theCalculation.calcBonus(multiplier, bonus);
    catch (Exception CreateException){
    CreateException.printStackTrace();
    //Display Data
    out.println("<H1>Bonus Calculation</H1>");
    out.println("<P>Soc Sec: " + socsec + "<P>");
    out.println("<P>Multiplier: " +
    multiplier + "<P>");
    out.println("<P>Bonus Amount: " + calc + "<P>");
    out.println("</BODY></HTML>");
    out.close();
    public void destroy() {
    System.out.println("Destroy");

    The error is that page cannot be found! When I run only the servlet it works, when I run the HTML page and enter the field throws eror that the page cannot be found!
    thanks
    Christian

  • Problem in passing data from 1 screen to another using BBP_DOC_CHANGE_BADI.

    Hi Experts,
    i am new to the SRM, i am facing problem in passing data from one screen to another.
    my requirement is that when we select one shopping cart and press the PROPOSE SOURCES OF SUPPLY button, we will fetch all the contracts that are attached to the shopping cart.
    we have implemented a BADI implementation of BBP_SOS_BADI (method BBP_SOS_CHECK) for passing some changed values to the contracts of the shopping cart into the popup screen that is displayed when we press PROPOSE SOURCES OF SUPPLY button and when we select any contract and press ASSIGN ONLY button in the popup screen the badi BBP_DOC_CHANGE_BADI is triggered.
    i have implemented another BADI implementation of BBP_DOC_CHANGE_BADI for fetching the selected contract and pass the values to another screen, but the problem is that when we select one contract and press the assign only button we are fetching the wrong contract number ( that is in the BADI method BB_SC_CHANGE parameter IT_ITEM we are fetching the wrong contract), if we again do the same procedure for the second time we are getting the correct contract.
    i am unable to understand why we are getting the wrong contract in the first time( that is we are getting contract other than the selected one).
    as per my understanding i think when we are passing data to the popup screen using BBP_DOC_CHANGE_BADI we are not updating the shopping cart with the changed data.
    can anyone tell me how we can update the SHOPPING CART with the changed contracts data, i have used BBP_PD_SC_UPDATE, BBP_PD_SC_SAVE and other shopping cart FM but nothing is happening.
    Thanks
    Tanveer

    Hello,
    What version of SRM are you on?  Have you check for OSS Notes?  I have had trouble with BBP_DOC_CHANGE_BADI but it was because of other issues.  The BADI works pretty well and it is called almost every time something happens to the shopping cart.
    I have noticed that sometimes that values are not changed til the second calling of the BADI.  I have yet understand why but I think it has to do with prompt processing. Usually, we train our requisitioners to click the 'Check'  button to flush things out.
    I don't know if I was helpful.... another thought.... could there be an error caught by BBP_DOC_CHECK_BADI that is preventing change in BBP_DOC_CHANGE_BADI?
    Regards, Dean.

Maybe you are looking for