Raise exception in function module call from SAP owned program

I need to raise an exception in a function module to terminate a transaction, display a error message and return to to previous selection screen so the user can fix the error before moving forward.......  
How do you do this when the program using the function module is SAP owned?
Thank You!
Jeff

Hi,
After calling the function module, you can do something like this.
IF SY-SUBRC <> 0.
  RAISE EXCEPTION.
ENDIF.
Regards,
Ferry Lianto

Similar Messages

  • RFC remote function module call from XI

    hi
    I am trying to call a remote function module directly from XI which is not a bespoke module.
    And i am getting the following error:
    com.sap.aii.af.ra.ms.api.DeliveryException: error while processing message to remote system:com.sap.aii.af.rfc.core.client.RfcClientException: failed to parse BAPI response due to: com.sap.aii.af.rfc.util.bapi.BapiException: Parameter with name RETURN not found.
    Please help me in this.
    Thanks in advance.

    Hi Naina,
    Normally RFC are synchronous, they do have return parameter as export parameter.
    If return parameter is missing then , you can create Wrapper RFC.
    Wrapper RFC:
    It is nothing but you just  create BAPI in SE37 transaction with Return parameter as export parameter and make it remote enabled by clicking on Radio button.
    Under source code, CALL BAPI which XI has to call.
    Thats it!
    I hope this helps.
    Let me know if any help required.

  • Function module to from sap to excel

    Hi Experts,,
    I wanted to know what are all the functiona module available to download sap data to excel sheet from internal table?
    Rewarded if useful.

    HI,
    refer to the thread.
    Re: wat r the function modules are  there to upload the Excel file to SAP
    refer to this example.
    TABLES:
      sflight.
    header data................................
    DATA :
      header1 LIKE gxxlt_p-text VALUE 'Suresh',
      header2 LIKE gxxlt_p-text VALUE 'Excel sheet'.
    Internal table for holding the SFLIGHT data
    DATA BEGIN OF t_sflight OCCURS 0.
            INCLUDE STRUCTURE sflight.
    DATA END   OF t_sflight.
    Internal table for holding the horizontal key.
    DATA BEGIN OF  t_hkey OCCURS 0.
            INCLUDE STRUCTURE gxxlt_h.
    DATA END   OF t_hkey .
    Internal table for holding the vertical key.
    DATA BEGIN OF t_vkey OCCURS 0.
            INCLUDE STRUCTURE gxxlt_v.
    DATA END   OF t_vkey .
    Internal table for holding the online text....
    DATA BEGIN OF t_online OCCURS 0.
            INCLUDE STRUCTURE gxxlt_o.
    DATA END   OF t_online.
    Internal table to hold print text.............
    DATA BEGIN OF t_print OCCURS 0.
            INCLUDE STRUCTURE gxxlt_p.
    DATA END   OF t_print.
    Internal table to hold SEMA data..............
    DATA BEGIN OF t_sema OCCURS 0.
            INCLUDE STRUCTURE gxxlt_s.
    DATA END   OF t_sema.
    Retreiving data from sflight.
    SELECT * FROM sflight
             INTO TABLE t_sflight.
    Text which will be displayed online is declared here....
    t_online-line_no    = '1'.
    t_online-info_name  = 'Created by'.
    t_online-info_value = 'SURESH KUMAR PARVATHANENI'.
    APPEND t_online.
    Text which will be printed out..........................
    t_print-hf     = 'H'.
    t_print-lcr    = 'L'.
    t_print-line_no = '1'.
    t_print-text   = 'This is the header'.
    APPEND t_print.
    t_print-hf     = 'F'.
    t_print-lcr    = 'C'.
    t_print-line_no = '1'.
    t_print-text   = 'This is the footer'.
    APPEND t_print.
    Defining the vertical key columns.......
    t_vkey-col_no   = '1'.
    t_vkey-col_name = 'MANDT'.
    APPEND t_vkey.
    t_vkey-col_no   = '2'.
    t_vkey-col_name = 'CARRID'.
    APPEND t_vkey.
    t_vkey-col_no   = '3'.
    t_vkey-col_name = 'CONNID'.
    APPEND t_vkey.
    t_vkey-col_no   = '4'.
    t_vkey-col_name = 'FLDATE'.
    APPEND t_vkey.
    Header text for the data columns................
    t_hkey-row_no = '1'.
    t_hkey-col_no = 1.
    t_hkey-col_name = 'PRICE'.
    APPEND t_hkey.
    t_hkey-col_no = 2.
    t_hkey-col_name = 'CURRENCY'.
    APPEND t_hkey.
    t_hkey-col_no = 3.
    t_hkey-col_name = 'PLANETYPE'.
    APPEND t_hkey.
    t_hkey-col_no = 4.
    t_hkey-col_name = 'SEATSMAX'.
    APPEND t_hkey.
    t_hkey-col_no = 5.
    t_hkey-col_name = 'SEATSOCC'.
    APPEND t_hkey.
    t_hkey-col_no = 6.
    t_hkey-col_name = 'PAYMENTSUM'.
    APPEND t_hkey.
    populating the SEMA data..........................
    t_sema-col_no  = 1.
    t_sema-col_typ = 'STR'.
    t_sema-col_ops = 'DFT'.
    APPEND t_sema.
    t_sema-col_no = 2.
    APPEND t_sema.
    t_sema-col_no = 3.
    APPEND t_sema.
    t_sema-col_no = 4.
    APPEND t_sema.
    t_sema-col_no = 5.
    APPEND t_sema.
    t_sema-col_no = 6.
    APPEND t_sema.
    t_sema-col_no = 7.
    APPEND t_sema.
    t_sema-col_no = 8.
    APPEND t_sema.
    t_sema-col_no = 9.
    APPEND t_sema.
    t_sema-col_no = 10.
    t_sema-col_typ = 'NUM'.
    t_sema-col_ops = 'ADD'.
    APPEND t_sema.
    CALL FUNCTION 'XXL_FULL_API'
      EXPORTING
      DATA_ENDING_AT          = 54
      DATA_STARTING_AT        = 5
       filename                = 'TESTFILE'
       header_1                = header1
       header_2                = header2
       no_dialog               = 'X'
       no_start                = ' '
        n_att_cols              = 6
        n_hrz_keys              = 1
        n_vrt_keys              = 4
       sema_type               = 'X'
      SO_TITLE                = ' '
      TABLES
        data                    = t_sflight
        hkey                    = t_hkey
        online_text             = t_online
        print_text              = t_print
        sema                    = t_sema
        vkey                    = t_vkey
    EXCEPTIONS
       cancelled_by_user       = 1
       data_too_big            = 2
       dim_mismatch_data       = 3
       dim_mismatch_sema       = 4
       dim_mismatch_vkey       = 5
       error_in_hkey           = 6
       error_in_sema           = 7
       file_open_error         = 8
       file_write_error        = 9
       inv_data_range          = 10
       inv_winsys              = 11
       inv_xxl                 = 12
       OTHERS                  = 13
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    regards,
    sreelakshmi

  • Regarding the RFC Function Module call from PI

    Hi All,
    I am working on one File to RFC interface, in which File adapter picks the file, this file data has to goto  2 function modules in SAP system. For this i added 2 Inbound interfaces in INTERFACE DETERMINATION and I developed 2 RECEIVER AGREEMENTS. In 2 RECEIVER AGREEMENTS i added single receiver RFC Communication Channel.
    Now i want assurance that once 1 st function module will execute completely, then only my second function module should be called. Is there any setting that i can do to make this sync?????.
    what is the use of  Send 'Confirm Transaction' in receiver RFC Communication Channel under Adavanced Mode.
    Thanks,
    Balu

    Hi,
    As per you requirement I would suggest to change your scenario as File To Proxy. It will much more easier and 100% sure to process second BAPI only after first gets successful inside the proxy.
    Pass the data from file adapter to inbound proxy and then inside proxy code you first call the first BAPI and use commit wrok. Once commit work is successful then you call the second BAPI otherwise rollback the changes.
    Example:
    Call First_BAPI
    <pass the data to it's import export parameters>
    Commit work.
    if sy-subrc =0.
    Call Second_BAPI.
    <pass the data to it's import export parameters>
    Commit work.
    endif.
    Note: If you are not very much comfortable with ABAP the discuss this with your ABAP team mate.
    Regards,
    Sarvesh

  • Error in Functional module calling from XI!!!

    Hi All,
    I'm using XI to pick data from ORACLE write it in SAP and take the response from SAP and write it back in ORACLE database. I'm using a custom functional module in SAP and calling it from XI .
    The custom functional module create the CUSTOMER and ORDER .
    Customer is getting created in SAP but order is not created. We are using two different functional modules for customers and orders.
    The above functional modules are executing in SAP but while calling from XI only the customer is getting created in SAP.
    Please post your views and suggestions on this issue.
    Thanks in advance.
    LN

    First put the commit work after successfuly executing the order creation in the custom function module.
    If you already put and doesn't know why it is not creating the orders, debug the function module by putting the same data which you are passing from XI in test tab.
    Suppose, the Orders are creating in the dubug mode. Then debug the custome function module dynamically using SM50.
    Regards,
    Krishnaraju.

  • HOW TO RAISE EXCEPTION IN FUNCTION MODULE !

    I have created a function module....where i want to raise some error message when some wrong data will be inputed
    what is the syntax ? Please tell me the syntax .

    hi you can do like this:
    in exception tab of FM write exceptions you want to raise.
    e.g. incorrect_input.
    now in code write
    if input not correct (write your validation condition here)
    raise incorrect_input.
    endif.
    reward if useful.

  • Remote function/method call from SAP

    Hi All,
    Can we make a call to non-R/3(ASP or JSP or anyother language) system to execute the external system Method/Function.
    Thanks & Regards,
    Kishore Yerra.

    Hi Kishor,
    You can use RFC or BAPI for this purpose....
    Go through below links...
    Re: How to send data to and from .ASP pages through BAPI function modules.
    RFC destination for outbound (ABAP calls Java) JCo
    hope it will help you.
    <b>Reward points if it is helpful</b>
    Thanks & Regards
    ilesh 24x7

  • Remote Function Module call from ECC to CRM (how to pass parameters?)

    Hi there,
    I have a remote FM that I would like to call from ECC to CRM. The FM is remote-enabled, so I assume that I can call this from CRM. However, in CRM some of the table structures that is required are not available. Hence, my export/import parameters won't be match, unless I create those types in CRM, but this is going to major work!! 
    How do we pass/import the parameters since the data type in ECC is vastly different/not available in CRM?
    Cheers

    The structure will need to be defined in CRM.

  • Raising exceptions in function module

    I am writing a coding inside the userexit. The call customer function has 'exception' parameters like below:
             EXCEPTIONS
               IDOC_ERROR          = 1
               DO_NOT_PROCESS_IDOC = 2
               OTHERS              = 3.
    Now, I want to raise the exception to '1' depending on some conditions. How do I do that? I used to just get the import parameters from the funciton module but never raised exceptiosn before.
    please advice.
    Thanks

    Hi,
    Please try this.
    IF <your field check>  NE <your condition>
      RAISE IDOC_ERROR.
    ENDIF.
    OR
    SY-SUBRC = '1'.
    Regards,
    Ferry Lianto

  • Is it possible to call custom designed RFC function module, apart from BAPI

    Hi Friends,
    1.     Is it possible to call custom designed RFC function module, apart from BAPI.
    2.     Why we call it Adaptive RFC layer, Since every time the JCO layer updated with SAP, Why can’t be dynamic.
    Thanx for Ur time.
    Cheers,
    Sam

    Also check <a href="http://help.sap.com/saphelp_nw04/helpdata/en/41/38bc8f813719488ddc9d9b21251ec3/frameset.htm">here</a> for more information on aRFC. Here you can find why it is called adaptive.
    Regards,
    Christophe

  • How to raise the exception in function module

    Dear abaper's.
                   I am creating a Function module .In that in' EXCEPTION' Tab i am giving
    3 exception .1.NO_DATA_FOUND 2.NO_PRINTER_FOUND 3.SMARTFORM_INTERFACE_NOT_FOUND.
    In my coding if this condtion matches i want to raise this exception.how can i do this in my coding .can any one suggest me..
    advance thanks,
    Warm regards,
    Veera

    Hi,
    if that condition is not satisfied,and u didn't handle that exception while calling function module then in the runtime error u will get the text as the description of the exception in function module definition.
    rgds,
    bharat.

  • Exceptions in function module.... for beginner......

    Dear all experts,
    I am new to ABAP. 
    Can anybody please tell, how to use the exceptions in function module ?
    and if any exception happens, then how to link some messages to that exceptions?
    I will also like to know, how to create those messages ?
    <b>Can anybody please illustrate with help of example, so that a beginner will be able to understand. ?</b>
    <b>eg,</b> i am adding two numbers in function module, and if any one passing number is negative, then i need to raise exception with message please do not enter -ve numbers for addition.
    your help will be surely, rewarded with points.
    waiting for reply.
    Regards & Thanks
    Vinay.

    hi..
    Raising Exceptions
    There are two ABAP statements for raising exceptions. They can only be used in function modules:
    RAISE <except>.
    and
    MESSAGE..... RAISING <except>.
    The effect of these statements depends on whether the calling program handles the exception or not. If the name <except> of the exception or OTHERS occurs in the EXCEPTIONS addition of the CALL FUNCTION statement, the exception is handled by the calling program.
    If the calling program does not handle the exception
    The RAISE statement terminates the program and switches to debugging mode.
    The MESSAGE ..... RAISING statement display the specified message. How the processing continues depends on the message type.
    If the calling program handles the exception, both statements return control to the program. No values are transferred. The MESSAGE ..... RAISING statement does not display a message. Instead, it fills the system fields SY-MSGID, SY-MSGTY, SY-MSGNO, and SY-MSGV1 to SY-MSGV4.
    Source Code of READ_SPFLI_INTO_TABLE
    The entire source code of READ_SPFLI_INTO_TABLE looks like this:
    FUNCTION READ_SPFLI_INTO_TABLE.
    ""Local interface:
    *"       IMPORTING
    *"             VALUE(ID) LIKE  SPFLI-CARRID DEFAULT 'LH '
    *"       EXPORTING
    *"             VALUE(ITAB) TYPE  SPFLI_TAB
    *"       EXCEPTIONS
    *"              NOT_FOUND
      SELECT * FROM SPFLI INTO TABLE ITAB WHERE CARRID = ID.
      IF SY-SUBRC NE 0.
        MESSAGE E007(AT) RAISING NOT_FOUND.
      ENDIF.
    ENDFUNCTION.
    The function module reads all of the data from the database table SPFLI where the key field CARRID is equal to the import parameter ID and places the entries that it finds into the internal table SPFLI_TAB. If it cannot find any entries, the exception NOT_FOUND is triggered using MESSAGE...RAISING. Otherwise, the table is passed to the caller as an exporting parameter.
    Also check these links
    http://help.sap.com/search/highlightContent.jsp
    http://help.sap.com/search/highlightContent.jsp
    http://help.sap.com/search/highlightContent.jsp
    regards,
    veeresh

  • Exceptions in Function Modules

    Hi
    How can I create an Exception in a Function Module and Raise that based on some condition? Plz help

    Hi Santo,,,,
    Look into this link ,, where u will get  a clear information on exceptions,,,,,
    http://help.sap.com/saphelp_nw70/helpdata/en/9f/db98fc35c111d1829f0000e829fbfe/content.htm
    http://abapprogramming.blogspot.com/2007/06/lesson-24-function-groups-and-function.html
    In the function module, you can create your own local types and data objects, and call subroutines or other function modules.
    You can make a function module trigger exceptions .
    To do this, you must first declare the exceptions in the interface definition, that is, assign each one a different name.
    In the source code of your function module, you program the statements that trigger an exception under the required condition. At runtime, the function module is terminated when an exception is triggered.
    The changes to exporting and changing parameters are the same as in subroutines. There are two statements that you can use to trigger an exception. In the forms given below, stands for the name of an exception that you declared in the interface. The system reacts differently according to whether or not the exception was listed in the function module call:
    RAISE .
    If the exception is listed in the calling program, the system returns control to it directly. If the exception is not listed, a runtime error occurs.
    MESSAGE () RAISING .
    If the exception is listed in the calling program, the statement has the same effect as RAISE . If it is not listed, the system sends message from message class with type , and no runtime error occurs.
    Function modules differ from subroutines in that you must assume that they will be used by other programmers. For this reason, you should ensure that you complete the steps listed here.
    Documentation (can be translated)
    You should document both your parameters and exceptions with short texts (and long texts if necessary) and your entire function module. The system provides a text editor for you to do this, containing predefined sections for Functionality, Example Call, Hints, and Further Information.
    Work list
    When you change an active function module, it acquires the status active (revised). When you save it, another version is created with the status inactive . When you are working on a function module, you can switch between the inactive version and the last version that you activated. When you activate the inactive version, the previous active version is overwritten.
    Function test
    Once you have activated your function module, you can test it using the built-in test environment in the Function Builder. If an exception is triggered, the test environment displays it, along with any message that you may have specified for it. You can also switch into the Debugger and the Runtime Analysis tool. You can save test data and compare sets of results.
    When you insert a function module call in your program, you should use the Pattern function. Then, you only need to enter the name of the function module (input help is available). The system then inserts the call and the exception handling (MESSAGE statement) into your program.
    You assign parameters by name. The formal parameters are always on the left-hand side of the expressions:
    Exporting parameters are passed by the program. If a parameter is optional, you do not need to pass it. Default values are displayed if they exist.
    Importing parameters are received by the program. All importing parameters are optional.
    Changing parameters are both passed and received. You do not have to list optional parameters.
    Default values are displayed if they exist.
    The system assigns a value to each exception, beginning at one, and continuing to number them sequentially in the order they are declared in the function module definition. You can assign a value to all other exceptions that you have not specifically listed using the special exception OTHERS.
    If you list the exceptions and one is triggered in the function module, the corresponding value is placed in the return code field sy-subrc. If you did not list the exception in the function call, a runtime error or a message occurs, depending on the statement you used in the function module to trigger the exception.
    When you create a function module, you must assign it to a function group. The function group is the main program in which a function module is embedded.
    A function group is a program with type F, and is not executable . The entire function group is loaded in a program the first time that you call a function module that belongs to it.
    The system also triggers the LOAD-OF-PROGRAM event for the function group.
    The function group remains active in the background until the end of the calling program. It is therefore a suitable means of retaining data objects for the entire duration of a program. All of the function modules in a group can access the group's global data.
    Please reward if found helpful,,,,,,,,,,,,,,,,
    Thanks And Regards ,,,,
    Sreekar.Kadiri.

  • How to write the exceptions in function module

    dear all,
         how to write the exceptions in function modules with example.
    thanq
    jyothi

    Hi,
    Raising Exceptions
    There are two ABAP statements for raising exceptions. They can only be used in function modules:
    RAISE except.
    und
    MESSAGE.....RAISING except.
    The effect of these statements depends on whether the calling program handles the exception or not. The calling program handles an exception If the name of the except exception or OTHERS is specified after the EXCEPTION option of the CALL FUNCTION statement.
    If the calling program does not handle the exception
    · The RAISEstatement terminates the program and switches to debugging mode.
    · The MESSAGE..... RAISING statement displays the specified message. Processing is continued in relation to the message type.
    If the calling program handles the exception, both statements return control to the program. No values are transferred. The MESSAGE..... RAISING statement does not display a message. Instead, it fills the system fields sy-msgid, sy-msgty, sy-msgno , and SY-MSGV1 to SY-MSGV4.
    Source Code of READ_SPFLI_INTO_TABLE
    The entire source code of READ_SPFLI_INTO_TABLE looks like this:
    FUNCTION read_spfli_into_table.
    ""Local Interface:
    *" IMPORTING
    *" VALUE(ID) LIKE SPFLI-CARRID DEFAULT 'LH '
    *" EXPORTING
    *" VALUE(ITAB) TYPE SPFLI_TAB
    *" EXCEPTIONS
    *" NOT_FOUND
    SELECT * FROM spfli INTO TABLE itab WHERE carrid = id.
    IF sy-subrc NE 0.
    MESSAGE e007(at) RAISING not_found.
    ENDIF.
    ENDFUNCTION.
    The function module reads all of the data from the database table SPFLI where the key field CARRID is equal to the import parameter ID and places the entries that it finds into the internal table spfli_tab. If it cannot find any entries, the exception NOT_FOUND is triggered with MESSAGE ... RAISING. Otherwise, the table is passed to the caller as an exporting parameter.
    Calling READ_SPFLI_INTO_TABLE
    The following program calls the function module READ_SPFLI_INTO_TABLE:
    REPORT demo_mod_tech_fb_read_spfli.
    PARAMETERS carrier TYPE s_carr_id.
    DATA: jtab TYPE spfli_tab,
    wa LIKE LINE OF jtab.
    CALL FUNCTION 'READ_SPFLI_INTO_TABLE'
    EXPORTING
    id = carrier
    IMPORTING
    itab = jtab
    EXCEPTIONS
    not_found = 1
    OTHERS = 2.
    CASE sy-subrc.
    WHEN 1.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno.
    WHEN 2.
    MESSAGE e702(at).
    ENDCASE.
    LOOP AT jtab INTO wa.
    WRITE: / wa-carrid, wa-connid, wa-cityfrom, wa-cityto.
    ENDLOOP.
    The actual parameters carrier and jtab have the same data types as their corresponding interface parameters in the function module. The exception NOT_FOUND is handled in the program. It displays the same message that the function module would have displayed had it handled the error.
    Or
    just have to decide what exceptions u want and under what conditions.
    then declarethese exeptions under the exceptions tab.
    in the source code of ur function module.
    if
    like this u can code .
    now when u call the function module in tme mainprogram.
    if some error occurs and u have declared a exception for this then it will set sy-subrc = value u give inthe call of this fm.
    in the fm u can program these sy-subrc values and trigger the code for ur exception.
    Please reward if useful
    Regards,
    Ravi
    Edited by: Ravikanth Alapati on Mar 27, 2008 9:36 AM

  • Exceptions in function module

    Hi,
    What are the exceptions in function module.
    Thanks in advance

    HI,
    Exceptions are used to return the error which happens in function module to the calling program.
    You can't show error messages directly from Function modules. So when there are some error occurs in function module it raises the desired exception. and this exception number is passed back to calling program. in this way calling program can trace out the error happens in function module.
    REgards,

Maybe you are looking for

  • Multiple music Directories?

    Hi,    I'm trying to move a bunch of iTunes music, plus more music I've collected, to a new laptop. So far iTunes isn't finding everything. 1) Is there a way for iTunes to manage more than one music directory? 2) Is there any simple way to have iTune

  • How to place footnotes and endnotes on the same page?

    I have a word document with nearly about 64 footnotes and 500 endnotes. Endnotes are basically references guiding to other sources which are quoted in the book. My client has asked me to place all endnotes (references) of each page at the bottom of t

  • How to show records from xml file

    HI All I have created one region its actually search region which having 5 items and result table region I want to search records based on that 5 items and want to show output in table I have table name as hr_api_transactions which contains lot of co

  • ConfigurationException

    Hi, I am getting the following error when I try to login into the portal. I am able to see the first page on the portal. As I try to login, it throws the following exception. <Feb 21, 2002 5:17:36 PM IST> <Error> <Webflow> <Error while parsing uri /p

  • Does not group music by album

    If I try to sort the music on my ipad by album and the album is from various artists it shows it as various albums intead of just one, any suggestion??