Function Module CHANGEDOCUMENT_PREPARE_TABLES causing exception

halo experts
I am using FM   CHANGEDOCUMENT_PREPARE_TABLES   for comparing PBO and PAI records .
I am passing the PBO and PAI records as input parameters to the FM . it was working fine. Once I changed the structure of the table ( I added some CURR fields to it ) it is throwing an exception CX_SY_RANGE_OUT_OF_BOUND
Anyone has idea regarding the same
Regards
Arshad

Hi Arshad,
Hope you have included the new field in both Old and New Table Structure.
Regards
Bala

Similar Messages

  • Issue in EP: Function module throwing an exception

    Hi Guys,
    I have an Issue in EP.....which is a replica of the production system i am working on. I have an excel file to upload. I am using the function module 'text_convert_xls_to_sap' . This is working in Production sytem.
    But i am getting an Error" File cannot be processed ".
    in portal environment of the same program.
    The exception is in the Function Module 'text_convert_xls_to_sap'  in the " PERFORM get_spreadsheet_interface USING g_con_excel....".
    Here sy-subrc = 1.
    Can anyone tell me what exactly is going wrong here?
    Thanks,
    San
    PS:Helpful answers will be rewarded

    Hi!
    The file is closed when i access. The issue is elsewhere and it is not reading the file...
    Thanks,
    San

  • Function module JOB_CLOSE throwing exception

    Hello,
    We have a batch job which has 2 steps:
    1) Step 1 uses job_open, job_submit and job_close and immediately schedules batch job A/P_ACCOUNTS which in turn creates batch input sessions A/P_ACCOUNTS.
    2) Step 2 Processes A/P_ACCOUNTS sessions created yesterday or today.
    In few cases, job_close is throwing exception job_close_failed. I believe that error is coming due to non availability of work processes. Job A/P_Accounts is defined as a class C batch job. There is a check in the FM job_close which does the following check:
    - if the class of a batch job is B or C, it calculates the number of free work processes. If there are no work processes available then JOB_CLOSE throws JOB_CLOSE_FAILED exception. 
    - If the class is u2018Au2019, it skips this check.
    We have an option of changing the class of batch job to A but there are some system critical jobs that are running as class A.
    My question is:
    In the code, JOB_CLOSE has been called for scheduling the job A/P_ACCOUNTS with parameter start immediately. Can anyone please let me know what will happen if function JOB_CLOSE is not called with start immediately option? Will the batch job A/P_ACCOUNTS wait till the time work processes are available?
    Or, can anything else be done to solve the issue?
    Regards,
    Siddharth

    HI,
    This is my experience with job_close..
    when i was working in zprograms then i was able to scedule it any time i wanted..
    but in my standard program when i tried it didn't worked....
    so i have to use that option of starting it immediately..
    and then it is working fine..
    now if i schedule 5 jobs... one after another..
    its get queued up...and once the processor is free...its working..
    my code of job close
      CALL FUNCTION 'JOB_CLOSE'
        EXPORTING
          jobcount             = job_count
          jobname              = job_name
          strtimmed            = yes " yes = 'X'
        IMPORTING
          job_was_released     = job_released
        EXCEPTIONS
          cant_start_immediate = 1
          invalid_startdate    = 2
          jobname_missing      = 3
          job_close_failed     = 4
          job_nosteps          = 5
          job_notex            = 6
          lock_failed          = 7
          invalid_target       = 8
          OTHERS               = 9.
    regards,
    Yadesh

  • 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

  • Exception Raising in Function Module

    Hi,
    I am having a custom function module that calls a standard function module. Custom function module has following exception defined: manufacture unknown.
    Standard function module has enhancement sections that I implement. For a defined condition I have to raise an exception and return from the function module. However, the exception is not defined in function module.
    Standard exception OTHERS is available. Is it possible to raise OTHERS exception from the code? I have tried statement Raise OTHERS. But it has syntax errors.
    Regards,
    Bhavish Bhatia

    Hi,
    If you raise an exception not defined at exception's tab, sy-subrc will be returned with the number of exception OTHERS.
    Just with the sentece:
    RAISE ZEXCEPTION. (Assuming that ZEXCEPTION is not included at exception's tab).
    Regards,
    Pablo.

  • How to create EXCEPTION in function module

    hi experts,
              how to create exeptions in function module i want step by step.
    regards,
    chaitu

    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.
    Hope this is helps,Do reward.

  • Error BT616 when calling function module SXPG_COMMAND_EXECUTE in background

    Hi All,
    We use function module SXPG_COMMAND_EXECUTE with a custom command we defined in SM69 to move files in unix (mv command).
    The function module call has worked fine for almost a year and recently we have been seeing an error (BT616) in our job lob (SM37) when the program is run in background. We have not been able to reproduce the error in foreground mode and it seems to be occuring only periodically in the background. (The appropriate SAP authorization objects where assigned to the batch job ID and the steps on the batch job.) We are in the process of setting up the trace flag and performing analysis on the trace log via ST11 to help identify the issue.
    After perform analysis on SXPG_COMMAND_EXECUTE, the error is occurring when calling function module SAPXPG_END_XPG for exception 2, system failure, yet function module SAPXPG_END_XPG does not exist. I assume this is a program at the operating system level and is just a signature of the parameters to be passed to the operating system program.
    Below is part of the SAP function module SXPG_COMMAND_EXECUTE that is failing.
    * Now we have to wait for the termination of the external
    * command if the caller wants us to.
        IF TERMINATIONWAIT = 'X'.
          CALL FUNCTION 'SAPXPG_END_XPG'
            DESTINATION DESTINATION
            IMPORTING   EXITSTAT = STATUS
                        EXITCODE = EXITCODE
            TABLES      LOG      = LOG
            EXCEPTIONS  COMMUNICATION_FAILURE = 1 MESSAGE MSG
                        SYSTEM_FAILURE        = 2 MESSAGE MSG.
    I performed a where used on function module SXPG_COMMAND_EXECUTE, and most of SAP programs call the function module with the parameter TERMINATIONWAIT = 'X', so I assume we should pass ‘X’ as well.
    Any ideas on what could be causing this issue?
    Mike Vondran

    I also remember I have this kind of issue, as I have some UNIX script at OS( UNIX) level . The problem was with the ID , as it don’t have proper authorization at OS level ( UNIX ) . Please check this ID authorization. This could be the one of reasons if you’re sure from SAP standpoint.
    Hope this’ll give you some guide line..
    Thanks
    Bye

  • Examples for using function modules and BApis.

    My Dear FRNDS,
    I am very new to ABAP. And I have read the documentation for  function modules but i am not that clear to practice them.So I would be very happy if u people share a little bit of ur experience with me.
    Please provide me some examples of all the use cases in function modules and specially exception handling.
    Frnds, i am going to work with bapis so i feel practicing function module will give me a edge.
    and please tell me after calling a BAPI FM why we have to perform   'BAPI_TRANSACTION_COMMIT' and 'BAPI_TRANSACTION_ROLLBACK'.
    .Ur efforts  will be greatly rewarded.
    thx,
    reshali

    Hi,
    Please check this sample codes.
    DATA: BAPI_Z05DOGI_DELIVERY LIKE BAPIOBDLVHDRCON-DELIV_NUMB ,
    BAPI_Z05DOGI_HEADER_DATA LIKE BAPIOBDLVHDRCON OCCURS 0 WITH HEADER LINE ,
    BAPI_Z05DOGI_HEADER_CONTROL LIKE BAPIOBDLVHDRCTRLCON OCCURS 0 WITH HEADER LINE,
    BAPI_Z05DOGI_ITEM_DATA LIKE BAPIOBDLVITEMCON OCCURS 0 WITH HEADER LINE,
    BAPI_Z05DOGI_ITEM_CONTROL LIKE BAPIOBDLVITEMCTRLCON OCCURS 0 WITH HEADER LINE ,
    BAPI_Z05DOGI_RETURN LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE .
    CLEAR: BAPI_Z05DOGI_DELIVERY , BAPI_Z05DOGI_HEADER_DATA , BAPI_Z05DOGI_HEADER_CONTROL , BAPI_Z05DOGI_ITEM_DATA ,BAPI_Z05DOGI_ITEM_CONTROL , BAPI_Z05DOGI_RETURN .
    REFRESH: BAPI_Z05DOGI_HEADER_DATA , BAPI_Z05DOGI_HEADER_CONTROL , BAPI_Z05DOGI_ITEM_DATA , BAPI_Z05DOGI_ITEM_CONTROL , BAPI_Z05DOGI_RETURN .
    BAPI_Z05DOGI_DELIVERY = ZMM_WB1-ISSUE .
    BAPI_Z05DOGI_HEADER_DATA-DELIV_NUMB = ZMM_WB1-ISSUE.
    APPEND BAPI_Z05DOGI_HEADER_DATA.
    BAPI_Z05DOGI_HEADER_CONTROL-DELIV_NUMB = ZMM_WB1-ISSUE.
    BAPI_Z05DOGI_HEADER_CONTROL-POST_GI_FLG = 'X'.
    APPEND BAPI_Z05DOGI_HEADER_CONTROL.
    BAPI_Z05DOGI_ITEM_DATA-DELIV_NUMB = ZMM_WB1-ISSUE.
    BAPI_Z05DOGI_ITEM_DATA-DELIV_ITEM = 10.
    BAPI_Z05DOGI_ITEM_DATA-DLV_QTY = LFIMGGIA.
    BAPI_Z05DOGI_ITEM_DATA-SALES_UNIT = XTAB-MEINS.
    BAPI_Z05DOGI_ITEM_DATA-DLV_QTY_IMUNIT = LFIMGGIA.
    BAPI_Z05DOGI_ITEM_DATA-FACT_UNIT_NOM = UMVKZLIPS.
    BAPI_Z05DOGI_ITEM_DATA-FACT_UNIT_DENOM = UMVKNLIPS.
    APPEND BAPI_Z05DOGI_ITEM_DATA.
    BAPI_Z05DOGI_ITEM_CONTROL-DELIV_NUMB = ZMM_WB1-ISSUE.
    BAPI_Z05DOGI_ITEM_CONTROL-DELIV_ITEM = 10.
    BAPI_Z05DOGI_ITEM_CONTROL-CHG_DELQTY = 'X'.
    APPEND BAPI_Z05DOGI_ITEM_CONTROL.
    CALL FUNCTION 'BAPI_OUTB_DELIVERY_CONFIRM_DEC'
    EXPORTING
    DELIVERY = BAPI_Z05DOGI_DELIVERY
    HEADER_DATA = BAPI_Z05DOGI_HEADER_DATA
    HEADER_CONTROL = BAPI_Z05DOGI_HEADER_CONTROL
    TABLES
    ITEM_DATA = BAPI_Z05DOGI_ITEM_DATA
    ITEM_CONTROL = BAPI_Z05DOGI_ITEM_CONTROL
    RETURN = BAPI_Z05DOGI_RETURN.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
    WAIT = 'X'
    IMPORTING
    RETURN = BAPI_Z05DOGI_RETURN.
    Go thru this link
    http://www.planetsap.com/LIST_ALL_BAPIs.htm
    BAPI_TRANSACTION_COMMIT
    Execute external Commit when using BAPIs
    This method executes a COMMIT WORK command. It is required for
    transactions developed externally to the R/3 System that change data in
    the R/3 System via BAPI calls.
    When you call BAPIs in your program that change data in the R/3 System,
    afterwards you must call this method to write the changes to the
    database.
    COMMIT WORK
    The statement COMMIT WORK completes the current SAP LUW and opens a new one, storing all change requests for the currenta SAP LUW in the process
    there are some FM that we use for creating trasaction . for example FM : that use for creating production order . if you execut the FM , the system will not create any data in the system so you need to excute the FM : BAPI_TRANSACTION_COMMIT to commit that creating the production order .
    in case of commit work, that is a syntax in abap program . if you use this syntax after you insert ,update or delete table in the sap ,system will do it immediately otherwise the system will do it after execution is complete.
    ROLLBACK WORK.
    for confirming or undoing database updates. COMMIT WORK always concludes a database LUW and starts a new one. ROLLBACK WORK always undoes all changes back to the start of the database LUW.
    Regards,
    Raj.

  • How to make use of SE37- Function Module & how to find out the table?

    Hi ,
    1.Could anyone help me what's this SE37-Function module is all about,How to make use of this?
    For Eg,If i want to delete a BOM permanently from the system then I have to use the Function module CM_DB_DEL_FROM_ROOT_BOM.
    But after giving the particular name what should i do?
    Please help me.
    2.How to find out the respective table for a particular field sya for T code-COGI, T code MFBF,where its values are getting populated.,Please help in this issue.
    Thanks in adavnce for spending some time
    Raj.S

    Hi Raj
    Function Modules
    Function modules are procedures that are defined in special ABAP programs only, so-called function groups, but can be called from all ABAP programs. Function groups act as containers for function modules that logically belong together. You create function groups and function modules in the ABAP Workbench using the Function Builder.
    Function modules allow you to encapsulate and reuse global functions in the SAP System. They are managed in a central function library. The SAP System contains several predefined functions modules that can be called from any ABAP program. Function modules also play an important role during updating  and in interaction between different SAP systems, or between SAP systems and remote systems through remote communications.
    Unlike subroutines, you do not define function modules in the source code of your program. Instead, you use the Function Builder. The actual ABAP interface definition remains hidden from the programmer. You can define the input parameters of a function module as optional. You can also assign default values to them. Function modules also support exception handling. This allows you to catch certain errors while the function module is running. You can test function modules without having to include them in a program using the Function Builder.
    The Function Builder  also has a release process for function modules. This ensures that incompatible changes cannot be made to any function modules that have already been released. This applies particularly to the interface. Programs that use a released function module will not cease to work if the function module is changed.
    Check this link
    http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/db988735c111d1829f0000e829fbfe/content.htm
    You can execute function module in SE37ie you can perform the activiites defined in the function module by executing it.
    By deleting BOM you mention the FM name in se37 and execute. In some function module it will ask input parameters as developed in the program , you have to give the input parameters and execute.

  • Error with the FIELD CAT function module.

    Hi folks,
    This was the error message i had got from the FIELDCAT function module.
    An exception occurred that is explained in detail below.
        The exception, which is assigned to class 'CX_SY_READ_SRC_LINE_TOO_LONG', was
         not caught in
        procedure "K_KKB_FIELDCAT_MERGE" "(FUNCTION)", nor was it propagated by a
         RAISING clause.
        Since the caller of the procedure could not have anticipated that the
        exception would occur, the current program is terminated.
        The reason for the exception is:
        There was an attempt to read program "/A1SSPC/ITP_SCH_REP" from the database.
        The READ REPORT statement allows you to copy a program text into an
        internal table. The occupied line length in the program text must not
        exceed the width of the internal table.
        The internal table "\FUNCTION=K_KKB_FIELDCAT_MERGE\DATA=???" is 72 characters
         wide. The program line is
        204 characters wide.
    Reg,
    Hariharan

    You can do this
    TYPE-POOLS:slis.
    DATA: it_vabp TYPE STANDARD TABLE OF vbap WITH HEADER LINE.
    DATA: it_fieldcat TYPE slis_t_fieldcat_alv.
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
       i_program_name               = sy-repid
       i_internal_tabname           = 'IT_VBAP'
       i_inclname                   = sy-repid
      CHANGING
        ct_fieldcat                  = it_fieldcat
    * EXCEPTIONS
    *   INCONSISTENT_INTERFACE       = 1
    *   PROGRAM_ERROR                = 2

  • Different types of function module

    hi,
    When we create a function module : in one of the tabs we can find
      1 general function module
      2. remote function module
    3. update function module.
    What is meant by update function module and remote function module. can anyone explain me with an example and when shd we opt for 2 and 3.
    thanxs
    hari

    Function Modules:
    Function modules allow you to encapsulate and reuse global functions in the R/3 System.
    They are stored in a central library. The R/3 System contains a wide range of predefined
    function modules that you can call from any ABAP program.
    Unlike subroutines, you do not define function modules in the source code of your program.
    Instead, you use the Function Builder. The actual ABAP interface definition remains hidden
    from the programmer. You can define the input parameters of a function module as optional.
    You can also assign default values to them. Function modules also support exception handling.
    This allows you to catch certain errors while the function module is running. You can test
    function modules without having to include them in a program using the Function Builder.
    Function Groups:
    Function groups are containers for function modules. You cannot execute a function group.
    When you call a function module, the system loads the whole of its function group into the
    internal session of the calling program.
    Calling Function Modules in ABAP:
    To call a function module, use the CALL FUNCTION statement:
    CALL FUNCTION <module>
    [EXPORTING f1 = a 1.... f n = a n]
    [IMPORTING f1 = a 1.... f n = a n]
    [CHANGING f1 = a 1.... f n = a n]
    [TABLES f1 = a 1.... f n = a n]
    [EXCEPTIONS e1 = r 1.... e n = r n [ERROR_MESSAGE = r E]
    [OTHERS = ro]].
    You can specify the name of the function module <module> either as a literal or a variable.
    Each interface parameter <fi> is explicitly assigned to an actual parameter <a i>. You can
    assign a return value <r i> to each exception <e i>. The assignment always takes the form
    <interface parameter> = <actual parameter>. The equals sign is not an assignment operator
    in this context.
    • After EXPORTING, you must supply all non-optional import parameters with values
    appropriate to their type. You can supply values to optional import parameters if you
    wish.
    [email protected]
    34
    • After IMPORTING, you can receive the export parameters from the function module by
    assigning them to variables of the appropriate type.
    • After CHANGING or TABLES, you must supply values to all of the non-optional
    changing or tables parameters. When the function module has finished running, the
    changed values are passed back to the actual parameters. You can supply values to
    optional changing or tables parameters if you wish.
    You can use the EXCEPTIONS option to handle the exceptions of the function module. If an
    exception <e i > is raised while the function module is running, the system terminates the
    function module and does not pass any values from the function module to the program,
    except those that were passed by reference. If <e i > is specified in the EXCEPTION option,
    the calling program handles the exception by assigning <r i > to SY-SUBRC. <r i > must be a
    numeric literal.
    If you specify of ERROR_MESSAGE in the exception list you can influence the message
    handling of function modules. Normally, you should only call messages in function modules
    using the MESSAGE ... RAISING statement. With ERROR_MESSAGE you can force the system
    to treat messages that are called without the RAISING option in a function module as follows
    for various FM's
    http://www.erpgenie.com/abap/functions.htm
    Calling Function Modules
    http://help.sap.com/saphelp_46c/helpdata/en/9f/db98ef35c111d1829f0000e829fbfe/content.htm
    remote enabled fm's are BAPI's
    refer
    Introduction to BAPIs:
    Definition
    The SAP Business Objects held in the Business Object Repository (BOR) encapsulate their data
    and processes. External access to the data and processes is only possible by means of specific
    methods - BAPIs (Business Application Program Interfaces).
    A BAPI is defined as a method of a SAP Business Object.
    For example, the functionality that is implemented with the SAP Business Object type
    "Material" includes a check for the material’s availability. Thus, the Business Object type
    "Material" offers a BAPI called "Material.CheckAvailability".
    Use
    To use a BAPI method, an application program only needs to know how to call the method;
    that is, it needs to know the method’s interface definition. Therefore, when including a BAPI
    invocation in your application program, you only need to supply the appropriate interface
    information.
    A BAPI interface is defined by:
    • Import parameters, which contain data to be transferred from the calling program to
    the BAPI
    • Export parameters, which contain data to be transferred from the BAPI back to the
    calling program
    • Import/export (table) parameters for both importing and exporting data
    Structure
    The BAPIs in the R/3 System are currently implemented as function modules, all of which are
    held in the Function Builder. Each function module underlying a BAPI:
    • Supports the Remote Function Call (RFC) protocol
    • Has been assigned as a method to an SAP Business Object in the BOR
    • Is processed without returning any screen dialogs to the calling application
    Integration
    The architecture enables SAP to change the details of a BAPI’s implementation without
    affecting external applications, which are using the BAPI.
    Advantages of Using BAPIs
    BAPIs are standardized methods of SAP Business Objects that enable customers and third
    parties to integrate their software components with the R/3 System and the Business
    Framework.
    Business Standard
    SAP Business Objects and their BAPIs provide a business content standard, rather than a
    technical interoperability standard; that is, they enable the integration of R/3 and other
    software components on a business level, not on a technical level.
    [email protected]
    97
    Standards Conformance
    BAPIs are being developed as part of the SAP joint initiative with customers, partners, and
    leading standards organizations. BAPIs are becoming a communication standard between
    business systems.
    You can access SAP Business Objects and their BAPIs by using object-oriented interfacing
    technologies such as Microsoft’s COM/DCOM (Component Object Model/Distributed Component
    Object Model).
    The SAP Business Objects already comply with the Open Applications Group (OAG)
    specifications, and, in conjunction with ObjectBridge from VisualEdge, conform to the Object
    Management Group’s CORBA (Common Object Request Broker Architecture) guidelines.
    Stability and Downward Compatibility
    Once a BAPI is implemented and released by SAP, its interface definition and parameters
    remain stable in the long term, thus ensuring that your application program remains
    unaffected by any changes to the underlying R/3 software and data.
    SAP can make any necessary extensions to the BAPIs, for example, additional optional
    parameters, without destabilizing the operation of existing applications and, at the same time,
    can offer the enhanced functionality to new applications.
    Object Orientation
    As methods of the SAP Business Objects, BAPIs provide access to R/3 data and processes
    following an object-oriented programming model. BAPIs can be called using object-oriented
    interfacing technologies, such as COM/DCOM, thus enabling software components from SAP
    and third parties to interact freely.
    Openness
    You can access BAPIs from all development platforms that support the SAP Remote Function
    Call (RFC) protocol.
    BAPI Definition
    A Business Application Programming Interface (BAPI) is a precisely defined interface providing
    access to processes and data in business application systems such as R/3. BAPIs are defined
    as API methods of SAP Business Objects. These business objects and their BAPIs are described
    and stored in the Business Object Repository (BOR).
    A BAPI is implemented, however, as a function module, that is stored and described in the
    Function Builder.
    BAPIs can be called within the R/3 System from external application systems and other
    programs. BAPIs are the communication standard for business applications. BAPI interface
    technology forms the basis for the following developments:
    • R/3 satellite systems
    • Isolating components within the R/3 System in the context of Business Framework
    • Distributed R/3 scenarios using Application Link Enabling (ALE)
    • Connecting R/3 Systems to the Internet using Internet Application Components (IACs)
    • Visual Basic programs as front-end to R/3 Systems
    • Workflow applications that extend beyond system boundaries
    • Customers’ and partners’ own developments
    • Connections to non-SAP software
    • Connections to legacy systems
    [email protected]
    98
    Standardized BAPIs
    Some BAPIs and methods provide basic functions and can be used for most SAP Business
    Objects. Such BAPIs are known as "standardized" BAPIs.
    Using the descriptions below as a guide, verify whether you can implement the BAPI as a
    standardized BAPI.
    Features
    BAPIs for Reading Data
    The following BAPIs provide you with read-only access to data in the associated business
    object:
    • GetList
    With this BAPI you can select a range of object key values, for example, company
    codes and material numbers. To specify appropriate selection requirements the calling
    program must pass the relevant parameters to the interface. The key values selected
    by the BAPI GetList are returned to the calling program in a table, together with other
    useful information, for example, short texts. The key values can then be passed on to
    another BAPI for further processing, for example, the BAPI GetDetail, as listed below.
    • GetDetail
    The BAPI GetDetail uses a key to retrieve details about an instance(s specific
    occurrence) of a business object and returns this data to the calling program.
    • GetStatus
    The BAPI GetStatus is used to query the status of an SAP Business Object, for
    example, to display the processing status of a sales order. This BAPI is used only for
    displaying the status of an object and does not retrieve full details like the BAPI
    GetDetail.
    • ExistenceCheck
    The BAPI ExistenceCheck checks, whether an entry exists for an SAP Business Object,
    for example, whether the customer master has been created. You should implement
    this method as a workflow method and not as a BAPI (RFC capable function module).
    The method CompanyCode.ExistenceCheck of the business object CompanyCode
    (BUS0002) is an example of this. This workflow method is indirectly invoked when the
    calling program instantiates an object, for example, by using
    GetSAPObject("CompanyCode") from within Visual Basic.
    BAPIs for Creating or Changing Data
    The following BAPIs can create, change or delete instances of a business object: If required,
    you can implement these BAPIs so that, several instances of a business object can be created,
    deleted or modified simultaneously in the same call. In such cases "multiple" is added to the
    method name, for example ChangeMultiple.
    BAPIs that can create, change or delete instances are:
    • Create or CreateFromData
    The BAPI Create or CreateFromData creates an instance of an SAP Business Object,
    for example, a sales order. Create is the preferred name for this BAPI. Use the name
    CreateFromData only when a workflow method called Create already exists for the
    business object in question.
    [email protected]
    99
    • Change
    The BAPI Change changes an existing instance of a SAP Business Object, for example,
    a sales order.
    • Delete
    The BAPI Delete deletes an instance of a SAP Business Object, for example, sales
    order.
    BAPIs for Replicating Business Object Instances
    The BAPIs below can be implemented as methods of business objects that can be replicated.
    They enable specific instances of an object type to be copied to one or more different systems.
    These BAPIs are used mainly to transfer data between distributed systems within the context
    of Application Link Enabling (ALE).
    The method below must be implemented for each business object to be replicated.
    • Replicate
    The BAPI Replicate is called in the system, which contains the originals of the business
    object instances to be replicated. It is used to:
    • Identify the business objects to be replicated and to organize the required data.
    • Call the clone methods described below in the receiving system
    Moreover, at least one of the clone methods below must be implemented for each business
    object to be replicated.
    • Clone
    The BAPI Clone is used by a system to replicate one business object on another
    system or to modify one business object that has already been cloned.
    • CloneMultiple
    The BAPI CloneMultiple is used by a system to replicate several business objects on
    another system or to modify several business objects that have already been cloned.
    Defining and Implementing the BAPI
    Purpose
    Various components of the ABAP Workbench are used when you define and implement a BAPI.
    A BAPI is an API method of a business object and is defined as such in the Business Object
    Repository (BOR). However, a BAPI is implemented as an RFC capable function module, which
    is maintained in the Function Builder. The definitions and descriptions of the data structures
    used by the BAPI are stored in the ABAP Dictionary.
    For function modules that implement BAPIs, certain standards and rules must be adhered to
    over and above the standard programming rules for function modules. For example, COMMIT
    WORK commands must not be used in the function modules that a BAPI is based on.
    The following sections guide you through the steps involved in developing a BAPI. The sections
    contain information about the guidelines and conventions that you should adhere to when
    defining and implementing a BAPI. When implementing BAPIs follow the requirements below
    to ensure you achieve consistent behavior and representation of BAPIs as object oriented
    methods of SAP Business Objects.
    [email protected]
    100
    BAPI Programming
    BAPI Definition
    A Business Application Programming Interface (BAPI) is a precisely defined interface providing
    access to processes and data in business application systems such as R/3.
    BAPIs are defined as API methods of SAP Objects. These objects and their BAPIs are described
    and stored in the BOR (BOR).
    Use
    BAPIs can be called within the R/3 System from external application systems and other
    programs. A BAPI call can either be made as an object oriented method call or as a remote
    function call (RFC).
    BAPIs are a global communication standard for business applications.
    Examples of what BAPIs can be used for include:
    • R/3 satellite systems
    • Distributed R/3 scenarios using Application Link Enabling (ALE)
    • Connecting R/3 Systems to the Internet using Internet application components (IACs)
    • Visual Basic programs as front-end to R/3 Systems
    • Workflow applications that extend beyond system boundaries
    • Customers’ and partners’ own developments
    • Connections to non-SAP software
    • Connections to legacy systems
    BOR Definition
    The Business Object Repository (BOR) is the object-oriented repository in the R/3 System. It
    contains, among other objects, SAP Business Objects and their methods. In the BOR a
    Business Application Programming Interface (BAPI) is defined as an API method of an SAP
    Business Object. Thus defined, the BAPIs become standard with full stability guarantees as
    regards their content and interface.
    Use
    With regard to SAP Business Objects and their BAPIs, the BOR has the following functions:
    • Provides an object-oriented view of R/3 System data and processes.
    R/3 application functions are accessed using methods (BAPIs) of SAP Business
    Objects. Implementation information is encapsulated; only the interface functionality
    of the method is visible to the user.
    • Arranges the various interfaces in accordance with the component hierarchy, enabling
    functions to be searched and retrieved quickly and simply.
    • Manages BAPIs in release updates.
    BAPI interface enhancements made by adding parameters are recorded in the BOR.
    Previous interface versions can thus be reconstructed at any time. When a BAPI is
    created the release version of the new BAPI is recorded in the BOR. The same applies
    when any interface parameter is created.
    The version control of the function module that a BAPI is based on is managed in the
    Function Builder.
    • Ensures interface stability.
    Any interface changes that are carried out in the BOR, are automatically checked for
    syntax compatibility against the associated development objects in the ABAP
    Dictionary.
    [email protected]
    101
    Integration
    You should only define a BAPI as a SAP Business Object method in the BOR if the function
    module that the BAPI is based on has been fully implemented. Full access to the BOR is
    restricted to the persons responsible for the objects involved and for quality control.
    BOR-BAPI Wizard
    The BOR-BAPI Wizard assists with creating new BAPI methods in the BOR. It takes you
    through the creation process step by step.
    Transaction Model for Developing BAPIs Purpose
    The transaction model in which BAPIs are used determines how you have to program BAPIs.
    The transaction model described here has been used to develop BAPIs for R/3 Releases 3.1
    and 4.0A.
    Logical Unit of Work (LUW) and Statelessness
    Within the context of this transaction model a transaction represents one processing step or
    one logical unit of work (LUW). When a transaction is called, database operations are either
    fully executed or not at all. The whole transaction must be programmed to be stateless.
    This transaction model requires that:
    • No data is imported that may indirectly affect the result. If a transaction is called more
    than once, each call must have the same result. For BAPIs this means, for example,
    that Set or Get parameters cannot be used. However, you can keep Customizing data
    in a global memory, as this data remains unchanged even if transaction calls are
    repeated.
    • There must be no functional dependencies between two transactions.
    • Either all relevant data has to be changed in the database or none at all.
    Determining the SAP Business Object and Its Key Fields
    You have to identify the relevant SAP Business Object in the Business Object Repository (BOR)
    and determine whether the key fields of the Business Object are relevant for your BAPI.
    A key is defined in the BOR for most SAP Business Objects. This key can consist of several key
    fields. The content of these key fields uniquely identifies one individual instance of an SAP
    Business Object.
    You can differentiate between instance-dependent and instance-independent BAPI methods.
    Unlike instance-independent methods, instance-dependent methods relate to one instance
    (one specific occurrence) of an SAP Business Object type, for example to one specific sales
    order.
    In the case of instance-dependent BAPIs, the key fields of the corresponding SAP Business
    Object must be used as parameters in the function module the BAPI is based on so that the
    associated object instance can be identified. The names of the key fields in the SAP Business
    Object and the corresponding parameters in the BAPI function module must be the same,
    because the name links the key fields to the parameters.
    All the key fields defined in the BOR for the SAP Business Object in question must be used as
    the parameters in the function module.
    Example
    SAP Business Object Creditor has a key field named CreditorId.
    This key field must be defined as a parameter with the name CREDITORID in the function
    modules of the instant-dependent BAPIs for this Business Object.
    [email protected]
    102
    To display the Business Object and its key fields follow the steps below:
    1. Select Tools -> ABAP Workbench -> Overview -> Business Object Browser . The
    business objects are displayed in the order of the R/3 application hierarchy.
    2. Select the required SAP Business Object in the application hierarchy and double click it
    to open it.
    3. To display the Business Object’s key fields, expand the node Key fields.
    Defining the Interface Structure of the BAPI
    In this step you are going to define the BAPI interface, that is, the individual import, export
    and table parameters required for calling the BAPI.
    Caution
    You cannot use Changing and Exception parameters in a function module which implements a
    BAPI.
    Process Flow
    To define the interface parameters, proceed as follows:
    1. Check whether the key fields of the SAP Business Object are required in the interface. The
    key fields of the SAP Business Object are some of the most important BAPI parameters.
    If a key value is to be passed to the BAPI by the calling program, the key field must be set as
    an import parameter in the function module of the BAPI. That way a specific instance of the
    Business Object is identified.
    For example, this could be a customer number (CustomerNo) in the BAPIs Customer.GetDetail
    and Customer.CheckPassword, or the number of a sales document in the BAPI
    SalesOrder.GetStatus.
    For BAPIs that generate instances, for example, the BAPIs Create or CreateFromData, the key
    field of the Business Object should be set as an export parameter in the BAPI function module.
    These BAPIs return one key value, for example, an order number in the BAPI
    SalesOrder.CreateFromData.
    For BAPIs that are class methods a key field is neither set as an import nor as an export
    parameter in the BAPI function module. Class methods are instance-independent and are
    called without the use of key values. Usually they return a table with a selection of key values.
    2. Specify what other data is relevant as import, export or table parameters for the BAPI.
    Every BAPI must have an Export parameter return that reports messages back to the calling
    program.
    Example
    The BAPI to be developed is to read data from the SAP Business Object Creditor. To read
    creditor details, the calling program has to pass the ID of the creditor and the company code.
    The creditor data returned is to include general details, specific details and bank details.
    To map these requirements onto the BAPI interface, the following parameters must be set in
    the function module which the BAPI is based on:
    • The key field CreditorID of the SAP Business Object as an import parameter
    • An import parameter for the company code
    • A Return parameter that reports messages back to the calling program
    • A parameter for general details of the creditor
    • A parameter for specific details of the creditor
    • A parameter for bank details of the creditor
    for BAPI list
    refer www.sapbapi.com
    for FM's refer www.se37.com
    regards
    srinivas
    <b>*reward for useful answers*</b>

  • Use of function module : NUMBER_GET_NEXT in BADI TRIP_WEB_NUMBER

    Hi All,
    I am implementing BADI TRIP_WEB_NUMBER and using function module NUMBER_GET_NEXT  to get the next number from a number range when the function module throws an exception how can i pass the exception to the exporting parameter
    of the BADI 'RETURN' which is of table type BAPIRETTAB.
    Do i need to handle exception as below?
    Case sy-subrc
    When '1'
    ls_return- MESSAGE = 'error message 1'
    When 2
    ls_return- MESSAGE = 'error message 2'
    What should i pass in the other fields of ls_return i mean like TYPE,ID,NUMBER etc??

    Hi
    You have to pass the message in the proper structure in the RETURN parameter
    Exampple
          return-type = 'E'.
          return-number = '12'.
          return-message = 'number generation error'
    Regards
    Vijay V

  • Regarding the function modules

    Hi anybody pls tell me
    what are the scenarios for the creation of function module
    can you give me the some examples
    thanks in advance

    <b>Function Modules</b>
    Function modules are procedures that are defined in function groups (special ABAP programs with type F) and can be called from any ABAP program. Function groups act as containers for function modules that logically belong together. You create function groups and function modules in the ABAP Workbench using the  Function Builder.
    Function modules allow you to encapsulate and reuse global functions in the R/3 System. They are stored in a central library. The R/3 System contains a wide range of predefined function modules that you can call from any ABAP program. Function modules also play an important role in database updates and in remote communications between R/3 Systems or between an R/3 System and a non-SAP system.
    Unlike subroutines, you do not define function modules in the source code of your program. Instead, you use the  Function Builder. The actual ABAP interface definition remains hidden from the programmer. You can define the input parameters of a function module as optional. You can also assign default values to them. Function modules also support exception handling. This allows you to catch certain errors while the function module is running. You can test function modules without having to include them in a program using the  Function Builder.
    The  Function Builder also has a release process for function modules. This ensures that incompatible changes cannot be made to any function modules that have already been released. This applies particularly to the interface. Programs that use a released function module will not cease to work if the function module is changed

  • How to create function module step by step

    hi experts,
    i am new to ABAP.
    can anybody tell me the step by step process on how to create a function module for adding two numbers without using editor screen.
    ex: 2+3=5.

    Hi,
    You can only create function modules and function groups using the Function Builder in the ABAP Workbench. For further information, refer to Creating New Function Modules. This section uses an example to illustrate how a function module is created from the point of view of ABAP programming.
    Function Groups and Function Modules:
    Firstly, we create a new function group DEMO_SPFLI to hold the function module. Then, we can create the new function module.
    Parameter Interface:
    You can specify the types of interface parameters in function modules in the
    same way as the parameter interfaces of subroutines. Since function
    modules can be used anywhere in the system, their interfaces can only contain
    references to data types that are declared systemwide. These are the elementary
    ABAP data types, the systemwide generic types, such as ANY TABLE, and types
    defined in the ABAP Dictionary. You cannot use LIKE to refer to data types
    declared in the main program.
    Exceptions:
    Our function module needs an exception that it can trigger if there are no entries
    in table SPFLI that meet the selection criterion. The exception NOT_FOUND
    serves this function.
    Source Code:
    Having defined the parameter interface and exceptions, we can now write the
    source code of our function module. To do this, choose Source code in the
    Function Builder. This opens the ABAP Editor for the include program
    L<fgrp>U<xx> (see Function Groups). This is the include that will
    hold the program code for the function module;
    Data in Function Modules
    You can use the TYPES and DATA statements to create local data types and
    objects. The interface parameters also behave like local data objects. In
    addition, you can access all of the global data of the main program. This data is
    defined in the include program L<fgrp>TOP. To open this include, choose Goto
      Global data. The global data behaves like the instance attributes of a class.
    The first time you call a function module in a particular function group, the data is
    loaded into memory. It can then be accessed and changed by all of the function
    modules in the group. The system retains the values until the next time a function
    module is called.
    Calling Subroutines
    You use subroutines for local modularization. Function modules can
    also use this technique. The function module that they call are defined in the
    corresponding main program.
    If you only want to call a subroutine from a single function module, it is best to
    define them in the same include program as the function module itself, directly
    after the ENDFUNCTION statement. These subroutines can be called from all
    function modules in the function group, but for clarity, they should only be called
    from the function module that precedes them.
    If you want to define a subroutine that will be called from several different function
    modules, you can define a special include program for it with the name
    L<fgrp>F<xx>.
    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, SYMSGTY,
    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.
    Regards,
    Chandru

  • IS-R:functional modules in IS-Retail

    Hi experts,
                    Can anyone tell me the" functional  modules" of IS-Retail?Give all the functional modules which you use and give the T-code to execute them.
    Regards
    Swamy

    A function module is a separate program that can be called from your ABAP code to perform a specific task.
    SAP comes with a library of pre-written function modules. Function modules are pooled together into function groups.
    E.g. calendar functions 
    Function modules have a clearly defined fixed interface for data exchange.
    As one of member suggested go to tcode se37 to explore functional builder.
    You can display information about existing function modules:
    Attributes: specifies administrative information like the person responsible for the module and a short description of the module.
    Import: contains a list of the formal parameters that are used to pass data to a function module. 
    Export: contains a list of the formal parameters that are used to receive data from a function module.
    Changing: contains a list of the formal parameters that are used both to pass data to and receive data from a function module. 
    Tables: specifies the tables that are to be passed to a function module. Table parameters are always passed by reference. 
    Exceptions: shows how the function module reacts to exceptions.
    Source code: program code of the function module.
    Documentation: provides information about the interface and exceptions.
    For retail specific fuctional module, u can explore yourself on tcode se37.
    Regards,

Maybe you are looking for