Abap oo concepts

Hi,
I have used this code in my prog.I got "Cref is not an object reference" error..how to rectify it..please help if u know...
data:cref type ref to c1.
create object cref.

Hi Kavitha,
For this u have to create a class with name zaccountMA in the
se24 class builder
or u have to define it locally in your program.
check this code .
In this i define the class locally.
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 DEFINITION
*--- 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.                    "constructor
  METHOD display_employee.
    WRITE:/ 'Employee', g_employee-no, g_employee-name.
  ENDMETHOD.                    "display_employee
  METHOD display_no_of_employees.
    WRITE: / 'Number of employees is:', g_no_of_employees.
  ENDMETHOD.                    "display_no_of_employees
ENDCLASS.                    "lcl_employee IMPLEMENTATION
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.
Regards
Manoj Kumar

Similar Messages

  • Best Practice: Usage of the ABAP Packages Concept?

    Hi SDN folks,
      I've just started on a new project - I have significant ABAP development experience (15 years+) - but one thing that I have never seen used correctly is the Package concept in ABAP - for any of the projects that I have worked on.
    I would like to define some best practices - about when we should create packages - and about how they should be structured.
    My understanding of the package concept is that they allow you to bundle all of the related objects of a piece of development work together. In previous projects - and almost every project I have ever worked on - we just have packages ZBASIS, ZMM, ZSD, ZFI and so on. But this to me is a very crude usage of packages, and really it seems that we have not moved on passed the 4.6 usage of the old development class concept - and it means that packages do not really add much value.
    I read in the SAP PRESS Next Generation ABAP book (Thomas Ljung, Rich Hellman) (I only have the 1st edition) - that we should use packages for defining separation of concern for an application. So it seems there they are recommending that for each and every application we write - we define at the least 3 packages - one for Model, one for Controller and one for view based objects. It occurs to me that following this approach will lead to a tremendous number of packages over the life cycle of an implementation, which could potentially lead to confusion - and so also add little value. Is this really the best practice approach? Has anyone tried this approach across a full blown implementation?
    As we are starting a new implementation - we will be running with 7 EHP2 and I would really like to get the most out of the functionality that is provided. I wonder what others have for experience in the definition of packages.
    One possible usage occurs to me that you could define the packages as a mirror image of the application business object class hierarchy (see below). But perhaps this is overcomplicating their usage - and would lead to issues later in terms of transportation conflicts etc.:
                                          ZSD
                                            |
                    ZSOrder    ZDelivery   ZBillingDoc
    Does anyone have any good recommendations for the usage of the ABAP Package concept - from real life project experience?
    All contributions are most welcome - although please refrain from sending links on how to create packages in SE80
    Kind Regards,
    Julian

    Hi Julian,
    I have struggled with the same questions you are addressing. On a previous project we tried to model based on packages, but during the course of the project we encountered some problems that grew overtime. The main problems were:
    1. It is hard to enforce rules on package assignments
    2. With multiple developers on the project and limited time we didn't have time to review package assignment
    3. Devopelers would click away warnings that an object was already part of another project and just continue
    4. After go-live the maintenance partner didn't care.
    So, my experience is is that it is a nice feature, but only from a high level design point of view. In real life it will get messy and above all, it doesn't add much value to the development. On my neew assignment we are just working with packages based on functional area and that works just fine.
    Roy

  • ABAP related concepts

    Hi All
    Could any body tell me wat all ABAP related concepts should a SD consultant know when working in support and implementation projects?

    hi,
    first and foremost is you should very comfortable in understanding the SD tables and how the data flows through them. Also you must be conversant with the important fields of these tables to start with.
    check this link for SD table flows :
    [sdtables|http://www.erpgenie.com/abap/tables_sd.htm]
    the others things would be
    1) to be able to prepare a good functional spec
    2) Decision making skill whether to do somehting in config or go for customization depending on the implications of a particular scenario after discussing with abapers.
    3) Understand output related developement work, in terms of driver program and screen layouts.
    4) To be able to locate userexits for your requirements and give a proper logic to work with. Generally the problem comes when you try to hard code something which is not so advisable and to eliminate this, a good logic based on the business requirement needs to derived which you again need to translate it to the abaper.
    regards
    sadhu kishore

  • HR-ABAP-Infotypes concept

    Hi Masters,
                           Can you please let me know the perfect reason for infotypes concept in HR-ABAP.
    1 Why we are using infotypes and exactly what is purpose?
    2.Why we are using LDB's why cannot we extract data directly from database tables?
    3.Can you please give me clear explanations about these infotypes.

    Hi
    Infotype(s) are used in the Personnel Management (PA) module primarily. This is where personnel master data is stored. Data is grouped according to subject matter. The Human Resources component aims to enable the user to process employee data in an effective structure in accordance with business requirements. The data structure of infotypes mirrors a logical set of data records. Infotypes can be identified by their four-digit keys, for example, the Addresses infotype (0006). To facilitate reporting on past employee data, infotypes can be saved for specific periods.
    Some people use the term HR ABAP to describe the method of managing the infotype data. Typically HR logical databases are used which offers more secure methods of accessing the infotype data. Once the infotypes are declared, you can use standard macros to access the data. Table TRMAC holds the macro name and the code behind it. This makes developing HR programs much quicker and easy to turn around.
    HR uses INFOTYPES instead of tables.
    There are different sub modules exist in HR.
    For Personal Admn the Infotypes start with PA0000 to PA1999
    Time Related Infotypes start with PA2000 to PA2999.
    Orgn related Infotypes start with HRP1000 to HRP1999.
    All custom developed infotypes stsrat with PA9000 onwards.
    In payroll processing we use Clusters like PCL1,2,3 and 4.
    Instead of Select query we use PROVIDE and ENDPROVIDE..
    You have to assign a Logical Database in the attributes PNP.
    Go through the SAp doc for HR programming and start doing.
    http://www.sapdevelopment.co.uk/hr/hrhome.htm
    See:
    http://help.sap.com/saphelp_46c/helpdata/en/4f/d5268a575e11d189270000e8322f96/content.htm
    http://help.sap.com/saphelp_47x200/helpdata/en/bb/bdb041575911d189240000e8323d3a/frameset.htm
    see this link you would get information about types of infotypes
    Logical databases are special ABAP programs that retrieve data and make it available toapplication programs. The most common use of logical databases is still to read data fromdatabase tables by linkin them to executable ABAP programs.
    Logical databases contain Open SQL statements that read data from the database.You do not therefore need to use SQL in your own programs. The logical database reads theprogram, stores them in the program if necessary, and then passes them line by line to theapplication program or the function module LDB_PROCESS using an interface work area .
    For further info
    check link http://help.sap.com/saphelp_nw70/helpdata/en/9f/db9b5e35c111d1829f0000e829fbfe/frameset.htm
    1. A logical database is in fact
    a program only.
    2. This LDB provides two main things :
    a) a pre-defined selection screen
    which handles all user inputs and validations
    b) pre defined set of data
    based upon the user selection.
    3. So we dont have to worry about from
    which tables to fetch data.
    4. Moreover, this LDB Program,
    handles all user-authorisations
    and is efficient in all respects.
    5. tcode is SLDB.
    /people/srivijaya.gutala/blog/2007/03/05/why-not-logical-databases
    <b>REward fi suefull</b>

  • ABAP webdynpro concepts

    If i want to work with ABAP webdynpro,
    what are all main areas or concepts to be covered in ABAP webdynpro?

    Hi,
    Go through the below links,
    Notes:   https://www.sdn.sap.com/irj/sdn/developerareas/webdynpro?rid=/webcontent/uuid/512040e1-0901-0010-769c-c238c6ca35d9 [original link is broken]
    Wiki : https://wiki.sdn.sap.com/wiki/display/WDABAP
    https://wiki.sdn.sap.com/wiki/display/WDABAP/NewtoWebDynproABAP
    and also links,
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/media/uuid/263c6874-0701-0010-3996-8266a631fead?prtmode=navigate
    /people/marilyn.pratt/blog/2005/12/20/web-dynpro-for-abap
    Regards,
    Azaz Ali.

  • ABAP & Java Concepts required for SAP-NW XI/PI

    Hi Experts,
        As a fresher, I want to start a career in SAP ans SAP Netweaver- XI/PI. After going through some blogs, forum, sap stuff etc, I came to know the prerequisites for XI is both ABAP and Java...
    But I am not sure which concepts in ABAP and Java are required for an SAP XI consultant, as I see SAP itself is an Ocean. So Apart from XI concepts , what are all the concepts needed in ABAP and Java.
    As for XI concepts are concerned there is a lot of stuff in SDN itself. Only thing is, one shd have patience to search and proper guidance while learning.
    Regards,
    Guru

    >
    Guru Bhai wrote:
    > Where and when do we need ABAP and Java in XI
    something quite common a question but here is a small desc.
    ABAP -
    for scenarios involving, IDoc, RFC, ABAP proxies and ABAP mappings
    Java -
    Core java - UDFs in graphical mapping
    advanced - java mapping, adapter modules, java proxies etc

  • ABAP OOPs concept

    why u want Events and whts the use of it in ABAP OOPs concept

    Locked for the same reason the others are
    And please don't use textspeak.
    Rob

  • Doubt in abap oo concepts

    Hi,
    I have created internal table based on mseg db table.can i use select query inside method implementation.how to write itab contents.please help if u know.
    thanks
    kavitha

    Check the code
          CLASS zcl_event_handler IMPLEMENTATION
    CLASS zcl_event_handler IMPLEMENTATION.
    Top-of-page event
      METHOD top_of_page.
        PERFORM event_top_of_page
                USING z_dyndoc_id.
      ENDMETHOD.   "METHOD top_of_page
    Change Status Button
      METHOD handle_toolbar.
        IF NOT pa_prodr IS INITIAL.
          DATA: lz_toolbar  TYPE stb_button.
          CLEAR lz_toolbar.
          MOVE    'CHANGE_STATUS'  TO lz_toolbar-function.
          MOVE    text-001         TO lz_toolbar-text.
          APPEND  lz_toolbar       TO e_object->mt_toolbar.
        ENDIF.          "IF NOT pa_prodr IS INITIAL
      ENDMETHOD.   "METHOD handle_toolbar
    Handle User Command
      METHOD handle_user_command.
        CASE e_ucomm.
          WHEN 'CHANGE_STATUS'.
            LOOP AT    it_output
                 INTO  wa_output.
              IF wa_output-chk_box EQ kc_x.
                z_flag = 1.
                EXIT.
              ENDIF.          "IF wa_output-chk_box EQ kc_x
            ENDLOOP.      "LOOP AT it_output INTO  wa_output
            IF z_flag EQ 1.
              PERFORM display_selected_data.
            ELSE.
              MESSAGE i001(zzrefn01)
                      WITH text-023.
            ENDIF.       "IF z_flag EQ 1
        ENDCASE.      "CASE e_ucomm
      ENDMETHOD.   "METHOD handle_user_command
    ENDCLASS.   "zcl_event_handler IMPLEMENTATION

  • ABAP programming concept

    I have created a program with its name not beginning with letter 'z' or 'y' and it ran perfectly without any error. Though it prompted error in other cases as in objects, structures  etc.So i want to know what can be the cause of it? Is it a bug in the software.? Please explain. I repeat it is only the case with the program name and not anything else?

    No problem, we were all beginners at one time.
    MY... and MZ... are actually in the customer name range, these are supposed to be includes for module pools SAPMY... and SAPMZ...
    Thomas
    P.S. [check this out|http://help.sap.com/saphelp_nw70/helpdata/EN/2a/6b0b1f547a11d189600000e829fbbd/frameset.htm]

  • Need to Learn ABAP OO and Workflow concepts.

    Hello Mates,
    I am just a 2 weeks old in Sap - ABAP, I was working on MS-.NET.
    But somehow ABAP is attracting me more than any other  language, I did certification as well.
    But somehow I am not able to understand the ABAP OO concepts inregards to workflow and exactly how to apply.
    I am reading every thread related to this from last 3 weeks now but didnt get any link/satisfactory answer to how to enhance my skill and use my OO knowledge of .NET in ABAP.
    I am very much familiar with OO concepts and dont want to read those again, but what I exactly want to read about
    1. THE SIGNIFICANCE OF OO IN ABAP.
    2. WHERE TO APPLY/ MAY BE HOW TO USE THOSE.
    3. ANYTHING RELATED TO ABAP WORKFLOW.
    if anyone used/or have knowledge of any such book/forum/blog/posts/sdn.forum/ please do let me know.
    This will help me in great level.
    Please do let me know, any kind of suggestions/critisism are welcome.
    I trust in your critisism also there will be something to read.
    Please post.
    Thanks and Regards,
    Ravindra Sonar.

    Your behavior is the only thing that counts here. And you look like a nice guy. If you would like to drop me a line in future, you can do that, I don´t mind, maybe we could find topics to talk about. And about that abap feature/ future post... I don´t care about the points (I don´t ask for any...) but the points count is the indicator of ones behavior:
    The guy, who always asks and nobody answers is selfish and not a candidate for me to answer. You must help to get helped, that is my motto. You must prove you´re worth the time and effort.
    I asked a question under B1 forum once where the top 1 contributor there tried hard to help because he knew I am active around here. That was a nice feeling. And from my point of view... get some points to prove you´re a nice guy and I will do my best to help you with any problem that may appear. I am not the only one who thinks this way, I think.
    But that is not a rule here, just my opinion.
    Maybe... one day, you will remember my words and write a blog for the beginners or help in some way to pay back what you have learnt here. Become a member of the community, spread the knowledge... and let´s talk:))
    Have a nice day, Otto

  • Learn New concepts in ABAP

    Dear Experts,
    I Have 3 more years of experience in SAP ABAP - Reports, Enhancements, BAPI, BADI, Forms, Etc...May i know how to improve my self.
    i plan to learn ABAP advance concepts, Please sugges suitable thing and it should be give bright feature for me.
    Please give your valuable suggestion.
    Thanks in Advance,
    Jayakumar.M
    Edited by: Jayakumar on Jul 22, 2009 8:39 AM

    You can start with the community contributed [eLearning titles|https://www.sdn.sap.com/irj/scn/abap-elearning].
    We have also recently launched [Learning on Demand by SAP |http://learningondemandbysap.com]which provides ready access to a variety of ABAP related courses.

  • ABAP OBJECTS FAQ

    Hi All SDN menbers,
    I am Pankaj Sinha learning ABAP-oops concept.Actually i want good faq on oop in abap(abap objects),So Any have good faq in ooa,Please send me as soon as possible,My mail id is [email protected]
    Thanks
    Pankaj.

    hi,
    <u>OOPS Sample Standard Programs.</u>
    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
    some helful links.
    Go through the below links,
    <u>For Materials:</u>
    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
    Regards
    Reshma

  • ABAP WEBDYNPRO - What is it all about ?

    Hi Guys & Gals,
    I am doing ABAP for last 5 years. Planning to learn ABAP WEBDYNPRO from any SAP education partner. But i don't know JAVA and Classes and Methods(Scared of these).
    1. Can i cope with ABAP WEBDYNPRO ?
    2. Is it more programming or layout design or configuration or what it is ?
    3. How is the scope ?
    Kindly provide as much info as you can. I should decide quickly will it fit for me or not.
    Thanks
    Raj

    Hi Raj kumar,
    Welcome to Web Dynpro for ABAP forum.
    As you said you have good knowledge of ABAP.That is enough to learn WDA.But you should aware of ABAP OO concepts prior learning WDA.No need to think about java classes.
    There are many threads,articles and sap documents to learn Web Dynpro for ABAP.You can easily learn through them.If you have any doubts you can post in this forum to get clarification.

  • Doubts on casting concepts in TAW12 part 1

    Can someone help me clarify a little confusion on Casting in materials provided by SAP Education on TAW12 part 1.
    I attended ILT and my instructor emphasized that: "wherever in this material we read 'Up-cast' or 'Down-cast', we should consider this as an error because what they meant to say is exactly the opposite".
    This has now left me confused especially after revising.
    Can someone please share some light on these terminologies and concept? especially in relation to materials provided on TAW12 ABAP Workbench Concept Part 1 (2013 SAP AG. All rights reserved)
    I have not been able to find much materials online for this section of the book and for many others.
    Any help would be greatly appreciated.
    Vince

    Hi Vince,
                   First thing, STOP worrying about the SAP material whether the contain is right/wrong.
                  Now, what I understand is that the instructor tried to explain the concepts in a easy way to remember but has that seems to have messed up your basics on up-cast & down-cast.
    I have looked in my sap material ( but its 2005 SAP AG reserved ).  The definition are fine.
    Anyways I'll try to explain in my style:
    Narrow casting( up-casting ):- Assigning of a subclass instance to a reference variable of type " reference to super class ". Here we navigate from a more detailed view to one with less details.
    Widening Cast( down-cast ):-  Assigning a super class to a sub class. From a less detailed view to more detailed view.
                             SUPER CLASS( vehicle ) less details
                                       |
                                       |
                                       |
                                SUB CLASS ( car, truck, bus, bike ) more details
    PS:- Try to understand the meaning from the example and then go back to the definition in the material.

  • OO ABAP + Performance

    Hi all…
    I have recently started working in an organization as an ABAP programmer. Earlier, as part of my curriculum, I have designed a couple of systems using UML and coded the same in JAVA. Having worked on OO systems, I have a few questions to ask about ABAP and Web AS.
    1) Does a company implementing SAP 6.0/ECC 6 have to decide in advance whether it will be coding its business logic/applications in JAVA or ABAP? Or Wes AS can process both languages once installed.
    2) If a program is written in OO ABAP as well as in JAVA for a given business scenario (using the same OO (UML) structure) and executed on a Web AS, which one will perform better? Why?
    3) Why is it that organizations, in spite of the visible benefits of OO programming, are unwilling to let go of procedural ABAP and adapt OO ABAP? Anyways, they don’t have to convert their existing code but just to begin any new development using OO concepts. Is it because programs written in ABAP are usually not that complex to be modeled in OO concepts or there are not many people who know both ABAP and OO concepts.
    Regards,
    Anoop Sahu

    1) If a company is implementing ECC, it is all written in ABAP.  THe R/3(ECC) backend system is comprised entirely in ABAP,  so there is no decision,  if you want to develop an application in ECC(R/3), you use ABAP.  If you want to develop a java based application to access the ECC backend, you may do so using tools like jCo and JCA, and the webdynpro java environment supplies tools for you to access the backend.  You can not directly access the ABAP backend data/tables from a java application, you must use the data access tools mentioned.  Of course you need the java add on, or a standalone java application server to do this.
    3)  A lot of shops are used to the procedural ABAP model and have not yet had a need to implement an application using OO concepts,  there are advantages, but an application does not have to use it.  In some cases, it is a better way to go, but really it is all about the design,  using ABAP OO is really not worth it without a good design.  It is advantagious for ABAPers to imbraced ABAP OO concepts as this will be the design paradigm of future developments in ECC. In order to understand how a standard program works, they will need to know OO concepts.
    Regards,
    Rich Heilman

Maybe you are looking for

  • How to restrict data for selection

    Hi, folk, I've faced with the following issue. I have set of items. There are, for example, income items and expense items. Items are distinguished by value of attribute. According to business process, planning for income and expense items is quite d

  • Windows 7 partition has died. now what?

    so ive been running windows 7 in bootcamp with no real issues for a month or so. great. today i try to boot into windows and i get an error report screen saying that some new software or hardware may be causing startup to fail (of course, not specify

  • Authentication and authorization for a custom connector

    I have the following problem: I have a software which tries to connect with the server through its own custom RMI connector. So I have the  RMI Connector deployed via Mlet-Service. I have written a small TestClient and can get a RemoteMBeanServer  wi

  • Netflix slow on MAC, speedy on Win 7 PC

    Hi, I am trying to get my macbook pro i5 to play streaming netflix. I used to do it on my win7 HP laptop for some time and it works nice. on my mac, quality went down, when I tried to figure out why, I found out that the netflix stream is of lower qu

  • Error in RE contract

    Hello Experts, We are facing an eror in RE contract profit center determination. We have reviewed the earlier posts on profit center determination, however for us we are unable to save the contract. While creating contract: Contract level no profit c