Problem while calling RFC function module in java

Hi all
com.sap.mw.jco.JCO$Exception: (102) RFC_ERROR_COMMUNICATION: Connect to SAP gateway failed
Connect_PM  GWHOST=<system.ab.ydydy.yyyd.com>, GWSERV=sapgw00, ASHOST=<system.ab.ydydy.yyyd.com>, SYSNR=00
LOCATION    CPIC (TCP/IP) on local host
ERROR       hostname '<system.ab.ydydy.yyyd.com>' unknown
TIME        Mon Jun 06 14:50:25 2005
RELEASE     640
COMPONENT   NI (network interface)
VERSION     37
RC          -2
MODULE      ninti.c
LINE        332
DETAIL      NiPGetHostByName2: hostname '<system.ab.ydydy.yyyd.com>' not found
SYSTEM CALL gethostbyname_r
COUNTER     1
     at com.sap.mw.jco.rfc.MiddlewareRFC$Client.nativeConnect(Native Method)
     at com.sap.mw.jco.rfc.MiddlewareRFC$Client.connect(MiddlewareRFC.java:1098)
     at com.sap.mw.jco.JCO$Client.connect(JCO.java:2983)
     at MyProject.Bapi2.<init>(Bapi2.java:43)
     at MyProject.Bapi2.main(Bapi2.java:231)
Pl help me
pradeep

