Skip to Content
author's profile photo Former Member
Former Member

structure of includes

Hi,

in Java developing I am using for everey new class a new file. Is it usual in ABAP to use for every local class a new include? I tried it and get in real problems. I wrote two classes in different includes. Both classes were using each other. I didn't know where to set which include and which class should be defined as deferred.

Can anybody give me a short answer or a link to something that documents it.

Thanks.

Adalbert

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Dec 18, 2008 at 04:16 AM

    Hi Adalbert,

    is it very important for you to use one include for each local class?

    You could define local class inside your program. Please, have a look at

    https://www.sdn.sap.com/irj/scn/profile?editmode=true&userid=3894531

    Regards,

    John

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 18, 2008 at 05:08 AM

    Hello Adalbert

    Perhaps there is a more elegant approach than the one shown below but I did not find another solution.

    The coding of the include is shown after the END-OF-SELECTION statement.

    *&---------------------------------------------------------------------*
    *& Report  ZUS_SDN_INCL_LOCAL_CLASSES
    *&
    *&---------------------------------------------------------------------*
    *&
    *&
    *&---------------------------------------------------------------------*
    
    REPORT  zus_sdn_incl_local_classes.
    
    
    CLASS lcl_myclass_2 DEFINITION DEFERRED.
    CLASS lcl_myclass_1 DEFINITION DEFERRED.
    
    "
    INCLUDE zus_sdn_incl_local_classes_c01. " Definition class 1
    INCLUDE zus_sdn_incl_local_classes_c02. " Definition class 2
    
    INCLUDE zus_sdn_incl_local_classes_c03. " Implementation 1 & 2
    
    
    
    
    START-OF-SELECTION.
    
    
    END-OF-SELECTION.
    
    
    *&---------------------------------------------------------------------*
    *&  Include           ZUS_SDN_INCL_LOCAL_CLASSES_C01
    *&---------------------------------------------------------------------*
    
    CLASS lcl_myclass_1 DEFINITION.
    
      PUBLIC SECTION.
    
        DATA:
          mo_class_2    TYPE REF TO lcl_myclass_2.
    
        METHODS:
          constructor.
    ENDCLASS.                    "lcl_myclass_1 DEFINITION
    
    *&---------------------------------------------------------------------*
    *&  Include           ZUS_SDN_INCL_LOCAL_CLASSES_C02
    *&---------------------------------------------------------------------*
    
    CLASS lcl_myclass_2 DEFINITION.
    
      PUBLIC SECTION.
        DATA:
          mo_class_1    TYPE REF TO lcl_myclass_1.
        METHODS:
          constructor.
    ENDCLASS.                    "lcl_myclass_1 DEFINITION
    
    
    *&---------------------------------------------------------------------*
    *&  Include           ZUS_SDN_INCL_LOCAL_CLASSES_C03
    *&---------------------------------------------------------------------*
    
    
    *----------------------------------------------------------------------*
    *       CLASS lcl_myclass_1 IMPLEMENTATION
    *----------------------------------------------------------------------*
    *
    *----------------------------------------------------------------------*
    CLASS lcl_myclass_1 IMPLEMENTATION.
    
      METHOD constructor.
        CREATE OBJECT me->mo_class_2.
      ENDMETHOD.                    "constructor
    
    ENDCLASS.                    "lcl_myclass_1 IMPLEMENTATION
    
    *----------------------------------------------------------------------*
    *       CLASS lcl_myclass_1 IMPLEMENTATION
    *----------------------------------------------------------------------*
    *
    *----------------------------------------------------------------------*
    CLASS lcl_myclass_2 IMPLEMENTATION.
    
      METHOD constructor.
        CREATE OBJECT me->mo_class_1.
      ENDMETHOD.                    "constructor
    
    ENDCLASS.                    "lcl_myclass_1 IMPLEMENTATION
    

    Regards

    Uwe

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 23, 2008 at 08:32 AM

    Hi,

    thank you both for the answers. I think that if the definition and the implementation of a local class is in one seperate include, then the code will be more readable. That's the reason why I asked it.

    Thanks,

    Adalbert

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.