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

Similar Messages

  • 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

  • How to call RFC from external System to get HR Data

    According to the requirement the "HR" Workflow has to be able to view the employee details from external system Using the standard Microsoft connectors.
    So, my job is to create an RFC where i need to fetch the HR data from the infotypes P0001 and P0002. And they will call this RFC by requesting employees surname, ID number and/or Employee number.
    Do i need to simply write OPEN SQL statements in RFC or
    do i need to call any BAPI's?
    Setting up RFC's(Creation of Destinations) is not our job.
    Someone Please help me in this regard with some valuable input. Thanks in Advance.
    Ram.

    Hi Ram,
    to get the information from HR sytem you could call the BAPI
    BAPI_EMPLOYEE_GETDATA
    Regards
    Bernd

  • 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 Excel

    Hi all,
    Can any one give me sample VBA code to connect to SAP and call an RFC.
    I have found some code fragments in this forum, I would be grateful if someone can send me code for end-to-end processing.
    Regards,
    Hanif
    Message was edited by: Muhammad Hanif

    check out this,
    http://www.vbforums.com/showthread.php?t=337408
    Regards
    Raja

  • 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..

  • Example-- Call RFC from external Java Application

    Update: I need code example to call RFC from External Java application. Can onybody help me?                                                      
    RGDS
    RP
    hi all.
    i want to create my own log for each interface.
    i saw this blog:
    /people/michal.krawczyk2/blog/2006/09/20/xi-abap-mapping-logs--more-standard-better-visibility
    my doubt is how to catch the error that i see in SXI_MONITOR y put it in a Sub-Objetc.
    For example: in sxi_monitor i get the error for my interface NMUCustomer: "No receiver could not be found" or "Error Mapping Traformation".
    I created an Object called ZNMUCUSTOMER and a Sub-Objetc called ZERROR.
    what i must do to get the error I see in monitor and assign it to Sub-Object??
    Rgds.
    Message was edited by:
            Rodrigo Pertierra
    Message was edited by:
            Rodrigo Pertierra
    Message was edited by:
            Rodrigo Pertierra

    Hi,
    Oh, you are using ABAP mapping ......
    then use the following in ABAP mapping ..
    TRACE1,TRACE2,TRACE3.... for trace level 1,2,3......
    http://help.sap.com/saphelp_nw04/helpdata/en/ba/e18b1a0fc14f1faf884ae50cece51b/content.htm
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/5c46ab90-0201-0010-42bd-9d0302591383
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/866ce290-0201-0010-338f-b8c3553aaa0f
    Regards
    Chilla

  • Calling RFC from custom connector

    Hi,
    I am developing a custom connector for UWL to get tasks from 3rd party system.
    I need to call a RFC from backend SAP system to complete Input data for this 3rd party provider.
    I assume that I have to make an RFC call from getItems() method of connector.
    Any idea how to call a RFC from UWL custom connector code?
    Please help.
    Thanks & Regards,
    Amey

    Hello Karri,
    Yes, I am aware of two ways of calling RFCs from Java code.
    Normally, I use following approach to call RFCs from my other Portal Components (JSPDynpages): -
    IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();
    IPortalComponentContext myContext = request.getComponentContext();
    IPortalComponentProfile myProfile = myContext.getProfile();
    String sapSystem = myProfile.getProperty("SystemIdentifier");
    ISystemLandscapeWrapper landscapeWrapper = (ISystemLandscapeWrapper) UMFactory.getSystemLandscapeWrappers().get(0);
    ISystemLandscapeObject systemLandscapeObject = landscapeWrapper.getSystemByAlias(sapSystem);
    IJCOClientService clientService = (IJCOClientService) PortalRuntime.
    getRuntimeResources().getService(JCO_CLIENT);
    request.getNode().putValue(LOCALE_NODE_KEY,     Locale.ENGLISH);
    IJCOClientPoolEntry poolEntry = clientService.getJCOClientPoolEntry(sapSystem,request);
    JCO.Client client = poolEntry.getJCOClient();
    client.connect();
    IRepository repository = JCO.createRepository("repository", client);
    IFunctionTemplate functionTemplate = repository.getFunctionTemplate(Z_BAPI_EMP_GBU_GET);
    JCO.Function function = new JCO.Function(functionTemplate);
    JCO.ParameterList importList = function.getImportParameterList();
    importList.setValue("US", "OBJTYP");
    importList.setValue(request.getUser().getUniqueName(), "USRID");
    client.execute(function);
    JCO.ParameterList outputList = function.getExportParameterList();
    gbuCountryBean.setGbu(outputList.getString("GBU"));
    gbuCountryBean.setCountry(outputList.getString("COUNTRYCODE"));
    gbuCountryBean.setPersArea(outputList.getString("PERS_AREA"));
    gbuCountryBean.setCompanyCode(outputList.getString("COMPANYCODE"));
    When I tried implementing same in UWL custom connector, I am not able to get instance of 'request' object.
    Any hints/ideas on this?
    Hence as an temporary alternative, I wrote following to successfully execute RFC.
    mConnection = JCO.createClient(sapclient,  sapuser,
    sappassword,  "EN", saphost, sapsysnumber);
    mConnection.connect();
    mRepository = new JCO.Repository("GetLeaveRequestFlag", mConnection );
    IFunctionTemplate ftemplate = mRepository.getFunctionTemplate(Z_BAPI_CHECK_LR_TO_APPROVE);
    myFunction = new JCO.Function(ftemplate);
    JCO.Field OBJECT_TYPE = myFunction.getImportParameterList().getField("OBJECT_TYPE");
    OBJECT_TYPE.setValue("US");
    JCO.Field USERID = myFunction.getImportParameterList().getField("USERID");
    OBJECT_TYPE.setValue(p_userID);
    mConnection.execute(myFunction);
    JCO.Field leaveRequestFlag = myFunction.getExportParameterList().getField("FLAG_LEAVE_REQUEST_RECORD");
    mConnection.disconnect();
    But only catch here is that I need to create & maintain SAP logon credentials for a particular user manually.
    It is not possible to single sign on connector user into SAP system (like its done above).
    Any thoughts on this?
    Thanks & Regards,
    Amey

  • 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

  • How to call a schema name using substitution name?

    Hi All,
    How to call a schema name using substitution menthod in odi?
    I was trying but I got the following error..
    ODI-1227: Task XXX(Procedure) fails on the source ORACLE connection YYY.
    Caused By: java.sql.SQLException: Missing IN or OUT parameter at index:: 1
    Here xxx procedurename.
    yyy-schemaname
    Please do the needful..
    Thanking you in Advance.
    Regards,
    PP

      1  declare
      2  sql_string varchar2(2000);
      3  begin
      4  sql_string := 'select ' || func_name || ' into a from dual ';
      5  execute immediate sql_string;
      6* end;
    SQL> /
    sql_string := 'select ' || func_name || ' into a from dual ';
    ERROR at line 4:
    ORA-06550: line 4, column 28:
    PLS-00201: identifier 'FUNC_NAME' must be declared
    ORA-06550: line 4, column 1:
    PL/SQL: Statement ignored
      1  declare
      2  sql_string varchar2(2000);
      3  func_name varchar2(30);
      4  begin
      5  func_name := 'some_func';
      6  sql_string := 'select ' || func_name || ' into a from dual ';
      7  execute immediate sql_string;
      8* end;
    SQL> /
    declare
    ERROR at line 1:
    ORA-00904: "SOME_FUNC": invalid identifier
    ORA-06512: at line 7
    SQL> desc some_func;
    ERROR:
    ORA-04043: object some_func does not exist
      1  create or replace function test_func
      2       return number
      3       is
      4       begin
      5          return 0;
      6*      end;
    SQL> /
    Function created.
      1  declare
      2  sql_string varchar2(2000);
      3  func_name varchar2(30);
      4  begin
      5  func_name := 'test_func';
      6  sql_string := 'select ' || func_name || ' into a from dual ';
      7  execute immediate sql_string;
      8* end;
    SQL> /
    declare
    ERROR at line 1:
    ORA-00905: missing keyword
    ORA-06512: at line 7
    SQL> Set serveroutput on
      1   declare
      2   sql_string varchar2(2000);
      3   func_name varchar2(30);
      4   return_value number;
      5   begin
      6   func_name := 'test_func';
      7   sql_string := 'select ' || func_name || ' from dual ';
      8   execute immediate sql_string into return_value;
      9   dbms_output.put_line(return_value);
    10* end;
    SQL> /
    0
    PL/SQL procedure successfully completed.Hope that helps.
    Regards
    Raj

  • Calling RFCs from Webdypro application!!!!

    Can anybody show me a suitable example for calling rfc from webdynpro application.

    Hi steve,
    Look at this tutorial..
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webdynpro/tutorial on accessing abap functions in web dynpro - 4.htm
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webdynpro/tutorial on handling transactions with bapis in web dynpro - 5.htm
    Follow the steps provided in those documents.
    You can easily understand how to access ABAP functions from WebDynpro.
    Let me know if you need more help on this.
    Regards,
    Karthick

  • Calling BRM from UDF using JNDI lookup with @EJB annotation

    Hi Experts
    I am trying to implement a UDF to invoke my BRM Rules set via JNDI Lookup instead of a SOAP Channel lookup.
    I have had a look at the following links/docs:
    Calling BRM from UDF using Public API
    http://www.gleanster.com/system/resources/W1siZiIsIjIwMTIvMDgvMDcvMjAvNDcvNTAvNDMvVGhpbmdzX1lvdV9TaG91bGRfS25vd19hYm91dF9TQVBfTmV0V2VhdmVyX0JSTS5wZGYiXV0/Things%20You%20Should%20Know%20about%20SAP%20NetWeaver%20BRM.pdf
    For item 1 above, the example looks really good, but it doesnt explain how I get access to the following required imports from my UDF:
    import com.sap.brms.qrules.ejb.*;
    import com.sap.brms.qrules.engine.AbstractProject;
    import com.sap.brms.qrules.engine.RuleEngine;
    import com.sap.brms.qrules.engine.RulesetContext;
    import javax.ejb.EJB;
    The second document is really good as well, but I could not figure out how to get it to work from my UDF.
    So, can anyone help me to understand specifically what is required to get this to work?
    Is is possible to invoke the rule set from my UDF?
    How do I give my UDF access to all the required jars/imports?
    I have manage to create a new DC (Development Component) with a public part and this enables me to get my code to compile on my local PC but I am not able to activate it due to the server not having access to the same java packages as my local copy.
    Any help would be greatly appreciated.

    You resolve the dependency by importing the required jars with using the dependency tab for the mapping program.
    As stipulated before, I have managed to resolve the dependency issue but I have now getting the same error as in the forum: Calling BRM from UDF using Public API
    The specific error is:
    com.sap.engine.services.cross.PortableRemoteObjectContainer.narrow(PortableRemoteObjectContainer.java:238)
    Has anyome manage to get invoke a BRM Ruleset using JNDI?

  • How to Call Custom BPEL Process using JSP

    Hi All,
    I m not able to find out the way " How to deploy Custom BPEL process using JSP." Suppose I m Designing my custom BPEL process , and I want to call process through JSP.
    In order to call the BPEL process using JSP I may get the Reference from Oracle guide, But it is for Existing Example like Hello world, Order Booking.
    But I am facing the problem in order to call the Custom BPEL process.
    In case of Oracle Example it looks Simple but How to call Custom BPEL process using JSP.
    Please help me.
    Thanks&Regards
    Devesh Mishra

    hi
    The BPEL Developer guide give the way to Locate the service.can you please specify where you are getting the problem.
    Thanks,
    Sivakumar

  • Sample Java code and detail to call RFC from Java clas developed in Eclipse

    Hi All,
    I am new to Java. I have downloaded Eclipse IDE  and planning to use for developing Java application to send data to SAP by calling RFC JCO Interface.
    I need a sample java code/tutorial step by step to create Java class for simple example to call RFC from Java.
    I have downloaded SAPJCO3 from service market place.
    Kindly help me to send steps involved to configure for JCO  with my Eclipse with JCO.
    Thanks in advance.
    Sharma

    Hi Sharma,
    Please have a look at [Example: Using Generated Proxies to Call Function Modules |http://help.sap.com/saphelp_nw04/helpdata/en/b6/55e3952a902447847066a0df27b0d6/content.htm]
    JCo Exceptions : http://help.sap.com/saphelp_nw70ehp1/helpdata/en/f6/daea401675752ae10000000a155106/content.htm
    Hope it will helps
    Regards
    Arun

  • How to call servlet from jsp

    i m trying to call it from jsp using
    <a href="../purchaseP?orderno=<%=pno%>"><%=pno%></a>
    but its giving error..
    type Status report
    message HTTP method GET is not supported by this URL
    description The specified HTTP method is not allowed for the requested resource (HTTP method GET is not supported by this URL).

    i m trying to call it from jsp using
    <a href="../purchaseP?orderno=<%=pno%>"><%=pno%></a>
    but its giving error..
    type Status report
    message HTTP method GET is not supported by this URL
    description The specified HTTP method is not allowed
    for the requested resource (HTTP method GET is not
    supported by this URL).Are you implementing the doGet or doPost method in your servlet? If you are calling from a hyperlink then it needs to be implementing the GET method. To access the POST method use a html form.

Maybe you are looking for