Hi
This is my code....
Created on Jun 2, 2005
To change the template for this generated file go to
Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
package MyProject;
@author pradeep
To change the template for this generated type comment go to
Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
import com.sap.mw.jco.*;
public class Bapi2 extends Object {
   JCO.Client mConnection;
   JCO.Repository mRepository;
   public Bapi2() {
       try {
          // Change the logon information to your own system/user
          mConnection =
            JCO.createClient("122", // SAP client
               "<pradeep>", // userid
               "*****", // password
               "EN", // language
               "<abc11.aa.abc23.company.com>", // application server host name
               "<00>");//system no
          mConnection.connect();
          mRepository = new JCO.Repository("HLL", 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");
           codes.setRow(2);
codes.deleteRow();
codes.deleteRow(5);
codes.appendRow();
codes.setValue("XXXX", "COMP_CODE");
codes.setValue("Does not exist", "COMP_NAME");
codes.appendRows(2);
codes.setValue("YYYY", "COMP_CODE");
codes.setValue("Does not exist either", "COMP_NAME");
codes.nextRow();
codes.setValue("ZZZZ", "COMP_CODE");
codes.setValue("Nor does this", "COMP_NAME");
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");
             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[]) {
      Bapi2 app = new Bapi2();
This is the error i'm getting...
com.sap.mw.jco.JCO$Exception: (102) RFC_ERROR_COMMUNICATION: Connect to SAP gateway failed
Connect_PM  GWHOST=<abc11.aa.abc23.company.com>, GWSERV=sapgw00, ASHOST=<abc11.aa.abc23.company.com>, SYSNR=00
LOCATION    CPIC (TCP/IP) on local host
ERROR       hostname '<abc11.aa.abc23.company.com>' unknown
TIME        Mon Jun 06 17:15:12 2005
RELEASE     640
COMPONENT   NI (network interface)
VERSION     37
RC          -2
MODULE      ninti.c
LINE        332
DETAIL      NiPGetHostByName2: hostname
            '<abc11.aa.abc23.company.com>' not
     at com.sap.mw.jco.rfc.MiddlewareRFC$Client.nativeConnect(Native Method)
     at com.sap.mw.jco.rfc.MiddlewareRFC$Client.connect(MiddlewareRFC.java:1098)
     at com.sap.mw.jco.JCO$Client.connect(JCO.java:2983)
     at MyProject.Bapi2.<init>(Bapi2.java:45)
     at MyProject.Bapi2.main(Bapi2.java:233)
Thx
PRadeep

Similar Messages

  • CNTL_ERROR while calling a function module from Java webdynpro

    I am calling a RFC function module from javawebdynpro app
    which inturn calls a function module performing BDC on CAPP transaction. When I run this from SE37 of the same system or a different system everything works fine. But when called from Java webdynpro app, it raises a CNTL_ERROR exception and creates a short dump.
    Any help on this is highly appreciated

    Good catch, BI Learner. This was exactly it: when assigning the values from SOURCEFIELDS directly to the import/export parameters, you have to make sure that the types are EXACTLY the same, otherwise it will not work (the routine stops with an error when calling the FM, but there is no dump).
    Therefore, to solve my problem, I created the declarations precisely as expected by the FM and assigned the values to these fields:
    DATA:
          SOURCEVAL TYPE  /BIC/OIINVQTY,
          SOURCEUOM TYPE  /BIC/OIUSUOM,
          USITM TYPE  /BIC/OIUSITM,
          TARGETUOM TYPE  /BIC/OIUSUOM,
          CONVERTED_COST TYPE  /BIC/OIINVQTY.
    DATA PRODUCTION_UOM TYPE /BIC/OIUSUOM.
    " get the Production UOM
        SELECT SINGLE I~/BIC/USPRDUOM
          FROM /BIC/PUSITM AS I
          INTO PRODUCTION_UOM
          WHERE I~/BIC/USITM = SOURCE_FIELDS-/BIC/USITM AND I~OBJVERS = 'A'.
        IF ( SY-SUBRC = 4 ). " no records found
          "RAISE PARTNO_NOT_FOUND.
          RAISE EXCEPTION TYPE CX_RSROUT_SKIP_RECORD.
        ENDIF.
    " load the parameters
        SOURCEVAL = SOURCE_FIELDS-/BIC/USFRZMFC.
        SOURCEUOM = SOURCE_FIELDS-BASE_UOM.
        USITM = SOURCE_FIELDS-/BIC/USITM.
    " then you can call the FM
        CALL FUNCTION 'Z_CA_CONVERT_US_COST'
          EXPORTING
            PSOURCEVAL                = SOURCEVAL
            PSOURCEUOM                = SOURCEUOM
            PUSITM                    = USITM
            PTARGETUOM                = PRODUCTION_UOM
          IMPORTING
            PTARGETVAL                = CONVERTED_COST
          EXCEPTIONS
            CONVERSION_NOT_MAINTAINED = 1
            PARTNO_NOT_FOUND          = 2
            OTHERS                    = 3.
    " ... [do the rest]
    Thanks for your help,
    Dennis

  • Calling RFC Function module from JAVA

    Hi All,
       We have created a RFC Function Module for Billing Plan tab in Sales order (BDC). The function Module contains BDC. When we are running the same function module in SAP it is working fine. But when the FM is called in Java , it is allowing only maximum of 5 entries , when we trying to insert at 6th position in billing plan tab, we are getting an error.
    Can any one help on this.
    Points will be rewarded for helpful answers.
    Thanks & Regards,
    Kiran I

    I think the problem is because of the number of lines displayed on the screen in the BDC session in the Billing Plan.
    You might have to add the page down logic to your BDC program.

  • Problem while importing RFC function module in XI. Please Help!

    Hi Experts,
               When I try to import RFC function module in XI I get the following error:
                 **Ready for import**
    Import started...
    YCOP_VALIDATE_GR:
      + com.sap.aii.ibrep.sbeans.upload.RemoteUploadException: connection closed without message (CM_NO_DATA_RECEIVED)
    Import failed with 1 error
    Any idea why is this error? How to resolve this?
    Thanks
    Gopal

    Hi
       The problem still persists.
       This is what I have done:
        1. My FM is RFC enabled. In the "Attribute" tab of the FM I have selected "Remote-enabled module" and "Start immed".
    2.Activated and tested the FM.
    3.Released the FM. In se37, Function Module -> Release ->Release. 
    4.Tried to import this FM in XI under "RFC". Get the same error.
    I have some questions:
    1. After releasing the FM do I have to activate it?
    2. In release there is "Internal Release" Do I have to use that?
    3.Do I have to do "Internal Release" first then "Release"?
    4.The FM i am trying to import makes a call to another FM. Both the FMs are in the same system. Both are remote enabled. The second FM updates data in custom table. the first FM which I am importing validates the data and then calls the second FM for update. Do I have to import both FMs?
    Please help me!
    Thanks
    Gopal

  • Error when call RFC Function module in R/3

    Dear All,
    We are trying to call RFC function module CBIF_GLM1_PROCESS_ORDER_READ (This is not a BAPI and also not released ) in R/3 from XI system.
    we are facing the error "Error while lookup Exception during processing the payload. Error when calling an adapter by using the communication channel CC_PPPI_MES_RFC_Rcvr (Party: , Service: WCD_320, Object ID: 16563889b449328eac76caa6a3bc592e) XI AF API call failed. Module exception: 'error while processing the request to rfc-client: com.sap.aii.adapter.rfc.afcommunication.RfcAFWException: error while processing message to remote system:com.sap.aii.adapter.rfc.core.client.RfcClientException: failed to parse BAPI response due to: com.sap.aii.adapter.rfc.util.bapi.BapiException: Parameter with name RETURN not found.'. Cause Exception: 'com.sap.aii.adapter.rfc.afcommunication.RfcAFWException: error while processing message to remote system:com.sap.aii.adapter.rfc.core.client.RfcClientException: failed to parse BAPI response due to: com.sap.aii.adapter.rfc.util.bapi.BapiException: Parameter with name RETURN not found.'."
    This is the first time we are doing this configuration.
    Could you please let me know what woulbe the reason.

    read the original message
    We are trying to call RFC function module CBIF_GLM1_PROCESS_ORDER_READ (This is not a BAPI and also not released ) in R/3 from XI system.
    I am talking about the above Receiver RFC channel which you guys are using to call R/3 from XI. That where you need to change the commit parameter

  • Standard Component in CRM that will call RFC Function Module

    HI all,
    Is there any Standard Component in CRM that will call RFC Function Module from ECC and that called RFC FM should Fetch the data from ECC.

    You can call RFC from different places, like programs, function modules, web dynpros, classes...
    So you just have to have appropriate RFC on ERP side and call it from CRM side. To call it you use the following statement...
          CALL FUNCTION 'YOUR RFC FUNCTION'
            DESTINATION i_dest "name of server
            EXPORTING
              your export parameters
            IMPORTING
              your import parameters
    Regards.

  • Call RFC Function Module and return 1000 records at a time

    I would like to call a Remote Enabled Function Module from a non SAP system.  This function module will select data from the database and return it to the calling program.
    Suppose there are 100,000 records that need to be returned, but the calling module would like the data in chunks of 1000 records.  Therefore the calling program would call the FM 100 times. 
    How do I code the function module to know on each subsequent call to grab the next chunk of 1000 records? 
    Let me know if additional information is needed.
    Thanks,
    Aaron

    Hello,
    Here is how you can go for this issue:
    1. Create one RFC function module with following parameter. These parameters are with respective of chunking logic.
         Import: Package Size
         Export: Total number of records
         Changing: chunk count
    Implement following logic:
    1. First of you need to know how many chunks you need to fetch for that get the count of total number of records. This is one  
        time activity so you better maintain one flag import parameter will be set to 'X' only first call.
    2. Get the number of chunk using total number of records / chunk size for e.g. 1000 / 100 so chunk count = 10.
    3. Define internal chunk counter in function module which will be used to locate the correct chunk depending on the chunk
        counter value sent from calling program.
    4. Send first call with package size 100 and chunk count = 1, execute select statement and increment internal
        chunk count check if chunk count = internal chunk count in current case chunk count = 1 so exit select statement and return
        with first chunk.
    5. Send second call with package size 100 and chunk count = 2. Execute select statement and check chunk count with internal
        chunk counter, in current case it will be 1 so skip that data and go for next chunk of 100 records increment internal chunk  
        counter. In this case it will match with external chunk count = 2. load output table with that data and return to calling program.
    6. Repeat step 4 until you reach last chunk.
    You need to use SELECT...ENDSELECT with PACKAGE SIZE addition so for every loop it will return number of records mentioned in package size.
    Hope this helps.
    Thanks,
    Augustin.

  • Call RFC Function Module in R/3 via XI during Mapping

    Hi,
    I have an XI scenario where I have to fill the IDoc ADRMAS03 in XI and send it to R/3. Unfortunately the sender system does not provide the required address number (ADRNR) for the Business Partner, only the Business Partner number. Therefore I want to call a Function Module in R/3 during the mapping in order to get the ADRNR.
    Does anybody know which RFC-Function Module I can call in R/3 4.6c providing the Busness Partner number in order to get the ADRNR?
    Thanks.
    Alex

    Hi,
    no need for RFC lookup it's better to do as he wants
    (inside an exit in R3) - just my point of view
    BTW
    don't use a FM just find a table with both values
    and create a select statement youself
    Regards,
    michal
    <a href="/people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions"><b>XI / PI FAQ - Frequently Asked Questions</b></a>

  • Calling RFC function module in other SAP system...

    Hi,
    I have a report on one SAP system and a function module on other system. The function module is RFC enabled. How can I call this RFC enabled function module from other SAP system in the report which is different SAP ?
    system.
    Thanks.
    Regards,
    Rajesh.

    call the function module in orginal system in se38 ,copy the function module ,paste the function module in other system,and maintain destination here ,otherwise you will get short dump.
    here detination should be SM59 destination,this is case sensitive.
    Reward Points if it is helpful
    Thanks
    Seshu

  • Calling BAPI(RFC function module) in java? Part 2

    Hi
    Can any body tell me or give me source code for calling give BAPI...i need to give the inputs to that parameters..
    data l_order_header_in    like bapisdhd1.
    data t_return             like bapiret2  occurs 0 with header line.
    data t_order_items_in     like bapisditm occurs 0 with header line.
    data t_order_schedules_in like bapischdl occurs 0 with header line.
    data t_order_partners     like bapiparnr occurs 0 with header line.
    *data t_order_condition_ex like bapicond   occurs 0 with header line.
    *clear   t_order_condition_ex.
    *refresh t_order_condition_ex.
    clear l_order_header_in.
    l_order_header_in-doc_type      =  'TA'.
    l_order_header_in-sales_org     =  'ZZ02'.
    l_order_header_in-distr_chan    =  'Z2'.
    l_order_header_in-division      =  'Z2'.
    *l_order_header_in-purch_no      =  '12'.
    clear   t_order_items_in.
    refresh t_order_items_in.
    t_order_items_in-itm_number     =  '000001'.
    t_order_items_in-material       =  'HAMAM'.                 " 'LBYA1'.
    t_order_items_in-target_qty     =  '0000000000001'.
    t_order_items_in-comp_quant     =  '0000000000001'.
    append t_order_items_in.
    clear   t_order_partners.
    refresh t_order_partners.
    t_order_partners-partn_role     =  'AG'.
    t_order_partners-partn_numb     =  '0000000006'.
    append t_order_partners.
    clear   t_order_schedules_in.
    refresh t_order_schedules_in.
    t_order_schedules_in-itm_number =  '000001'.
    t_order_schedules_in-sched_line =  '0001'.
    t_order_schedules_in-req_qty    =  1.
    append t_order_schedules_in.
    clear   t_order_partners.
    t_order_partners-partn_role     =  'WE'.
    t_order_partners-partn_numb     =  '0000000006'.
    append t_order_partners.
    break kumars.
    call function 'BAPI_SALESORDER_CREATEFROMDAT2'
      exporting
      SALESDOCUMENTIN               =
        order_header_in               = l_order_header_in
      ORDER_HEADER_INX              =
      SENDER                        =
      BINARY_RELATIONSHIPTYPE       =
      INT_NUMBER_ASSIGNMENT         =
      BEHAVE_WHEN_ERROR             =
      LOGIC_SWITCH                  =
      TESTRUN                       =
      CONVERT                       = ' '
    IMPORTING
      SALESDOCUMENT                 =
      tables
        return                        = t_return
        order_items_in                = t_order_items_in
      ORDER_ITEMS_INX               =
        order_partners                = t_order_partners
        order_schedules_in            = t_order_schedules_in
      ORDER_SCHEDULES_INX           =
      ORDER_CONDITIONS_IN           =
      ORDER_CONDITIONS_INX          =
      ORDER_CFGS_REF                =
      ORDER_CFGS_INST               =
      ORDER_CFGS_PART_OF            =
      ORDER_CFGS_VALUE              =
      ORDER_CFGS_BLOB               =
      ORDER_CFGS_VK                 =
      ORDER_CFGS_REFINST            =
      ORDER_CCARD                   =
      ORDER_TEXT                    =
      ORDER_KEYS                    =
      EXTENSIONIN                   =
      PARTNERADDRESSES              =
    break venkat.
    call function 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
      WAIT          =
    IMPORTING
      RETURN        =
    Awaiting for ur responses..
    Thx
    PRadeep

    To call an RFC, you need to import that first. For that right click on the project into which you need to add the rfc.
    Import >>import RFC modules from r/3>>Give the package name and a port name for the rfc.
    set the server options as your r/3 server properties.
    Then you can search the Function name >> it will be displayed in the result area>> select it and press finish.
    The RFC will be imported to your project.
    Then you need to create JCO for calling that rfc.
    Here is a sample code which calls an RFC and setting jco..
    import com.sap.mw.jco.JCO;
    import com.sapportals.portal.prt.component.*;
    public class rfc extends AbstractPortalComponent
         private JCO.Client jcoClient;
         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");
    //calling RFC
         try{
         op=insFunc.zinsert_Pgm(ip);
         }catch(Exception e){}
              response.write(op.getMessage());
              this.disconnect();
    //creating JCO connection
         private void connect() {
                   try {
                        jcoClient =
                             JCO.createClient("Client","userid","password","Language","servername","Systemid");
                             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

  • Calling New Function Module from JAVA ISA b2b

    I need to call a new function module which accepts some parameters as input and
    returns some result parameters back as output.
    These returned value needs to be displayed on the JSP pages of ISA B2B applications.
    Can someone please guide me and provide code snippet on how to do this?
    Thanks in advance.
    Points will be awarded for all relevant and helpful answers.

    Stride,
    I did this on CRM ISA 4.0...  I used the dev and extension guide as a basis - I think the ISA 5.0 guide has the examples and tutorials in a separate document that can also be downloaded from service.sap.com.
    Here’s some info on how to do it although I can't guarantee this is the full solution or that it will work the same for ISA 5.0, and I will probably forget a lot of stuff as its been a few years since I did it!  I also can’t guarantee it is the correct way to do it – but it worked!  Basically, we built a link into the order overview page to display url’s to order tracking websites using an RFC on the backend CRM system.  Hope it helps anyway.
    1. Create RFC enabled function module in backend.
    2. Edit file backendobject-config.xml in folder project_root\b2b_z\WEB-INF\xcm\customer\modification:-
    [code] <backendobject
         xmlns:isa="com.sapmarkets.isa.core.config"
         xmlns:xi="http://www.w3.org/2001/XInclude"
         xmlns:xml="http://www.w3.org/XML/1998/namespace">
         <configs>
              <!-- customer changes in backendobject-config should be done here by extending/overwriting the base configuration-->
              <xi:include
                   href="$
    Template for backend object in customer projects
    Concrete implementation of a backend object
    This implemenation demonstrates how a backend object
    is used to communicate with the CRM system
    @see com.ao.isa.backend.boi.Z_AOFuncBackend#getOrderDeliveryTrackingData(java.lang.String)
    Interface used to communicate with a backend object
    The purpose of this interface is to hide backend implementation details
    from the business objects
    Returns a vector of Z_OrderDeliverTracking objects containing data to link
    to external delivery tracking websites
    @param orderNo The sales order document number
    @return A vector of order tracking objects
    @return
    @return
    @return
    @return
    @return
    @param string
    @param string
    @param string
    @param string
    @param string
    /modification/backendobject-config.xml#xpointer(backendobject/configs/*)"/>
              <!-- This is an example customer extension. A new Backend Object is registered in the framework using XCM extension mechanism. -->
              <!-- If you write customer extensions you should register your backend objects in the same way. -->
              <!-- Please make sure that you use the correct base configuration (e.g. crmdefault for CRM or r3default, r3pidefault for R/3) -->
              <config
                   isa:extends="../config[@id='crmdefault']">
                   <businessObject
                        type="Z_AO_Custom"
                        name="Z_AO_Custom"
                        className="com.ao.isa.backend.crm.Z_AOFuncCRM"
                        connectionFactoryName="JCO"
                        defaultConnectionName="ISAStateless"/>
              </config>
         </configs>
    </backendobject>
    [/code]
    File com.ao.isa.backend.crm.Z_AOFuncCRM.java looks like this :-
    [code] package com.ao.isa.backend.crm;
    //jco imports
    import java.util.Vector;
    import com.ao.isa.backend.boi.Z_AOFuncBackend;
    import com.ao.isa.businessobject.order.Z_OrderDeliveryTrackingItem;
    import com.sap.mw.jco.JCO;
    import com.sap.mw.jco.JCO.ParameterList;
    import com.sapmarkets.isa.core.eai.BackendException;
    import com.sapmarkets.isa.core.eai.sp.jco.BackendBusinessObjectBaseSAP;
    import com.sapmarkets.isa.core.logging.IsaLocation;
    public class Z_AOFuncCRM
         extends BackendBusinessObjectBaseSAP
         implements Z_AOFuncBackend
         // initialize logging
         private static IsaLocation log =
              IsaLocation.getInstance(Z_AOFuncCRM.class.getName());
         /* (non-Javadoc)
         public Vector getOrderDeliveryTrackingData(String orderNo)
              Vector urlData = new Vector();
              try
                   // get Java representation of function module
                   JCO.Function func =
                        getDefaultJCoConnection().getJCoFunction(
                             "Z_BAPI_CRM_ORDER_TRACKING_URLS");
                   // provide export parameters
                   ParameterList params = func.getImportParameterList();
                   params.setValue(orderNo, "ORDER_NO");
                   func.setExportParameterList(params);
                   // execute function
                   getDefaultJCoConnection().execute(func);
                   // get result table
                   JCO.Table table =
                        func.getTableParameterList().getTable("TRACKING_DATA");
                   int numRows = table.getNumRows();
                   for (int i = 0; i < numRows; i++)
                        // get row
                        table.setRow(i);
                        // create a new Z_orderdeliverytracking object
                        Z_OrderDeliveryTrackingItem trackItem =
                             new Z_OrderDeliveryTrackingItem(
                                  table.getString(0),
                                  table.getString(1),
                                  table.getString(2),
                                  table.getString(3),
                                  table.getString(4));
                        urlData.addElement(trackItem);
                        trackItem = new Z_OrderDeliveryTrackingItem();
                   return urlData;
              catch (BackendException bex)
                   // The following key has to be added to WEB-INF/classes/ISAResources.properties
                   // in order to see the exception correctly
                   log.config("ao.b2b.order.error.getOrderTrackingURLs", bex);
              return null;
    [/code]
    And file com.ao.isa.backend.boi.Z_AOFuncBackend.java looks like this:-
    [code] package com.ao.isa.backend.boi;
    //package java.ao.com.ao.isa.backend.boi;
    import java.util.Vector;
    import com.sapmarkets.isa.core.eai.sp.jco.JCoConnectionEventListener;
    public interface Z_AOFuncBackend
         public Vector getOrderDeliveryTrackingData(String orderNo);
    [/code]
    Whilst file com.ao.isa.businessobject.order.Z_OrderDeliveryTrackingItem.java looks like this:-
    [code]
    package com.ao.isa.businessobject.order;
    // Referenced classes of package com.sapmarkets.isa.businessobject.order:
    //            PaymentType
    public class Z_OrderDeliveryTrackingItem // extends SalesDocument implements OrderData
         private String deliveryDocNo;
         private String goodsIssuedDate;
         private String consignmentNo;
         private String status;
         private String url;
         public Z_OrderDeliveryTrackingItem()
         public Z_OrderDeliveryTrackingItem(
              String delDocNo,
              String GIDate,
              String consNo,
              String status,
              String url)
              this.setDeliveryDocNo(delDocNo);
              this.setGoodsIssuedDate(GIDate);
              this.setConsignmentNo(consNo);
              this.setStatus(status);
              this.setUrl(url);
         public String getConsignmentNo()
              return consignmentNo;
         public String getDeliveryDocNo()
              return deliveryDocNo;
         public String getGoodsIssuedDate()
              return goodsIssuedDate;
         public String getStatus()
              return status;
         public String getUrl()
              return url;
         public void setConsignmentNo(String string)
              consignmentNo = string;
         public void setDeliveryDocNo(String string)
              deliveryDocNo = string;
         public void setGoodsIssuedDate(String string)
              goodsIssuedDate = string;
         public void setStatus(String string)
              status = string;
         public void setUrl(String string)
              url = string;
    [/code]
    3. Edit file bom-config.xml in folder project_root\b2b_z\WEB-INF\xcm\customer\modification :-
    [code] <BusinessObjectManagers
         xmlns:isa="com.sapmarkets.isa.core.config"
         xmlns:xi="http://www.w3.org/2001/XInclude"
         xmlns:xml="http://www.w3.org/XML/1998/namespace">
         <!-- customer changes in bom-config should be done here by extending/overwriting the base configuration-->
         <xi:include
              href="$/modification/bom-config.xml#xpointer(BusinessObjectManagers/*)"/>
         <!-- This is an example Business Object Manager. It can act as template for customer written Business Object Managers -->
         <BusinessObjectManager
              name="Z_AO-BOM"
              className="com.ao.isa.businessobject.Z_AOBusinessObjectManager"
              />
    </BusinessObjectManagers>
    [/code]
    File com.ao.isa.businessobject.Z_AOBusinessObjectManager.java looks like this:-
    [code] package com.ao.isa.businessobject;
    // Internet Sales imports
    import com.sapmarkets.isa.core.businessobject.management.BOManager;
    import com.sapmarkets.isa.core.businessobject.management.DefaultBusinessObjectManager;
    import com.sapmarkets.isa.core.businessobject.BackendAware;
    Template for a custom BusinessObjectManager in customer projects
    public class Z_AOBusinessObjectManager
         extends DefaultBusinessObjectManager
         implements BOManager, BackendAware {
         // key used for the backend object in customer version of backendobject-config.xml
         public static final String CUSTOM_BOM = "Z_AO-BOM";
         // reference to backend object
         private Z_AOFunc mCustomBasket;
    constructor
         public Z_AOBusinessObjectManager() {
    Method is called by the framework before the session is invalidated.
    The implemenation of this method should free any allocated resources
         public void release() {
    Returns custom business object
         public Z_AOFunc getCustomBasket() {
              if (mCustomBasket == null) {
                   mCustomBasket = new Z_AOFunc();
                   assignBackendObjectManager(mCustomBasket);
              return mCustomBasket;
    [/code]
    And uses file com.ao.isa.businessobject.Z_AOFunc.java which looks like this:-
    [code]
    package com.ao.isa.businessobject;
    // Internet Sales imports
    import com.sapmarkets.isa.core.businessobject.BOBase;
    import com.sapmarkets.isa.core.businessobject.BackendAware;
    import com.sapmarkets.isa.core.eai.BackendObjectManager;
    import com.sapmarkets.isa.core.eai.BackendException;
    import com.sapmarkets.isa.core.logging.IsaLocation;
    // custom imports
    import com.ao.isa.backend.boi.Z_AOFuncBackend;
    import java.util.Vector;
    Template for business object in customer projects
    public class Z_AOFunc extends BOBase implements BackendAware
         // initialize logging
         private static IsaLocation log =
              IsaLocation.getInstance(Z_AOFunc.class.getName());
         private BackendObjectManager bem;
         private Z_AOFuncBackend backendAOBasket;
    Returns a reference to the backend object. The backend object
    is instantiated by the framework.
    @return a reference to the backend object
         private Z_AOFuncBackend getCustomBasketBackend()
              if (backendAOBasket == null)
                   //create new backend object
                   try
                        backendAOBasket =
                             (Z_AOFuncBackend) bem.createBackendBusinessObject(
                                  "Z_AO_Custom");
                        // the backend object is registered in customer version
                        // of backendobject-config.xml using the 'Z_AO_Custom' type
                   catch (BackendException bex)
                        // The following key has to be added to WEB-INF/classes/ISAResources.properties
                        // in order to see the exception correctly
                        log.config("ao.b2b.order.error.getOrderTrackingURLs", bex);
              return backendAOBasket;
    This method is needed when a business object has a corresponding
    backend object.
         public void setBackendObjectManager(BackendObjectManager bem)
              this.bem = bem;
    Returns a vector of url links for tracking
    @return vector of urls
         public Vector getOrderDeliveryTrackingData(String orderNo)
              // the call is delegated to the CRM aware backend object
              return getCustomBasketBackend().getOrderDeliveryTrackingData(orderNo);
    [/code]
    4. Edit file config.xml in folder project_root\b2b_z\WEB-INF to add custom actions (the section below is just the custom stuff added at the end of the file – the Z_orderTracking is the relevant one) :-
    [code] <!-- Begin of custom AO action definitions -->
         <action path="/b2b/Z_orderTracking" type="com.ao.isa.order.actions.Z_OrderTrackingAction">
              <forward name="success" path="/b2b/order/Z_orderTracking.jsp"/>
         </action>
         <action path="/catalog/Z_displaySVGPage" type="com.ao.isa.catalog.actions.Z_SVGPageAction">
              <forward name="success" path="/catalog/Z_SVG_fs.jsp"/>
         </action> [/code]
    Which points at Java file com.ao.isa.order.actions.Z_OrderTrackingAction.java which looks like this :-
    [code] package com.ao.isa.order.actions;
    // internet sales imports
    import com.sapmarkets.isa.core.BaseAction;
    import com.sapmarkets.isa.core.UserSessionData;
    // struts imports
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;
    import org.apache.struts.action.ActionForm;
    // servlet imports
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.ServletException;
    // Internet Sales imports
    import com.ao.isa.businessobject.Z_AOBusinessObjectManager;
    import java.util.Vector;
    This action acts as a template for customer extensions
    public class Z_OrderTrackingAction extends BaseAction
    This method is called by the ISA Framework when the
    action is executed
         public ActionForward doPerform(
              ActionMapping mapping,
              ActionForm form,
              HttpServletRequest request,
              HttpServletResponse response)
              throws ServletException
              // get user session data object
              UserSessionData userSessionData =
                   UserSessionData.getUserSessionData(request.getSession());
              // gettting custom BOM
              Z_AOBusinessObjectManager myBOM =
                   (Z_AOBusinessObjectManager) userSessionData.getBOM(
                        Z_AOBusinessObjectManager.CUSTOM_BOM);
              // get the order number being processed
              String orderDocNumber = request.getParameter("orderNo");
              // pass the order number back to the page
              request.setAttribute("orderNo", orderDocNumber);
              if (orderDocNumber != null)
                   // Get a vector of delivery tracking objects from lower layers (Business Object layer =>
                   // Business Logic Service Layer)
                   Vector trackingTable =
                        myBOM.getCustomBasket().getOrderDeliveryTrackingData(
                             orderDocNumber);
                   String error = "";
                   if (trackingTable != null)
                        if (trackingTable.size() == 0)
                             error = "true";
                        else
                             error = "false";
                   else
                        error = "true";
                   request.setAttribute("errorMessage", error);
                   request.setAttribute("trackingTable", trackingTable);
              return mapping.findForward("success");
    [/code]
    5. I added the call to the function module for page orderstatusdetail.jsp in folder project_root\b2b_z\b2b\order to display a custom page Z_orderTracking.jsp in the same folder.  To do this I added a link into the HTML to call a JavaScript function that passed the current order number to the /b2b/Z_orderTracking.do actionhandler mapped in the config.xml file.
    So, in summary!  Create an RFC; define business managers for it in the XML files; create a new Strut action and supporting Java class; create all the Java class’ for the managers.
    I hope this makes some sense!
    Gareth.

  • Problem while working with function module RFC_READ_TABLE

    Dear Experts,
                     I am facing a problem while working on the FM RFC_READ_TABLE, in which there is a tables parameter options which is of table type, to which I am passing the condition of selection.  In the debugg mode I found the select quiry in the source code of function module is not executing the condition passed in the options parameter.
    My actual requirement is to fetch all the custom programs in a remote server, the code I have written is below.
    TYPES :
             BEGIN OF ty_tadir,
               pgmid  TYPE pgmid,
               object TYPE  trobjtype,
               obj_name  TYPE  sobj_name,
             END OF ty_tadir.
    DATA : it_tadir TYPE STANDARD TABLE OF ty_tadir,
            wa_tadir TYPE ty_tadir.
      data: stmp_dokhl  like TAB512       occurs 100000 with header line.
      data: options1    like rfc_db_opt occurs     10 with header line.
    data: wa_options1 like line of options1.
      data: nametab1    like rfc_db_fld  occurs     10 with header line.
    START-OF-SELECTION.
    DATA : W_VALUE(5)  TYPE C,
           W_VALUE1(20) TYPE C.
    W_VALUE1 =  'OBJ_NAME like'.
    W_VALUE = 'z*'.
    CONCATENATE 'OBJ_NAME LIKE' ' ''' W_VALUE '''' INTO OPTIONS1-TEXT.
    CONCATENATE W_VALUE1 W_VALUE INTO wa_OPTIONS1-TEXT SEPARATED BY SPACE.
    APPEND wa_OPTIONS1 to OPTIONS1.
    CLEAR wa_OPTIONS1.
        call function 'RFC_READ_TABLE'
             destination                'zard'
             exporting
                  query_table          = 'TADIR' "'ZBANK_GUARANTEE'
             tables
                  options              = options1
                  fields               = nametab1
                  data                 = stmp_dokhl
             exceptions
                  table_not_available  = 1
                  table_without_data   = 2
                  option_not_valid     = 3
                  field_not_valid      = 4
                  not_authorized       = 5
                  data_buffer_exceeded = 6
                  others               = 7 .
    Please give me some inputs on this,
    With warm regards,
    Murthy.
    Edited by: pr murthy on Sep 18, 2008 1:49 PM
    Edited by: pr murthy on Sep 18, 2008 2:14 PM

    Hi
    I have tried this and with small change this is working fine.
    TYPES :
    BEGIN OF ty_tadir,
    pgmid TYPE pgmid,
    object TYPE trobjtype,
    obj_name TYPE sobj_name,
    END OF ty_tadir.
    DATA : it_tadir TYPE STANDARD TABLE OF ty_tadir,
    wa_tadir TYPE ty_tadir.
    data: stmp_dokhl like TAB512 occurs 100000 with header line.
    data: options1 like rfc_db_opt occurs 10 with header line.
    data: wa_options1 like line of options1.
    data: nametab1 like rfc_db_fld occurs 10 with header line.
    START-OF-SELECTION.
    DATA : W_VALUE(5) TYPE C,
    W_VALUE1(20) TYPE C.
    W_VALUE1 = 'OBJ_NAME LIKE ''Z%'''.
    wa_options1-text = w_value1.
    APPEND wa_OPTIONS1 to OPTIONS1.
    CLEAR wa_OPTIONS1.
    call function 'RFC_READ_TABLE'
    *destination 'zard'
    exporting
    query_table = 'TADIR' "'ZBANK_GUARANTEE'
    tables
    options = options1
    fields = nametab1
    data = stmp_dokhl
    exceptions
    table_not_available = 1
    table_without_data = 2
    option_not_valid = 3
    field_not_valid = 4
    not_authorized = 5
    data_buffer_exceeded = 6
    others = 7 .

  • INTERNAL_SERVER_ERROR    while Calling SCMS_HTTP_CREATE Function Module

    Dear All,
    We want to attach document (PDF, DOCX, TXT etc.) in DMS using WD application.
    We converted data xstring to binary format. Now when we call Function Module SCMS_HTTP_CREATE, it gives SY-SUBRC = 5. INTERNAL_SERVER_ERROR.
    Code:
    *"*"Local Interface:
    *"  IMPORTING
    *"     VALUE(IV_ARCHIV_ID) TYPE  TOAOM-ARCHIV_ID
    *"     VALUE(IV_AR_OBJECT) TYPE  TOAOM-AR_OBJECT
    *"     VALUE(IV_OBJECT_ID) TYPE  SAPB-SAPOBJID
    *"     VALUE(IV_SAP_OBJECT) TYPE  TOAOM-SAP_OBJECT
    *"     VALUE(IV_LENGTH) TYPE  I
    *"     VALUE(IV_MIMETYPE) TYPE  STRING
    *"     VALUE(IT_DATA) TYPE  ZTAB
    *"  EXPORTING
    *"     VALUE(EV_FLAG) TYPE  CHAR1
    *"     VALUE(EV_DOC_ID) TYPE  SAEARDOID
    DATA : LV_ARC_DOC TYPE SYSUUID-C,
            LV_MIMETYPE TYPE W3CONTTYPE,
            LV_ARCDOC TYPE TOAV0-ARC_DOC_ID.
    CALL FUNCTION 'SYSTEM_UUID_C_CREATE'
      IMPORTING
        UUID          = LV_ARC_DOC.
    CALL FUNCTION 'SCMS_FE_GROUP_OPEN'.
    LV_MIMETYPE = IV_MIMETYPE.
    CALL FUNCTION 'SCMS_HTTP_CREATE'
       EXPORTING
        MANDT                       = SY-MANDT
         CREP_ID                     = IV_ARCHIV_ID
        DOC_ID                      = LV_ARC_DOC
        COMP_ID                     = 'data'
        MIMETYPE                    = LV_MIMETYPE
         LENGTH                      = IV_LENGTH
    *   SIGNATURE                   = 'X'
    *   DOC_PROT                    = 'rcud'
    *   TEXT_MODE                   = ' '
    *   ACCESSMODE                  = 'c'
    *   SECURITY                    = ' '
    *   OVERWRITE                   = '-'
    * IMPORTING
    *   DOC_ID_OUT                  =
       TABLES
         DATA                        = IT_DATA
      EXCEPTIONS
        BAD_REQUEST                 = 1
        UNAUTHORIZED                = 2
        FORBIDDEN                   = 3
        CONFLICT                    = 4
        INTERNAL_SERVER_ERROR       = 5
        ERROR_HTTP                  = 6
        ERROR_URL                   = 7
        ERROR_SIGNATURE             = 8
        ERROR_PARAMETER             = 9
        OTHERS                      = 10
    IF SY-SUBRC <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    CALL FUNCTION 'SCMS_FE_GROUP_CLOSE'
    LV_ARCDOC = LV_ARC_DOC.
    CALL FUNCTION 'ARCHIV_CONNECTION_INSERT'
       EXPORTING
        ARCHIV_ID                    = IV_ARCHIV_ID
         ARC_DOC_ID                  = LV_ARCDOC
    *   AR_DATE                     = ' '
         AR_OBJECT                   = IV_AR_OBJECT
    *   DEL_DATE                    = ' '
    *   MANDANT                     = ' '
         OBJECT_ID                   = IV_OBJECT_ID
         SAP_OBJECT                  = IV_SAP_OBJECT
    *   DOC_TYPE                    = ' '
    *   BARCODE                     = ' '
      EXCEPTIONS
        ERROR_CONNECTIONTABLE       = 1
        OTHERS                      = 2
    IF SY-SUBRC <> 0.
    ** MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    While Calling FM 'SCMS_HTTP_CREATE' is Raise Exception 5 INTERNAL_SERVER_ERROR.
    Thanks
    Regards
    Rohit      

    Hi,
    Content-Type: application/xml
    ...check for the content type of the message that is sent ot the WS.....with the above mentioned content-type going to the WS currently...WS is not able to parse the req and hence the error....in other words wrong format being being passed.
    Regards,
    ABhishek.

  • Problem while Calling a CGI pgm From Java with code sample

    Hey guys,
    I am calling a CGI program from java servlet, while calling cgi program I am passing encoded(Base64) content via post process,
    My problem is the encoded data is not posted as expected, the encoded data is corrupting. But when I send encoded data in a text file, cgi program is perfectly decoding and working fine.
    Here I am doing Base64 encoding as per requirement, I cannot avoid this encoding.
    My doubt is about OutputStreamWriter constructor argument , In OutputStream Constructor I am passing one argument is OutputStream object and another argument is encoding type. I tried with ASCII, US-ASCII & UTF-8 .
    My code is as follows, please help me to resolve this issue.
    URL url = new URL("CGI server path");
    URLConnection urlConnection = url.openConnection();
    urlConnection.setDoOutput(true);
    OutputStream os = urlConnection.getOutputStream();
    BufferedOutputStream buffer = new BufferedOutputStream(os);
    OutputStreamWriter  writer = new
                                                   OutputStreamWriter(buffer, "US-ASCII");
    writer.write(encodedPDF-Content);
    writer.write("\r\n");
    writer.flush();
    writer.close();
    here encodedPDF-Content is String and it's size is 9565 bytes

    Whenever you read something in java into string (with Reader implementation) it expects source to contain text in encoding you specified. It then decodes it and makes 16 bit unicode string from it. Whenever you store string using Writers it does reverse operation with specified encoding (may be different than this which you used to read source) and stores text as a sequence of bytes made of 16 bit unicode string. So, passing text back and forth between programs with the help of files or I/O you can make mistake at both reading and writing encoding. Check for it.
    Now, when C programm or other application reads file it may take another assumptions about encoding or may even completly ignore it and read source as a binary file. Then, if you have a source text as a file and have to pass it to other application never do it using Reader/Writer. User raw InputStream/OutputStream instead what will preserve all information unchanged.
    here encodedPDF-Content is String and it's size is 9565 byteHow id you get this info? String.length() gets you how many chars is in it, it will be half the number of bytes. If you see your input file beeing 9565 bytes long, see my above statements.

  • Call RFC function module

    Hi all,
    i try to call a remote enabled function module via rfc from erp to apo.
    CALL FUNCTION 'Z_XXXXXXXXXXXX
            DESTINATION XXXXX
            EXPORTING
              wa_truid = it_tab_pre-trguid
            IMPORTING
              status   = wa_status.
    In debugging the parameter it_tab_pre-trguid is filled correctly (in ERP).
    But in APO the field is empty.
    Any ideas?
    regards

    Hi!
    Calling an FM with RFC means, you just simply run it on their system with giving  some parameters to it.
    It will use the remote database to select data.
    Log into the APO system and run the FM there, with the same parameters, and you'll see, what's wrong.
    Regards
    Tamá

Maybe you are looking for

  • Ipad "other space" from a third party app

    i have downloaded a third party app (torrent) but to no avail it doesn't play the movie that i have downloaded, even worse it took up "other" space when I tried opening it on VLC and File Manager but when i browsed on SETTINGS>General>Usage it did no

  • Client Proxy success acknowledgements to PI

    Hi All, Is it possible to send the client proxy successful acknowledgements to PI? If there is an error in data, the Fault message will be used to communicate back to PI. But where as the message processed successfully in ABAP , the I need to send su

  • RFx Response - How to get answers from questions

    Hey, I would like to know how to get the answers from questions ( by IAPI or table where they are stored ) and if i can manipulate them. Thanks!

  • Transforming A Selection Using A Path As A Guide (In CS3)

    Sometimes I like to draw a path first to be my guide when performing a transformation. But, silly-billy old me, I often press command-T which then attempts to transform the path, not the selection. So I end up pressing: command-T, command-Z, command-

  • Help me with a problem

    I have a problem with a string that sounds like this: Which are the most used N characters in the V_string? (N and V_string are two input parameters, N a number and v_string a 5000 characters long string). I need to solve this problem using collectio