Converting sample Procedural ABAP code in Object oriented code...

Hello Gurus,
I am learning object oriented ABAP. The best way to learn it is do it practically. If I want to change the following code in OO code , how can it be done ?
TABLES : gb01.
Data Declaration
DATA : BEGIN OF i_mid OCCURS 0,
        mid(2),
        text(10),
       END OF i_mid.
DATA :v_tabix LIKE sy-tabix.
Selection Screen
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME
                                   TITLE text-001.
PARAMETER : p_modif(1) DEFAULT 'U',
            p_class LIKE gb01-boolclass DEFAULT '009',
            p_cltyp LIKE gb01-classtype DEFAULT 'S',
            p_table LIKE gb01-bcltab DEFAULT 'BSEG',
            p_field LIKE gb01-bclfield DEFAULT 'HKONT',
            p_excld LIKE gb01-bexclude DEFAULT ' '.
SELECTION-SCREEN END OF BLOCK b1.
Selection Screen F4 Help for Modif ID's
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_modif.
  PERFORM get_modifid.
Start of Selection
START-OF-SELECTION.
  CLEAR gb01.
  CASE p_modif.
    WHEN 'U'. "Update
      UPDATE gb01
      SET bexclude = p_excld
      WHERE bcltab = p_table
      AND bclfield = p_field
      AND boolclass = p_class
      AND classtype = p_cltyp.
      IF sy-subrc NE 0.
        WRITE : / 'UPDATE - KO'.
      ELSE.
        WRITE : / 'UPDATE - OK'.
      ENDIF.
    WHEN 'I'. "Insert
      gb01-bcltab = p_table.
      gb01-bclfield = p_field.
      gb01-boolclass = p_class.
      gb01-classtype = p_cltyp.
      gb01-bexclude = p_excld.
      INSERT INTO gb01 VALUES gb01.
      IF sy-subrc NE 0.
        WRITE : / 'INSERTION - KO'.
      ELSE.
        WRITE : / 'INSERTION - OK'.
      ENDIF.
    WHEN 'D'. "Delete
      DELETE FROM gb01
      WHERE bcltab = p_table
      AND bclfield = p_field
      AND boolclass = p_class
      AND classtype = p_cltyp.
      IF sy-subrc NE 0.
        WRITE : / 'DELETE - KO'.
      ELSE.
        WRITE : / 'DELETE - OK'.
      ENDIF.
  ENDCASE.
*&      Form  get_modifid
      F4 Help for modif id field
FORM get_modifid.
  i_mid-mid = 'U'.
  i_mid-text = 'Update'.
  APPEND i_mid.
  i_mid-mid = 'I'.
  i_mid-text = 'Insert'.
  APPEND i_mid.
  i_mid-mid = 'D'.
  i_mid-text = 'Delete'.
  APPEND i_mid.
  CALL FUNCTION 'POPUP_WITH_TABLE_DISPLAY'
       EXPORTING
            endpos_col   = '20'
            endpos_row   = '12'
            startpos_col = '10'
            startpos_row = '10'
            titletext    = 'Modification Ids'
       IMPORTING
            choise       = v_tabix
       TABLES
            valuetab     = i_mid
       EXCEPTIONS
            break_off    = 1
            OTHERS       = 2.
  IF sy-subrc NE 0.
    EXIT.
  ENDIF.
  READ TABLE  i_mid INDEX v_tabix.
  IF sy-subrc EQ 0.
    p_modif = i_mid-mid.
  ENDIF.
  REFRESH i_mid.
ENDFORM.                    " get_modifid
Regards,
Rajesh.

Hi Rajesh,
Hey here are some of  the links, please chek these links u have lot of examples
http://www.****************/Tutorials/OOPS/MainPage.htm
and also please check these threads
OOABAP
book for OOABAP?
Best regards,
raam

