Calling an ABAP function module

Hi friends,
I am developing an application in EP6 SP2 using JSPDynPage from which, want to call an ABAP function module that returns table and show the values from this table in this application.
I went thru various blogs and APIs. I am confused between SAP JCO, JCO client service and connector framework. Do u have any documentation on how to connect to R3 systems and call a function module, retrieve results etc.
Regards,
Nilz

JCo is the point to start. This gives you low level access to all rfc functions. Everything else (accept BSP and Web dynpro) are just layers of encapsulation around the low level JCo function.
The steps are always like this:
call the sap system for rfc login
prepare data areas and call in java
call the rfc in the R/3 system
handle exceptions
logoff and free ressource
continue with data obtained in R/3
There is a lot of material around jco. One book that is fairly ok is :
SAP Interface Programming
A comprehensive reference for RFC, BAPI, and JCo programming
J. Meiners, W. Nüßer
SAP PRESS ISBN 1-59229-034-5
This helps you navigate through the wealth of information also at SDN

Similar Messages

  • Call an ABAP Function module on click of Button in BSP page

    Hello ,
    i would like to run a ABAP function module on click of a button in BSP page.
    or in other words i want a Funtion module ex: 'test1' to run after clicking this button ex: 'button1'
    and how to pass the values for a function module after clicking the button.
    i an new to bsp application .
    Can anyone help me on this .

    Hi Shalaxy,
    Triggering a URL to WDJ:
    I suppose the URL of WDJ app. is also a portal URL. I assume that from a BSP application inside portal you need to trigger the WDJ url.
    But the catch is that you cannot hotcode this URL, since it varies for a development, quality and production systems(diff. portal environments).
    To solve this issue, ABAP provides a system variable named sy-sysid, which says want system your ABAP system is, normally a development R/3 system will be associated to development portal system and quality R/3 to quality portal ans so forth.
    So you could have a internal table/db table/ variable for dev, quality or prod portal urls and from the bsp on button click based on the value in the sy-sysid you can trigger the url accordingly.
    Creating a URL in WDJ
    The above is about triggering a WDJ from BSP. But if you dynamically want to create a link in WDJ on a button click, then apparently you could not do that from BSP, since the applications are different. All you could do is to pass some URL parameters to WDJ application from BSP app. Then based on the URL parameters the WDJ application has to dynamically create a link and add it to its application.
    Hope it helps.
    Regards,
    Maheswaran
    Edited by: Maheswaran B on Mar 1, 2010 4:17 PM

  • Ways to call a ABAP Function module or ABAP Program from WAD

    Hi,
      Is there any way to execute an ABAP function module or program from the WAD?
    Thanks

    what you could do is create a bsp application which receives workbook id as url parameter.
    from WAD create a link to this BSP page and pass the wbook id in the url.
    within the BSP you can then read the excel as binary string like below
    select * from rsrwbstore into table wb_tab
          where workbookid = wbid.
    you can then set wb_tab-clustd as the response of the page with mime type to 'application/vnd.ms-excel'. which will open as excel
    Regards
    Raja

  • Calling unremotable ABAP function modules (JCO)

    Hello,
    i want to develop a java-application around cFolders calling RFCs with JCO.
    I get the following error code from JCO:
    "[code]com.sap.mw.jco.JCO$Exception: (104) RFC_ERROR_SYSTEM_FAILURE: The function module "CFX_API_USER_GET_LIST" cannot be used for 'remote' calls.
         at com.sap.mw.jco.rfc.MiddlewareRFC$Client.nativeExecute(Native Method)[/code]
    Is there an easy ABAP-code example which offers the function modules in the cfx_*-namespace remotable to bind it in the JAVA-Code?

    Hi,
    For some reason I cannot see the entire error message that you have posted, but sounds like you are calling a function that is NOT remote enabled, that means you can call it only from inside SAP.
    If you look at the attributes of the function, it should be remote enabled, only then you can call it from an external system.
    Regards,
    Ravi
    Note : Please mark the helpful answers

  • Call ABAP function module from script?

    Hi,
    I have an ABAP function module, which works fine when I call it in a transformation.
    Since I don't need to execute this function for each record but rather for each file I process, I would like to move the call from the DataFlow to a script in the WorkFlow. When I click on the 'functions' button the ABAP FM is available in my SAP Datastore, so I drag and drop it into my script. I also make sure to populate all required variables.
    There are no error messages or warning when I check my job definition.
    When I execute it, I get the following RFC error:
    Function call <xxx  ( abcd ) > failed, due to error <150413>: <RFC CallReceive exception <FUNCTION_NOT_FOUND>.>.
    Is it just not possible to call an RFC enabled function module in SAP from a script or am I doing something wrong here?
    Thanks,
    Jan.

    Could you please let me know how I can call an abap function module from a transformation? (from abap xslt program). I know how we can call methods of a class from the transformations, but no idea how we can call function modules. Any suggestions or a sample code snippet towards this will be very useful for me.
    Thanks,
    Shashi.

  • BW/ABAP- Function module is called infinitely by Datasource Extractor.

    Hi All,
    A quick ABAP question related to Function Modules and BW data source extractors.
    I’ve written a function module to select data from a database and simply output the data as a table. I then created a text Datasource using transaction rso2 and set it to Extraction by Function Module.
    When I test this using transaction rsa6, I can manipulate the number of calls to my function module using the Display Extra Calls field.
    However, when I test this using transaction rsa1, my function module seems to be called infinite times. So, the number of records being retrieved is increasing exponentially and finally ends with a dump.
    My question: Do I need to include something in my code such that the Function Module by itself will only be called once?
    Or is there some configuration for the Datasource that will limit my function module call to once only.
    Tried so far
    • Introducing a static variable in the function module that exits as soon as the value is greater than 1.
    o Is there another way out?
    Regards,
    Preethi.

    You need to raise the EXEPTION NO_MORE_DATA afte the last record is populated in the output table. Otherwise the program goes into an infinite loop.
    * From now on records get fetched from the database or gets read from the internal table
        FETCH NEXT CURSOR v_cursor
                   APPENDING CORRESPONDING FIELDS
                   OF TABLE <internal table>
                   PACKAGE SIZE i_s_if-maxsize.
        IF sy-subrc <> 0.
          CLOSE CURSOR v_cursor.
          RAISE no_more_data.
        ENDIF.
    * Populate the Output Data Structure into table E_T_DATA and you need to raise the EXEPTION NO_MORE_DATA and close the cursor to avoid any memory leaks

  • Calling ABAP Function Module in BODS, but not RFC_enabled

    Hello Experts
    We have an ECC ABAP Function Module takes 5 input parameters and returns Division Name for an Employee and Employee PERNR is one of the input parameters for the Function Module.
    I tried adding a function call in the target schema of Query Transform and the output parm passes out as an Output column. But getting an error that ABAP FM is not RFC_enabled. I checked attributes, and it is not RFC_enabled.
    So is there way to invoke this FM as part of BODS ABAP Dataflow?. Becuase the code executes on ECC, it does not need to be RFC enabled, I believe. But on the Query Transform, the option "New Function Call" isn't enabled or it is greyed out, I can't select it.
    What is the solution to invoke this ABAP FM with enabling RFC on it ?
    Please provide me your inputs.
    thank you

    Hi,
    Create a custom wrapper FM which is Remote enabled & call the FM DD_DOMA_GET inside your custom Remote FM. Changing the std. FM would be a core code mod. hence above approach would be safe.
    Thanks,
    Best regards,
    Prashant

  • Problem while calling an RFC Function Module in Background

    Hello,
    I have created a RFC function module for reading data from an external DB system. The FM calls an external RFC program (coded in C++ using RFC SDK), which delivers the required data. This external program is maintainged as an TCP RFC Connection in SM59.
    Further I have created a report, that calls the RFC function module to get the data from the external RFC programm.
    My problem is, when I call the report in foreground, everything works OK, the RFC connection works and data can be read from the external program.
    However, when I schedule the report to run in background as a job, the report is stating in the protocoll that there was a problem calling the defined RFC connection (although the connection is working properly at that time).
    More funny is, this particular problem with running in background occurs only in the productive system, in test and development system the report works correctly also while running as a job in background.
    Can you suggest the solution to this problem? Could it be something with authorisations or server settings?
    I will be on holiday for the next 6 weeks, so take your time to answer .
    Regards,
    Dusan.
    Edited by: Julius Bussche on Jan 22, 2009 7:19 PM
    Please read the forum rules about u r g e n t ...

    This is an external RFC server program, not a remote enabled ABAP RFC function module as the others seem to be assuming, right?
    Is it possible that your DEV and QAS systems only have one application server, but the PROD has many and dedicated one(s) for processing low priority background jobs?
    It might be that the target server of your TCP connection is not this BTC instance, and your RFC server is returning the data "locally" - so, into nirvana...
    Just guessing, but might be worth checking.
    Cheers,
    Julius

  • Calling a RFC Function Module

    Hello Guys,
    I have a question regarding calling a RFC function module.
    In BW - BI 7.0 I call a RFC function module:
    (The ABAP program in BW-BI 7.0 is below)
      CALL FUNCTION ''ZTESTFUNCTIONMODULE'  " Function module in ECC
         DESTINATION 'DECCLNT110'  " ECC system
        TABLES
          it_gl_item   = it_gl
          it_errlog_gl = it_errlog_gl.
    The 'ZTESTFUNCTIONMODULE'   is RFC enabled in the ECC system.
    The purpose is we retarct the data from BW to ECC.
    When I run the function module it always asks for the user id and password.
    The SAP logon screen appears and it asks for the user id and password.
    The destination is maintained in the SM59 transaction and also the user is maintained there. I think it should login automatically into remote system and return the tables. is it correct. How to skip the logon screen.
    Do I have to pass the user id and password in the function module. I think it should take the user id from the SM59 destination. Is it correct.
    Please advise. As always thanks for your help guys.

    Hi Senthil,
    I think you answered your query in your question itself
    The user ID and password need to be maintained in RFC destination in SM59.
    Go to SM59 and then click on test connection..if it does not ask for ID and passwoed that means correct ID and password is maintained in SM59 otherwise maintain it.
    Regards,
    Atish

  • Issue in creating web service for a ABAP Function Module

    Hi,
    now i'm learning how to create web service for a ABAP Function Module. I used the following steps.
    1. select the Function Module, named "zws_test".
    2. in the context menu, select "create->proxy object". so we enter into wizard.
    3. in the wizard, press the radio button "Service Provider".
    4. in the next page, press the radio button "Existing ABAP Objects(Inside Out)".
    5. In the next page, Enter the "zws_test_prvider" as Service Definition and select "Function Module" as Endpoint Type.
    6. in the next page, enter "zws_test" as Function Module and mark the "Mapping der Namen" button
    7. in the next page,select "PRF_DT_IF_SEC_LOW" as Profile and mark "Deploy Service".
    8. Save in the local package.
    9. then it will pop up a window with title "WSDL Source". i selected "URL/HTTP Destination" and press "OK".
    10.in the next page, i enter the URL as "http://hostname:portnumber/", and press "OK".
    11. then it will pop up a window with title "Display logs". A record with error message "HTTP error(return code 404, message "Not found")" appears.
    12. i press "ok" and a service provider with name "zws_test_prvider" appears in my local package.
    13. i use "zws_test_prvider"'s URL to create a service consumer "ZCO_WS_TEST_CONSUMER" and logic portal "LP1".
    14. But when i test my service consumer "ZCO_WS_TEST_CONSUMER", it will throw an exception "cx_ai_system_fault" with errortext "SOAP:14 Unexpected element -el=definitions ns=http://schemas.xmlsoap.org/wsdl/".
    15. I use t-code SM59 to test connection  and get the following info.
          Status HTTP Response     200
          Status Text                      OK
          Duration Test Call             328 ms.
    who can give me the reasons about item 11 and 14, and explain me how to create service provider and service consumer for a Function Module.
    Thanks in advance
    Johnney

    have you seen this weblog
    /people/thomas.jung3/blog/2004/11/15/bsp-150-a-developer146s-journal-part-xiii-developing-abap-webservices

  • Help on ABAP Function Module (Unit 1)

    Hello ABAP Experts,
    I need help with the below mentioned lesson plan. I donot have source code for The ABAP Function Module - BC401_GET_SEP_STRING. For the Source Code Solution in the Lesson Plan to work, I need the source code for the above mentioned function module.
    The Lesson Plan with Solution is posted below:
    Exercise 1 
    Unit: Data Types and Data Objects in Detail
    Topic: Defining Data Types and Data Objects
    Basic Statements
    Processing Character Strings
    At the conclusion of these exercises, you will be able to:
    u2022     Define structure types locally in the program
    u2022     Define elementary and complex data objects
    u2022     Split strings
    u2022     Use conversion rules
    u2022     Display the contents of data objects in lists
    In this exercise, you will use a template to create a program that receives a single data record from the database table SFLIGHT in form of a character string. The program will split the this character string into its components and display it formatted in a list.
    Because the focus of this exercise is not on the transfer of data as a character string, we will use a function module that will provide us with the required database. This will simulate actual cases, such as data transfer from an external system.
    Program: ZBC401_##_SPLIT_STRING
    Template: SAPBC401_DTOT_SPLIT_STRING
    Model solution: SAPBC401_DTOS_SPLIT_STRING
    is your two-digit group number
    1-1 Copy the program, SAPBC401_DTOT_SPLIT_STRING and give it the new name ZBC401_##_SPLIT_STRING.
    1-2 Familiarize yourself with the main body of the program. Pay special attention to the content of the data object datastring after the function module call. Use the Debugger to do this, and/or display the character string in a list. (The function module itself is here seen as a black box. For this exercise, it is not necessary to understand its construction.)
    1-3 To be able to split the character string into its components you must first remove the ## characters. Remove the two leading separators from the character string first. Then copy the initial part up to the closing separators to the auxiliary variable set_string. For this, set_string has to be defined appropriately.
    1-4 Now use the separators to split the contents of the auxiliary variable set_string into the structure wa_flight_c. The latter is typed with the local program structure type st_flight_c. You still have to comment out the components of this structure type and assign them an appropriate type.
    1-5 As a test, display the fields of the structure, wa_flight_c in a list.
    1-6 In the list displayed in exercise 1-5, you should have observed that some of the fields were displayed without formatting u2013 for example, the PRICE field. Your next step is to change this.
    To do this, convert the data you have extracted by copying it to data objects with suitable types. Also, not all components of wa_flight_c are to be displayed.
    For this purpose, a structure wa_flight has already been defined. It is typed with the structure type st_flight. You must comment out the components of st_flight and find appropriate types for these components for the formatting. Then copy the identically-named components of the character-type structure wa_flight_c to the fields of the structure wa_flight.
    Display the contents of the structure wa_flight in a list. Use the appropriate formatting options for the WRITE statement for the fldate and price components.
    Data Types and Data Objects in Detail Solution 1
    Unit: Data Types and Data Objects in Detail
    Topic: Defining Data Types and Data Objects
    Basic Statements
    Processing Character Strings
    REPORT sapbc401_dtos_split_string.
    TYPES:
    BEGIN OF st_flight_c,
    mandt(3) TYPE c,
    carrid(3) TYPE c,
    connid(4) TYPE n,
    fldate(8) TYPE n,
    price(20) TYPE c,
    currency(5) TYPE c,
    planetype(10) TYPE c,
    seatsmax(10) TYPE n,
    seatsocc(10) TYPE n,
    paymentsum(22) TYPE c,
    seatsmax_b(10) TYPE n,
    seatsocc_b(10) TYPE n,
    seatsmax_f(10) TYPE n,
    seatsocc_f(10) TYPE n,
    END OF st_flight_c,
    BEGIN OF st_flight,
    carrid(3) TYPE c,
    connid(4) TYPE n,
    fldate TYPE d,
    price(9) TYPE p DECIMALS 2,
    currency(5) TYPE c,
    planetype(10) TYPE c,
    seatsmax TYPE i,
    seatsocc TYPE i,
    END OF st_flight.
    DATA:
    datastring TYPE string,
    set_string TYPE string,
    wa_flight_c TYPE st_flight_c,
    wa_flight TYPE st_flight.
    START-OF-SELECTION.
    CALL FUNCTION 'BC401_GET_SEP_STRING'
    EXPORTING
    IM_NUMBER = '1'
    IM_TABLE_NAME = 'SFLIGHT'
    IM_SEPARATOR = '#'
    IM_UNIQUE = 'X'
    IMPORTING
    ex_string = datastring
    EXCEPTIONS
    no_data = 1
    OTHERS = 2.
    IF sy-subrc <> 0.
    MESSAGE a038(bc401).
    ENDIF.
    SHIFT datastring BY 2 PLACES.
    FIND '##' IN datastring.
    IF sy-subrc <> 0.
    MESSAGE a702(bc401).
    ENDIF.
    SPLIT datastring AT '##' INTO set_string datastring.
    SPLIT set_string AT '#' INTO
    wa_flight_c-mandt
    wa_flight_c-carrid
    wa_flight_c-connid
    wa_flight_c-fldate
    wa_flight_c-price
    wa_flight_c-currency
    wa_flight_c-planetype
    wa_flight_c-seatsmax
    wa_flight_c-seatsocc
    wa_flight_c-paymentsum
    wa_flight_c-seatsmax_b
    wa_flight_c-seatsocc_b
    wa_flight_c-seatsmax_f
    wa_flight_c-seatsocc_f.
    MOVE-CORRESPONDING wa_flight_c TO wa_flight.
    WRITE: /
    wa_flight-carrid,
    wa_flight-connid,
    wa_flight-fldate DD/MM/YYYY,
    wa_flight-price CURRENCY wa_flight-currency,
    wa_flight-currency,
    wa_flight-planetype,
    wa_flight-seatsmax,
    wa_flight-seatsocc.

    this FM is to get one element value from the XML
    if you want to convert the whole XML use FM SMUM_XML_PARSE
    Regards
    Raja
    Kindly close your previous threads and assing points.
    Re: Creation of SIMPLE TRANSFORMATIO(ST)for deserialisation of XML ->ABAP data.

  • Web Services  from ABAP function modules return values- leading zeros

    I am using several web services from SAP CRM (5.0) that were created from Function modules ( I am assuming that that they are in ABAP).
    I can call the web services fine and they work as expected, but I am seeing a lot of leading zeros in the return values of fields in tables from the Web service.
    The ABAP er’s are telling me that they cannot see the leading zero’s.
    So my question is where these are appended to the values in the whole process. When I execute the Function Module in SAP CRM from transaction SE37 I can see the leading zeros. So I think that this is something that has to be handled by the ABAP er’s and not in the client consuming the web service.
    Are the functions in SAP CRM that can remove leading zeros for fields in a table (that is an export parameter?)
    Jawahar

    Hello Jawahar
    If you run your (RFC-enabled) function modules using the SAP-GUI (i.e. in dialog) then the GUI automatically replaces leading zero when the function module returns any data. However, calling the same function module remotely you will always see these leading zeros.
    These so-called conversion exits are defined as attribute of domains in the ABAP dictionary. If the function module used for the WebService is a standard fm then you have little chances to get rid of the leading zero. Perhaps the WebService has some attribute to suppress conversion exits or activate them when retrieving the data.
    Regards, 
       Uwe

  • Where should i call the rfc function module? in xi or in r/3

    where should i call the rfc function module?
    for the synch scenario: file < -- >  xi <---> rfc
    i know the type of rfc is tcp/ip; but i'm not sure with the followings,
    and with some trials i can not even see any message via rwb even all the setting
    can be activated without errors.
    where should i create the rfc destination? in r/3 or xi
    where should i call the rfc via abap program? in r/3 or xi
    i guess the calling program should belong to the different server with the rfc itself....
    so confused....
    Thanks for your reply!!
    Jun

    if i create the destination in xi point to r/3, then i call the rfc use the destination in r/3 right ?
    The call doesnt use the destination in R3. XI has the RFC destination which is just used to connect to the R3 system
    but where i need to create the fm via se37? in xi or r/3 ?
    In R3
    Regards,
    Prateek

  • How to run ABAP Function Module in Background Wchich Takes Long Time to Run

    How to run ABAP Function Module in Background FOR LONG TIME
    I am not that experienced with ABAP. I am on SAP BI 7.0. I WANT TO RUN A FUNCTION MODULE
    RSDRT_INFOCUBE_DATA_COPY.
    I used SE37 and then executed the module, I supplied  the parameters on the form which opped-up and then  program started running. . Program was however interrupted after 10 minutes by ABAP. How can I run  it in background without interruption?
    THANKS A LOT.

    Hi,
    You can call this FM in a program and run that program in background.
    Regards,
    Raju

  • Debuggin a Call to Remote Function Module

    Hi
    I have a scenario where i have a Remote Function Module in r3 which is being called synchronously by an external java application. The FM has a lot of input and output parameters and many tables.  The output returned by the FM is not as expected.
    Can anyone tell me how debug a Remote Function Module when a call has been made from an external application.
    I am not able to get the test data sent by the external application . So when the external application gives a call to this Remote FM and if it is possibele to debug it would be great.
    regards
    Nilesh Taunk.

    Hi Nilesh,
    1) Login to SAP with the same ID with which you will calling the RFC function module from the outside system.
    2) Goto transaction - se37/se38
    3) Goto Utilities => Settings.
    4) Select the ABAP Editor Tab.
    5) Click on the Debugging tab.
    6) Tick the Actv. button and give the user name with which you will be debugging the code. In this case the logged in user id.
    7) Press Enter.
    8) Now put an external break point inside the Function Module.
    9) Load your external application (from where you want to debug the FM) once again.
    The execution will stop in the FM.
    Hope it helps..
    Lokesh
    PS: This was a simple question, but I guess the reason no one has answered your question is due to the fact that you havent rewarded points to members helping you. Also remember to close your post once it has been answered.

Maybe you are looking for