ABAP OOP / Calling Method  ...Help

Trying out few oop codes....
While calling class instance methods and passing parameters, when to use the following syntax.
data: cvar  type ref to class1.
         cvar->method( exporting variable1 = value )
       (or) some time i see sample codes with out key  word 'exporting'
              cvar->method(  variable1 = value  ) .
       (or)
              cvar->method(  value  ) .
       (or) some times with key word CALL  METHOD
   CREATE OBJECT cvar
   CALL METHOD cvar->method
   EXPORTING
   variable1 = value. 
Tried out a uniform way of calling ,but getting errors.Any inputs please..
Thanks,
Bvan

Bhavan,
  First  declare the class.
  Implement the class.
Declare the Class reference variable
Create the class object.
call the method.
  data: cvar type ref to class1.
          CREATE OBJECT cvar
Calling Methods
To call a method, use the following statement:
CALL METHOD <meth> EXPORTING... <ii> =.<f i>...
                   IMPORTING... <ei> =.<g i>...
                   CHANGING ... <ci> =.<f i>...
                   RECEIVING         r = h
                   EXCEPTIONS... <ei> = rc i...
The way in which you address the method <method> depends on the method itself and from where you are calling it. Within the implementation part of a class, you can call the methods of the same class directly using their name <meth>.
CALL METHOD <meth>...
Outside the class, the visibility of the method depends on whether you can call it at all. Visible instance methods can be called from outside the class using
CALL METHOD <ref>-><meth>...
where <ref> is a reference variable whose value points to an instance of the class. Visible instance methods can be called from outside the class using
CALL METHOD <class>=><meth>...
where <class> is the name of the relevant class.
When you call a method, you must pass all non-optional input parameters using the EXPORTING or CHANGING addition in the CALL METHOD statement. You can (but do not have to) import the output parameters into your program using the IMPORTING or RECEIVING addition. Equally, you can (but do not have to) handle any exceptions triggered by the exceptions using the EXCEPTIONS addition. However, this is recommended.
You pass and receive values to and from methods in the same way as with function modules, that is, with the syntax:
... <Formal parameter> = <Actual parameter>
after the corresponding addition. The interface parameters (formal parameters) are always on the left-hand side of the equals sign. The actual parameters are always on the right. The equals sign is not an assignment operator in this context; it merely serves to assign program variables to the interface parameters of the method.
If the interface of a method consists only of a single IMPORTING parameter, you can use the following shortened form of the method call:
CALL METHOD <method>( f).
The actual parameter <f> is passed to the input parameters of the method.
If the interface of a method consists only of IMPORTING parameters, you can use the following shortened form of the method call:
CALL METHOD <method>(....<ii> =.<f i>...).
Each actual parameter <f i > is passed to the corresponding formal parameter <i i >.
Pls. mark if useful

