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;

Similar Messages

  • How to call rfc fuction module designed in sap from netweaver

    Hi all.
          Can any one pls let me know how to call the trfc,arfc function modules designed in sap from netweaver system.
    Is the method of calling trfc , arfc fuction modules from non sap system same?
    If not let me know how to call trffc & arfc function modules from non  sap systems.Thanks in advance.
    Kind Regards,
    sami.

    Hi
    Use
    in background task
    and
    destination
    additions when you call tRFC function modules from
    SAP system to SAP system.

  • Problem when call rfc using function control

    i try to call rfc using functin control but error "wdtfuncs error '800a03eb' Fail to call Remote Function Module" be popuped.
    my code like that:
    Set objSAPFunction = Server.CreateObject("SAP.Functions")
              Set objSAPFunction.Connection = objSAPConn.NewConnection
              IsLogOnSAP = False
              If objSAPFunction.Connection.Logon(1, True) Then
                   IsLogOnSAP = True
                   'Upload Cancel Invoice
                  Set objFunc = objSAPFunction.Add("ZRFC_SD_BILLINGDOC_GET1")
                   Set objISGR1 = objFunc.exports("DOCUMENT")
                   Set objISGR2 = objFunc.exports("COMPANYCODE")
                   Set objISGR3 = objFunc.exports("YEAR")
                   set objOSGR1 = objFunc.imports("NETVALUE")
                   set objOSGR2 = objFunc.imports("CURRENCY")
                   set objOSGR3 = objFunc.imports("DATE")
                   set objOSGR4 = objFunc.imports("CUSTOMERCODE")
                   set objOSGR5 = objFunc.imports("CUSTOMERNAME")
                   objISGR1.value = cstr(doc)
                   objISGR2.value = cstr(companycode)
                   objISGR3.value = cstr(year)
                   bResult = objFunc.Call          <<<<< Error
                   GetDataFromSAP = Array(cstr(objOSGR1),cstr(objOSGR2),cstr(InvDateFormat(objOSGR3)),cstr(objOSGR4),cstr(objOSGR5))
                   If IsLogOnSAP Then
                             objSAPFunction.Connection.Logoff
                        End If
              End If
    These code can run on the A machine, but do not run on the B machine. And both two machines have been installed SAP FrontEnd.
    which problem about it?

    To change all definition of parameters of the function from type to like may be solution.

  • Exposing WebServices Using EJB Module

    Hi,
    I am facing problems in exposing Web Services using EJB module. But the same is working fine when i am using webDynpro to expose the services.
    I am using the following code which gives error. 
                                                                     IUser user = UMFactory.getUserFactory().getUserByLogonID(userID);                                    UWLContext uwlContext = null;
                   IUWLService service = null;
                   uwlContext = new UWLContext();
                   service = UWLServiceHelper.findService();
                   uwlContext.setUser(user);
                   uwlContext.setLocale(user.getLocale());
    any suggestion how to go about it??
    Thanks
    Utsav

    Hello Utsav
    I see that you have not been able to find a solution for this.
    Can you provide some more information which may help the other SDN posters to assist you?
    Thanks
    Kenny

  • 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

  • How to call serlvet using ftp protocal

    Hai,
    How to call servlet using ftp protocal . if any one having please send that program . because generic servlet will receive any protocal request .

    The basics are to have your Server listen to port 21.
    You would then have to parse the request information to determine what is being asked for and generate an appropriate response.

  • How to call the secured EJB from timer ejb timedout method.

    Hi All,
    I have a couple of questions on EJB 3.1 Timer Service.
    1. How to call the secured EJB (annotated @RolesAllowed) from Timer EJB @Timeout Method?
    2. What's the default role/principal with which the Timer @Timeout Method gets called?
    Please let me know any info regarding the same.
    Thanks,
    Suresh

    I'd start here:
    http://ant.apache.org/manual/index.html
    If that doesn't help, go to the table of contents and start poking around. You don't need to read the whole thing front to back, but if you're not willing to spend some time researching and reading, you're not going to get very far.

  • How to call RFC in Async Mode using TCP/IP RFC Destination ?

    Hi experts,
         Can anybody tell me how to call an Async RFC using TCP/IP RFC Destination ?
    Regards,
    Umesh

    Check the link
    http://help.sap.com/saphelp_nw04/helpdata/en/80/09680289c751429ab3b07ad2a61c10/content.htm
    It says
    <b> For asynchronous calls, no connection to external systems is possible (TCP/IP connections in transaction SM59).</b>
    Regards,
    Abhishek

  • 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);

  • How to Call RFC from PortalService using a ServiceUser

    Hi,
    I have some code that calls an RFC using JCO.
    (I have other code I wrote using JCA to connect from a portlet, but that requires a Session and uses an IProfile)
    Our security team wants me to use a Serviceuser instead. But I can't seem to figure out how to use a ServiceUser to call an RFC.
    If I can just get an IConnection, i can use the rest of my JCA code to call the RFC. But I'm stuck getting the connection
    The closes I've gotten is this:
    com.sapportals.portal.security.usermanagement.IUser user = WPUMFactory.getServiceUserFactory().getServiceUser("myserviceuser");
    IConnectorGatewayService cgs=PortalRuntime.getRuntimeResources().getService (IConnectorGatewayService.KEY);
    ConnectionProperties cp=new ConnectionProperties(new Locale(),user);
    IConnection conn=cgs.getConnection("mySAPsystemalias",cp);
    There are two problems with this (or maybe more)
    The connectionproperties takes an IProfile not an IUser
    I also thought I needed a com.sap.security.api.IUser, not the one above.
    Can someone point out what is wrong or a different way?
    thanks
    Chris Buchholz

    Chris,
    You could always use a JCO JNDI connection, in which case you dont need anything other than a HashMap of the the following properties
    client
    messageserverHost
    systemLangauge
    group
    type
    systemType
    systemId
    serverPort
    username
    password
    The username and password you supply can be a service user or a normal logon user as far as I know.
    Cheers,
    Steve

  • HOW TO CALL  RFC....

    hi...
        how to call a  function module using rfc from non sap program( java, vb.net)....

    Passing a Structure from RFC to non SAP system
    call a remote RFC from one sap system to to other sap system
    Rewards point please..

  • How to maintain Ztable using function module instead of SM30

    Hi Friends,
    please tell me , How to maintain Ztable or view using function module instead of SM30.
    Thanks,
    Veerendra.

    Hi,
    You can design your report and use Function module VIEW_MAINTENANCE_CALL for that.
    You need to use Action type as 'S' for displaying and 'U' for maintaining the table.
    Ex:
    CALL FUNCTION 'VIEW_MAINTENANCE_CALL'
      EXPORTING
        ACTION                               =  'S'
        VIEW_NAME                            =  'Table Name'
    EXCEPTIONS
       CLIENT_REFERENCE                     = 1
       FOREIGN_LOCK                         = 2
       INVALID_ACTION                       = 3
       NO_CLIENTINDEPENDENT_AUTH            = 4
       NO_DATABASE_FUNCTION                 = 5
       NO_EDITOR_FUNCTION                   = 6
       NO_SHOW_AUTH                         = 7
       NO_TVDIR_ENTRY                       = 8
       NO_UPD_AUTH                          = 9
       ONLY_SHOW_ALLOWED                    = 10
       SYSTEM_FAILURE                       = 11
       UNKNOWN_FIELD_IN_DBA_SELLIST         = 12
       VIEW_NOT_FOUND                       = 13
       OTHERS                               = 14.
    Hope this helps.
    Message was edited by: Imtiaz Ahmed

  • Call RFC  using java procedure

    Hi
    How can I to use java procedure and call RFC for to access tables of SAP ?
    Thank You

    RFC? That term in the IT environment usually means "+Request For Comments+" and refers to Internet protocol and usage standards.
    Do you perhaps means RPC (Remote Process/Procedure Calls)? Or something else?
    Also, SAP is a company. Not a product. SAP has a product called R3. This runs inside a database.
    Connecting from Java to a database typically requires nothing more than a JDBC driver. So why can't you use a JDBC driver and need to call the database (and access tables) using another method?

  • How to call RFC from Power Builder

    Hi,
    I am using Power Builder Tools and I want to know how can i call RFC from Power Builder
    Thanks for ur reply

    Hi,
    Although I have not worked with Powerbuilder, I am sure if you have a certain level of proficiency with it, you will be able to code your logic that will call your wrappers written in VB/C/.NET etc. Check out the wonderful weblog by Thomas Jung on integrating ActiveX controls with ABAP Control Framework at https://www.sdn.sap.com/sdn/weblogs.sdn?blog=/pub/wlg/995. [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]
    Do get back if you have further queries.
    Regards
    Message was edited by: Shehryar Khan

  • What is the best way to use EJB modules with JAX-WS?

    Hi.
    I am doing a project that returns EAN13 encoded data to external java clients.
    I think I need to use a webservice that send response, a webservice client that send the request, and other project that transforms a data to an EAN encoded data, returns it and store it in MySql database.
    It is possible that I need to authenticate users for every request made.
    -I have created a EJB module contained into Glassfish for the webservice
    -I have created a Common Java project with 3 layers: Entities, bussines and data access layer for mysql database
    -I have a project for the webservice client with JAX-WS ( is the best choice? or Would be better JAX-RPC? )
    **How would you suggest me create the structure of the project with all the java power?*
    **Could you help me with goods tutorial of design patterns about webservices using EJB and the best way for use databases for this kind of projects ( I have heard about JNDI, Hibernate, Session EJB, ... )?*
    **Would be better use other EJB module instead of a Common java project that has classes?*
    h3. {color:#333399}I shall be pleased with your help{color}

    Kappy is dead on correct about Bridge Mode as a requirement for the Time Capsule.
    Do you know how to check to see if the Time Capsule is configured this way?
    Next question.....you really should not try to have two wireless networks....one Arris and another Time Capsule.....unless it is absolutely necessary. Two wireless routers in close proximity can create wireless interference effects that can cause problems with either...or both...networks.
    Best to turn off the wireless on one router to keep the chances of wireless interference between routers minimized.
    Are both the Arris and Time Capsule providing wireless signals?

Maybe you are looking for

  • ICal week view window is gone. When selected the window disappears.

    Whenever I click on view->week view (or just the "week" button on the bottom row) my ical window disappears. No idea where it is going. If I click on view->day/month the window comes back. However, after it comes back in day or month view, the info s

  • Satellite A300-1EI - What is the best RAM for upgrading to 8GB?

    HI, I wanna put 8GB RAM in my laptop. I just want know what is the best RAM type that will be supported with my pc configrations Here are my laptop configration: PC Information] Model Name Satellite A300 Part Number PSAGCE-00C006AR Serial Number 9802

  • Why can't I serve a webpage from my Mac?

    I cannot for the life of me figure out how to place a website at Hard Drive>Library>Webserver>Documents and then be able to reach that website from anywhere other than the actual Mac it's sitting on (and even that's iffy sometimes). Here's what I'm d

  • Hp Photosmart C7280 all-in-one will not work with Snow leopard

    My nephew just installed Snow Leopard on my IMAC 2008. I cannot get to printer to work. I have tried uninstalling the HP software and reinstalling. I have updated the software thru Apple updates. It still won't print or scan any documents.

  • Decimal places in standard cost

    Dear All How many Decimal places does SAP Support for Standard cost estimate. Thanks