Similar Messages

  • Mathscript and object oriented code m code

    Hello,
    I have some existing code written in Matlab with object-oriented programming that I would like to use with Mathscript RT nodes in LabVIEW.
    Does NI have any plan to support object-oriented programming in mathscript RT nodes in the future?
    In the mean time, is there any easy solution with minimum changes that would allow me to use my existing code?
    Thanks

    Hey L54,
    Unfortunately, there have not been any public announcements regarding the support of object-oriented code for the MathScript RT nodes. Also, for tips on how to change your code to make it work, there really is no easy way to go about doing this.
    Are you deploying to a RT target? Would it be possible for you to use the MATLAB Script Node? This is included with LabVIEW and actually connects to your MATLAB software and would most likely be able to run the object-oriented code.
    Sorry about not supporting object-oriented code, but hopefully using the MATLAB Script Node help you achieve your desired functionality.
    Joe S
    Applications Engineer
    National Instruments
    MATLAB is a registered trademark of The MathWorks, Inc.

  • Extremely long build times using object oriented code

    We have a LabVIEW application that we need to build an .exe for distrubution purposes.  The application relies on several object-oriented classes for data handling and dynamic dispatch type casting and function selection.  Currently it takes approximately 1.5 hours to build the application and it seems that most of the time is spent processing the object oriented files.  Has anyone else seen this issue and are there any creative ways to improve the build times?

    Hi again.  We are still having issues using LVOOP due to extrmely long .exe build times as well as long labview loading times.  I traced the source of this to one class hierarchy, shown below.  This hierarchy also relies heavily on overriding top-level functions, declared as virtual VIs in the top level class, which I suspect contributes to this problem.  While debugging another issue, I was trying to build a small piece of my main code into an .exe to verify its functionality and experienced the same extremely long build times.  When I removed this class hierarchy from the VI, it built extremely fast.  Also to be clear, I am using neither the mean function or Mean.vi anywhere in this set of code.  To date we have been delighted with LVOOP and how it has made our code cleaner, mroe robust, and more maintanable.  However, when creating new functionality in the code we often elect NOT to create new objects (even though they would be beneficial) because we are hesitant to introduce the extra time (load and build) required for LabVIEW to handle these classes.  If our entire system was rewritten in LVOOP, I would suspect that it would become unmaintainable and unbuildable due to the LVOOP overhead.  I was hoping that LV2009 would address some of these issues but, alas, it did not. Still looking for a way to improve this and thanks in advance for all of the replies.

  • Procedural ABAP refactoring or mass source code replacement

    I am trying to change hard coded values from multiple source codes with respective constant names. Is there a tool to find and replace them according to a rules table. I wouldn't mind even if this tool was not in SAP (eg. Eclipse).
    Thank you in advance,
    Michalis.

    Dear Thomas,
    thank you for your prompt response.
    My idea was (and is) that since the ABAP compiler is embedded in Netweaver, it would be smart to get the compiler functionality together with regular expressions declaration in order to do what unix like systems do for years, replace strings with other strings. The program you suggest is well known for finding literals (substrings) in source, but when it does you never know what is the role of the literal on the source code line (in the particular code statement).
    Of course I agree with you regarding the term refactoring, that a human eye is needed, if I was to do real source code pattern recognition and replacement, but my driving need is more simple and way far from that (at least for now).
    Please keep me posted in case you have any news on the subject.

  • Abap based on object oriented program

    hi all,
    I am knew in OOPS as i want to make a autority object that is globally used in several reports in our several company
    can u provide me such kind of authority object which uses check on
    user name sales organization sales division sales group
    thanks
    babbal

    this is solve...

  • Does access scope change the way Object oriented code compiles or executes

    I have started using Acess Scope (Private/Public/Protected/Friend) in my code and I am wondering if ti changes the way the software is compiled and executed.
    I am suffering a 6 minute pre-load startup time and am scrambling to find aything that helps.
    Tim L.
    iTm - Senior Systems Engineer
    uses: LABVIEW 2012 SP1 x86 on Windows 7 x64. cFP, cRIO, PXI-RT

    Hi Timmar,
    I don’t think that the Access Scope is the cause of this long pre-load time. However, you can try to set to public in order to see if that makes any change.
    I think this long pre-load time could be related to how many files (VIs and dependencies) are included in your project. Also, if you move the Project folder to a different location (or computer) the next time that you try to open the project it will take a little while to open.
    Regards,
    Richard.

  • Learning tips for Object Oriented ABAP

    Hi Gurus,
    I am in ABAP for last 1 year,
    I want to learn Object oriented ABAP can you please guide me where to start.
    Some learning material etc.
    Regards
    Bikas

    Normal ABAP is process oriented, where is OOP-ABAP is a new methodology in ABAP which uses object oriented programming.
    we have C++, java, C#, etc as OOP languages.
    ABAP has also implemented the OOP technology.
    it uses classes, methods and interfaces instead of functiongroups and function modules.
    As part of SAP’s long-standing commitment to object technology, Release 4.0
    of R/3 will contain object-oriented enhancements to the ABAP programming
    language. SAP’s object strategy is based on SAP Business Objects and now
    covers modeling, programming, interfacing, and workflow. By using principles
    like encapsulation, inheritance, and polymorphism, the object-oriented
    extensions of ABAP will support real object-oriented development. This will
    result in improvements in the areas of reusability, maintenance, and quality of
    code. SAP offers an evolutionary approach toward objects which leverages
    SAP’s own and its customers’ investments in existing business processes,
    functionality and data.
    OO ABAP
    http://www.sapgenie.com/abap/OO/eg.htm
    http://www.sapgenie.com/abap/OO/syntax.htm
    http://www.sapgenie.com/abap/OO/index.htm
    http://www.sapgenie.com/abap/OO/defn.htm
    Detailed
    OOPS – OO ABAP
    http://esnips.com/doc/5c65b0dd-eddf-4512-8e32-ecd26735f0f2/prefinalppt.ppt
    http://esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
    http://esnips.com/doc/0ef39d4b-586a-4637-abbb-e4f69d2d9307/SAP-CONTROLS-WORKSHOP.pdf
    http://esnips.com/doc/92be4457-1b6e-4061-92e5-8e4b3a6e3239/Object-Oriented-ABAP.ppt
    http://esnips.com/doc/448e8302-68b1-4046-9fef-8fa8808caee0/abap-objects-by-helen.pdf
    http://esnips.com/doc/39fdc647-1aed-4b40-a476-4d3042b6ec28/class_builder.ppt
    http://www.amazon.com/gp/explorer/0201750805/2/ref=pd_lpo_ase/102-9378020-8749710?ie=UTF8
    http://help.sap.com/saphelp_nw04/helpdata/en/c3/225b5654f411d194a60000e8353423/content.htm
    http://help.sap.com/saphelp_nw2004s/helpdata/en/c3/225b5654f411d194a60000e8353423/content.htm
    REward points if useful.

  • Differences between Procedural ABAP & OOPs ABAP

    Hi Friends,
    Can any one explain the differences between Procedural ABAP and OOPs ABAP in brief ? pls explain the most important ( atleast 3 or 4 points ). pls don't give me any other links,  i will appreciate for good responses... and will be awarded with full points...
    Thanks and Regards
    Vijaya

    Let me add some comments about the difference in design between Procedural Programming and OOP.  If you are used to writing procedural/imperative code, then it will take a while to adjust to object oriented code, because the design is quite different.  These are a few points that may take some time to get used to.
    I.  In procedural code, you normally think about functionality first and pass the data around to several procedures to be manipulated until eventually you get our result, whatever that may be.  In OOP, you think about data first, and attach functionality to the data to which it applies.  In this way, you create a virtual object with its own properties and actions that can be performed on it or by it.
    II.  Objects should always have a consistent and valid interface.  What I mean by this is that public attributes and methods should accurately reflect the state of the data at all times.  It should not be possible for code that uses an object to call the methods in the wrong order and get invalid results.  Each method call should update all data necessary to keep the data that is visible to the user of the object in a valid state.  The idea of getter and setter methods is very useful here.  If calling code does something that does not make sense, you can always throw an exception, however, when it is possible, you should design the class such that calling code does not even have a chance to misuse it.
    III.  OOP trades efficiency of execution for efficiency of development.  In the past, computers were more expensive than programmers, so it was worth taking a great deal of time to make code as efficient as possible.  This is no longer the case.  Due to the rapid drop in hardware costs, the precious resource that needs to be conserved is development time.  OOP organizes code in a way that is less efficient, but provides a level of modularity that decreases the cost of development/maintenance.  Therefore, the focus of the programmer should be on good design first, even if it means compromising efficiency.  There are still ways to make OOP efficient, but it will never be as efficient as Procedural.
    I hope this is helpful to someone.

  • Object orientated, serious help needed

    Hi all Im very new to java and I would like to know how I could be this object orientated code into java;
    Room
    -length: int
    -width: int
    +Room( aLength: int, aWidth:
    +getLength(): int
    +getWidth(): int
    +getArea(): int
    Thx, I know its proably simple But I have be struggling to get this code to run, thanks in advance

    I know its UML im having trouble turning this UML into java,
    If I do
    public class Room
    private int length;
    private int width;
    then length and width are underlined. Yup your IDE concluded that those private member variables aren't
    used, not set anywhere in that class, that's what those warning/error
    lines are all about.
    Can I carry on even though they are underlined.And also if someone
    could show how I would put;
    +Room( aLength: int, aWidth: int)
    into java and should be ok from here, thx in advanceThe transformation is almost mechanical:public class Room {
       private int length;
       private int width;
       public Room(int aLength, int aWidth) {
          length= aLength;
          width = aWidth;
    }kind regards,
    Jos

  • Abap object oriented

    Hi experts.,
    i am very new in  abap oo . please give me documentation and if possible sample   code.
    thanks in advance,

    Some documentation related with OOPs Abao :
    oops_beginers
    http://help.sap.com/saphelp_nw04/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm
    ALV Gird Control (BC-SRV-ALE)
    SAP Container
    SAP Control Framework
    or Thread New To OOPs ABAP
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/abap/abap%20code%20samples/abap%20objects/abap%20code%20sample%20to%20learn%20basic%20concept%20of%20object-oriented%20programming.doc
    General Tutorial for OOPS
    check all the below links
    http://www.sapgenie.com/abap/OO/index.htm
    http://www.geocities.com/victorav15/sapr3/abap_ood.html
    http://www.brabandt.de/html/abap_oo.html
    Check this cool weblog:
    /people/thomas.jung3/blog/2004/12/08/abap-persistent-classes-coding-without-sql
    /people/thomas.jung3/blog/2004/12/08/abap-persistent-classes-coding-without-sql
    http://help.sap.com/saphelp_nw04/helpdata/en/c3/225b6254f411d194a60000e8353423/frameset.htm
    http://www.sapgenie.com/abap/OO/
    http://www.sapgenie.com/abap/OO/index.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/c3/225b5654f411d194a60000e8353423/content.htm
    http://www.esnips.com/doc/375fff1b-5a62-444d-8ec1-55508c308b17/prefinalppt.ppt
    http://www.esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
    http://www.esnips.com/doc/5c65b0dd-eddf-4512-8e32-ecd26735f0f2/prefinalppt.ppt
    http://www.allsaplinks.com/
    http://www.sap-img.com/
    http://www.sapgenie.com/
    http://help.sap.com
    http://www.sapgenie.com/abap/OO/
    http://www.sapgenie.com/abap/OO/index.htm
    http://www.sapgenie.com/abap/controls/index.htm
    http://www.esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
    http://www.esnips.com/doc/0ef39d4b-586a-4637-abbb-e4f69d2d9307/SAP-CONTROLS-WORKSHOP.pdf
    http://www.sapgenie.com/abap/OO/index.htm
    http://help.sap.com/saphelp_erp2005/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm
    http://www.sapgenie.com/abap/OO/
    these links
    http://help.sap.com/saphelp_47x200/helpdata/en/ce/b518b6513611d194a50000e8353423/content.htm
    For funtion module to class
    http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b5954f411d194a60000e8353423/content.htm
    for classes
    http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b5c54f411d194a60000e8353423/content.htm
    for methods
    http://help.sap.com/saphelp_47x200/helpdata/en/08/d27c03b81011d194f60000e8353423/content.htm
    for inheritance
    http://help.sap.com/saphelp_47x200/helpdata/en/dd/4049c40f4611d3b9380000e8353423/content.htm
    for interfaces
    http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b6254f411d194a60000e8353423/content.htm
    Check these links.
    http://www.henrikfrank.dk/abapuk.html
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/abap/abap%20code%20samples/abap%20objects/abap%20code%20sample%20to%20learn%20basic%20concept%20of%20object-oriented%20programming.doc
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/abap/abap%20code%20samples/alv%20grid/abap%20code%20sample%20to%20display%20data%20in%20alv%20grid%20using%20object%20oriented%20programming.doc
    Go through the below links,
    For Materials:
    1) http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCABA/BCABA.pdf -- Page no: 1291
    2) http://esnips.com/doc/5c65b0dd-eddf-4512-8e32-ecd26735f0f2/prefinalppt.ppt
    3) http://esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
    4) http://esnips.com/doc/0ef39d4b-586a-4637-abbb-e4f69d2d9307/SAP-CONTROLS-WORKSHOP.pdf
    5) http://esnips.com/doc/92be4457-1b6e-4061-92e5-8e4b3a6e3239/Object-Oriented-ABAP.ppt
    6) http://esnips.com/doc/448e8302-68b1-4046-9fef-8fa8808caee0/abap-objects-by-helen.pdf
    7) http://esnips.com/doc/39fdc647-1aed-4b40-a476-4d3042b6ec28/class_builder.ppt
    8) http://www.amazon.com/gp/explorer/0201750805/2/ref=pd_lpo_ase/102-9378020-8749710?ie=UTF8
    OO ABAP links:
    1) http://www.erpgenie.com/sap/abap/OO/index.htm
    2) http://help.sap.com/saphelp_nw04/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm
    go through these links
    http://www.erpgenie.com/abap/index.htm
    http://sic.fh-lu.de/sic/bic.nsf/(vJobangebote)/EC8AD2AE0349CE92C12572200026FDB8/$File/Intern%20or%20Working%20Student%20as%20ABAB%20OO%20Developer.pdf?Open
    http://help.sap.com/saphelp_nw2004s/helpdata/en/43/41341147041806e10000000a1553f6/frameset.htm
    http://help.sap.com/saphelp_47x200/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm
    ABAP_OBJECTS_ENJOY_0 Template for Solutions of ABAP Object Enjoy Course
    ABAP_OBJECTS_ENJOY_1 Model Solution 1: ABAP Objects Enjoy Course
    ABAP_OBJECTS_ENJOY_2 Model Solution 2: ABAP Objects Enjoy Course
    ABAP_OBJECTS_ENJOY_3 Model Solution 3: ABAP Objects Enjoy Course
    ABAP_OBJECTS_ENJOY_4 Model Solution 4: ABAP Objects Enjoy Course
    ABAP_OBJECTS_ENJOY_5 Model Solution 5: ABAP Objects Enjoy Course
    DEMO_ABAP_OBJECTS Complete Demonstration for ABAP Objects
    DEMO_ABAP_OBJECTS_CONTROLS GUI Controls on Screen
    DEMO_ABAP_OBJECTS_EVENTS Demonstration of Events in ABAP Objects
    DEMO_ABAP_OBJECTS_GENERAL ABAP Objects Demonstration
    DEMO_ABAP_OBJECTS_INTERFACES Demonstration of Interfaces in ABAP Objects
    DEMO_ABAP_OBJECTS_METHODS Demonstration of Methods in ABAP Objects
    DEMO_ABAP_OBJECTS_SPLIT_SCREEN Splitter Control on Screen
    check the below links lot of info and examples r there
    http://www.sapgenie.com/abap/OO/index.htm
    http://www.geocities.com/victorav15/sapr3/abap_ood.html
    http://www.brabandt.de/html/abap_oo.html
    Check this cool weblog:
    /people/thomas.jung3/blog/2004/12/08/abap-persistent-classes-coding-without-sql
    /people/thomas.jung3/blog/2004/12/08/abap-persistent-classes-coding-without-sql
    http://help.sap.com/saphelp_nw04/helpdata/en/c3/225b6254f411d194a60000e8353423/frameset.htm
    http://www.sapgenie.com/abap/OO/
    http://www.sapgenie.com/abap/OO/index.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/c3/225b5654f411d194a60000e8353423/content.htm
    http://www.esnips.com/doc/375fff1b-5a62-444d-8ec1-55508c308b17/prefinalppt.ppt
    http://www.esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
    http://www.esnips.com/doc/5c65b0dd-eddf-4512-8e32-ecd26735f0f2/prefinalppt.ppt
    http://www.allsaplinks.com/
    http://www.sap-img.com/
    http://www.sapgenie.com/
    http://help.sap.com
    http://www.sapgenie.com/abap/OO/
    http://www.sapgenie.com/abap/OO/index.htm
    http://www.sapgenie.com/abap/controls/index.htm
    http://www.esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
    http://www.esnips.com/doc/0ef39d4b-586a-4637-abbb-e4f69d2d9307/SAP-CONTROLS-WORKSHOP.pdf
    http://www.sapgenie.com/abap/OO/index.htm
    http://help.sap.com/saphelp_erp2005/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm
    http://www.sapgenie.com/abap/OO/
    these links
    http://help.sap.com/saphelp_47x200/helpdata/en/ce/b518b6513611d194a50000e8353423/content.htm
    For funtion module to class
    http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b5954f411d194a60000e8353423/content.htm
    for classes
    http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b5c54f411d194a60000e8353423/content.htm
    for methods
    http://help.sap.com/saphelp_47x200/helpdata/en/08/d27c03b81011d194f60000e8353423/content.htm
    for inheritance
    http://help.sap.com/saphelp_47x200/helpdata/en/dd/4049c40f4611d3b9380000e8353423/content.htm
    for interfaces
    http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b6254f411d194a60000e8353423/content.htm
    For Materials:
    1) http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCABA/BCABA.pdf -- Page no: 1291
    2) http://esnips.com/doc/5c65b0dd-eddf-4512-8e32-ecd26735f0f2/prefinalppt.ppt
    3) http://esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
    4) http://esnips.com/doc/0ef39d4b-586a-4637-abbb-e4f69d2d9307/SAP-CONTROLS-WORKSHOP.pdf
    5) http://esnips.com/doc/92be4457-1b6e-4061-92e5-8e4b3a6e3239/Object-Oriented-ABAP.ppt
    6) http://esnips.com/doc/448e8302-68b1-4046-9fef-8fa8808caee0/abap-objects-by-helen.pdf
    7) http://esnips.com/doc/39fdc647-1aed-4b40-a476-4d3042b6ec28/class_builder.ppt
    8) http://www.amazon.com/gp/explorer/0201750805/2/ref=pd_lpo_ase/102-9378020-8749710?ie=UTF8
    1) http://www.erpgenie.com/sap/abap/OO/index.htm
    2) http://help.sap.com/saphelp_nw04/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm
    ALVOOPS
    http://www.abap4.it/download/ALV.pdf
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a415907
    http://www.erpgenie.com/abap/controls/alvgrid.htm
    OOPS with ABAP
    https://www.sdn.sap.com/irj/sdn/wiki?path=/pages/viewpage.action&pageid=37566
    /people/rich.heilman2/blog/2005/07/27/dynamic-internal-tables-and-structures--abap
    http://www.sapgenie.com/abap/OO/
    For understanding COntrol Frameworks in OO ABAP, check this.
    http://www.sapgenie.com/abap/controls/index.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/ce/b518b6513611d194a50000e8353423/content.htm
    http://www.sapgenie.com/abap/OO/
    http://www.sapgenie.com/abap/OO/index.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/c3/225b5654f411d194a60000e8353423/content.htm
    http://www.esnips.com/doc/375fff1b-5a62-444d-8ec1-55508c308b17/prefinalppt.ppt
    http://www.esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
    http://www.esnips.com/doc/5c65b0dd-eddf-4512-8e32-ecd26735f0f2/prefinalppt.ppt
    http://www.allsaplinks.com/
    http://www.sap-img.com/
    http://www.sapgenie.com/
    http://help.sap.com
    http://www.sapgenie.com/abap/OO/
    http://www.sapgenie.com.
    http://www.sapgenie.com/abap/OO/index.htm
    http://www.sapgenie.com/abap/controls/index.htm
    http://www.esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
    http://www.esnips.com/doc/0ef39d4b-586a-4637-abbb-e4f69d2d9307/SAP-CONTROLS-WORKSHOP.pdf
    http://www.sapgenie.com/abap/OO/index.htm
    http://help.sap.com/saphelp_erp2005/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm
    http://www.sapgenie.com/abap/OO/
    http://www.sapgenie.com/abap/OO/index.htm
    http://www.geocities.com/victorav15/sapr3/abap_ood.html
    http://www.brabandt.de/html/abap_oo.html
    ALVOOPS
    http://www.erpgenie.com/abap/controls/alvgrid.htm
    OOPS with ABAP
    https://www.sdn.sap.com/irj/sdn/wiki?path=/pages/viewpage.action&pageid=37566
    /people/rich.heilman2/blog/2005/07/27/dynamic-internal-tables-and-structures--abap
    http://www.sapgenie.com/abap/OO/
    For understanding COntrol Frameworks in OO ABAP, check this.
    http://www.sapgenie.com/abap/controls/index.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/ce/b518b6513611d194a50000e8353423/content.htm
    http://www.sapgenie.com/abap/OO/
    http://www.sapgenie.com/abap/OO/index.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/c3/225b5654f411d194a60000e8353423/content.htm
    http://www.esnips.com/doc/375fff1b-5a62-444d-8ec1-55508c308b17/prefinalppt.ppt
    http://www.esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
    http://www.esnips.com/doc/5c65b0dd-eddf-4512-8e32-ecd26735f0f2/prefinalppt.ppt
    http://www.allsaplinks.com/
    http://www.sap-img.com/
    http://www.sapgenie.com/
    http://help.sap.com
    http://www.sapgenie.com/abap/OO/
    http://www.sapgenie.com.
    http://www.sapgenie.com/abap/OO/index.htm
    http://www.sapgenie.com/abap/controls/index.htm
    http://www.esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
    http://www.esnips.com/doc/0ef39d4b-586a-4637-abbb-e4f69d2d9307/SAP-CONTROLS-WORKSHOP.pdf
    http://www.sapgenie.com/abap/OO/index.htm
    http://help.sap.com/saphelp_erp2005/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm
    http://www.sapgenie.com/abap/OO/
    http://www.sapgenie.com/abap/OO/index.htm
    http://www.geocities.com/victorav15/sapr3/abap_ood.html
    http://www.brabandt.de/html/abap_oo.html
    Regarding  ALV Grid  Control using OOPs concepts
    Regarding  ALV Grid  Control using OOPs concepts
    OOPS – OO ABAP
    http://esnips.com/doc/5c65b0dd-eddf-4512-8e32-ecd26735f0f2/prefinalppt.ppt
    http://esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
    http://esnips.com/doc/0ef39d4b-586a-4637-abbb-e4f69d2d9307/SAP-CONTROLS-WORKSHOP.pdf
    http://esnips.com/doc/92be4457-1b6e-4061-92e5-8e4b3a6e3239/Object-Oriented-ABAP.ppt
    http://esnips.com/doc/448e8302-68b1-4046-9fef-8fa8808caee0/abap-objects-by-helen.pdf
    http://esnips.com/doc/39fdc647-1aed-4b40-a476-4d3042b6ec28/class_builder.ppt
    http://www.amazon.com/gp/explorer/0201750805/2/ref=pd_lpo_ase/102-9378020-8749710?ie=UTF8
    http://help.sap.com/saphelp_nw04/helpdata/en/c3/225b5654f411d194a60000e8353423/content.htm
    http://help.sap.com/saphelp_nw2004s/helpdata/en/c3/225b5654f411d194a60000e8353423/content.htm
    DIRLL DOWN AND INTERACTIVE REPORT
    http://www.sap-img.com/abap/difference-between-drilldown-report-and-interactive-report.htm
    PAGE BREAK FOR ALV LIST
    check out this link
    http://www.abap4.it/download/ALV.pdf
    good book on ABAP objects(OOPS)
    http://www.esnips.com/doc/bc475662-82d6-4412-9083-28a7e7f1ce09/Abap-Objects---An-Introduction-To-Programming-Sap-Applications
    How to check Cluster Table Data
    https://forums.sdn.sap.com/click.jspa?searchID=5215473&messageID=3520315
    http://www.sap-img.com/abap/the-different-types-of-sap-tables.htm
    http://help.sap.com/saphelp_47x200/helpdata/en/81/415d363640933fe10000009b38f839/frameset.htm
    Check this cool weblog:
    /people/thomas.jung3/blog/2004/12/08/abap-persistent-classes-coding-without-sql
    /people/thomas.jung3/blog/2004/12/08/abap-persistent-classes-coding-without-sql
    http://help.sap.com/saphelp_nw04/helpdata/en/c3/225b6254f411d194a60000e8353423/frameset.htm
    http://www.sapgenie.com/abap/OO/
    http://www.sapgenie.com/abap/OO/index.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/c3/225b5654f411d194a60000e8353423/content.htm
    http://www.esnips.com/doc/375fff1b-5a62-444d-8ec1-55508c308b17/prefinalppt.ppt
    http://www.esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
    http://www.esnips.com/doc/5c65b0dd-eddf-4512-8e32-ecd26735f0f2/prefinalppt.ppt
    http://www.allsaplinks.com/
    http://www.sap-img.com/
    http://www.sapgenie.com/
    http://help.sap.com
    http://www.sapgenie.com/abap/OO/
    http://www.sapgenie.com/abap/OO/index.htm
    http://www.sapgenie.com/abap/controls/index.htm
    http://www.esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
    http://www.esnips.com/doc/0ef39d4b-586a-4637-abbb-e4f69d2d9307/SAP-CONTROLS-WORKSHOP.pdf
    http://www.sapgenie.com/abap/OO/index.htm
    http://help.sap.com/saphelp_erp2005/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm
    http://www.sapgenie.com/abap/OO/
    these links
    http://help.sap.com/saphelp_47x200/helpdata/en/ce/b518b6513611d194a50000e8353423/content.htm
    For funtion module to class
    http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b5954f411d194a60000e8353423/content.htm
    for classes
    http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b5c54f411d194a60000e8353423/content.htm
    for methods
    http://help.sap.com/saphelp_47x200/helpdata/en/08/d27c03b81011d194f60000e8353423/content.htm
    for inheritance
    http://help.sap.com/saphelp_47x200/helpdata/en/dd/4049c40f4611d3b9380000e8353423/content.htm
    for interfaces
    http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b6254f411d194a60000e8353423/content.htm
    For Materials:
    1) http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCABA/BCABA.pdf -- Page no: 1291
    2) http://esnips.com/doc/5c65b0dd-eddf-4512-8e32-ecd26735f0f2/prefinalppt.ppt
    3) http://esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
    4) http://esnips.com/doc/0ef39d4b-586a-4637-abbb-e4f69d2d9307/SAP-CONTROLS-WORKSHOP.pdf
    5) http://esnips.com/doc/92be4457-1b6e-4061-92e5-8e4b3a6e3239/Object-Oriented-ABAP.ppt
    6) http://esnips.com/doc/448e8302-68b1-4046-9fef-8fa8808caee0/abap-objects-by-helen.pdf
    7) http://esnips.com/doc/39fdc647-1aed-4b40-a476-4d3042b6ec28/class_builder.ppt
    8) http://www.amazon.com/gp/explorer/0201750805/2/ref=pd_lpo_ase/102-9378020-8749710?ie=UTF8
    1) http://www.erpgenie.com/sap/abap/OO/index.htm
    2) http://help.sap.com/saphelp_nw04/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm
    COLOURING Single Columan
    http://www.sapfans.com/forums/viewtopic.php?t=52107
    Check this thread to get more idea about ALVs.
    Interactive ALV
    Rewards if useful.............
    Minal

  • Error : while converting a WD ABAP object into SAP Transaction

    Hi,
    I am trying to converting a WD ABAP object into SAP Transaction but i am getting the following error while executing the transaction :
    Network Access Message: The page cannot be displayed
    Technical Information (for Support personnel)
    Error Code: 502 Proxy Error. The specified Secure Sockets Layer (SSL) port is not allowed. ISA Server is not configured to allow SSL requests from this port. Most Web browsers use port 443 for SSL requests. (12204)
    IP Address: 10.114.6.144
    Date: 4/7/2011 10:41:
    Please help.

    > ISA Server is not configured to allow SSL requests from this port. Most Web browsers use port 443 for SSL requests. (12204)
    This seems to be your specific network configuration.  It seems that your corporate network is blocking HTTPS requests which don't use port 443. Your ABAP system is configured to use a port other than 443. Either talk to your basis admins about changing your ABAP system configuration to use port 443 or talk to your network administrators to allow whichever port the ABAP system is running on.

  • Expose Object Oriented Service code as Web Services?

    Hello All,
    I would appreciate for your insight on this matter!
    Web Services are basically RPC (Procedure Oriented) over Soap. Each service invocation by a client results a procedure execution on the server side (In many case, a service class may need to be instantiated before the procedure can be called).
    Suppose I have developed server-side logics in Object Oriented manners. How can I expose the OO server logics as Web Services? Does JDeveloper handle OO services any different from PO (procedure-oriented) services as far as the generated wrapper code/interface and WSDL?
    Specifically, I have the following example in mind. Assume we are able to successfully expose an OO services. A client calls one of the OO service (let's say service1 in portType1) the 1st time, and establish some transit state (not committing into DB), the same client subsequently calls another service (service2) of the same server portType1. How would the server retrieve the transit state established earlier by service1 while executing service2? (note, this situation would not be resulted in a procedure-oriented case. since each RPC call is independent from the others)
    I realize that "stateful" deployment may be of an option. However, stateful seems relying on client cooperation (e.g., via cookies) to establish context across multiple invocations. This may or may not be possible given an arbitrary client parties write its client code based on a WSDL.
    Another option I can think about is for Jdeveloper to generated different code for PO services vs. OO services. However, it seems not the case in current Jdeveloper.
    Thank you so much!
    jason

    Web services in general have two styles of invocation: RPC style and Doc style. RPC maps as you say directly to methods on Java class (or if a DB PL/SQL package to procedures and functions).
    The alternative, DOC, generally (though not all the time) maps to a message oriented interface. Often DOC style Web services map to messaging infrastructure such as Java Message Service Queues and Topics.
    That said RPC works well with EJB's, the component model for J2EE.
    Often what folks will do is build a service layer that is very coarse grained when exposing backend infrastructure as Web services. This abstraction typically hides a more OO underpinning (or quite often hides a very procedural backend too).
    The bottom line is the Web services do not force an OO paradigm but nor do they hinder you in any way from adopting an OO paradigm.
    In terms of JDeveloper currently it supports RPC and supports DOC only with some tweaking. On the server side, the Oracle9iAS infrastructure supports both DOC and RPC.
    Hope this is a start to answering what I think is a hard question to answer!
    Mike.

  • Notes on using Object  oriented concept in ABAP

    Hi ,
    I want somes notes on how to use Object  oriented concept in ABAP.
    Thanks in advance.
    Chetan

    Hi, this may help you
    OOPs ABAP uses Classes and Interfaces which uses Methods and events.
    If you have Java skills it is advantage for you.
    There are Local classes as well as Global Classes.
    Local classes we can work in SE38 straight away.
    But mostly it is better to use the Global classes.
    Global Classes or Interfaces are to be created in SE24.
    SAP already given some predefined classes and Interfaces.
    This OOPS concepts very useful for writing BADI's also.
    So first create a class in SE 24.
    Define attributes, Methods for that class.
    Define parameters for that Method.
    You can define event handlers also to handle the messages.
    After creation in each method write the code.
    Methods are similar to ABAP PERFORM -FORM statements.
    After the creation of CLass and methods come to SE38 and create the program.
    In the program create a object type ref to that class and with the help of that Object call the methods of that Class and display the data.
    Example:
    REPORT sapmz_hf_alv_grid .
    Type pool for icons - used in the toolbar
    TYPE-POOLS: icon.
    TABLES: zsflight.
    To allow the declaration of o_event_receiver before the
    lcl_event_receiver class is defined, decale it as deferred in the
    start of the program
    CLASS lcl_event_receiver DEFINITION DEFERRED.
    G L O B A L I N T E R N A L T A B L E S
    *DATA: gi_sflight TYPE STANDARD TABLE OF sflight.
    To include a traffic light and/or color a line the structure of the
    table must include fields for the traffic light and/or the color
    TYPES: BEGIN OF st_sflight.
    INCLUDE STRUCTURE zsflight.
    Field for traffic light
    TYPES: traffic_light TYPE c.
    Field for line color
    types: line_color(4) type c.
    TYPES: END OF st_sflight.
    TYPES: tt_sflight TYPE STANDARD TABLE OF st_sflight.
    DATA: gi_sflight TYPE tt_sflight.
    G L O B A L D A T A
    DATA: ok_code LIKE sy-ucomm,
    Work area for internal table
    g_wa_sflight TYPE st_sflight,
    ALV control: Layout structure
    gs_layout TYPE lvc_s_layo.
    Declare reference variables to the ALV grid and the container
    DATA:
    go_grid TYPE REF TO cl_gui_alv_grid,
    go_custom_container TYPE REF TO cl_gui_custom_container,
    o_event_receiver TYPE REF TO lcl_event_receiver.
    DATA:
    Work area for screen 200
    g_screen200 LIKE zsflight.
    Data for storing information about selected rows in the grid
    DATA:
    Internal table
    gi_index_rows TYPE lvc_t_row,
    Information about 1 row
    g_selected_row LIKE lvc_s_row.
    C L A S S E S
    CLASS lcl_event_receiver DEFINITION.
    PUBLIC SECTION.
    METHODS:
    handle_toolbar FOR EVENT toolbar OF cl_gui_alv_grid
    IMPORTING
    e_object e_interactive,
    handle_user_command FOR EVENT user_command OF cl_gui_alv_grid
    IMPORTING e_ucomm.
    ENDCLASS.
    CLASS lcl_event_receiver IMPLEMENTATION
    CLASS lcl_event_receiver IMPLEMENTATION.
    METHOD handle_toolbar.
    Event handler method for event toolbar.
    CONSTANTS:
    Constants for button type
    c_button_normal TYPE i VALUE 0,
    c_menu_and_default_button TYPE i VALUE 1,
    c_menu TYPE i VALUE 2,
    c_separator TYPE i VALUE 3,
    c_radio_button TYPE i VALUE 4,
    c_checkbox TYPE i VALUE 5,
    c_menu_entry TYPE i VALUE 6.
    DATA:
    ls_toolbar TYPE stb_button.
    Append seperator to the normal toolbar
    CLEAR ls_toolbar.
    MOVE c_separator TO ls_toolbar-butn_type..
    APPEND ls_toolbar TO e_object->mt_toolbar.
    Append a new button that to the toolbar. Use E_OBJECT of
    event toolbar. E_OBJECT is of type CL_ALV_EVENT_TOOLBAR_SET.
    This class has one attribute MT_TOOLBAR which is of table type
    TTB_BUTTON. The structure is STB_BUTTON
    CLEAR ls_toolbar.
    MOVE 'CHANGE' TO ls_toolbar-function.
    MOVE icon_change TO ls_toolbar-icon.
    MOVE 'Change flight' TO ls_toolbar-quickinfo.
    MOVE 'Change' TO ls_toolbar-text.
    MOVE ' ' TO ls_toolbar-disabled.
    APPEND ls_toolbar TO e_object->mt_toolbar.
    ENDMETHOD.
    METHOD handle_user_command.
    Handle own functions defined in the toolbar
    CASE e_ucomm.
    WHEN 'CHANGE'.
    PERFORM change_flight.
    LEAVE TO SCREEN 0.
    ENDCASE.
    ENDMETHOD.
    ENDCLASS.
    S T A R T - O F - S E L E C T I O N.
    START-OF-SELECTION.
    SET SCREEN '100'.
    *& Module USER_COMMAND_0100 INPUT
    MODULE user_command_0100 INPUT.
    CASE ok_code.
    WHEN 'EXIT'.
    LEAVE TO SCREEN 0.
    ENDCASE.
    ENDMODULE. " USER_COMMAND_0100 INPUT
    *& Module STATUS_0100 OUTPUT
    MODULE status_0100 OUTPUT.
    DATA:
    For parameter IS_VARIANT that is sued to set up options for storing
    the grid layout as a variant in method set_table_for_first_display
    l_layout TYPE disvariant,
    Utillity field
    l_lines TYPE i.
    After returning from screen 200 the line that was selected before
    going to screen 200, should be selected again. The table gi_index_rows
    was the output table from the GET_SELECTED_ROWS method in form
    CHANGE_FLIGHT
    DESCRIBE TABLE gi_index_rows LINES l_lines.
    IF l_lines > 0.
    CALL METHOD go_grid->set_selected_rows
    EXPORTING
    it_index_rows = gi_index_rows.
    CALL METHOD cl_gui_cfw=>flush.
    REFRESH gi_index_rows.
    ENDIF.
    Read data and create objects
    IF go_custom_container IS INITIAL.
    Read data from datbase table
    PERFORM get_data.
    Create objects for container and ALV grid
    CREATE OBJECT go_custom_container
    EXPORTING container_name = 'ALV_CONTAINER'.
    CREATE OBJECT go_grid
    EXPORTING
    i_parent = go_custom_container.
    Create object for event_receiver class
    and set handlers
    CREATE OBJECT o_event_receiver.
    SET HANDLER o_event_receiver->handle_user_command FOR go_grid.
    SET HANDLER o_event_receiver->handle_toolbar FOR go_grid.
    Layout (Variant) for ALV grid
    l_layout-report = sy-repid. "Layout fo report
    Setup the grid layout using a variable of structure lvc_s_layo
    Set grid title
    gs_layout-grid_title = 'Flights'.
    Selection mode - Single row without buttons
    (This is the default mode
    gs_layout-sel_mode = 'B'.
    Name of the exception field (Traffic light field) and the color
    field + set the exception and color field of the table
    gs_layout-excp_fname = 'TRAFFIC_LIGHT'.
    gs_layout-info_fname = 'LINE_COLOR'.
    LOOP AT gi_sflight INTO g_wa_sflight.
    IF g_wa_sflight-paymentsum < 100000.
    Value of traffic light field
    g_wa_sflight-traffic_light = '1'.
    Value of color field:
    C = Color, 6=Color 1=Intesified on, 0: Inverse display off
    g_wa_sflight-line_color = 'C610'.
    ELSEIF g_wa_sflight-paymentsum => 100000 AND
    g_wa_sflight-paymentsum < 1000000.
    g_wa_sflight-traffic_light = '2'.
    ELSE.
    g_wa_sflight-traffic_light = '3'.
    ENDIF.
    MODIFY gi_sflight FROM g_wa_sflight.
    ENDLOOP.
    Grid setup for first display
    CALL METHOD go_grid->set_table_for_first_display
    EXPORTING i_structure_name = 'SFLIGHT'
    is_variant = l_layout
    i_save = 'A'
    is_layout = gs_layout
    CHANGING it_outtab = gi_sflight.
    *-- End of grid setup -
    Raise event toolbar to show the modified toolbar
    CALL METHOD go_grid->set_toolbar_interactive.
    Set focus to the grid. This is not necessary in this
    example as there is only one control on the screen
    CALL METHOD cl_gui_control=>set_focus EXPORTING control = go_grid.
    ENDIF.
    ENDMODULE. " STATUS_0100 OUTPUT
    *& Module USER_COMMAND_0200 INPUT
    MODULE user_command_0200 INPUT.
    CASE ok_code.
    WHEN 'EXIT200'.
    LEAVE TO SCREEN 100.
    WHEN'SAVE'.
    PERFORM save_changes.
    ENDCASE.
    ENDMODULE. " USER_COMMAND_0200 INPUT
    *& Form get_data
    FORM get_data.
    Read data from table SFLIGHT
    SELECT *
    FROM zsflight
    INTO TABLE gi_sflight.
    ENDFORM. " load_data_into_grid
    *& Form change_flight
    Reads the contents of the selected row in the grid, ans transfers
    the data to screen 200, where it can be changed and saved.
    FORM change_flight.
    DATA:l_lines TYPE i.
    REFRESH gi_index_rows.
    CLEAR g_selected_row.
    Read index of selected rows
    CALL METHOD go_grid->get_selected_rows
    IMPORTING
    et_index_rows = gi_index_rows.
    Check if any row are selected at all. If not
    table gi_index_rows will be empty
    DESCRIBE TABLE gi_index_rows LINES l_lines.
    IF l_lines = 0.
    CALL FUNCTION 'POPUP_TO_DISPLAY_TEXT'
    EXPORTING
    textline1 = 'You must choose a line'.
    EXIT.
    ENDIF.
    Read indexes of selected rows. In this example only one
    row can be selected as we are using gs_layout-sel_mode = 'B',
    so it is only ncessary to read the first entry in
    table gi_index_rows
    LOOP AT gi_index_rows INTO g_selected_row.
    IF sy-tabix = 1.
    READ TABLE gi_sflight INDEX g_selected_row-index INTO g_wa_sflight.
    ENDIF.
    ENDLOOP.
    Transfer data from the selected row to screenm 200 and show
    screen 200
    CLEAR g_screen200.
    MOVE-CORRESPONDING g_wa_sflight TO g_screen200.
    LEAVE TO SCREEN '200'.
    ENDFORM. " change_flight
    *& Form save_changes
    Changes made in screen 200 are written to the datbase table
    zsflight, and to the grid table gi_sflight, and the grid is
    updated with method refresh_table_display to display the changes
    FORM save_changes.
    DATA: l_traffic_light TYPE c.
    Update traffic light field
    Update database table
    MODIFY zsflight FROM g_screen200.
    Update grid table , traffic light field and color field.
    Note that it is necessary to use structure g_wa_sflight
    for the update, as the screen structure does not have a
    traffic light field
    MOVE-CORRESPONDING g_screen200 TO g_wa_sflight.
    IF g_wa_sflight-paymentsum < 100000.
    g_wa_sflight-traffic_light = '1'.
    C = Color, 6=Color 1=Intesified on, 0: Inverse display off
    g_wa_sflight-line_color = 'C610'.
    ELSEIF g_wa_sflight-paymentsum => 100000 AND
    g_wa_sflight-paymentsum < 1000000.
    g_wa_sflight-traffic_light = '2'.
    clear g_wa_sflight-line_color.
    ELSE.
    g_wa_sflight-traffic_light = '3'.
    clear g_wa_sflight-line_color.
    ENDIF.
    MODIFY gi_sflight INDEX g_selected_row-index FROM g_wa_sflight.
    Refresh grid
    CALL METHOD go_grid->refresh_table_display.
    CALL METHOD cl_gui_cfw=>flush.
    LEAVE TO SCREEN '100'.
    ENDFORM. " save_changes
    chk this blog
    /people/vijaybabu.dudla/blog/2006/07/21/topofpage-in-alv-using-clguialvgrid
    Reward if helpfull.
    Regards Madhu.

  • Object oriented abap

    hello abapers,
    am new to object oriented abap.cud u pls help me out in explaining me object oriented abap with examples.cud u also pls send me some links related to OO ABAP..
    explanation wid suitable examples will b rewarded higher pints.
    regards,
    praveen

    Hi,
    please find the below material with examples,
    reward points if helpful.
    Public attributes
    Public attributes are defined in the PUBLIC section and can be viewed and changed from outside the class. There is direct access to public attributes. As a general rule, as few public attributes should be defined as possible.
    PUBLIC SECTION.
      DATA: Counter type i.
    Private attributes
    Private attributes are defined in the PRIVATE section. The can only be viewes and changed from within the class. There is no direct access from outside the class.
    PRIVATE SECTION.
        DATA: name(25) TYPE c,
              planetype LIKE saplane-planetyp,
    Instance attributes
    There exist one instance attribute for each instance of the class, thus they exist seperately for each object. Instance attributes are declared with the DATA keyword.
    Static attributes
    Static attributes exist only once for each class. The data are the same for all instances of the class, and can be used e.g. for instance counters. Static attributes are defined with the keyword CLASS-DATA.
    PRIVATE SECTION.
      CLASS-DATA: counter type i,  
    Public methods
    Can called from outside the class
    PUBLIC SECTION.
      METHODS:  set_attributes IMPORTING p_name(25) TYPE c,
                                                                p_planetype LIKE saplane-planetyp,
    Private methods
    Can only be called from inside the class. They are placed in the PRIVATE section of the class.
    Constructor method
    Implicitly, each class has an instance constructor method with the reserved name constructor and a static constructor method with the reserved name class_constructor.
    The instance constructor is executed each time you create an object (instance) with the CREATE OBJECT statement, while the class constructor is executed exactly once before you first access a class.
    The constructors are always present. However, to implement a constructor you must declare it explicitly with the METHODS or CLASS-METHODS statements. An instance constructor can have IMPORTING parameters and exceptions. You must pass all non-optional parameters when creating an object. Static constructors have no parameters.
    Static constructor
    The static constructor is always called CLASS_CONSTRUCTER, and is called autmatically before the clas is first accessed, that is before any of the following actions are executed:
    •     Creating an instance using CREATE_OBJECT
    •     Adressing a static attribute using 
    •     Calling a ststic attribute using CALL METHOD
    •     Registering a static event handler
    •     Registering an evetm handler method for a static event
    The static constructor cannot be called explicitly.
    Protected components
    When we are talking subclassing and enheritance there is one more component than Public and Private, the Protected component. Protected components can be used by the superclass and all of the subclasses. Note that Subclasses cannot access Private components.
    Polymorphism
    Polymorphism: When the same method is implemented differently in different classes. This can be done using enheritance, by redefining a method from the superclass in subclasses and implement it differently.
    Template for making a class
    Delete the parts that should not be used
    Definition part
    CLASS xxx DEFINITION.
    Public section
      PUBLIC SECTION.
        TYPES:
        DATA:
      Static data
        CLASS-DATA:
      Methods
        METHODS:
        Using the constructor to initialize parameters
           constructor    IMPORTING xxx type yyy,
        Method with parameters
          mm1 IMPORTING iii   TYPE ttt.
        Method without parameters
          mm2.
      Static methods
        CLASS-METHODS: 
    Protected section. Also accessable by subclasses
      PROTECTED SECTION.
    Private section. Not accessable by subclasses
      PRIVATE SECTION.
    ENDCLASS.
    Implementation part
    CLASS lcl_airplane IMPLEMENTATION.
      METHOD constructor.
      ENDMETHOD.
      METHOD mm1.
      ENDMETHOD.
      METHOD mm2.
      ENDMETHOD.
    ENDCLASS.
    Template for calling a class
    Create reference to class lcl_airplane
    DATA: airplane1 TYPE REF TO lcl_airplane.
    START-OF-SELECTION.
    Create instance using parameters in the cosntructor method
      CREATE OBJECT airplane1 exporting im_name = 'Hansemand'
                                        im_planetype = 'Boing 747'.
    Calling a method with parameters
      CALL METHOD: airplane1->display_n_o_airplanes,
                   airplane1->display_attributes.
    Subclass
    CLASS xxx DEFINITION INHERITING FROM yyy.
    Using af class as a parameter for a method
    The class LCL_AIRPLANE is used as a parameter for method add_a_new_airplane:
    METHODS:
      add_a_new_airplane importing im_airplane TYPE REF to lcl_airplane.
    Interfaces
    In ABAP interfaces are implemented in addition to, and independently of classes. An interface only has a declaration part, and do not have visibillity sections. Components (Attributes, methods, constants, types) can be defined the same way as in classes.
    •     Interfaces are listed in the definition part lof the class, and must always be in the PUBLIC SECTION.
    •     Operations defined in the interface atre impemented as methods of the class. All methods of the interface must be present in the
    •     implementation part of the class.
    •     Attributes, events, constants and types defined in the interface are automatically available to the class carying out the implementation.
    •     Interface components are adresse in the class by ]
    Define, implement and use simple class
    ***INCLUDE ZBC404_HF_LCL_AIRPLANE .
    Definition part
    CLASS lcl_airplane DEFINITION.
    Public section
      PUBLIC SECTION.
        TYPES: t_name(25) TYPE c.
        METHODS:
          constructor,
          set_attributes IMPORTING p_name       TYPE t_name
                                   p_planetype  TYPE saplane-planetype,
          display_attributes,
          display_n_o_airplanes.
    Private section
      PRIVATE SECTION.
      Private attributes
        DATA: name(25) TYPE c,
              planetype TYPE saplane-planetype.
      Private static attribute
        CLASS-DATA n_o_airplanes TYPE i.
    ENDCLASS.
    Implementation part
    CLASS lcl_airplane IMPLEMENTATION.
      METHOD constructor.
      Counts number of instances
        n_o_airplanes = n_o_airplanes + 1.
      ENDMETHOD.
      METHOD set_attributes.
        name      = p_name.
        planetype = p_planetype.
      ENDMETHOD.
      METHOD display_attributes.
        WRITE:/ 'Name:', name, 'Planetype:', planetype.
      ENDMETHOD.
      METHOD display_n_o_airplanes.
        WRITE: / 'No. planes:', n_o_airplanes.
      ENDMETHOD.
    ENDCLASS.
    REPORT zbc404_hf_maintain_airplanes .
    INCLUDE zbc404_hf_lcl_airplane.
    Create reference to class lcl_airplane
    DATA: airplane1 TYPE REF TO lcl_airplane,
          airplane2 TYPE REF TO lcl_airplane.
    START-OF-SELECTION.
    Create instance
      CREATE OBJECT airplane1.
      CALL METHOD: airplane1->display_n_o_airplanes.
      CREATE OBJECT airplane2.
    Setting attributes using a method with parameters
      CALL METHOD airplane1->set_attributes EXPORTING p_name      = 'Kurt'
                                                      p_planetype = 'MD80'.
    END-OF-SELECTION.
    Using methods
      CALL METHOD: airplane1->display_n_o_airplanes,
                   airplane1->display_attributes. 
    The resulting report:
    Maintain airplanes                                                                               
    No. planes:          1                                
    No. planes:          2                                
    Name: Kurt                      Planetype: MD80       
    Use constructor to create an object with parameters
    CLASS lcl_airplane DEFINITION.
      PUBLIC SECTION.
        TYPES: t_name(25) TYPE c.
        METHODS:
          constructor    importing p2_name      type t_name
                                   p2_planetype  TYPE saplane-planetype,
    ..... more code .......
    CLASS lcl_airplane IMPLEMENTATION.
      METHOD constructor.
        name      = p2_name.
        planetype = p2_planetype.
    ..... more code .......
    START-OF-SELECTION.
      CREATE OBJECT airplane1 exporting p2_name = 'Hansemand'
                                        p2_planetype = 'Boing 747'.
    Subclassing
    This example uses a superclass LCL_AIRPLANE and subclasses it into LCL_PASSENGER_AIRPLANE and LCL_CARGO_PLANE.
    LCL_AIRPLANE has a method display_n_o_airplanes that displays the number of object instances.
    LCL_PASSENGER_AIRPLANE has the private instance attribute n_o_seats, and redefines the superclass method display_attributes, so it also displays n_o_seats.
    LCL_CARGO_PLANE has the private instance attribute cargomax, and redefines the superclass method display_attributes, so it also displays cargomax.
    All instance attributes are provided by the cunstructor method.
    Superclass LCL_AIRPLANE
    ***INCLUDE ZBC404_HF_LCL_AIRPLANE .
    Definition part
    CLASS lcl_airplane DEFINITION.
    Public section
      PUBLIC SECTION.
        TYPES: t_name(25) TYPE c.
        METHODS:
          constructor    IMPORTING im_name      TYPE t_name
                                   im_planetype  TYPE saplane-planetype,
          display_attributes.
      Static methods
        CLASS-METHODS:
          display_n_o_airplanes.
    Protected section
      PROTECTED SECTION.
      Private attributes
        DATA: name(25) TYPE c,
              planetype TYPE saplane-planetype.
      Private static attribute
        CLASS-DATA n_o_airplanes TYPE i.
    ENDCLASS.
    Implementation part
    CLASS lcl_airplane IMPLEMENTATION.
      METHOD constructor.
        name      = im_name.
        planetype = im_planetype.
      Counts number of instances
        n_o_airplanes = n_o_airplanes + 1.
      ENDMETHOD.
      METHOD display_attributes.
        WRITE:/ 'Name:', name, 'Planetype:', planetype.
      ENDMETHOD.
      METHOD display_n_o_airplanes.
        WRITE: / 'No. planes:', n_o_airplanes.
      ENDMETHOD.
    ENDCLASS.
    Sub class LCL_PASSENGER_AIRPLANE
    ***INCLUDE ZBC404_HF_LCL_PASSENGER_PLANE .
    This is a subclass of class lcl_airplane
    CLASS lcl_passenger_airplane DEFINITION INHERITING FROM lcl_airplane.
      PUBLIC SECTION.
      The constructor contains the parameters from the superclass
      plus the parameters from the subclass
        METHODS:
          constructor IMPORTING im_name      TYPE t_name
                                im_planetype TYPE saplane-planetype
                                im_n_o_seats TYPE sflight-seatsmax,
        Redefinition of superclass method display_attributes
          display_attributes REDEFINITION.
      PRIVATE SECTION.
        DATA: n_o_seats TYPE sflight-seatsmax.
    ENDCLASS.
    CLASS lcl_passenger_airplane IMPLEMENTATION.
      METHOD constructor.
      The constructor method of the superclass MUST be called withing the
      construtor
        CALL METHOD super->constructor
                              EXPORTING im_name      = im_name
                                        im_planetype = im_planetype.
        n_o_seats = im_n_o_seats.
      ENDMETHOD.
      The redefined  display_attributes method
      METHOD display_attributes.
        CALL METHOD super->display_attributes.
        WRITE: / 'No. seats:', n_o_seats.
      ENDMETHOD.
    ENDCLASS.
    Sub class LCL_CARGO_PLANE
    ***INCLUDE ZBC404_HF_LCL_CARGO_PLANE .
    This is a subclass of class lcl_airplane
    CLASS lcl_cargo_plane DEFINITION INHERITING FROM lcl_airplane.
      PUBLIC SECTION.
        METHODS:
        The constructor contains the parameters from the superclass
        plus the parameters from the subclass
          constructor IMPORTING im_name      TYPE t_name
                                im_planetype TYPE saplane-planetype
                                im_cargomax  type scplane-cargomax,
        Redefinition of superclass method display_attributes
          display_attributes REDEFINITION.
      PRIVATE SECTION.
        DATA:cargomax TYPE scplane-cargomax.
    ENDCLASS.
    CLASS lcl_cargo_plane IMPLEMENTATION.
      METHOD constructor.
      The constructor method of the superclass MUST be called withing the
      constructor
        CALL METHOD super->constructor
                              EXPORTING im_name      = im_name
                                        im_planetype = im_planetype.
        cargomax = im_cargomax.
      ENDMETHOD.
      METHOD display_attributes.
      The redefined  display_attributes method
        CALL METHOD super->display_attributes.
        WRITE: / 'Cargo max:', cargomax.
      ENDMETHOD.
    ENDCLASS.
    The Main program that uses the classes
    REPORT zbc404_hf_main .
    Super class
    INCLUDE zbc404_hf_lcl_airplane.
    Sub classes
    INCLUDE zbc404_hf_lcl_passenger_plane.
    INCLUDE zbc404_hf_lcl_cargo_plane.
    DATA:
    Type ref to sub classes. Note: It is not necesssary to make typeref to the superclass
      o_passenger_airplane TYPE REF TO lcl_passenger_airplane,
      o_cargo_plane        TYPE REF TO lcl_cargo_plane.
    START-OF-SELECTION.
    Display initial number of instances = 0
      CALL METHOD  lcl_airplane=>display_n_o_airplanes.
    Create objects
      CREATE OBJECT o_passenger_airplane
        EXPORTING
          im_name      = 'LH505'
          im_planetype = 'Boing 747'
          im_n_o_seats = 350.
      CREATE OBJECT o_cargo_plane
        EXPORTING
          im_name      = 'AR13'
          im_planetype = 'DC 3'
          im_cargomax = 35.
    Display attributes
      CALL METHOD o_passenger_airplane->display_attributes.
      CALL METHOD o_cargo_plane->display_attributes.
    Call static method display_n_o_airplanes
    Note: The syntax for calling a superclass method, differs from the syntax when calling a subclass method.
    When calling a superclass => must be used instead of ->
      CALL METHOD  lcl_airplane=>display_n_o_airplanes.
    Result:
    No. planes: 0
    Name: LH505 Planetype: Boing 747
    No. seats: 350
    Name: AR13 Planetype: DC 3
    Cargo max: 35,0000
    No. planes: 2
    Polymorphism
    Polymorphism: When the same method is implemented differently in different classes. This can be done using enheritance, by redefining a method from the superclass in subclasses and implement it differently.
    Classes:
    •     lcl_airplane Superclass
    •     lcl_cargo_airplane Subclass
    •     lcl_passenger_airplane Subclass
    The method estimate_fuel_consumption is implemented differently in the 3 classes, as it depends on the airplane type.
    Object from different classes are stored in an internal table (plane_list) consisting of references to the superclass, and the processed
    identically for all the classes.
    What coding for the estimate_fuel_consumption method taht is actually executed, depends on the dynamic type of the plane reference variable,
    that is, depends on which object plane points to.
    DATA: cargo_plane            TYPE REF to lcl_cargo_airplane,
              passenger_plane    TYPE REF to lcl_passenger_airplane,
              plane_list                  TYPE TABLE OF REF TO lcl_airplane.
    Creating the list of references
    CREATE OBJECT cargo_plane.
    APPEND cargo_plane to plane_list.
    CREATE OBJECT passenger_plane
    APPEND passenger_plane to plane list.
    Generic method for calucalting required fuel
    METHOD calculate required_fuel.
      DATA: plane TYPE REF TO lcl_airplane.
      LOOP AT plane_list INTO plane.
        re_fuel = re_fuel + plane->estimate_fuel_consumption( distance ).
      ENDLOOP.
    ENDMETHOD.
    Working example:
    This example assumes that the classes lcl_airplane,  lcl_passnger_airplane and lcl_cargo plane (Se Subcallsing)  exists.
    Create objects of type lcl_cargo_plane and lcl_passenger_airplane, adds them to a list in lcl_carrier, and displays the list. 
    *& Include  ZBC404_HF_LCL_CARRIER                                      *
          CLASS lcl_carrier DEFINITION                                   *
    CLASS lcl_carrier DEFINITION.
      PUBLIC SECTION.
        TYPES: BEGIN OF flight_list_type,
                  connid   TYPE sflight-connid,
                  fldate   TYPE sflight-fldate,
                  airplane TYPE REF TO lcl_airplane,
                  seatsocc TYPE sflight-seatsocc,
                  cargo(5) TYPE p DECIMALS 3,
               END OF flight_list_type.
        METHODS: constructor IMPORTING im_name TYPE string,
                 get_name RETURNING value(ex_name) TYPE string,
                 add_a_new_airplane IMPORTING
                                       im_airplane TYPE REF TO lcl_airplane,
        create_a_new_flight importing
                              im_connid   type sflight-connid
                              im_fldate   type sflight-fldate
                              im_airplane type ref to lcl_airplane
                              im_seatsocc type sflight-seatsocc
                                        optional
                            im_cargo    type p optional,
         display_airplanes.
      PRIVATE SECTION.
        DATA: name              TYPE string,
              list_of_airplanes TYPE TABLE OF REF TO lcl_airplane,
              list_of_flights   TYPE TABLE OF flight_list_type.
    ENDCLASS.
          CLASS lcl_carrier IMPLEMENTATION
    CLASS lcl_carrier IMPLEMENTATION.
      METHOD constructor.
        name = im_name.
      ENDMETHOD.
      METHOD get_name.
        ex_name = name.
      ENDMETHOD.
      METHOD create_a_new_flight.
        DATA: wa_list_of_flights TYPE flight_list_type.
        wa_list_of_flights-connid   = im_connid.
        wa_list_of_flights-fldate   = im_fldate.
        wa_list_of_flights-airplane = im_airplane.
        IF im_seatsocc IS INITIAL.
          wa_list_of_flights-cargo = im_cargo.
        ELSE.
          wa_list_of_flights-seatsocc = im_seatsocc.
        ENDIF.
        APPEND wa_list_of_flights TO list_of_flights.
      ENDMETHOD.
      METHOD add_a_new_airplane.
        APPEND im_airplane TO list_of_airplanes.
      ENDMETHOD.
      METHOD display_airplanes.
        DATA: l_airplane TYPE REF TO lcl_airplane.
        LOOP AT list_of_airplanes INTO l_airplane.
          CALL METHOD l_airplane->display_attributes.
        ENDLOOP.
      ENDMETHOD.
    ENDCLASS.
    REPORT zbc404_hf_main .
    This reprort uses class LCL_AIRPLNAE and subclasses
    LCL_CARGO_PLANE and LCL_PASSENGER_AIRPLANE and class LCL_CARRIER
    Super class for airplanes
    INCLUDE zbc404_hf_lcl_airplane.
    Sub classes for airplanes
    INCLUDE zbc404_hf_lcl_passenger_plane.
    INCLUDE zbc404_hf_lcl_cargo_plane.
    Carrier class
    INCLUDE zbc404_hf_lcl_carrier.
    DATA:
    Type ref to classes
      o_passenger_airplane  TYPE REF TO lcl_passenger_airplane,
      o_passenger_airplane2 TYPE REF TO lcl_passenger_airplane,
      o_cargo_plane         TYPE REF TO lcl_cargo_plane,
      o_cargo_plane2        TYPE REF TO lcl_cargo_plane,
      o_carrier             TYPE REF TO lcl_carrier.
    START-OF-SELECTION.
    Create objects
      CREATE OBJECT o_passenger_airplane
        EXPORTING
          im_name      = 'LH505'
          im_planetype = 'Boing 747'
          im_n_o_seats = 350.
      CREATE OBJECT o_passenger_airplane2
        EXPORTING
          im_name      = 'SK333'
          im_planetype = 'MD80'
          im_n_o_seats = 110.
      CREATE OBJECT o_cargo_plane
        EXPORTING
          im_name      = 'AR13'
          im_planetype = 'DC 3'
          im_cargomax = 35.
      CREATE OBJECT o_cargo_plane2
        EXPORTING
          im_name      = 'AFL124'
          im_planetype = 'Iljutsin 2'
          im_cargomax = 35000.
      CREATE OBJECT o_carrier
        EXPORTING im_name = 'Spritisch Airways'.
    Add passenger and cargo planes to the list of airplanes
      CALL METHOD o_carrier->add_a_new_airplane
         EXPORTING im_airplane = o_passenger_airplane.
      CALL METHOD o_carrier->add_a_new_airplane
         EXPORTING im_airplane = o_passenger_airplane2.
      CALL METHOD o_carrier->add_a_new_airplane
         EXPORTING im_airplane = o_cargo_plane.
      CALL METHOD o_carrier->add_a_new_airplane
         EXPORTING im_airplane = o_cargo_plane2.
    Display list of airplanes
      call method o_carrier->display_airplanes.
    Result:
    Name: LH505                     Planetype: Boing 747        
    No. seats:       350                                        
    Name: SK333                     Planetype: MD80             
    No. seats:       110                                        
    Name: AR13                      Planetype: DC 3             
    Cargo max:             35,0000                              
    Name: AFL124                    Planetype: Iljutsin 2       
    Cargo max:         35.000,0000                              
    Events
    Below is a simple example of how to implement an event.
    REPORT zbc404_hf_events_5.
          CLASS lcl_dog DEFINITION
    CLASS lcl_dog DEFINITION.
      PUBLIC SECTION.
      Declare events
        EVENTS:
          dog_is_hungry
            EXPORTING value(ex_time_since_last_meal) TYPE i.
        METHODS:
          constructor
              IMPORTING im_name TYPE string,
          set_time_since_last_meal
              IMPORTING im_time TYPE i,
          on_dog_is_hungry FOR EVENT dog_is_hungry OF lcl_dog
              IMPORTING ex_time_since_last_meal.
    ENDCLASS.
          CLASS lcl_dog IMPLEMENTATION
    CLASS lcl_dog IMPLEMENTATION.
      METHOD constructor.
        WRITE: / 'I am a dog and my name is', im_name.
      ENDMETHOD.
      METHOD set_time_since_last_meal.
        IF im_time < 4.
          SKIP 1.
          WRITE: / 'You fool, I am not hungry yet'.
        ELSE.
       Subsrcribe for event:
       set handler <Event handler method>
       FOR <ref_sender>!FOR ALL INSTANCES [ACTIVATION <var>]
          SET HANDLER on_dog_is_hungry FOR ALL INSTANCES ACTIVATION 'X'.
       Raise event
          RAISE EVENT dog_is_hungry
            EXPORTING ex_time_since_last_meal = im_time.
        ENDIF.
      ENDMETHOD.
      METHOD on_dog_is_hungry.
      Event method, called when the event dog_is_hungry is raised
        SKIP 1.
        WRITE: /  'You son of a *****. I have not eaten for more than',
                  ex_time_since_last_meal, ' hours'.
        WRITE: / 'Give me something to eat NOW!'.
      ENDMETHOD.
    ENDCLASS.
          R E P O R T
    DATA: o_dog1 TYPE REF TO lcl_dog.
    START-OF-SELECTION.
      CREATE OBJECT o_dog1 EXPORTING im_name = 'Beefeater'.
      CALL METHOD o_dog1->set_time_since_last_meal
        EXPORTING im_time = 2.
    This method call will raise the event dog_is_hungy
    because time > 3
      CALL METHOD o_dog1->set_time_since_last_meal
        EXPORTING im_time = 5.
    Result:
    I am a dog and my name is Beefeater
    You fool, I am not hungry yet
    You son of a *****. I have not eaten for more than 5 hours
    Give me something to eat NOW!
    1. Simple class
    This example shows how to create a simple employee class. The constructor method is used to initialize number and name of thje employee when the object is created. A display_employee method can be called to show the attributes of the employee, and CLASS-METHOD dosplay_no_of_employees can be called to show the total number of employees (Number of instances of the employee class).
    REPORT zbc404_hf_events_1.
    L C L _ E M P L O Y E E
    *---- LCL Employee - Definition
    CLASS lcl_employee DEFINITION.
      PUBLIC SECTION.
    The public section is accesible from outside  
        TYPES:
          BEGIN OF t_employee,
            no  TYPE i,
            name TYPE string,
         END OF t_employee.
        METHODS:
          constructor
            IMPORTING im_employee_no TYPE i
                      im_employee_name TYPE string,
          display_employee.
      Class methods are global for all instances      
        CLASS-METHODS: display_no_of_employees.
      PROTECTED SECTION.
    The protecetd section is accesible from the class and its subclasses 
      Class data are global for all instances      
        CLASS-DATA: g_no_of_employees TYPE i.
      PRIVATE SECTION.
    The private section is only accesible from within the classs 
        DATA: g_employee TYPE t_employee.
    ENDCLASS.
    *--- LCL Employee - Implementation
    CLASS lcl_employee IMPLEMENTATION.
      METHOD constructor.
        g_employee-no = im_employee_no.
        g_employee-name = im_employee_name.
        g_no_of_employees = g_no_of_employees + 1.
      ENDMETHOD.
      METHOD display_employee.
        WRITE:/ 'Employee', g_employee-no, g_employee-name.
      ENDMETHOD.
      METHOD display_no_of_employees.
        WRITE: / 'Number of employees is:', g_no_of_employees.
      ENDMETHOD.
    ENDCLASS.
    R E P O R T
    DATA: g_employee1 TYPE REF TO lcl_employee,
          g_employee2 TYPE REF TO lcl_employee.
    START-OF-SELECTION.
      CREATE OBJECT g_employee1
        EXPORTING im_employee_no = 1
                  im_employee_name = 'John Jones'.
      CREATE OBJECT g_employee2
        EXPORTING im_employee_no = 2
                  im_employee_name = 'Sally Summer'.
      CALL METHOD g_employee1->display_employee.
      CALL METHOD g_employee2->display_employee.
      CALL METHOD g_employee2->display_no_of_employees.
    2. Inheritance and polymorphism
    This example uses a superclass lcl_company_employees and two subclasses lcl_bluecollar_employee and lcl_whitecollar_employee to add employees to a list and then display a list of employees and there wages. The wages are calcukated in the method add_employee, but as the wages are calculated differently for blue collar employees and white collar emplyees, the superclass method add_employee is redeifined in the subclasses.
    Principles:
    Create super class LCL_CompanyEmployees.
    The class has the methods:
    •     Constructor
    •     Add_Employee - Adds a new employee to the list of employees
    •     Display_Employee_List - Displays all employees and there wage
    •     Display_no_of_employees - Displays total number of employees
    Note the use of CLASS-DATA to keep the list of employees and number of employees the same from instance to instance.
    Create subclasses lcl_bluecollar_employee and lcl_whitecollar_employee. The calsses are identical, except for the redifinition of the add_employee method, where the caclculation of wage is different.
    Methodes:
    •     Constructor. The constructor is used to initialize the attributes of the employee. Note that the constructor in the supclasss has to be called from within the constructor of the subclass.
    •     Add_Employee. This is a redinition of the same method in the superclass. In the redefined class the wage is calcuated, and the superclass method is called to add the employees to the emploee list.:
    The program
    REPORT zbc404_hf_events_2 .
    Super class LCL_CompanyEmployees
    CLASS lcl_company_employees DEFINITION.
      PUBLIC SECTION.
        TYPES:
          BEGIN OF t_employee,
            no  TYPE i,
            name TYPE string,
            wage TYPE i,
         END OF t_employee.
        METHODS:
          constructor,
          add_employee
            IMPORTING im_no   TYPE i
                      im_name TYPE string
                      im_wage TYPE i,
          display_employee_list,
          display_no_of_employees.
      PRIVATE SECTION.
        CLASS-DATA: i_employee_list TYPE TABLE OF t_employee,
                    no_of_employees TYPE i.
    ENDCLASS.
    *-- CLASS LCL_CompanyEmployees IMPLEMENTATION
    CLASS lcl_company_employees IMPLEMENTATION.
      METHOD constructor.
        no_of_employees = no_of_employees + 1.
      ENDMETHOD.
      METHOD add_employee.
      Adds a new employee to the list of employees
        DATA: l_employee TYPE t_employee.
        l_employee-no = im_no.
        l_employee-name = im_name.
        l_employee-wage = im_wage.
        APPEND l_employee TO i_employee_list.
      ENDMETHOD.
      METHOD display_employee_list.
      Displays all employees and there wage
        DATA: l_employee TYPE t_employee.
        WRITE: / 'List of Employees'.
        LOOP AT i_employee_list INTO l_employee.
          WRITE: / l_employee-no, l_employee-name, l_employee-wage.
        ENDLOOP.
      ENDMETHOD.
      METHOD display_no_of_employees.
      Displays total number of employees
        SKIP 3.
        WRITE: / 'Total number of employees:', no_of_employees.
      ENDMETHOD.
    ENDCLASS.
    Sub class LCL_BlueCollar_Employee
    CLASS lcl_bluecollar_employee DEFINITION
              INHERITING FROM lcl_company_employees.
      PUBLIC SECTION.
        METHODS:
            constructor
              IMPORTING im_no             TYPE i
                        im_name           TYPE string
                        im_hours          TYPE i
                        im_hourly_payment TYPE i,
             add_employee REDEFINITION.
      PRIVATE SECTION.
        DATA:no             TYPE i,
             name           TYPE string,
             hours          TYPE i,
             hourly_payment TYPE i.
    ENDCLASS.
    *---- CLASS LCL_BlueCollar_Employee IMPLEMENTATION
    CLASS lcl_bluecollar_employee IMPLEMENTATION.
      METHOD constructor.
      The superclass constructor method must be called from the subclass
      constructor method
        CALL METHOD super->constructor.
        no = im_no.
        name = im_name.
        hours = im_hours.
        hourly_payment = im_hourly_payment.
      ENDMETHOD.
      METHOD add_employee.
      Calculate wage an call the superclass method add_employee to add
      the employee to the employee list
        DATA: l_wage TYPE i.
        l_wage = hours * hourly_payment.
        CALL METHOD super->add_employee
          EXPORTING im_no = no
                    im_name = name
                    im_wage = l_wage.
      ENDMETHOD.
    ENDCLASS.
    Sub class LCL_WhiteCollar_Employee
    CLASS lcl_whitecollar_employee DEFINITION
        INHERITING FROM lcl_company_employees.
      PUBLIC SECTION.
        METHODS:
            constructor
              IMPORTING im_no                 TYPE i
                        im_name               TYPE string
                        im_monthly_salary     TYPE i
                        im_monthly_deductions TYPE i,
             add_employee REDEFINITION.
      PRIVATE SECTION.
        DATA:
          no                    TYPE i,
          name                  TYPE string,
          monthly_salary        TYPE i,
          monthly_deductions    TYPE i.
    ENDCLASS.
    *---- CLASS LCL_WhiteCollar_Employee IMPLEMENTATION
    CLASS lcl_whitecollar_employee IMPLEMENTATION.
      METHOD constructor.
      The superclass constructor method must be called from the subclass
      constructor method
        CALL METHOD super->constructor.
        no = im_no.
        name = im_name.
        monthly_salary = im_monthly_salary.
        monthly_deductions = im_monthly_deductions.
      ENDMETHOD.
      METHOD add_employee.
      Calculate wage an call the superclass method add_employee to add
      the employee to the employee list
        DATA: l_wage TYPE i.
        l_wage = monthly_salary - monthly_deductions.
        CALL METHOD super->add_employee
          EXPORTING im_no = no
                    im_name = name
                    im_wage = l_wage.
      ENDMETHOD.
    ENDCLASS.
    R E P O R T
    DATA:
    Object references
      o_bluecollar_employee1  TYPE REF TO lcl_bluecollar_employee,
      o_whitecollar_employee1 TYPE REF TO lcl_whitecollar_employee.
    START-OF-SELECTION.
    Create bluecollar employee obeject
      CREATE OBJECT o_bluecollar_employee1
          EXPORTING im_no  = 1
                    im_name  = 'Gylle Karen'
                    im_hours = 38
                    im_hourly_payment = 75.
    Add bluecollar employee to employee list
      CALL METHOD o_bluecollar_employee1->add_employee
          EXPORTING im_no  = 1
                    im_name  = 'Gylle Karen'
                    im_wage = 0.
    Create whitecollar employee obeject
      CREATE OBJECT o_whitecollar_employee1
          EXPORTING im_no  = 2
                    im_name  = 'John Dickens'
                    im_monthly_salary = 10000
                    im_monthly_deductions = 2500.
    Add bluecollar employee to employee list
      CALL METHOD o_whitecollar_employee1->add_employee
          EXPORTING im_no  = 1
                    im_name  = 'Karen Johnson'
                    im_wage = 0.
    Display employee list and number of employees. Note that the result
    will be the same when called from o_whitecollar_employee1 or
    o_bluecolarcollar_employee1, because the methods are defined
    as static (CLASS-METHODS)
      CALL METHOD o_whitecollar_employee1->display_employee_list.
      CALL METHOD o_whitecollar_employee1->display_no_of_employees.
    The resulting report
    List of Employees
    1 Karen Johnson 2.850
    2 John Dickens 7.500
    Total number of employees: 2
    3. Interfaces
    This example is similiar to th eprevious example, however an interface is implemented with the method add_employee. Note that the interface is only implemented in the superclass ( The INTERFACE stament), but also used in the subclasses.
    The interface in the example only contains a method, but an iterface can also contain attrbutes, constants, types and alias names.
    The output from example 3 is similiar to the output in example 2.
    All changes in the program compared to example 2 are marked with red.
    REPORT zbc404_hf_events_3 .
          INTERFACE lif_employee
    INTERFACE lif_employee.
      METHODS:
        add_employee
           IMPORTING im_no   TYPE i
                      im_name TYPE string
                      im_wage TYPE i.
    ENDINTERFACE.
    Super class LCL_CompanyEmployees
    CLASS lcl_company_employees DEFINITION.
      PUBLIC SECTION.
        INTERFACES lif_employee.
        TYPES:
          BEGIN OF t_employee,
            no  TYPE i,
            name TYPE string,
            wage TYPE i,
         END OF t_employee.
        METHODS:
          constructor,
         add_employee      "Removed
            IMPORTING im_no   TYPE i
                      im_name TYPE string
                      im_wage TYPE i,
          display_employee_list,
          display_no_of_employees.
      PRIVATE SECTION.
        CLASS-DATA: i_employee_list TYPE TABLE OF t_employee,
                    no_of_employees TYPE i.
    ENDCLASS.
    *-- CLASS LCL_CompanyEmployees IMPLEMENTATION
    CLASS lcl_company_employees IMPLEMENTATION.
      METHOD constructor.
        no_of_employees = no_of_employees + 1.
      ENDMETHOD.
      METHOD lif_employee~add_employee.
      Adds a new employee to the list of employees
        DATA: l_employee TYPE t_employee.
        l_employee-no = im_no.
        l_employee-name = im_name.
        l_employee-wage = im_wage.
        APPEND l_employee TO i_employee_list.
      ENDMETHOD.
      METHOD display_employee_list.
      Displays all employees and there wage
        DATA: l_employee TYPE t_employee.
        WRITE: / 'List of Employees'.
        LOOP AT i_employee_list INTO l_employee.
          WRITE: / l_employee-no, l_employee-name, l_employee-wage.
        ENDLOOP.
      ENDMETHOD.
      METHOD display_no_of_employees.
      Displays total number of employees
        SKIP 3.
        WRITE: / 'Total number of employees:', no_of_employees.
      ENDMETHOD.
    ENDCLASS.
    Sub class LCL_BlueCollar_Employee
    CLASS lcl_bluecollar_employee DEFINITION
              INHERITING FROM lcl_company_employees.
      PUBLIC SECTION.
        METHODS:
            constructor
              IMPORTING im_no             TYPE i
                        im_name           TYPE string
                        im_hours          TYPE i
                        im_hourly_payment TYPE i,
             lif_employee~add_employee REDEFINITION..
      PRIVATE SECTION.
        DATA:no             TYPE i,
             name           TYPE string,
             hours          TYPE i,
             hourly_payment TYPE i.
    ENDCLASS.
    *---- CLASS LCL_BlueCollar_Employee IMPLEMENTATION
    CLASS lcl_bluecollar_employee IMPLEMENTATION.
      METHOD constructor.
      The superclass constructor method must be called from the subclass
      constructor method
        CALL METHOD super->constructor.
        no = im_no.
        name = im_name.
        hours = im_hours.
        hourly_payment = im_hourly_payment.
      ENDMETHOD.
      METHOD lif_employee~add_employee.
      Calculate wage an call the superclass method add_employee to add
      the employee to the employee list
        DATA: l_wage TYPE i.
        l_wage = hours * hourly_payment.
        CALL METHOD super->lif_employee~add_employee
          EXPORTING im_no = no
                    im_name = name
                    im_wage = l_wage.
      ENDMETHOD.
    ENDCLASS.
    Sub class LCL_WhiteCollar_Employee
    CLASS lcl_whitecollar_employee DEFINITION
        INHERITING FROM lcl_company_employees.
      PUBLIC SECTION.
        METHODS:
            constructor
              IMPORTING im_no                 TYPE i
                        im_name               TYPE string
                        im_monthly_salary     TYPE i
                        im_monthly_deductions TYPE i,
             lif_employee~add_employee REDEFINITION.
      PRIVATE SECTION.
        DATA:
          no                    TYPE i,
          name                  TYPE string,
          monthly_salary        TYPE i,
          monthly_deductions    TYPE i.
    ENDCLASS.
    *---- CLASS LCL_WhiteCollar_Employee IMPLEMENTATION
    CLASS lcl_whitecollar_employee IMPLEMENTATION.
      METHOD constructor.
      The superclass constructor method must be called from the subclass
      constructor method
        CALL METHOD super->constructor.
        no = im_no.
        name = im_name.
        monthly_salary = im_monthly_salary.
        monthly_deductions = im_monthly_deductions.
      ENDMETHOD.
      METHOD lif_employee~add_employee.
      Calculate wage an call the superclass method add_employee to add
      the employee to the employee list
        DATA: l_wage TYPE i.
        l_wage = monthly_salary - monthly_deductions.
        CALL METHOD super->lif_employee~add_employee
          EXPORTING im_no = no
                    im_name = name
                    im_wage = l_wage.
      ENDMETHOD.
    ENDCLASS.
    R E P O R T
    DATA:
    Object references
      o_bluecollar_employee1  TYPE REF TO lcl_bluecollar_employee,
      o_whitecollar_employee1 TYPE REF TO lcl_whitecollar_employee.
    START-OF-SELECTION.
    Create bluecollar employee obeject
      CREATE OBJECT o_bluecollar_employee1
          EXPORTING im_no  = 1
                    im_name  = 'Gylle Karen'
                    im_hours = 38
                    im_hourly_payment = 75.
    Add bluecollar employee to employee list
      CALL METHOD o_bluecollar_employee1->lif_employee~add_employee
          EXPORTING im_no  = 1
                    im_name  = 'Karen Johnson'
                    im_wage = 0.
    Create whitecollar employee obeject
      CREATE OBJECT o_whitecollar_employee1
          EXPORTING im_no  = 2
                    im_name  = 'John Dickens'
                    im_monthly_salary = 10000
                    im_monthly_deductions = 2500.
    Add bluecollar employee to employee list
      CALL METHOD o_whitecollar_employee1->lif_employee~add_employee
          EXPORTING im_no  = 1
                    im_name  = 'Gylle Karen'
                    im_wage = 0.
    Display employee list and number of employees. Note that the result
    will be the same when called from o_whitecollar_employee1 or
    o_bluecolarcollar_employee1, because the methods are defined
    as static (CLASS-METHODS)
      CALL METHOD o_whitecollar_employee1->display_employee_list.
      CALL METHOD o_whitecollar_employee1->display_no_of_employees.
    4. Events
    This is the same example as example 4. All changes are marked with red. There have been no canges to the subclasses, only to the superclass and the report, sp the code for th esubclasses is not shown.
    For a simple example refer to Events in Examples.
    REPORT zbc404_hf_events_4 .
          INTERFACE lif_employee
    INTERFACE lif_employee.
      METHODS:
        add_employee
           IMPORTING im_no   TYPE i
                      im_name TYPE string
                      im_wage TYPE i.
    ENDINTERFACE.
    Super class LCL_CompanyEmployees
    CLASS lcl_company_employees DEFINITION.
      PUBLIC SECTION.
        TYPES:
        BEGIN OF t_employee,
          no  TYPE i,
          name TYPE string,
          wage TYPE i,
       END OF t_employee.
      Declare event. Note that declaration could also be placed in the
      interface

  • Shifting from procedural to object oriented

    Hi people,
    I've been programming in ABAP in a procedural fashion since I started, because that's the way I was taught. Now I want to slowly shift to object oriented development. I know and understand all object oriented concepts (please don't copy paste OOP explanations or links merely to get points). Problem is, in the projects i'm involved everything is done in the old fashion. There's no use of UML whatsoever. I believe it's very difficult to shift my mind to OOP (an already difficult task for someone programming procedural for years) if the analisys and design is not done with OO as the base, as additionally I have very little practical experience with OOP (using ALV classes and such). If every other programmer does things in procedural way, when the time comes to integrate programs, problems arise.
    I've been experimenting with OOP in my safe minisap at home, but in day to day work as pressure is put to finish programs on time, always procedural solutions come to mind.
    Do you have any advice on how to cope with this? Can you post your experience on this subject? Has someone gone through this same problems?
    Many thanks.

    Hello Alejandro
    When I started with object-oriented ABAP programming about 2 years ago I made horrible mistakes in my classes and interfaces. However, I have my lessons learnt from these mistakes and improved my skills and knowledge step by step.
    I have 3 recommendations for you:
    <b>(1) Start now!</b>
    Do not expect to develop perfect interfaces and classes from the very beginning. Understanding Object-Orientation takes its time.
    <b>(2) Start with simple objects.</b>
    Interfaces (or classes) can be used to define globally visible constants. Your first classes may contain only static methods. Yet while developing these "simple" objects you will get familiar with the class builder (SE24).
    <b>
    (3) Make heavy use of SAP standard classes.</b>
    Before creating your own class(es) make a comprehensive search for available standard classes (of course, if you are dealing with custom-developed business objects you have to create your own classes).
    For example, if you have to work with purchase orders have a look at the following classes:
    - CL_PO_HEADER_HANDLE_MM
    - CL_PO_ITEM_HANDLE_MM
    If you create an instance of CL_PO_HEADER_HANDLE_MM you will have thousands of coding lines at your fingertip (e.g. method IF_PURCHASE_ORDER_MMGET_DATA returns the header data, method IF_PURCHASE_ORDER_MMGET_ITEMS returns the  order items -> no need of coding, just CALLING).
    Finally, you may have a look at the following examples:
    <a href="https://wiki.sdn.sap.com/wiki/display/profile/2007/07/09/UnderstandingABAPObjects">Understanding ABAP Objects</a>
    <a href="https://wiki.sdn.sap.com/wiki/display/profile/2007/07/09/MessageHandling-FindingtheNeedleintheHaystack">Message Handling - Finding the Needle in the Haystack</a>
    <a href="https://wiki.sdn.sap.com/wiki/display/Snippets/UnifiedAccesstoAllHR+Infotypes">Unified Access to All HR Infotypes</a>
    Regards
      Uwe

Maybe you are looking for

  • How can I set up two iCloud accounts

    I want to set up two different iCloud accounts for my wife and I. We both use the same account for buying apps but we want different iCloud accounts. How do I do that? Can I do that?  Thanks for the help!

  • JBL PowerUp Speaker Power Cord

    I have a JBL powerup speaker, and I love it, however theower cord that came with it is one of those that has a switchable outlet, which broke and now causes the device to go on and off unless held in place. Is there anyone who knows where exactly I c

  • Which modem should I buy?

    Hi all, I use my apple TC for my home network and this is plugged into a pretty basic netgear modem. I've recently had an internet issue and have identified that the problem is the modem so i'm after some advice as to which modem I should buy to repl

  • Question from functional consultant

    Hi I was working on a report under report writer transaction code GR32. I was suppose to make a small change but actually I made lot of changes to fix one issue or other.Now the report is not usable.Is it possible for a basis guys to restore the orig

  • {Edited per forum guidelines} Need assistance NOW‏

    Best Buy I am appalled by the lack of empowerment your associates are given. After an hour of being told "no" by your in-store associates about a replacement phone which was approved for junk out replacement, I now have to deal with the product being