Local class and function group

I want to write a local class in a function group, where is the best place I put the code? thanks!

The best practice (according to a paper written by Horst Keller and Andreas Blumenthal - "An insider's guide...") is to put the DEFINITION in the TOP include and the IMPLEMENTATION part in a separate include such as LZ...C01.
Get the paper here: https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/c2992ca9-0e01-0010-adb1-b7629adb623c
Regards
Edited by: Alejandro Bindi on Apr 25, 2009 12:46 AM

Similar Messages

  • Define local classes in function groups

    Hi,
    I have seen in few code examples that programmers defined their classes as follows:
    1. Interfaces are defined globally i.e. under package->class library->interfaces.
    2. implementing classes are defined locally under: package->function group (as public local class in the function group).
    My question is What is the advantage/disadvantage of it?
    (beside encapsulation).
    I heard that the class loader is working better in that way, is that right?
    thanks,
    Yaron

    Hi
    excuse me I miserunderstood.
    Perhaps it's true I don't know.
    I think the different is the SE24 is a library, so it's the tool arranged to analyze all class components you can need.
    I don't think it's easier to analyze an include (function group) where the class is defined and implemented.
    You shuold measure the time in order to load the class for both case, but probably the different isn't meaningful.
    You should consider that ABAP wasn't OO language, but it was adapted for OO, and so the most ABAP developer weren't used to use OO.
    I think you should define a class as local class if it's your own class.
    Max
    Message was edited by: max bianchi

  • Creation and Change Date for Tcode and Function Groups

    Hello All,
    I need to display the Creation and Change Dates for Custom Tcodes and Function Groups in a Report. Can anyone please let me know the logic of retrieving it.
    regards,
    Mahesh

    Hi,
    TADIR and TRDIR is the tables where you can find all these data
    Regards
    Sudheer

  • What is meant by Local Class and how we can create local classes in abap?

    Hi Friends
    what is meant by Local Class and how we can create local classes in abap?
    Regards,
    Sree

    Hi
    Local classes are the classes which we declare and use using the SE38 ABAP editor
    Global classes are the classes which we find in SE24 and call the methods of them into our program.
    see the sample code
    REPORT zs_class.
    SELECTION SCREEN
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
    PARAMETERS:p_var TYPE i,
    p_var1 TYPE i.
    SELECTION-SCREEN END OF BLOCK b1.
    CLASS d_class DEFINITION
    CLASS d_class DEFINITION.
    PUBLIC SECTION.
    METHODS:
    add,
    sub.
    PROTECTED SECTION.
    DATA : var2 TYPE i.
    ENDCLASS. "d_class DEFINITION
    CLASS d_class IMPLEMENTATION
    CLASS d_class IMPLEMENTATION.
    METHOD add.
    var2 = p_var + p_var1.
    WRITE:/ var2.
    ENDMETHOD. "add
    METHOD sub.
    var2 = p_var - p_var1.
    WRITE:/ var2.
    ENDMETHOD. "sub
    ENDCLASS. "d_class IMPLEMENTATION
    START-OF-SELECTION
    START-OF-SELECTION.
    DATA: obj TYPE REF TO d_class.
    CREATE OBJECT: obj .
    CALL METHOD: obj->add,
    Regards
    Anji

  • 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

  • Automatic generation of ABAP-classes from Function Groups?

    Hey there,
    is there a way of having (SE24)-ABAP-Classes generatetd outomaticaly by providing an existing function group?
    I think, the following mapping shold be possible::
    - the function group is the class
    - its function modules are public (static) methods
    - any form-routines are private methods
    -> I don't want to to that boring work myself, some tool should be able to do that just fine, right? So, is there such a tool?
    Thanks, regards
    Joachim

    Sorry, sounds like the only two people who answered are not aware of such a tool...
    There is one additional point, which I hadn't thought about initially. With ABAP OO you also have a much stricter syntax and many more statement variants that are obsolete and thus cannot be used. This is another hindrance for writing such a tool (but of course not impossible, I just kind of doubt that any reasonable programmer would write such a thing).
    Anyhow, I never understood why SAP is pushing OO so much (declaring all non-OO as obsolete), even going as far as implementing stricter syntax checks for OO. In my opinion a much better option would've been to implement some flag that switches on the more strict syntax checks, similarly to the Unicode check they've introduced. Coding in OO or non-OO, both have its use. Rules from SAP to code everything in OO even in cases where OO doesn't work seems straight silly as a general recommendation: E.g. if I have to code an RFC module, why would I want to bloat my code by introducing a class for implementing the functionality so that the RFC is just a wrapper around the class (unless the additional class gives me some real benefit)?
    As much as I appreciate using OO classes supplied by SAP, I often have difficulties seeing objects in the requirements that I have to code (which might of course just be a reflection of my programming skills). A class with just some static methods is often an indication of poor OO design, i.e. there is no reasonable/tangible object and all you have is a utility class with a collection of various methods. To me it's important that the code is well structured, doesn't have any side effects, etc. This can be achieved with non-OO coding as well as OO, but switching from non-OO to OO doesn't guarantee at all that the code is any better.
    In the end, if you just have a single function group, I'd recommend to do the translation manually and try to apply good OO design principles (instead of a straightforward 1-to-1 translation). E.g. for a class with just static methods (which I'd expect an automated translation would result in) one might want to take a peek at [singletons are evil|http://www.c2.com/cgi/wiki?SingletonsAreEvil] versus [singletons are good|http://www.c2.com/cgi/wiki?SingletonsAreGood]. I know it's silly advice if you're a seasoned OO programmer; but if not, I think your time is much better spent by thinking about the design and then applying it instead of using some automated tools where you'd later have to anyhow do some refactoring...

  • Class and release group and code in release strategy??

    hi experts ,
    Can some body explain me..
    I have created Characteristics and Class for for release strategy.
    But while creating release group , i should assign my class with release group , after doing this when i save , its giving error as check the release classes????
    I m using the same class what i have created for my company..
    So how to over come this issue
    Thanks

    Release Prerequisites
    Definition
    The release prerequisites indicate the sequence in which a purchase requisition or an external purchasing document must be approved via the release codes. The release prerequisites are defined in the Purchasing Customizing facility (in the release strategy).
    The approval procedure for purchase requisitions in an enterprise may be set up in such a way that a department manager must approve a requisition item before the next level of authority (e.g. the cost center manager). In this case, approval by the department manager is a prerequisite for approval by the cost center manager.
    Release Indicator
    Definition
    When a requisition or an external purchasing document has been processed via a release code, a release indicator is assigned to it.
    When the system sets which release indicator is defined in the Customizing facility for Purchasing (in the release strategy via the release statuses).
    What does the release indicator determine?
    Requisitions...
    External purchasing documents....
    Whether the item may be changed by Purchasing or Materials Planning and Control after the start of the release procedure
    Whether a new strategy is determined and whether existing releases must be cancelled in the event of changes
    Whether an RFQ or a PO may be created with reference to the item
    Whether the document may be changed by Purchasing after the start of the release procedure
    Whether a new strategy is determined and whether existing releases must be cancelled in the event of changes
    Whether the purchasing document is released for transmission
    Alternative Release
    Definition
    Within the release sequence, you can define alternatives. This means that several employees can effect release (signify approval) at a certain point in the sequence. If just one of these employees has effected release, the next release status is reached. The other employees thus need take no action.
    Five release codes are defined for purchase requisitions in an ascending hierarchy. The requisition item can be converted into either an RFQ or a PO if release has been effected either with the release codes 01, 02, 03 and 04 or - alternatively - with release code 05.
    The box with the information on the release strategy also offers you the possible alternatives for selection (see Displaying Release Information).
    An alternative release cannot be a prerequisite for the next release code. In the above example, the releases with codes 01, 02, 03 and 04 could not be prerequisites for release with 05.
    Release w. Classification (PReqs./Ext. Pur. Docs.)
    Use
    The aim of this procedure is to replace manual written authorization procedures using signatures by an electronic one, while maintaining the dual control principle.
    The person responsible processes the requisition or other purchasing document in the system, thereby marking it with an "electronic signature" which can give the document legal force.
    This release procedure can be used to approve requisitions and the external purchasing documents RFQ, PO, contract, scheduling agreement, and service entry sheet.
    Purchase requisitions are released either at item level or in total. There is no provision for item-wise release (i.e. partial approval) in the case of the external purchasing documents. The latter can only be released in their entirety.
    If you set up the release procedure with classification for purchase requisitions, the procedure without classification is deactivated.
    Prerequisites
    The release procedure with classification must have been set up in Customizing for Purchasing. In addition, a class with characteristics must have been created for each document (requisition, purchase order, etc.).
    If you wish to set up both the overall release procedure and the item-wise procedure for requisitions, you must create one class for each procedure.
    How to do this is outlined in the Implementation Guide (IMG) for Purchasing in Define Release Procedure for the relevant documents and in Set Up Release Procedure with Classification for purchase requisitions. You will find detailed information on classification in the R/3 Library in the documentation CA Characteristics and CA The Classification System.
    This procedure offers a wide range of possible combinations of release criteria. Should you nevertheless have other requirements, use the enhancement provided by SAP.
    Operation of Release Procedure w. Classification
    The characteristic values from a requisition or external purchasing document are passed on to the classification system.
    The system checks whether the values correspond with release conditions. If so, it assigns a release strategy.
    The persons responsible for the release codes process the document in the sequence defined in the release strategy.

  • UWL and function group swk1

    Hi,
    I have configured my UWL but could not see any work items in the Portal. Checked the user's RFC authorization to fuction group SWK1 via fuction module AUTHORITY_CHECK_RFC, and found that he didn't have that. How do I give a user RFC authorization to function group SWK1?
    Any help is much appreciated. Thank you.
    Best Regards,
    Hapizorr Rozi Alias

    Hello,
          You have to manually add the authorization object S_RFC from tocde: PFCG -> Edit the role you want -> Authorization tab -> Change authorization data -> From the menu: Edit -> Insert authorization -> Manual input -> Add the auth object S_RFC here -> Now you will see the object and make the required entries
    Your SAP security admin should be easily able to assist you with this issue.
    Best Regards,
    Phani - SAP Basis Expert.

  • Table name in which function module and function group store

    Hai,
    Any one help me, What is the table name, the function modules and fouction groups are stored.
    Thanks,
    Elamaran

    ...and table enlfdir has additional info.... function module RS_GET_ALL_INCLUDES is useful for getting a list of includes used by an fm.
    Message was edited by: Neil Woodruff

  • Port, Message type and Function Group

    Hai,
      Iam working on an inbound process for four different Partners.
    Is there any need of Port for Inbound?
    Shall i use the same message type and Idoc type?
    And what about the function Group?
    Thanks
    Avi

    Hello,
    <b> If the functionality is same , you can use the same function Group.
    If functionality is different , you want to use different Function Group.
    Obvisouly, it is suggested to use different Message types .
    If you are using same fields ,you can use the same idoc type.
    depends on the scenior , the process code is needed. Generally no need.</b>
    Thanks
    Manju

  • Reg. table maintenance generator and function group

    I am trying to create a table maintenance for a custom table. It is asking for a function group. Should I create a new function group for each table maintenance I generate?
    Thanks in advance for your input.

    Hi Krishen,
    You can also assign authorization groups to tables to avoid users accessing tables using general access tools (such as transaction SE16). A user requires not only authorization to execute the tool, but must also have authorization to be permitted to access tables with the relevant group assignments. For this case, we deliver tables with predefined assignments to authorization groups. The assignments are defined in table TDDAT; the checked authorization object is S_TABU_DIS.
    You can assign a table to authorization group Z000. (Use transaction SM30 for table TDDAT) A user that wants to access this table must have authorization object S_TABU_DIS in his or her profile with the value Z000 in the field DICBERCLS (authorization group for ABAP Dictionary objects).
    Please check this link for more info.
    http://help.sap.com/saphelp_nw04s/helpdata/en/52/67129f439b11d1896f0000e8322d00/content.htm
    Regards,
    Ferry Lianto

  • Local class and switch statement -- compiler bug?

    Does anybody know why the following does not compile with "LocalClass cannot be resolved to a type" error in the case 1: block
    public class ProblemClass {
         public void localClassProblem() {
                   class LocalClass {
                        void doNothing() {};          
                   int i = 0; 
                   switch (i) {                    
                        case 1: {
                             LocalClass instance1 = new LocalClass();  //ERROR: unresolved type
                                            break;
    }while the following does (I only added case 2: where LocalClass type is not referenced within an embedded block)
    public class ProblemClass {
         public void localClassProblem() {
                   class LocalClass {
                        void doNothing() {};          
                   int i = 0; 
                   switch (i) {                    
                        case 1: {
                             LocalClass instance1 = new LocalClass();
                                            break;
                        case 2:
                             LocalClass instance2 = new LocalClass();
    }Is it a compiler bug? Thanks for clarifying this.
    --Michal                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    I'm using 1.5.0-b64
    --Michal                                                                                                                                                                                                                                   

  • 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

  • Construction and Function Class

    Hi All,
    I will be using concept of Construction class and Function class for my device category. Acc to the two classes i will be getting certain number of device categories How will I map my register groups for them?

    Hi Madhu,
    Construction Class, Function Class and register group are all part of device category master data. So, you can create device categories based on atleast three parameters. However, while you are creating devices you have an option to change register group. So, technically register group can be considered as template value which gets copied to device from device category.
    If you want to know the table in which all three values are available, then they are available in table ETYP. 
    Let us know if you had any other question.
    Regards,
    Avinash

  • Problem with local class, static private attribute and public method

    Hello SDN,
    Consider the following situation:
    1) I have defined a LOCAL class airplane.
    2) This class has a private static attribute "type table of ref to" airplane (array of airplanes)
    3) A public method should return the private static table attribute
    Problems:
    a) The table cannot be given as an EXPORTING parameter in the method because TYPE TABLE OF... is not supported and I get syntax errors. I also cannot define a dictionary table type because it is a local class.
    b) The table cannot be given as a TABLES parameter in the method because TABLES is not supported in the OO context.
    c) The table cannot be given as an EXPORTING parameter in the method defined as LIKE myStaticAttribute because my method is PUBLIC and my attribute is PRIVATE. ABAP syntax requires that all PUBLIC statements are defined before PRIVATE ones, therefore it cannot find the attribute to reference to with LIKE.
    I see only 2 solutions:
    a) Never ever use local classes and always use global classes so that I might define a dictionary table type of my class which I can then use in my class.
    b) Make the attribute public, but this goes against OO principles, and isn't really an option.
    Am I missing anything here, or is this simply overlooked so far?

    Hello Niels
    Since your class is local and, thus, only know to the "surrounding" application is does not really make sense to make it public to any other application.
    However, if you require to store instances of your local classes in internal tables simply use the most generic reference type possible, i.e. <b>OBJECT</b>.
    The following sample report shows how to do that. Furthermore, I believe it also shows that there are <u><b>no </b></u>serious inconsistency in the ABAP language.
    *& Report  ZUS_SDN_LOCAL_CLASS
    REPORT  zus_sdn_local_class.
    " NOTE: SWF_UTL_OBJECT_TAB is a table type having reference type OBJECT
    *       CLASS lcl_airplane DEFINITION
    CLASS lcl_airplane DEFINITION.
      PUBLIC SECTION.
        DATA:    md_counter(3)             TYPE n.
        METHODS: constructor,
                 get_instances
                   RETURNING
                     value(rt_instances)   TYPE swf_utl_object_tab.
      PRIVATE SECTION.
        CLASS-DATA: mt_instances    TYPE swf_utl_object_tab.
    ENDCLASS.                    "lcl_airplane DEFINITION
    *       CLASS lcl_airplane IMPLEMENTATION
    CLASS lcl_airplane IMPLEMENTATION.
      METHOD constructor.
        APPEND me TO mt_instances.
        DESCRIBE TABLE mt_instances.
        md_counter = syst-tfill.
      ENDMETHOD.                    "constructor
      METHOD get_instances.
        rt_instances = mt_instances.
      ENDMETHOD.                    "get_instance
    ENDCLASS.                    "lcl_airplane IMPLEMENTATION
    DATA:
      gt_instances      TYPE swf_utl_object_tab,
      go_object         TYPE REF TO object,
      go_airplane       TYPE REF TO lcl_airplane.
    START-OF-SELECTION.
      " Create a few airplane instance
      DO 5 TIMES.
        CREATE OBJECT go_airplane.
      ENDDO.
      gt_instances = go_airplane->get_instances( ).
      CLEAR: go_airplane.
      LOOP AT gt_instances INTO go_object.
        go_airplane ?= go_object.
        WRITE: / 'Airplane =', go_airplane->md_counter.
      ENDLOOP.
    END-OF-SELECTION.
    Regards
      Uwe<u></u>

Maybe you are looking for

  • Is it possible to unlock my iPhone from Sprint?

    I want to switch my carrier from Sprint.

  • Outlook Express 6 is missing calendar app..where do I get it ???????

    I have Windows XP sp2, and my calendar seems to be missing from the Outlook Express 6 app. Where can I download the calendar app from? I checked on the Microsoft website, but did not see what I was looking for. Thanks!

  • Is there a keyboard shortcut to "Pin as App Tab"?

    Sometimes (mainly with a touchpad) moving the mouse cursor to the tab, right-clicking and choosing "Pin as App Tab" is a lot of work compared to just using a keyboard shortcut. Is there a keyboard shortcut to do this?

  • BT Phonebill

    Hello, It seems as though there has been a restriction put on our phone line as well as the BT Broadband Talk Line as well however broadband is still working (And I'd like to keep it working) Supposedly, we have an outstanding balance we have had no

  • WebLogic Server Tools 1.1 Released

    We are happy to announce the 1.1 release of WebLogic Server Tools for Eclipse 3.3. This release contains two major new features as well as 28 bug fixes and enhancements. One of these new features is a direct result of community input. Thanks for help