Function Group and Subroutines

Hi all,
I have two Function Groups.
I have a subroutine defined in one Function Group and want to use same subroutine in another Function Group.
Is there any way to do it, <u><b>without redefining same Subroutine in another Function Group?</b></u>

Hi,
    either define subroutines in include
    and inlude in function group
     include ztest.
      perform abc .
      perfrom add.
Function group ZFG
     include ztest.
Function group ZFG1
     include ztest.
<b>    or</b>   
perform test(prog1).
Regards
amole

Similar Messages

  • Function Groups and Function Modules

    Hi,
    Can anyone give me the detail steps for creating Function Group and then from that function group creation of function module with example?
    Regards,
    Chandru

    Hi,
    Function Group creation -
           A function group is a program that contains function modules. With each R/3 system, SAP supplies more than 5,000 pre-existing function groups.
         In total, they contain more than 30,000 function modules. If the functionality you require is not already covered by these SAP-supplied function modules, you can also create your own function groups and function modules.
          We can put all the relevant function modules under one function group and all the global variables can be declared in this FG.
    FG Creation:
    1)     Function group can be created in SE80. There choose the 'Function Group' from the list of objects.
    2)    Then give a name for ur function group (starts with Y or Z) and press ENTER.
    3)   The click 'YES' in the create object dialog box and give a short desc. for this FG and save.
    Function Module:
                 A function module is the last of the four main ABAP/4 modularization units. It is very similar to an external subroutine in these ways:
    Both exist within an external program.
    Both enable parameters to be passed and returned.
    Parameters can be passed by value, by value and result, or by reference.
    The major differences between function modules and external subroutines are the following:
    Function modules have a special screen used for defining parameters-parameters are not defined via ABAP/4 statements.
    tables work areas are not shared between the function module and the calling program.
    Different syntax is used to call a function module than to call a subroutine.
    Leaving a function module is accomplished via the raise statement instead of check, exit, or stop.
    A function module name has a practical minimum length of three characters and a maximum length of 30 characters. Customer function modules must begin with Y_ or Z_. The name of each function module is unique within the entire R/3 system.
    Defining Data within a Function Module
    Data definitions within function modules are similar to those of subroutines.
    Within a function module, use the data statement to define local variables that are reinitialized each time the function module is called. Use the statics statement to define local variables that are allocated the first time the function module is called. The value of a static variable is remembered between calls.
    Define parameters within the function module interface to create local definitions of variables that are passed into the function module and returned from it (see the next section).
    You cannot use the local statement within a function module. Instead, globalized interface parameters serve the same purpose. See the following section on defining global data to learn about local and global interface parameters.
    Defining the Function Module Interface
    To pass parameters to a function module, you must define a function module interface. The function module interface is the description of the parameters that are passed to and received from the function module. It is also simply known as the interface. In the remainder of this chapter, I will refer to the function module interface simply as the interface.
    To define parameters, you must go to one of two parameter definition screens:
    1) Import/Export Parameter Interface
    2) Table Parameters/Exceptions Interface
    Then in the FM interface screen, give the following
    1) Import parameters
    2) Export parameters
    3) Changing parameters
    Then give
    1) Define internal table parameters
    2) Document exceptions
    You enter the name of the parameter in the first column and the attributes of the parameter in the remaining columns. Enter one parameter per row.
    Import parameters are variables or field strings that contain values passed into the function module from the calling program. These values originate outside of the function module and they are imported into it.
    Export parameters are variables or field strings that contain values returned from the function module. These values originate within the function module and they are exported out of it.
    Changing parameters are variables or field strings that contain values that are passed into the function module, changed by the code within the function module, and then returned. These values originate outside the function module. They are passed into it, changed, and passed back.
    Table parameters are internal tables that are passed to the function module, changed within it, and returned. The internal tables must be defined in the calling program.
    An exception is a name for an error that occurs within a function module. Exceptions are described in detail in the following section.
    Syntax for the call function Statement
    The following is the syntax for the call function statement.
    call function 'F'
        [exporting   p1 = v1 ... ]
        [importing   p2 = v2 ... ]
        [changing    p3 = v3 ... ]
        [tables      p4 = it ... ]
        [exceptions  x1 = n [others = n]].
    where:
    F is the function module name.
    p1 through p4 are parameter names defined in the function module interface.
    v1 through v3 are variable or field string names defined within the calling program.
    it is an internal table defined within the calling program.
    n is any integer literal; n cannot be a variable.
    x1 is an exception name raised within the function module.
    The following points apply:
    All additions are optional.
    call function is a single statement. Do not place periods or commas after parameters or exception names.
    The function module name must be coded in uppercase. If it is coded in lowercase, the function will not be found and a short dump will result.
    Use the call function statement to transfer control to a function module and specify parameters. Figure 19.9 illustrates how parameters are passed to and received from the function module.
    sample FM
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      I_INTERFACE_CHECK                 = ' '
      I_BYPASSING_BUFFER                = ' '
      I_BUFFER_ACTIVE                   = ' '
      I_CALLBACK_PROGRAM                = ' '
      I_CALLBACK_PF_STATUS_SET          = ' '
      I_CALLBACK_USER_COMMAND           = ' '
      I_CALLBACK_TOP_OF_PAGE            = ' '
      I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
      I_CALLBACK_HTML_END_OF_LIST       = ' '
      I_STRUCTURE_NAME                  =
      I_BACKGROUND_ID                   = ' '
      I_GRID_TITLE                      =
      I_GRID_SETTINGS                   =
      IS_LAYOUT                         =
      IT_FIELDCAT                       =
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
      IT_SORT                           =
      IT_FILTER                         =
      IS_SEL_HIDE                       =
      I_DEFAULT                         = 'X'
      I_SAVE                            = ' '
      IS_VARIANT                        =
      IT_EVENTS                         =
      IT_EVENT_EXIT                     =
      IS_PRINT                          =
      IS_REPREP_ID                      =
      I_SCREEN_START_COLUMN             = 0
      I_SCREEN_START_LINE               = 0
      I_SCREEN_END_COLUMN               = 0
      I_SCREEN_END_LINE                 = 0
      I_HTML_HEIGHT_TOP                 = 0
      I_HTML_HEIGHT_END                 = 0
      IT_ALV_GRAPHICS                   =
      IT_HYPERLINK                      =
      IT_ADD_FIELDCAT                   =
      IT_EXCEPT_QINFO                   =
      IR_SALV_FULLSCREEN_ADAPTER        =
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER           =
      ES_EXIT_CAUSED_BY_USER            =
      TABLES
        t_outtab                          =
    EXCEPTIONS
      PROGRAM_ERROR                     = 1
      OTHERS                            = 2
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    Example
    1  report ztx1905.
    2  parameters: op1 type i default 2,   "operand 1
    3              op2 type i default 3.   "operand 2
    4  data rslt type p decimals 2.        "result
    5
    6  call function 'Z_TX_DIV'
    7       exporting
    8            p1      = op1
    9            p2      = op2
    10      importing
    11           p3      = rslt.
    12
    13 write: / op1, '/', op2, '=', rslt.
    Regards,
    Shanthi.P
    Reward points if useful ****
    Edited by: shanthi ps on Jan 26, 2008 12:03 PM

  • Diff between Function Module and subroutine

    sir,
      explain the difference between Function Module and Subroutine.

    Hi Sandeep,
    Subroutines:
       Subroutines are procedures that you can define in any ABAP program and also call from any program. Subroutines are normally called internally, that is, they contain sections of code or algorithms that are used frequently locally. If you want a function to be reusable throughout the system, use a function module.
    Function Modules:
    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.
    Unlike subroutines, you do not define function modules in the source code of your program. Instead, you use the Function Builder.
    Regards,
    Sunil

  • What is the difference between function groups and Object Orientation

    Hello all
    I have read about this on the help.sap.com site, I still do not understand it completely, can some one explain me with  a simple example please ? (Not the increment counter example please !).
    Thanks a ton.
    Rgds
    Sameer

    Hello Sameer
    When you call a module of a function group for the first time in your program then the entire function group is loaded. However, this can happen only once within your report and all global variables within the function group will have the same values all the time (except they are manipulated via fm's).
    In contrast, you can create as many instances of the same class as you want and all of them can have different global attributes. And all these instances are independent of each other.
    On the other hand, if fm_A changes global attributes of the function group and fm_B reads these attributes then fm_B read the changed values.
    Or in other words:
    Function Group = can be instantiated only ONCE
    Class = can be instantiated unlimited
    Regards
      Uwe

  • Function Group and Module Transport

    Hi All,
    I have created a new Function group and is part of transport request. Created new function modules and assigned to the same function group. When i see object list in SE09 for the transport request i see only function group, all the FM are part of same transportable package of Function group. Do i need to assign them manually in object list through SE09 as pseudo changes to FM is not capturing in the request.
    Thanks in advance.
    Regards
    Kunal.

    There is no need to manually assign fm to fg. If you transport the fg , objects under the fg get transported automatically.
    Next time if you changing only function module then your se09 entry will be
    LIMU              FUNC

  • Custome BAPI - declare ITAB and define the Function Module and Subroutine

    Hello Experts
    I want to create a Custom BAPI and it has the following scenario:
    1) a Function Module which collects some records into it internal table, say ITAB
    2) a Subroutine which moved the records from ITAB to BAPI table
    Now, I want to declare ITAB and define the Function Module and Subroutine.
    Where and How can I do this?
    Plz suggest.
    Regards
    BD

    Hi,
      1) Got to SE37 and create an RFC .
      2) Declare the ITAB directly in the TABLES tab of the FM.
      3) Inside the FM source Code tab, collect all the data using SELECT query and directly or by using logic, put the data into the
          ITAB.
      4) Since the data collected is directly put into the itab you dont need a subroutine to be written.
      5) If subroutine is a necessity, then just write PERFORM SUB ROUTINE NAME.
           AND DEFINE THE FORM ENDFORM OF THE SUBROUTINE AFTER THE ENDFUNCTION OF THE FM
       Let me know if any issues....
    Regards,
    Vimal.

  • Difference between function module and subroutines

    hey all...
    can u pls explai me the exact difference between subroutines and function modules...
    also, when is a sub routine used and also when is a function module used..???
    regards..
    vishal

    Hi Vishal,
    Basically they do the same thing and purpose is almost same but tecnically the are way apart:
    Function modules must belong to a pool called a function group.
    They possess a fixed interface for data exchange. This makes it easier for you to pass input and output parameters to and from the function module.
          For example, you can assign default values to the input parameters. The interface also supports exception handling. This allows you to catch errors and pass them back to the calling program for handling.
    They use their own memory area. The calling program and the function module cannot exchange data using a shared memory area - they must use the function module interface. This avoids unpleasant side effects such as accidentally overwriting data.
    You call a function module by its name (which must be unique) in a CALL FUNCTION statement.
    and also
    Unlike subroutines, you do not define function modules in the source code of your program. Instead, you use the Structure link Function Builder.
    Check this link too
    Re: Regarding difference between Subroutines and Function modules
    Hope this helps you,
    Regards
    Amit
    Message was edited by: Amit Kumar

  • Can we move SAP standard Function Group and Table defintion to BW

    Dear Forum,
    We are in a ‘pilot’ process of migrating SAP R/3 Custom development objects to our BW client and we have a few questions that we would like to know if possible.
    We are currently in the ‘To Be’ Blueprint Phase of migrating SAP 45B to ERP2005 as a Ramp-Up customer and we need to determine as soon as possible the feasibility of moving one particular Custom application
    from our SAP R/3 environment to BW.  This application primarily performs computational processing and does reporting of the results at the
    conclusion
    We have selected one Custom R/3 ABAP program to do a ‘pilot’ to determine the feasibility of migrating it to the BW platform. This Custom program utilizes objects from standard SAP Function Groups which are non existent in BW.  In this particular case Function groups KMS0
    (Cost Center Selection) and KAB2 (CO Reporting: General).
    Questions:
    Are we allowed to move these 2 standard SAP Function Groups to BW ? Would it alter the BW environment integrity as intended and designed by SAP?
    If we move the Function Group KMS0 and KAB2 will
    SAP support our BW environment if we decide to move them?
    Would it be considered a ‘SAP Best Practice’ to move standard SAP R/3
    objects to BW?
    Thank you in advance for your help,
    Paulo Silveira
    [email protected]

    Hi Paulo and welcome on board !
    Please don't post twice the same question...(look in the other one...)
    ..and don't forget to rewards the answers...it's THE way to say thanks here !
    Anyway, I'd suggest to close this thread to avoid to receive answers in both threads...
    Cheers,
    Roberto

  • Function group and transaction hav same name.

    Is  it   possible to re-name a function group name which is accidently nameed same as a transaction code.
    Thanks in advance,
    Rupesh.

    You can't rename a function group, but you can copy it. Go to SE80, put in your function group, right click on the function group name and click COPY. You can now choose a new name for the function group. After confirming you'll get another popup, where you can select the function modules you want to copy. Don't forget to rename them as well.
    Hope that helps,
    Michael

  • Are Classes better than Function groups and Modules

    Hi,
    Are classes better than Function groups? For example if you want to execute something is back ground or use parallel processing you can't do it using classes. Even inside classes most of the places we use Function modules.
    Then how classes are beneficial?
    Regards,
    Deepak Bhalla

    Yes they are compared in the sense that the class and function group are the containers, and the methods and function modules are the interfaces in which you interact with the encapsulated data. 
    Again if you are developing an application in which you are not forced to push the processing to differenet work processes,  then using classes/methods is preferrable. The reason I say this, is because anything coming from SAP will most likely be implemented as a class as opposed to a function group.  This is not to say that SAP will not create new function modules, because of course there still is a use for them.
    Regards,
    Rich Heilman

  • About function groups and includes?

    I ahve created 1 function groupa nd module
    then id int keep any thing in function module like tables,impot..exportsourcecode
    i dint fill ..when im checking for errors its showing nothing but when activating its saying "report stmt is missing"
    y this happening?
    about includes..
    I wanted to include one in other include
    when im im wriitng select stmt in second include the error is
    "stmt is not accessble"
    pls clarify my doubts as soon as possible

    Hi,
    When ever you execute or check it will give "report stmt is missing" so you need to use this includes in report program only.
    For include in which select is there also need to keep in report program.
    You cannot execute include/module pool pragram
    regards,
    Sreevani

  • Macros, Function modules and subroutines

    Hi Experts,
    In performance wise which one is best macro or subroutine or Function module?
    Thanks.

    Hi Nandini,
    Each and every one has its importance in certain situations..
    Macros
    If you want to reuse the same set of statements more than once in a program, you can include them in a macro. For example, this can be useful for long calculations or complex WRITE statements. You can only use a macro within the program in which it is defined, and it can only be called in lines of the program following its definition.
    Subroutines can call other subroutines (nested calls) and may also call themselves (recursive calls). Once a subroutine has finished running, the calling program carries on processing after the PERFORM statement. You can use the USING and CHANGING additions to supply values to the parameter interface of the subroutine.
    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.
    Best regards,
    raam

  • How to organize function modules & subroutines in a function group?

    Hi,
    There are several function modules and subroutines in a function group. And the subroutines will be called by severel modules.
    Originally:
    1. I put subroutine forms in an Include.
    2. and in the function modules which will use the forms, I include the Include before the function definition.
    3. While when activating the functin modules, it's reported that the forms had already been defined. Only if one function module includes the Include, it's OK.
    How should the forms and function modules be organized?
    Thanks!
    Sayid

    Hi Atish
    Yes, you are right.
    It works.
    Thank you.
    Regards,
    Sayid

  • Function modules and function groups

    Hi alll
       Can anybody explain me abt function module and function groups...please
    Thanks and Regards
    vijaya

    <b>Function groups</b> are containers for function modules. You cannot execute a function group. When you call an function module, the system loads the whole of its function group into the internal session of the calling program (if it has not already been loaded).
    The name of a function group can be up to 26 characters long. This is used by the system to create the components of the group (main program and corresponding include programs). When you create a function group or
    function module in the Function Builder [Ext.] , the main program and include programs are generated automatically.
    When you create a new function group, the system automatically creates a main program containing two includes. Like any other programs and includes, you can display them in the Repository Browser.
    The name of the main program is assigned by the system. This is made up of the prefix SAPL followed by the function group name. For example, the main program for function group SXXX is called SAPLSXXX.
    The names of the include files begin with L followed by the name of the function group, and conclude with UXX ( or TOP for the TOP include). The TOP include contains global data declarations that are used by all of the function modules in the function group. The other include file within the main program is used to hold the function modules within the group.
    You cannot declare a COMMON PART in a function group. Function groups have their own table work areas (TABLES). Function groups encapsulate data.
    All of the function modules in a function group can access the global data of the group. For this
    reason, you should place all function modules that use the same data in a single function group.
    For example, if you have a set of function modules that all use the same internal table, you could
    place them in a function group containing the table definition in its global data.
    Like executable programs (type 1) and module pools (type M), function groups can contain screens, selection screens, and lists. User input is processed either in dialog modules or in the corresponding event blocks in the main program of the function group. There are special include programs in which you can write this code. In this way, you can use function groups to
    encapsulate single screens or screen sequences.
    For function module, have a look at
    http://help.sap.com/saphelp_nw04/helpdata/en/26/64f623fa8911d386e70000e82011b8/content.htm
    I hope it helps.
    Best Regards,
    Vibha

  • How many includes will create when we are activating a function group...

    hi all.
      And one more thing if i see in 4.7 there are three includes r there generated by function group starts with 'L'.....If i created in ECC Same function group and module only two includes are there.....
    missing includes are, what ever we write in tat form sub routine is missing in ECC.....
    can any one help me out in this..

    Hi
    I have created the Function Group in ECC 6.0 and the Following Includes are generated for the same.
      System-defined Include-files.                                 *
      include lzfunctiontop.                     " Global Data
      include lzfunctionuxx.                     " Function Modules
      User-defined Include-files (if necessary).                    *
    INCLUDE LZFUNCTIONF...                     " Subprograms
    INCLUDE LZFUNCTIONO...                     " PBO-Modules
    INCLUDE LZFUNCTIONI...                     " PAI-Modules
    What is your problem exactly? IF you want to write any subroutine jus uncomment the necessary includes and write your code inside it.
    Cheers,
    Hakim

Maybe you are looking for

  • Problem with Equali

    Hey i have an audigy 2 platinum. i use the equalizer program to make my sound better. i notice that it does not function with a lot of games. i dont have a big problem with that, however, when exiting games (main ones i have noticed that cause proble

  • Step Type not updating properly with LabVIEW

    I have a custom steptype that reads the information from the step properties.  I also want this VI to be used as a stand alone.  So I read the sequence context handle to determine if I am running in TS or standalone.  This works fine.  Because it is

  • Accessing loader's content using XML

    Hi, I've loaded an image into a loader from an XML file. Now I need to access that image to change it's X position. How do I go about doing this? I have used the debug to list all my objects, but my image is going to change whenever it loads a new on

  • Data uload to ODS ending up with an error. URGENT HELP NEEDED!!!!!!

    Hi My Sceniro is Full load from ODS1 to 5 other ODS. Iam uploading the data to other 5 ODS by selecting 1 ODS at a time. Problem i am facing is upload is ending up with error mesg. Error Mesg are <b>Error 8 when starting the extraction program - R301

  • HT201412 my wifi switched itself off and i cant get it to switch back on. Any suggestions?

    my wifi switched itself off and i cant get it to switch back on. Any suggestions?