Similar Messages

  • *JSP*Calling method *Help*

    Hello Every1,
    I have an JSP page, wich at the top of the page I have a method (Declared Global <%!%>), and at the buttom of tha page I have a JSP form which takes the users data, but I donr know how to call it, can any1 help me plaese, my JSP method is
         public void insertIntoCustomers(String Name, String userid, String Address,
                   String Email, String Password, String type) {
              Connection con = null;
              Statement stmt = null;
              ResultSet rs = null;
              try {
                   con = getDatabaseCon();
                   stmt = con.createStatement();
                   String queryText = "insert into customers values ('" + Name+ "', '" + userid + "','" + Address + "','" + Email + "','"+ Password + "','" + type + "')";
                   int i = stmt.executeUpdate(queryText);
              } catch (Exception ex) {
                   ex.printStackTrace();
         }and My jsp form is:
    <FORM METHOD="POST" ACTION="register">
                   <H1>test</H1><p>
                   Enter your name: <INPUT TYPE=TEXT NAME="name"> <BR>
                   Enter your address: <INPUT TYPE=TEXT NAME="address"> <BR>
                   Enter your email: <INPUT TYPE=TEXT NAME="email"> <BR>
                   Enter your password: <INPUT TYPE=TEXT NAME="password"> <BR><p>
                   <INPUT TYPE="SUBMIT" VALUE="Register">
    </FORM>
    my code:
    if (request.getParameter("action").equals("register")
    {//          String Name = request.getParameter("name");
              String Address = request.getParameter("address");
              String Email = request.getParameter("email");
              String Password = request.getParameter("password");
    }But I dont know how to link them to the method????
    Anyone can help me please,,,
    Thank you

    Hi,
    This:
    <html>
    <head><title></title>
    </head>
    <body>
    <FORM METHOD="POST" ACTION="register.jsp">
    <H1>test</H1>
    Enter your name: <INPUT TYPE=TEXT NAME="name"> <BR>
    Enter your address: <INPUT TYPE=TEXT NAME="address"> <BR>
    Enter your email: <INPUT TYPE=TEXT NAME="email"> <BR>
    Enter your password: <INPUT TYPE=TEXT NAME="password"> <BR>
    <INPUT TYPE="SUBMIT" VALUE="Register">
    </FORM>
    </body>
    </html>should be on a page called something like: getUserInfo.htm. The action attribute of the form tag should specify your .jsp page:
    <FORM METHOD="POST" ACTION="register.jsp">
    When the user clicks on submit, the information entered on the form automatically will be sent to register.jsp. Your register.jsp page will look like this:
    <%!
    public void insertIntoCustomers(String Name, String userid, String Address,
              String Email, String Password, String type) {
              Connection con = null;
              Statement stmt = null;
              ResultSet rs = null;
              try {
                   con = getDatabaseCon();
                   stmt = con.createStatement();
                   String queryText = "insert into customers values ('" + Name+ "', '" + userid + "','" + Address + "','" + Email + "','"+ Password + "','" + type + "')";
                   int i = stmt.executeUpdate(queryText);
              } catch (Exception ex) {
                   ex.printStackTrace();
    if (request.getParameter("action").equals("register.jsp")
              String Name = request.getParameter("name");
              String Address = request.getParameter("address");
              String Email = request.getParameter("email");
              String Password = request.getParameter("password");
              /****/ insertIntoCustomers(Name, Address, Email, Password);
    %>However, you have not defined Connection, Statement and ResultSet before using those names, so you are going to get errors.

  • Basic abap-oops material

    hi ,
    i am very new to abap-oops concepts please help me in getting the basic oops concept materials
    regards
    Nandini

    Refer these link,
    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
    Reward if found helpfull,
    Regards,
    K.Tharani.

  • I need  abap oops help docu?

    i need abap oops help docu?

    Hi Karthikeyan,
    Chk this standard Programs.
    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
    links for OO ABAP.
    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/
    some more materials.
    Go through the following Documents Links & Materials for ABAP Objects
    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
    /people/sap.user72/blog/2005/05/10/a-small-tip-for-the-beginners-in-oo-abap
    /people/ravikumar.allampallam/blog/2005/02/11/abap-oo-in-action
    /people/thomas.jung3/blog/2005/09/08/oo-abap-dynpro-programming
    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 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
    OO ABAP is nothing but a class-method apprach to write ABAP codes and define them : below are few of the informations which will be of help for a newbie :
    Types of attributes and the basic concepts :
    Public attributes
    Private attributes
    Instance attributes
    Static attributes
    Public methods
    Private methods
    Constructor method
    Static constructor
    Protected components
    Polymorphism
    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 <classname>-><attrbute>
    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.
    Reward points if helpful.
    Regards,
    Harini.S

  • CALL METHOD ABAP run SQL wrong

    Dear All
             I have a problem in ABAP connect SQL,Below is my code snippet sentence.
    CONCATENATE 'Insert Into [timportcortrol]'
                    '(zucode,zstate,zdate,zkind) Values('''
                      VG_PCID ''','''
                      '1'','''
                      SY-DATUM ''','''
                      '1' ''')'
                     INTO SQL.
        CALL METHOD OF REC 'Execute'
         EXPORTING #1 = SQL
         #2 = CON
         #3 = '1'.
    IF NOT SY-SUBRC = 0.
        MESSAGE I000 WITH 'Download  to [timportcortrol] failure,Please Check the SQL Connect!!! '.
        EXIT.
      ENDIF.
    Con:is the connect SQL String ,the connect SQL is Okay.
    I debug this code,when I used u2018Select u2026sentenceu2019,the program can work.if I  use u2018insert intou2019 then canu2019t work,but I copied the SQL of the u2018inset Into sentenceu2026u2019run it into SQL server then it can work also.
    And I found the SY-SUBRC eq u20182u2019.whatu2019s mean about of the sy-subrc eq u20182u2019.
    I think the insert into sentence in abap I have write the wrong ,but I canu2019t assurance.
    The Insert Into Sentence is:u2019 Insert Into [timportcortrol](zucode,zstate,zdate,zkind) Values('20080807094713','1','20080807','1')u2019
    Could you give me some advice for this issue?
    Thanks of all
    Sun.

    Have you checked whether it's a problem with mixed case?  Some SQL dialects are case sensitive.
    The not very helpful meanings of the sy-subrc value can be found in ABAP help.
    0 Successful processing of the method meth.
    1 Communication Error to SAP GUI.
    2 Error when calling method meth.
    3 Error when setting a property.
    4 Error when reading a property
    matt

  • Is it possible to call methods of JAVA objects from ABAP?

    Hi all,
    Does anyone know if it is possible to call methods of java classes from ABAP?
    Regards,
    Sukru

    Hi,
    Yes we can access the classes of JAVA in ABP.
    This is posible from version ECC 6 onward with NETWEAVER atrhcitecuture.
    Pls go through this link-
    http://help.sap.com/saphelp_nw04s/helpdata/en/84/54953fc405330ee10000000a114084/frameset.htm
    http://help.sap.com/saphelp_nw04s/helpdata/en/e1/b5443e02a9ab4186a6e1240a9a2455/frameset.htm
    Here also we use the JCO connector  objects
    These clearly show the methods to use JAVA.
    <removed_by_moderator_together_with_points>
    Regards
    Chandralekha
    Edited by: Julius Bussche on Jul 8, 2008 5:58 PM

  • ABAP Objects : calling one method from another class

    Hi,
    Can you please tell me how to call method from one class or interfce to another class.The scenario is
    I have one class CL_WORKFLOW_TASK, this class have interface IF_WORKFLOW_TASK & this interface have method IF_WORKFLOW_TASK~CLOSE. Now my requirement is ,
    There is another class CL_WORKFLOW_CHAIN ,this class have interface IF_WORKFLOW_CHAIN & this interface have method IF_WORKFLOW_CHAINCLOSE_ALL_PREDECESSORS. Now i have to write my code in this method but i have to use IF_WORKFLOW_TASKCLOSE method for closing the task.
    Can you please give me the code for the above .
    Please waiting for reply.

    Hi,
    You can use the concept of INHERITANCE  in this scenario.By using this concept, you can call all the public and protected  methods of class CL_WORKFLOW_TASK  in the required calss CL_WORKFLOW_CHAIN as per your requirement.
    Go through the  Introdctory(INHERITANCE) programming from this SAPHELP link.
    http://help.sap.com/saphelp_nw70/helpdata/en/1d/df5f57127111d3b9390000e8353423/content.htm
    I hope, it will help in you inresolving your problem.
    by
    Prasad GVK.

  • ABAP OO Doubt - validate call method.

    Hi experts
    I'm beginer in ABAP OO and i created this code :
    output-cep = ch_adrc_struc-post_code1.
                 TRY.
                     CREATE OBJECT lr_cep.
                   CATCH cx_ai_system_fault .
                 ENDTRY.
                 TRY.
                     CALL METHOD lr_cep->si_servico_cep_out
                       EXPORTING
                         output = output
                       IMPORTING
                         input  = input.
                   CATCH cx_ai_system_fault .
                 ENDTRY.
    My doubt is : How to know the call method worked?
    In call function i use = if sy-subrc = 0 for check the return but can i use it after call method ?
    thanks a lot.

    there is an importing which is used to get back data.
    once you process input then you can decide whether method worked or not.

  • Calling method of a custom infotype from ABAP

    Hi Experts,
    I am working on an application where i need to call a method of a custom defined infotype.
    I have done this -->
    1. Create a custom infotype 9111
    2. SAP creates a class of that infotype ZCL_HRPA_INFOTYPE_9111
    3. Inside this method there are few inherited method which provide me functionality of insert , update , delete
    i want to call methods IF_HRPA_INFTY_BL~MODIFY,
    IF_HRPA_INFTY_BL~INSERT
    However when i call these method from abap report this method does not work.
    where as when i try to insert an entry using PA30 transaction it works.
    Does anyone know why does this happen and what is the solution?
    Regards,
    Ashish Shah

    Had the same problem (probably copied from the same program). The answer is that you need to commit the work at the end using something like
    * Commit
    CALL METHOD busilog->flush
      EXPORTING
        no_commit = space.
    Here is an example of my code for IT0002 which works.
    *& Report  Z_TEST2
    REPORT  z_test2.
    DATA: a_masterdata_bl TYPE REF TO if_hrpa_masterdata_bl,
          p0002         TYPE p0002,
          lo_0002 TYPE REF TO cl_hrpa_infotype_0002,
          ls_p0002_ref TYPE REF TO data,
          container_tab    TYPE hrpad_infty_container_tab,
          container  TYPE REF TO if_hrpa_infty_container,
          message_handler TYPE REF TO cl_hrpa_message_list,
          infotype_logic TYPE REF TO if_hrpa_infty_bl,
          update_mode TYPE hrpad_update_mode VALUE 'XXX',
          lt_0002_container TYPE REF TO cl_hrpa_infotype_container,
          key TYPE pskey,
          l_is_ok          TYPE boole_d.
    FIELD-SYMBOLS <p0002> TYPE p0002.
    * get business logic from masterdata factory
    CALL METHOD cl_hrpa_masterdata_factory=>get_business_logic
      IMPORTING
        business_logic = a_masterdata_bl.
    * CATCH cx_hrpa_violated_assertion .
    *ENDTRY.
    *TRY.
    CALL METHOD a_masterdata_bl->read
      EXPORTING
        tclas           = 'A'
        pernr           = '508'
        infty           = '0002'
        begda           = sy-datum
        endda           = sy-datum
        no_auth_check   = 'X'
        message_handler = message_handler
      IMPORTING
        container_tab   = container_tab
        is_ok           = l_is_ok
    * CATCH cx_hrpa_violated_assertion .
    *ENDTRY.
    READ TABLE container_tab INTO container INDEX 1.
    lt_0002_container ?= container.
    TRY.
        CALL METHOD lt_0002_container->primary_record_ref
          IMPORTING
            pnnnn_ref = ls_p0002_ref.
      CATCH cx_hrpa_violated_assertion.
    ENDTRY.
    ASSIGN ls_p0002_ref->* TO <p0002>.
    MOVE-CORRESPONDING <p0002> TO key.
    break stantric.
    <p0002>-vorna = 'Rick'.
    container ?= lt_0002_container->modify_primary_record( <p0002> ).
    TRY.
        CREATE OBJECT lo_0002
          EXPORTING
            tclas = 'A'
            infty = '0002'.
      CATCH cx_hrpa_violated_assertion .
    ENDTRY.
    CREATE OBJECT message_handler.
    TRY.
        CALL METHOD lo_0002->get_specific_bl
          EXPORTING
            versionid      = '01'
            tclas          = 'A'
            pskey          = key
          IMPORTING
            infotype_logic = infotype_logic.
      CATCH cx_hrpa_violated_assertion .
    ENDTRY.
    TRY.
        CALL METHOD infotype_logic->modify
          EXPORTING
            old_container   = lt_0002_container
            massn           = space
            massg           = space
            update_mode     = update_mode
            no_auth_check   = 'X'
            message_handler = message_handler
          IMPORTING
            is_ok           = l_is_ok
          CHANGING
            container       = container.
      CATCH cx_hrpa_violated_assertion .
    ENDTRY.
    * Commit
    CALL METHOD a_masterdata_bl->flush
      EXPORTING
        no_commit = space.

  • Oop report programme:  call method

    hi, i need ur guys advice about my oop report.  its contain 2 class, lcl_main (main programme), lcl_disp(display report), lcl_update (upload report).  all 3 class defination as below:
    *                     C.L.A.S.S  D.E.F.I.N.I.T.I.O.N
    class lcl_main definition.
    public section.
      methods: init,
               get_filename,
               load_data,
               chk_col,
               chk_data,
               chk_mandatory,
               disp_status.
    endclass.
    class lcl_disp definition inheriting from lcl_main.
    public section.
      methods: chk_9700,
               disp_success.
    endclass.
    class lcl_update definition inheriting from lcl_main.
    public section.
      methods: update9700.
    endclass.
    the idea was, i planned to put all methods which will be access by lcl_disp and lcl_update into lcl_main.  i currently cofious to call method at lcl_main. currently i done as below, which if want to display (user will choose radio button display - p_view) i will create the object for lcl_disp and call all method in lcl_main and lcl_disp , for example o_disp-> init ... o_disp->loaddata .. and etc. the problem was if i want to choose the update , i need to object for lcl_update and call again the lcl_main with:  o_update-> init ... o_update->loaddata .. and etc. the code as below.
    the question , the programme can be successfully run with this method but i faced the problem when i tried to create a call method inside others method because at the START-OF-SELECTION i need to identify with object (lcl_disp or lcl_update) first.
    2nd, i tried to figure out how at the start-of-selection , i no need to repeat to call method init, loaddata repeatly for different class (lcl_disp and lcl_update). really need advice. thank you.
    *---------------------------------------------------------------------|
    *                       INITIALIZATION                                             |
    *---------------------------------------------------------------------|
    initialization.
    data: o_main type ref to lcl_main.
    create object: o_main.
    *                       START OF SELECTION                              *
    start-of-selection.
    data: o_disp type ref to lcl_disp,
            o_update type ref to lcl_update.
    create object: o_disp, o_update.
    if  p_view = 'X'. "for view report
      set handler o_handler->handle_event for all instances.
      call method o_disp->init.
      call method o_disp->load_data.
      call method o_disp->chk_col.
      "only proceeed if initial - col header and pernr syntax (pre 100 and length = 8)
        if o_disp->status = 0.
         call method o_disp->chk_data.
        endif.
         if o_disp->status = 0.
         call method o_disp->chk_mandatory.
        endif.
        if  o_disp->status = 0.
          call method o_disp->chk_9700.
        endif.
        call method o_disp->disp_status.
    elseif p_upld = 'X'."for update report
      set handler o_handler->handle_event for all instances.
      call method o_update->init.
      call method o_update->load_data.
      call method o_update->chk_col.
      "only proceeed if initial - col header and pernr syntax (pre 100 and length = 8)
        if o_update->status = 0.
         call method o_update->chk_data.
        endif.
        if  o_update->status = 0.
          call method o_update->update9700.
        endif.
        call method o_update->disp_status.
    endif.
    class lcl_main implementation.
      method get_filename.
    endmethod.
      method init.
      endmethod.
      method load_data.
    endmethod.
    method chk_col.
    endmethod.
    method chk_data.
    endmethod.
    method chk_mandatory.
    endmethod.
    method disp_status.
    endmethod.
    endclass.
    class lcl_disp implementation.
    method chk_9700.
    endmethod.
    method disp_success.
    endclass.
    class lcl_update implementation.
    method update9700.
    endmethod.
    endclass.
    Edited by: firdaus hashim on Nov 23, 2009 11:01 AM

    Hello Sam,
    Go to the class CL_DD_DOCUMENT (trxn SE24).
    In the 'Attributes' tab, check for the attributes with SDYDO_ATTRIBUTE as the associated type.
    It gives all the available attributes.
    BR,
    Suhas

  • Help me to call method in the mouselistener

    hi all expert,
    I have a program having code structure as following:
    public class A {
    public void methodA {
    //do something
    MouseListener mltree = new MouseAdapter(){
    //Where is I want to call methodA ,
    //I don't do like this: this.methodA because "this" is refer to mltree
    Anyone can help me,
    thanks verry much for your help in advance
    }

    That's unnecessary code, when you could just do this:public class A
      public void methodA()
        //do something
       MouseListener mltree = new MouseAdapter(){
        //I don't do like this: this.methodA because "this" is refer to mltree
        A.this.methodA();};

  • ALV using OOPS class CL_GUI_ALV_GRID, call method SET_TABLE_FOR_FIRST_DISPL

    I NEVER USED OOPS CONCEPT.BUT I GOT A TASK ON ALV REPORT USING class CL_GUI_ALV_GRID, call method SET_TABLE_FOR_FIRST_DISPLAY for ALV . I HAD PASSED THE VALUES FROM INTERNAL TABLE AND GOT OUTPUT IN ALV.
    The problem is When i save an layout(default setting button ).
    iam unable to get the output for all fields.
    if u want i will send screenshots to ur mail
    THANKS IN ADVANCE.

    ok fine,
    In the output (alv grid) there is an icon for layout settings.
    if i want to save layout (as DEFAULT SETTING) i am missing some fields in output
    EX:
    mat no | batch  | proces order | time  |  date |
    when i save layout (as DEFAULT SETTING) i am missing some fields in output
    mat no | batch  |
    the rest of the field were not displayed.
    if u are not clear just ask me. i will send some more examples.

  • Help In Call Method Using types Tables.

    dear gurus
    im having a problem in my code please help me
    TYPES: BEGIN OF itab,
              vtext TYPE tvfkt-vtext,
              fkart TYPE vbrk-fkart,
              fkdat TYPE vbrk-fkdat,
              vbeln TYPE vbrk-vbeln,
              END OF itab.
    DATA:  itab1 TYPE itab OCCURS 0 WITH HEADER LINE.
      DATA:  itab2 TYPE itab OCCURS 0 WITH HEADER LINE.
    SELECT *
        INTO CORRESPONDING FIELDS OF TABLE itab1
        FROM vbrk
        INNER JOIN vbrp ON vbrp~vbeln = vbrk~vbeln
        WHERE vbrk~fkart IN fkart
        AND   vbrk~fkdat IN fkdat
        AND   vbrp~vstel IN vstel
        AND   vbrk~kunag IN kunag
        AND   vbrp~matnr IN matnr.
    LOOP AT itab1.
        SELECT SINGLE vtext FROM tvfkt
          INTO itab1-vtext WHERE fkart EQ itab1-fkart
          AND spras EQ 'EN'.
        IF itab1-fkart EQ 'F2'.
          CONCATENATE 'Tax' itab1-vtext INTO itab1-vtext SEPARATED BY space.
        ENDIF.
        SELECT SINGLE bstkd FROM vbkd INTO itab1-bstkd
          WHERE vbeln EQ itab1-aubel.
        SELECT SINGLE name1 FROM kna1 INTO itab1-name1 WHERE
          kunnr EQ itab1-kunag.
        MODIFY itab1.
        COLLECT itab1 INTO itab2.
        MOVE-CORRESPONDING itab1 TO itab2.
        CLEAR itab1.
      ENDLOOP.
    LOOP AT itab2.
        SELECT SINGLE kbetr FROM konv INTO itab2-kbetr
        WHERE kschl EQ 'PR00'
        AND   knumv EQ itab2-knumv.
        itab2-kwert = itab2-fklmg * itab2-kbetr.
        itab2-gst   = itab2-kwert * 21 / 100.
        itab2-sed   = itab2-kwert * 1 / 100.
        itab2-gt    = itab2-kwert + itab2-gst + itab2-sed.
        MODIFY itab2.
      ENDLOOP.
    CALL METHOD w_handle->insert_full
            EXPORTING
              n_vrt_keys        = 1
              n_hrz_keys        = 1
              n_att_cols        = 3
              sema              = t_sema[]
              hkey              = t_hkey[]
              vkey              = t_vkey[]
              online_text       = t_online[]
              data              = itab2   " "ITAB2" is not type-compatible with formal parameter "DATA". <- ERROR
            EXCEPTIONS
              dim_mismatch_data = 1
              dim_mismatch_sema = 2
              dim_mismatch_vkey = 3
              error_in_hkey     = 4
              error_in_sema     = 5
              inv_data_range    = 6
              error_in_vkey     = 7.

    Hi,
    In your case, please change itab2 into itab2[].
    Because you defined itab2 with header line, itab2 means header line in the method call.
    Cheers,

  • ABAP Objects: Calling private Methods

    Hi,
    i would choose an private Method of an global class (for example class: CL_GUI_ALV_GRID private Method: SEARCH_START) in a local class.
    class lcl_test definition for testing.
      private section.
        methods test for testing.
      data ref_alv type ref to cl_gui_alv_grid.
    endclass.
    class lcl_test implementation.
      method for test.
        create object ref_alv ...
    * How to call a private Method?
    call method ref_alv->search_start( ). "not possible!   
      endmethod.
    endclass.
    Is this possible?
    Regards,
    Damir

    Damir, of course you can call a private method of a class, if this class has made you a friend with the syntax element FRIENDS (available since Release 6.10). Here is a syntactically correct example, when my_method is a private class method:
    REPORT test.
    CLASS mytest DEFINITION FOR TESTING.
      PRIVATE SECTION.
        METHODS test FOR TESTING.
    ENDCLASS.
    CLASS myclass DEFINITION FRIENDS mytest.
      PUBLIC SECTION.
        CLASS-METHODS my_method.
    ENDCLASS.
    CLASS myclass IMPLEMENTATION.
      METHOD my_method.
      ENDMETHOD.
    ENDCLASS.
    CLASS mytest IMPLEMENTATION.
      METHOD test.  
        CALL METHOD myclass=>my_method.
      ENDMETHOD.
    ENDCLASS.
    If my_method is not a class method, then you need to create an object of the class first, whose methods you want to test.
    Kind regards,
    Michael Kraemer

  • Scrolling Issue - ALV- ABAP OOPS!

    Hello All,
    I have a strange issue with regards to ALV developed using ABAP OOPS. I have more than 25 fields on the output screen.
    For each field on output screen, F4 help is possible. So when I scroll to the right most fields on the screen, do a f4 help and fill the value, the alv output screen automatically moves to the left side.
    I tried to resolve using SET_SCROLL_INFO_VIA_ID method of the class CL_GUI_ALV_GRID.
    CALL METHOD g_alvgrid->set_scroll_info_via_id
        EXPORTING
          is_row_info = v_scrl_row_info
          is_col_info = v_scrl_col_info.
    * Set Scroll Position
      CALL METHOD g_alvgrid->set_current_cell_via_id
        EXPORTING
          is_row_id    = v_scrl_row_set
          is_column_id = v_scrl_col_set.
    But still moves to the left side.
    If you have some ideas on this, pls share the same. Thanks in advance.
    Best Regards
    Himayat.
    Edited by: Himayatullah Md on Nov 25, 2011 4:42 PM
    Please use code tags
    Edited by: Rob Burbank on Nov 25, 2011 10:49 AM

    If you use [refresh_table_display|http://help.sap.com/saphelp_erp2004/helpdata/en/0a/b5531ed30911d2b467006094192fe3/frameset.htm] set paramter is_stable to keep scrollbar on desired position.
    Regards
    Marcin

Maybe you are looking for