Call RFC through EJB

Hi,
I have senerio in which i need to call RFC through EJB.
Thanks.
Abhilasha
Edited by: Abhilasha Dahare on Oct 3, 2008 1:29 PM

Hi,
Go through the following links:
Extract R/3 data via EJB
http://help.sap.com/saphelp_nw04/helpdata/en/35/42e13d82fcfb34e10000000a114084/frameset.htm
Siddharth

Similar Messages

  • How to call RFC using EJB module.

    hi,
        I want to call the RFC using EJB module in java. how to do it.
        if someone having the code plz post it.
    regards,
    Shanthakumar.

    /***Start of JRA specific code***//
    // Retrive connection factory                
    InitialContext initialcontext = new InitialContext();
    connectionfactory = (ConnectionFactory) initialcontext.lookup("java:comp/env/ConnFactory");
    //Request a connection handle:
    connection = connectionfactory.getConnection();
    //Create a RecordFactory object to get a metadata description
    // of the RFC SALERT_CREATE
    RecordFactory recordFactory = connectionfactory.getRecordFactory();
    // Create Record objects containing all
    // necessary information about the RFM.
    MappedRecord input = recordFactory.createMappedRecord("SALERT_CREATE");
    //Fill in the import parameters and the import table structure data here
    input.put("IP_CAT", "ALRT_CAT"); // alert category
    // Refer to the SW_CONT structure of the table of RFC SALERT_CREATE
    ResultSet inputITContainer = (ResultSet) input.get("IT_CONTAINER");
    int tabIndex = 0;
    inputITContainer.moveToInsertRow();
    inputITContainer.updateString("ELEMENT", "CONT_1");
    inputITContainer.updateString("TAB_INDEX", "" + tabIndex++);
    inputITContainer.updateString("ELEMLENGTH", "250");
    inputITContainer.updateString("TYPE", "C");
    inputITContainer.updateString("VALUE","Container_1 value");
    inputITContainer.insertRow();
    inputITContainer.moveToInsertRow();
    inputITContainer.updateString("ELEMENT", "CONT_N");
    inputITContainer.updateString("TAB_INDEX", "" + tabIndex++);
    inputITContainer.updateString("ELEMLENGTH", "250");
    inputITContainer.updateString("TYPE", "C");
    inputITContainer.updateString("VALUE","Container_N value");
    inputITContainer.insertRow();
    interaction = connection.createInteraction();
    // execute the call with the input parameters.
    interaction.execute(null, input);
    }catch(Exception e){
         // Error handling code goes here
    }finally{
         try {
                    if (interaction != null)
                   interaction.close();
              if (connection != null)
                   connection.close();
         } catch (Exception ignored) {
              // Do nothing
    // Pass on module data to the next module in chain, unaltered
    return moduleData;

  • Call WebService through EJB

    Hi friends,
    I have created one web service , how can i call that web service through ejb . Is this possible ?.. can anybody help me....
    Thanks and Regards,
    Krish

    Hi Krish,
    This recent [thread|How to Call webservice by another webservice; deals with the same question. See the answers / links there.
    Hope it helps!
    -- Vladimir

  • Call RFC from EJB using SSO

    Can anyone point me in the right direction on the best practice for calling an RFC using SSO from an EJB?
    When using the local interface for the EJB, the only solution I see is to pass the authenticated IUser instance from the portal component to the EJB business method through the method signature.
    I am guessing that there is a better way to get access to an authenticated user in the EJB container.

    Thanks for the reply.
    Actually I was able to solve the problem last night. To get SSO to work in my local EJBs I created an RFC destination in the destination service using the visual administrator. I then used the destination service at runtime to pull the system definition from the J2EE system definitions store instead of the portal system landscape definitions and my connection object was created as expected.
    Here is the code to create the connection in my EJB business method:
    //get the user
    IUser user = UMFactory.getUserFactory().getUserByUniqueName(this.myContext.getCallerPrincipal().getName());
    // get the destination service
    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sapportals.portal.prt.registry.PortalRegistryFactory");
    InitialContext context = new InitialContext(env);
    IDestinationsService destinationsService =
         (IDestinationsService) context.lookup(IDestinationsService.SERVICE_JNDI_NAME);
    // define a destination filter to restrict to the RFC defined destinations
    DestinationFilter destinationFilter1 =
         new DestinationFilter(DestinationFilter.SOURCE_J2EE_DESTINATION_SERVICE, DestinationFilter.TYPE_SAP);
    // get a user specific connection
    IConnection connection = destinationsService.getConnection(user, "ECC", destinationFilter1);

  • Call RFC from EJB code

    Hi,
         I have a scenario where I need to write an EJB from where I need to execute a JCO call to an RFC. This RFC takes an XString as input (this is the input file) and returns a XString from which an XML needs to be generated.
    Can anyone suggest how to go about this?
    Thanks,
    Shiladitya

    JRA is the way to go....
    check my blog on this...
    /people/amol.joshi2/blog/2006/11/27/alerts-from-adapter-modules--the-jra-way

  • Calling SessionBean through @EJB Annotation

    Hello All
    I was a fan of J2EE but now have just started working on JavaEE after hearing so much about it. I read a lot of tutorials and now i am using NetBeans IDE 5.5 and the application server is JBoss.
    My application scenario is:
    1. Stateless Session Bean
    2. Business Interface (Remote)
    3. Client
    Code for Stateless Session Bean
    package com.testing;
    import javax.ejb.*;
    import javax.annotation.*;
    @Remote({HelloRemote.class})
    @Stateless
    public class HelloBean implements com.testing.HelloRemote {
    public String helloWorld()
            String value = "hello there";
            return value;
    }Code for Remote Business Interface:
    package com.testing;
    import javax.ejb.Remote;
    * This is the business interface for Hello enterprise bean.
    @Remote
    public interface HelloRemote {
        public String helloWorld();
    }Finally code for Client:
    package enterpriseapplication3;
    import java.io.*;
    import java.util.*;
    import javax.ejb.EJB;
    import javax.ejb.*;
    import javax.naming.*;
    import java.rmi.*;
    import com.testing.*;
    public class Main {
        public Main()
         @EJB static private com.testing.HelloRemote hello;
        public void call()
            try
                 String value = hello.helloWorld();
                 System.out.println(value);
            catch(Exception e)
                e.printStackTrace();
         * @param args the command line arguments
        public static void main(String[] args) throws Exception
            Main main = new Main();
            main.call();
    }The problem is when i run my application i get:
    java.lang.NullPointerException
            at enterpriseapplication3.Main.call(Main.java:42)
            at enterpriseapplication3.Main.main(Main.java:57)Please help me out with this issue as I cannot resolve it even though I have tried so many different tutorials but no luck.
    best regards
    rabbia

    You'll need to check the JBoss documentation to see how to invoke the client application.
    This kind of client is referred to as an Application Client. In order for the injection to work
    there must be some special system code provided by your vendor that initializes the client
    app. In the Java EE SDK, it's called the "appclient" command.
    --ken                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Call RFC in Delphi

    Hi,all
        I am a SAP newbie .I have a strange question. My Delphi Development Environment is Delphi 7. SAP ECC 6 , Delphi Call RFC through COM.
    procedure TFrm_SAP.Button3Click(Sender: TObject);
    var
      myIFunction:IFunction;
      myIStructure_EDRAT:IStructure;
      myIStructure_ORDER:IStructure;
      myIParam_AUFNR  :IParameter;
      myIParam_AUTYP10:IParameter;
      myIParam_WERKS  :IParameter;
    begin
      if not Logon_bool then
      begin
        Showmessage('Logon SAP/R3 Failure');
        Exit;
      end;
      SAPFunctions1.Connection:=Connection;
      myIFunction:=SAPFunctions1.Add('Z_XX_GET_PRODORDER_HEADER') AS IFunction;
      myIParam_AUFNR:=myIFunction.Exports_['I_AUFNR'] AS IParameter;
      myIParam_AUFNR.value:='000001002864';
      myIParam_AUTYP10:=myIFunction.Exports_['I_AUTYP10'] AS IParameter;
      myIParam_AUTYP10.Value:='X';
      myIParam_WERKS:=myIFunction.Exports_['I_WERKS'] AS IParameter;
      myIParam_WERKS.Value:='2010';
      myIStructure_EDRAT:=myIFunction.Exports_['IT_ERDAT'] AS IStructure;
      myIStructure_EDRAT.Value['SIGN']  :='I';
      myIStructure_EDRAT.Value['OPTION']:='BT';
      myIStructure_EDRAT.Value['LOW']   :='20090101';
      myIStructure_EDRAT.Value['HIGH']  :='20090330';
      if  not myIFunction.Call then
      begin
        ShowMessage(myIFunction.Exception);  
      end
      else
      begin
         myIStructure_ORDER:=myIFunction.Imports['ET_ORDER'] AS IStructure;
      end;
    end;
    after  execute myIFunction.Call method ,Show
    I trace Log file , as following Show
    T:764 Error in program '': ======> Data error (invalid data type 17) in a Remote Function Call
    T:764 Error in program '': <* RfcReceive [1] : returns 3:RFC_SYS_EXCEPTION
    T:764 Error in program '': <* RfcCallReceive [1] : returns 3:RFC_SYS_EXCEPTION
    Could anybody have helped me to resolve this problem?

    Hi
    Check RFC Import Parameters Data Type and Data Sent from your Delphi System is not matching , Some data type mismatch is going on.
    Check Data Type of when Sent from Delphi == Import (Request) of RFC is equal
    rgds
    srini

  • Calling RFC

    Hi Team,
    I am calling RFC fron ECC 6.0 to SAP 4.6c.
    Destination is maitained in SM59.
    Problem:
    When i am calling RFC through my report program.
    Sy-subrc is 1.
    When running FM at orginal destination it is working fine.
    Any helpful pointers...

    Sy-subrc represents the value of the exception.
    For example
    CALL ZFUNC DESTINATION ZZ.
      EXPORTING
      IMPORTNG
    EXCEPTIONS
           data not found = 1.          "Check this description for your case, This is your error
           communication error = 2.
    Whatever is defined for one is your problem

  • Call Transaction Through RFC

    Hi ,
    I am trying to do a call transaction through RFC call from a Middleware which is a CPIC user (only communication Non dialog User ) . 
    Call  transaction does gets executed without any error but it does not update any data.But when I run it through my user id it works absolutely fine .
    I am not sure what is causing the issue
    Security authorization?
    RFC through Non Dialog user ?
    Paramters missing in RFC  ?
    Paramatertes missing in call transaction option?
    If anyone of you has faced a similiar issue then please let me know the path forward.
    Thanks
    Vikas

    Hi Vikas,
        The problem is in Authorization? And check the mode of Process Synchoronus or asynchoronous? Both the RFC and CALL transaction should be Same /
    Thanks
    MAnju

  • Calling  RFCs from Web through XI

    We have used SAP.NET connector in the past to call RFCs from ASP.NET pages from our public website. We have now decided to use XI as the enterprise integration engine going forward.I am interested to know whether anybody has used XI to call RFCs from ASP.NET webpages. I do know that the XI to SAP calls would be made through RFC adapter.Will the communication from ASP.NET page to XI  be thourgh the HTTP adapter ? or is there any other smarter way. Can somebody point me to sample code for the calls through http adapter or  a how to guide?
    cheers
    Ramesh

    Hi
    U have scenario like this ASP.NET->XI->RFC, that means u will send a value from the ASP.NET page to RFC thru XI and then this RFC will give result which will come to ASP.NET frontend.
    For this go thru this blog it will help u to understand how to communicate from ASP.NET to XI
    <b>https://www.sdn.sap.com/sdn/weblogs.sdn?blog=/pub/wlg/1442</b [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken]> [original link is broken]
    Code Sample is provided in the blog.
    Hope it helps.
    Regards
    Arpit Seth

  • Calling RFC from Adobe Interactive Form

    Hello,
       After creating and calling Adobe Interactive form from ABAP web dynpro, within the form designer is it possible to call RFC or Business Object method from the form script to get the data back from SAP for specific Click events?

    Yes,
    this is possible, but not through pure RFC, but using webservices and webservice enabled function modules within SAP.
    Technically it is quite simple. Create a functionmodule, and create a webserve from that (all SE37 or SE80 but from WAS 6.40). Generate a WSDL (with the Java tool) and import that into the form that you are designing. From there you can bind the data from the dataset (as defined in the WSDL) to screenfields or treat the data any other way Javascript can.
    BTW. I only managed this so far by using anonymous logins, so with a password and username bound to the webservice (in SICF).
    Hope this helps, regards, Hans Gmelig Meyling

  • Call RFC from java (j2ee) /  call to j2ee from R/3

    hello
    i´ve browsed the forum for some time to find how to:
    1.) call ejb from r/3 system via rfc
    2.) call rfc enabled function modules on r/3 from within an j2ee enviroment
    but i didn´t quite get it, because i was a bit confused about all the mentionend techniques
    what i found out about
    1.) use ejb (session bean) and jndi; configure RFC-Engine Service (we use sap webas)
    2.) use jco / jca
        (or all rfc enables rfm´s are available as web service, but didn´t find anything about this)
    so my question:
    are these the preferred techniques to connect j2ee (webAS) <-> r/3; if not are there any others, maybe easier methods?
    and last but not least: are there any good online tutorials for this topic?
    thanks in advance
    franz

    Just as a short partial reply.
    The generic Java --> RFC method is JCO (it will work on older versions as well), you can think of it as a JDBC driver where R/3 is the database, it behaves very similar in many ways.
    EJB development on SAP WAS is really not any different from EJB development on any other J2EE server. The deploy tool is superb. very easy to use and the JNDI registry, etc. are standard stuff...
    ABAP to EJB calls, haven't looked at this in over a year now, but back then we did a Proof Of Concept based on information at http://help.sap.com and it did work indeed. The only thing was back then that you needed to do a few tweaks to get it to work properly.
    As mentioned above, look at the JCO examples and then you can ask more specific questions once you get stuck.
    Good Luck!
    Cheers,
    Kalle

  • Can not call RFC contains "call transaction"  in webdynpro

    We use Webdynpro to develope a UI that can create service orders in CRM
    system. We create an RFC funciton "ZKLEE_CRM_ORDER_MODIFY" in CRM,which
    contain a statement of "CALL TRANSACTION 'CRMD_BUS2000120' USING T_BDC
    MODE 'N' MESSAGES INTO MESSTAB.".
    But as we exacute the RFC from WEB,we got 3 error messages in the
    output "MESSTAB":
    1.MESSAGE ID = "DC",MESSAGE NUMBER = "006", MESSAGE = "Control
    Framework: Fatal error - GUI cannot be reached".
    2.MESSAGE ID = "SY",MESSAGE NUMBER = "002", MESSAGE = "Exception
    condition CNTL_ERROR raised."
    3.MESSAGE ID = "00",MESSAGE NUMBER = "359",and it is a terminate
    message.
    The problem is that we can use webdynpro to call RFCs that do not
    contain "call transaction" freely. At first we suspect that it is our
    RFC function's fault, but we tried it in ABAP enviroment,and it works
    OK. We also tried to call this RFC in JSP through JCO,the same error
    occurs.
    Our system enviroment is CRM 4.0, J2EE 640, kernel 640 patch 109.

    HI,
    Thank you for your information.
    Maybe you are right that BAPI/RFC can not contain "call transaction" statement. But two weeks ago, one of my colleagues tried to use "call transaction" in RFC through JCO in our R/3 enviroment(not in CRM),and he successed.
    So I suspect the kernel release. The kernel of R/3 is 640,while CRM is 620(I said our CRM kernel release is 640 before,and it is a mistake.).I will confirm whether what my colleague said is right by myself, and will also told you the result.
    Message was edited by: Vincent zklee

  • Calling from an EJB into a JSF Backing Bean

    Hello all,
    I'm looking for some help in making calls from an EJB into a Backing Bean (the converse is fairly straightforward). My basic question is: what is regarded as the best way to do this?
    However, for anybody who's interested, I'll describe what I've been trying...
    Here's my situation (I'm working with OC4J 10.1.3.2). I have a simple application-scoped backing bean:
       public class BackingBean implements SimpleInterface, Serializable {
           private String greeting = "Hello, World";
           private SessionEJBRemote blBeanRemote = null;
           public BackingBean() {
               // get hold of EJB
               // [ ... code to obtain EJB's remote interface snipped ... ]
               // set the callback with the EJB       
               try {
                   blBeanRemote.setCallback(this);
               } catch (Exception ex) {
                   ex.printStackTrace();
           // methods to manipulate the greeting string
           public String getGreeting() {
               return greeting;
           public void setGreeting(String greeting) {
               this.greeting = greeting;
       }SimpleInterface, which my Backing Bean implements is, well, a simple interface:
       public interface SimpleInterface {
           public void setGreeting(String greeting);
       }And my EJB is also pretty straightforward:
       @Stateful(name="SessionEJB")
       public class SessionEJBBean implements SessionEJBRemote, SessionEJBLocal {
           private SimpleInterface callback = null;
           public void setCallback(SimpleInterface callback) {
               this.callback = callback;
               callback.setGreeting("Goodbye, World");
       }Now, by using SimpleInterface, my intention was to ensure a one-way dependency: i.e. the JSF-level code would depend on the EJB-level code, but not vice versa.
    However, my experimentation has shown that when I make the call to blBeanRemote.setCallback, the parameter appears to be passed by value rather than by reference. This means firstly that, at runtime, by EJB needs to have access to my backing bean class and secondly, that the call to callback.setGreeting has no effect.
    Can anybody suggest how to work around this? Is it possible to pass the backing bean by reference? Is there a better way to achieve this callback? I appreciate that these questions might be more general Java/AppServer queries rather than JSF-specific ones - but hopefully this is something that all you JSF experts have encountered before.
    (Incidentally, I realise that what I'm doing in this example is pointless - what I'm building towards is using the ICEFaces framework to have the EJBs prod a backing bean which will in turn cause a user's browser to rerender.)
    Many thanks - any help very much appreciated!
    Alistair.

    Hi Raymond - yes, you've pretty much got that spot on: an event occurs (say receipt of a JMS message - which is spontaneous, as far as the users are concerned). As a result of that event, the client's view (in their browser) needs to be re-rendered.
    ICEFaces uses the AJAX technique to allow server-pushes, and rather than refreshing the whole page it uses "Direct-to-DOM" rendering to maninpulate the page components. If you've not come across it, and you're interested, then there are some pretty interesting demos here: http://www.icefaces.org/main/demos/ - the "chat" feature of the Auction Monitor demo (if you open it up in two browsers) is the nearest to the effect I'm looking for.
    The Auction Monitor demo uses a number of session-scoped beans, each implementing the ICEFaces "Renderable" interface, and each of which registers itself with an application-scoped bean. The application-scoped bean can thus iterate through each of the session-scoped beans and cause the corresponding browser to refresh.
    Unfortunately, in the Auction Monitor demo, the entry point is always from a browser - albeit the result is then mirrored across all connected browsers. I haven't found any examples of this processing being driven by an external event, hence my experimentation in this area!

  • Calling RFC placed in PI from Portal

    Dear All,
    We have a scenario where we have RFCs in ECC and it has to be called from Portal through PI.
    Please suggest the possible and easiest ways.
    Please note these RFC are already being called from Portal to ECC directly. So we need to change it be called from PI.
    with regards,
    Ravi Siddam

    Hi Ravi,
    You can do it in either any one of the below ways.
    Use PI Http Url to push the data to PI and from there you can call RFC.
    Plz check below link: Sender Synchronous HTTP Adapter
    Or you can use Web sevice to push the data to PI and then you call RFC.
    Plz check below link on Web service scenario:/people/shabarish.vijayakumar/blog/2007/11/07/walkthrough--soap-xi-rfcbapi
    But before going for above solutions. Please have a looku2026 on below info and decide whether to go for it or not.
    SAP NetWeaver PI 7.1 Usage Scenarios: When NOT to use SAP PI
    User Interface Integration scenario: This is a common scenario faced by the development team u2013 the Webdynpro application is developed on the SAP J2EE application server integrated with the portal. The business data has to be fetched from the SAP ECC backend.
    The User Interface would demand a quick response from the backend for fetching data and conducting the transaction. This is a synchronous scenario, and it would also be conducted with high usage every day. Hence, it is recommended to have a direct integration between the source application (WebDynpro application) and the target application (SAP ECC6) without using SAP PI. It is also recommended to expose the backend functionality as standard services.
    For example, integration between SAP Portals (containing SAP BPM, SAP CAF, SAP WebDynpro) and SAP Suite (SAP ECC, SAP CRM, SAP SCM, SAP SRM etc.) should be conducted without the usage of SAP PI; the services should be exposed from the SAP suite as standards-compliant enterprise services.
    Web Service interface of backend application: Many times, the target application in SAP/Microsoft/Java/Legacy is available as a standard web service. In such cases, the web service interface can be easily consumed in the source application. In such scenarios, SAP PI adds no value for transformation or backend integration.
    In conclusion, SAP PI usage is usually not recommended for User facing applications where the backend application is available as a standard web service. SAP PI is almost always suitable for integration between backend applications not requiring human intervention.

Maybe you are looking for

  • Setting up Figure and Table Titles for Translation Import and Export?

    Hi, I use InDesign to write User Manuals. Once the manual complete, I use SDL World Server to translate the document which works wonderful. The way it works is the document is parsed by the xml data and when you export the document from SDL, the tran

  • Set Decision Step outcomes Runtime .

    Hi Friends , I have one decision Step in my Workflow,  i want to set the outcomes of the decision in runtime . it may be two or more than two outcomes , how to do it in runtime,  Is there any Function module available . Pls give suggestion . Thanks a

  • Scenario for EDI

    hi can anybody tell me how the concept of EDI works? 1)do configurations like setting logical system, partner profiles etc have to be  made? 2)is there standard idocs like MATMAS or CREMAS that are sent via EDI? 3)is there a step-by-step procedure fo

  • PS CC 2014 requires less than what my laptop is capable of, but still says "not enough ram". Help?

    I have an Acer Aspire with Windows 7. I downloaded Photoshop CC 2014, which said it's requirements were less than what my laptop has, plus I upgraded the ram to 8 already. If I go to lighting, it opens, stalls, then says not enough ram, and another m

  • Question on process flow

    hi guys, i need some input here. hope u guys can give me some. i've created some process flows. when i'm trying to deploy my process flows, i got an error saying that i don have a workflow repository in my target database. so i can't do my deployment