Class contructor internal table

Hi epert,
I am new for abap objects and i am trying to change the standard program.Please refer below.
CLASS a DEFINITION.
  CLASS-METHODS b.
  METHODS: constructor.
  METHODS: my,
           name.
ENDCLASS.                    "A DEFINITION
CLASS a IMPLEMENTATION.
  METHOD b.
    DATA screen TYPE REF TO a.
    CREATE OBJECT screen.
  ENDMETHOD.                    "B
  METHOD constructor.
    CALL METHOD : me->my.
  ENDMETHOD.                    "Constructor
ENDCLASS.                    "A IMPLEMENTATION
START-OF-SELECTION.
  CALL METHOD a=>b.
How it is possbile for me to pass a internal table to the method MY. I have internal table and i need to assign to the method MY.
Please guide me.  standard program DEMO_ABAP_OBJECTS_SPLIT_SCREEN
Edited by: Matt on Sep 30, 2010 4:47 PM - added  tags
Edited by: Matt on Sep 30, 2010 4:49 PM

>
mrsaravannan wrote:
> How it is possbile for me to pass a internal table to the method MY.
Hello,
You have to create a formal parameter for the method MY & pass your internal table to it:
Something like this:
Class A definition.
class-methods B.
methods: constructor.
methods: my IMPORTING im_itab TYPE <line type of your internal table>,
name.
Endclass.
In your CONSTRUCTOR pass the Internal Table value:
Method Constructor.
call method me->my EXPORTING im_tab = itab[].
endmethod.
BR,
Suhas

Similar Messages

  • Class reference internal table

    Hello Gurus,
    i have an internal table filled with class references and i need to acces the one field of a structure of every class.
    I am now trying something like this:
    loop ref_table assigning <l_wrk_ref_but0id>.
          IF <l_wrk_ref_but0id>->m_str_but0id-type = /gkv/cd40_cl_const=>con_pkkv.
          ENDIF.
    endloop.
    I need the field "type" in the structure "m_str_but0id" of every class (reference) in the table. The error that i'm getting is: "Field m_str_but0id unknown".
    Please help.
    Ioan Constantin.

    Hello Ioan
    You have to access the field dynamically as well:
    DATA:
       ld_structure  TYPE <name of structure>,
       ld_attribute    TYPE tabname,
       ld_field          TYPE fieldname.
    FIELD-SYMBOLS:
      <ls_struct>     TYPE any,
      <ld_fld>           TYPE any.
    ld_attribute = 'M_STR_BUT0ID'.
    ld_field       = 'TYPE'. 
    loop ref_table assigning <l_wrk_ref_but0id>.
         ASSIGN <l_wrk_ref>but0id>->(ld_attribute) TO <ls_struct>.
         ASSIGN COMPONENT (ld_field) OF STRUCTURE <ls_struct> TO <ld_fld>.
    "      IF <l_wrk_ref_but0id>->m_str_but0id-type = /gkv/cd40_cl_const=>con_pkkv.
           IF ( <ld_fld> = /gkv/cd40_cl_const=>con_pkkv ).
          ENDIF.
    endloop.
    Even simpler might be the following approach:
    LOOP AT ref_table assigning <l_wrk_ref_but0id>
                    WHERE ( table_line->m_str_but0id-type = /gkv/cd40_cl_const=>con_pkkv ).
    ENDLOOP.
    " Assumption: Itab has class reference type as line type.
    Regards
      Uwe

  • How to join THREE different tables into internal table using one select statement .

    How to join THREE different tables into internal table using one select statement .
    Hi experts,
    I would like to request your guidance in solving the problem of joining the data from three different database tables into one internal table
    Scenario:
    Database tables:
    SPFLI
    SFLIGHT
    SBOOK.
    Table Fields:
    SPFLI - CARRID CONNID COUNTRYFR CITYFRM COUNTRYTO CITYTO
    SFLIGHT - CARRID CONNID FLDATE SEATSMAX SEATSOCC SEATSMAX_C
    SEATSOCC_C SEATSMAX_F SEATSOCC_F
    SBOOK - CARRID CONNID CLASS
    MY INTERNAL TABLE IS IT_XX.
    Your help much appreciated.
    Thanks in advance.
    Pawan.

    Hi Pawan,
    please check below codes. hope it can help you.
    TYPES: BEGIN OF ty_xx,
            carrid     TYPE spfli-carrid   ,
            connid     TYPE spfli-connid   ,
            countryfr  TYPE spfli-countryfr,
            cityfrom   TYPE spfli-cityfrom  ,
            countryto  TYPE spfli-countryto,
            cityto     TYPE spfli-cityto   ,
            fldate     TYPE sflight-fldate ,
            seatsmax   TYPE sflight-seatsmax ,
            seatsocc   TYPE sflight-seatsocc ,
            seatsmax_b TYPE sflight-seatsmax_b,
            seatsocc_b TYPE sflight-seatsocc_b,
            seatsmax_f TYPE sflight-seatsmax_f,
            seatsocc_f TYPE sflight-seatsocc_f,
            class      TYPE sbook-class,
          END OF ty_xx,
          t_xx TYPE STANDARD TABLE OF ty_xx.
    DATA: it_xx TYPE t_xx.
    SELECT spfli~carrid
           spfli~connid
           spfli~countryfr
           spfli~cityfrom
           spfli~countryto
           spfli~cityto
           sflight~fldate
           sflight~seatsmax
           sflight~seatsocc
           sflight~seatsmax_b
           sflight~seatsocc_b
           sflight~seatsmax_f
           sflight~seatsocc_f
           sbook~class
      INTO TABLE it_xx
      FROM spfli INNER JOIN sflight
      ON spfli~carrid = sflight~carrid
      AND spfli~connid = sflight~connid
      INNER JOIN sbook
      ON spfli~carrid = sbook~carrid
      AND spfli~connid = sbook~connid.
    Thanks,
    Yawa

  • How to pass internal table to method of class

    Hi all,
    I am new to abap objects, i want to pass one internal table to class.
    i am trying in this way.
    class c1 definition.
    method get_material importing t_stpo  type any table
                                   exporting t_mast type any table.
    endmethod.
    endclass.
    class c1 implementation.
    method get_material.
    select f1 f2 f3 from <tab> into table t_mast
            for all entries in t_stpo
            where stlnr = t_stpo-stlnr.
    endmethod.
    endclass.
    ERROR:
    "stlnr" is not available
    if i use this way. its not giing error.
    class c1 definition.
    method get_material exporting t_mast type any table.
    endmethod.
    endclass.
    class c1 implementation.
    method get_material.
    select f1 f2 f3 from <tab> into table t_mast
            for all entries in it_stpo
            where stlnr = it_stpo-stlnr.
    endmethod.
    endclass.
    how to pass internal table with some specific reference may be using like or type <it_xxxx>
    thanks

    Try this.
    TYPES : BEGIN OF ty_stpo,
             stlnr TYPE stpo-stlnr,
             idnrk TYPE stpo-idnrk,
             menge TYPE stpo-menge,
            END OF ty_stpo,
            BEGIN OF ty_mast,
             matnr TYPE mast-matnr,
             werks TYPE mast-werks,
             stlnr TYPE mast-stlnr,
            END OF ty_mast,
            tt_stpo TYPE TABLE OF ty_stpo,
            tt_mast TYPE TABLE OF ty_mast.
    DATA : it_stpo TYPE tt_stpo,
           it_mast TYPE tt_mast.
    *       CLASS c1 DEFINITION
    CLASS c1 DEFINITION.
      PUBLIC SECTION.
        METHODS : get_bom_numbers EXPORTING ex_stpo type tt_stpo,
                  get_parent_material IMPORTING im_stpo TYPE tt_stpo
                                      EXPORTING ex_mast TYPE tt_mast.
        endclass.
    *       CLASS c1 IMPLEMENTATION
    CLASS c1 IMPLEMENTATION.
      METHOD get_bom_numbers.
      ENDMETHOD.                    "get_bom_numbers
      METHOD get_parent_material.
      ENDMETHOD.                    "get_parent_material
    START-OF-SELECTION.
      DATA : obj TYPE REF TO c1.
      CREATE OBJECT obj.
      CALL METHOD obj->get_bom_numbers
        IMPORTING
          t_stpo = it_stpo.
      CALL METHOD obj->get_parent_material
        EXPORTING
          im_stpo = it_stpo
        IMPORTING
          ex_mast = it_mast.
    Regards,
    Rich Heilman

  • Internal table in method of class (BADI)

    Hello people !!
    I need to use an internal table into method of class. I don´t know very well how to use it. I know that it hasn´t a header; but I don´t know how to defined and use it.
    I need to use in a method of badi.-
    I will be grateful by the help that your could offer to me.-
    Thank you so much,
    Esther.-

    Thank you for your answer.
    But, I had defined as de fist item, but I had defined with a structure of dictinary.
    Now, in my code, I need to deposit information to the above mentioned table. Then, when I try to accede to the fields of the estructure, when I compile it gives me the following mistake:
    "ACC_DATA" is a table without a header line and therefore has no          
    component called "CUENTA".     
    I attach departs from the code:
    types: es_accdata type standard table of Z_ES_ACCDATA.
    data: acc_data  type es_accdata.
          loop at it_mseg into r_mseg.
          si es Entrada de Mercancía
            if r_mseg-bwart = '101'.
              at first.
                acc_data-cuenta = r_mseg-sakto.
                if not r_mseg-kostl is initial.
                  acc_data-centro_coste = r_mseg-kostl.
                else.
                  acc_data-orden_inversion = r_mseg-aufnr.
                endif.
              endat.
              monto = monto + r_mseg-dmbtr.
            endif.
          endloop.
    Thank you againg, for a new answer !!!!
    bye, Esther.-

  • Internal table my_items not getting populated in class CL_HANDLE_MANAGER_MM

    hi experts,
    i have a problem while using ME38 transaction.
    ME38 calls exit EXIT_SAPMM06E_012
    inside this exit we are calling macro   mmpur_business_obj_id tekpo-id. in turn it goes to method search of class CL_HANDLE_MANAGER_MM where internal table my_items is not getting filled. due to that we are getting dump "Exception FAILURE".
    Thanks in advance
    Chandra

    hi
    put break point before the step and find out the value of your table or check the paramter value you are passing

  • XML to internal table conversion within ABAP mapping class

    I am doing a ABAP mapping for file to Idoc. My requirement is to convert XML file into ABAP internal table (within ABAP mapping class). Is there any standard FM, method, transformation etc, which can be used here.
    Thanks, Dehra

    Dehra,
    Have you seen this weblogs which talks about this:
    /people/r.eijpe/blog/2005/11/10/xml-dom-processing-in-abap-part-i--convert-an-abap-table-into-xml-file-using-sap-dom-approach
    /people/r.eijpe/blog/2005/11/21/xml-dom-processing-in-abap-part-ii--convert-an-xml-file-into-an-abap-table-using-sap-dom-approach
    /people/r.eijpe/blog/2006/02/19/xml-dom-processing-in-abap-part-iiia150-xml-dom-within-sap-xi-abap-mapping
    /people/r.eijpe/blog/2006/02/20/xml-dom-processing-in-abap-part-iiib150-xml-dom-within-sap-xi-abap-mapping
    Hope this helps you....
    ---Satish

  • Defining attribute for internal table within class builder?

    Hello there,
    I use an function module that provides me an internal table which has the reference type of the DDIC object zml_output. Furthermore I call this function module within a global class that should keep the result of the function module into the attribute lt_result, that is declared as private and typed with
    lt_result TYPE zml_output.
    Even the definition of that attribute causes the following error message:
    "lt_result" is not an internal table.
    I don't have any clue how to type lt_result differently. Actually I would need the following type of typing "TYPE TABLE OF" but that does not exist within the class builder.
    Thanks for your help in advanced!
    Robert

    Hi Konstantinidis ...
    Of course I can provide it to you. The code of my methode load_data reads as follows:
    method LOAD_DATA.
        CALL FUNCTION 'ZDATAGET'
        EXPORTING
          iv_dat    = iv_dat
          iv_time1  = iv_time1
          iv_delta  = iv_delta
        TABLES
          et_result = lt_result.
    endmethod.
    Especially the lt_result causes the mentioned error message
    The compiler seems to expect something "TABLE" like for attribute lt_result. But whatever I tried it doesn't seem to work out.
    Many thanks for help...

  • Internal table when creating a class

    Hi everybody
    im defining parameters when defining a class
    one of the parameters is IT_MARA, of type MARA
    Ive declared a method - SELECT_DATA, where the code is
    SELECT * FROM MARA
    INTO TABLE IT_MARA....
    When activating it
    Im getting the error - IT_MARA is not an internal table 'OCCURS n ' specification is missing
    anybody knows how to solve that issue?

    Hi Anjali,
    I figure out you are having trouble passing an internal table out of a method of a class.
    The error you get is because the parameter you have declared using TYPE MARA actually creates a line type and not an internal table in the signature of the method.
    You have to declare the parameter with a 'table type' rather, and it will create an internal table.
    You could use either a global table type or a local one.
    Please have a look at the code below using a local table type for this problem:
    CLASS a DEFINITION.
      PUBLIC SECTION.
        TYPES ty_mara TYPE TABLE OF mara.     "Local Table Type
        METHODS meth EXPORTING et_mara TYPE ty_mara.   "This makes an internal table
    ENDCLASS.
    CLASS a IMPLEMENTATION.
      METHOD meth.
        SELECT * FROM mara INTO TABLE et_mara UP TO 10 ROWS.
      ENDMETHOD.
    ENDCLASS.
    START-OF-SELECTION.
      DATA lt_mara TYPE TABLE OF mara.
      DATA lr_a    TYPE REF TO a.
      CREATE OBJECT lr_a.
      CALL METHOD lr_a->meth
        IMPORTING
          et_mara = lt_mara.
      BREAK-POINT.

  • Global Class that returns an internal table

    Hello,
       Is it possible to create a global class (under class builder) that returns an internal table like we used to do in a function module?
        e.g. call function '<Function module name>'
                        tables = i_tab.
    Thanks,
    Jeffrey

    Hi Jeffrey,
      Yeah u can do that by specifying importing parameters
      to method.You can give table type for the parameters.
    Thanks&Regards,
    Siri.

  • Passing internal tables as parameters to a class method.

    Hai,
            I have a requirement to pass an internal table(not structure) as a parameter to a method of a class.Are there ways to do it?
            Plz reply.
    Thanks in advance.
    Hema

    HI
    GOOD
    GO THROUGH THIS LINK
    http://www.abapforum.com/forum/viewtopic.php?t=1962&language=english
    THANKS
    MRUTYUN

  • Passing an Internal table to a "Z" class

    Hi,
    I am new to ABAP Objects. I am developing a "Z" class and would like to pass an internal table to this "Z" class. How do I pass it. What declarations do I need to make in the "Z" class and where?
    Thanks in advance.
    Mick

    if you want to pass internal table, then you have to use the table types. create the Table type (you can define in Se11 or you can define your own type pool and include in the properties section  )and refer it when you are defining the importing or exporting parameter.

  • Passing internal tables to a class

    Hi All,
    I have a problem at the moment, I need to pass an internal table to a class
    The problem is that depending on user input one of two differnet tables will be passed.
    TYPES: BEGIN OF t_destination_structure,
              matnr        TYPE mbew-matnr,   
              swerk         TYPE mbew-bwkey,  
              sverpr        TYPE mbew-verpr,   
              speinh        TYPE mbew-peinh,  
              bwkey        TYPE mbew-bwkey,
              verpr          TYPE mbew-verpr,   
              peinh          TYPE mbew-peinh,  
              lbkum         TYPE mbew-lbkum,
              salk3          TYPE mbew-salk3,  
              new_verpr  TYPE mbew-verpr,
              new_salk3  TYPE mbew-salk3,
              bwtar           TYPE mbew-bwtar,   
              it_colours    TYPE lvc_t_scol,   
           END OF t_destination_structure.
    TYPES: BEGIN OF t_pur_org_structure,
              matnr         TYPE mbew-matnr,
              bwkey       TYPE mbew-bwkey,
              verpr          TYPE mbew-verpr,
              peinh         TYPE mbew-peinh,
              lbkum         TYPE mbew-lbkum,
              salk3          TYPE mbew-salk3,
              new_verpr  TYPE mbew-verpr,
              new_salk3  TYPE mbew-salk3,
              bwtar          TYPE mbew-bwtar,
              it_colours   TYPE lvc_t_scol,
               END OF t_pur_org_structure.
    DATA:       i_destination_structure     TYPE TABLE OF t_destination_structure,
                     i_pur_org_structure         TYPE TABLE OF t_pur_org_structure.
    PERFORM Output USING i_destination_structure 1.
    OR
    PERFORM Output USING i_pur_org_structure 2.
    " Output for def
    FORM Output USING fuw_PassedTable fuw_Output_Switch
    " assignment that I want to make o_EventHandle is already created
    o_EventHandle->li_destination_structure = fuw_PassedTable.
    " Class definition
    CLASS lcl_LocalEventHandler DEFINITION.
        PUBLIC SECTION.
            DATA: li_destination_structure TYPE REF TO data, ************************************************************************
                  lw_radio_choice TYPE string.
            METHODS: OnUserCommand FOR EVENT added_function OF cl_salv_events IMPORTING e_salv_function.
            " Applies the GLEP from a souce branch to selected branch(es) GELP
             " DATA: iPassedTable TYPE passedtable.
        PROTECTED SECTION.
        PRIVATE SECTION.
            METHODS: apply_change.
            METHODS: simulate_change.
    ENDCLASS.
    When run this produces the error cannot convert type H to I
    All I need is the attribute to be a generic tabe that will become the passed table type, this sort of thing shouldnt be rocket science but I am having real trouble in my TYPE assignment
    If anyone can help or maybe have some ideas in how I can do this that would be great
    Cheers
    Ian

    Hi,
    You have to create the tables dynamic. You can do this via CREATE DATA.. Also have a look at the RTTI classes.
    I have added an example. Pass the itab via importing parameter (TYPE ANY TABLE), create data like the imported table, assign a field-symbol to the created data and, if needed, move the data from the passed itab to the dynamic itab.
    REPORT  zz_dynamic_itab.
    CLASS lcl_sample DEFINITION DEFERRED.
    DATA lt_sflight     TYPE TABLE OF sflight.
    DATA lt_spfli        TYPE TABLE OF spfli.
    DATA lcl_sample  TYPE REF TO lcl_sample.
          CLASS lcl_sample DEFINITION
    CLASS lcl_sample DEFINITION.
      PUBLIC SECTION.
        METHODS
          create_itab_from_data IMPORTING it_table TYPE ANY TABLE.
    ENDCLASS.                    "lcl_sample DEFINITION
          CLASS lcl_sample IMPLEMENTATION
    CLASS lcl_sample IMPLEMENTATION.
      METHOD create_itab_from_data.
        DATA lr_table    TYPE REF TO data.
        DATA lr_wa_table TYPE REF TO data.
        FIELD-SYMBOLS <lt_table> TYPE ANY TABLE.        "Dynamic Table
        FIELD-SYMBOLS <ls_table> TYPE ANY.              "Dynamic WA of Table
      Create data object from your table
        CREATE DATA lr_table LIKE it_table.
      Create your itab.
        ASSIGN lr_table->* TO <lt_table>.
        <lt_table> = it_table.
      Create wa
        CREATE DATA lr_wa_table LIKE LINE OF <lt_table>.
        ASSIGN lr_wa_table->* TO <ls_table>.
      ENDMETHOD.                    "create_table_from_data
    ENDCLASS.                        "lcl_sample IMPLEMENTATION
    START-OF-SELECTION.
    Creates local class
      CREATE OBJECT lcl_sample.
    First table: sflight
      SELECT *
        FROM sflight
        INTO TABLE lt_sflight.
    Pass to class with method
      lcl_sample->create_itab_from_data( lt_sflight ).
    Second table: spfli
      SELECT *
      FROM spfli
      INTO TABLE lt_spfli.
    Pass to class with same method
      lcl_sample->create_itab_from_data( lt_spfli ).
    Cheers,
    Roelof

  • Grid with classes not updating Internal Table

    Hi everyone
    I´m developing a Grid with classes.
    The first field in the Grid is a checkbox, I want it to response like a User action when I select or deselect it, but it´s not working. The Internal Table data isn´t updating the info in this field.
    Can someone give me some light please??
    Also I´m thinking in Add a Button like a Submit, so when the user clicks it I can get the last data captured in all fileds. Do you think it may be better??
    Thanks in advanced.
    Emmanuel

    Welcode to SCN
    Please check this link

  • How to create internal table storing instances of ABAP class

    Hi experts, any one knows how to create internal table storing instances of ABAP class or alternative to implement such function?

    Hi
    Please see below example from ABAPDOCU, this might help you.
    Internal Table cnt_tab is used to store class objects.
    Regards,
    Vishal
    REPORT demo_objects_references.
    CLASS counter DEFINITION.
      PUBLIC SECTION.
        METHODS: set IMPORTING value(set_value) TYPE i,
                 increment,
                 get EXPORTING value(get_value) TYPE i.
      PRIVATE SECTION.
        DATA count TYPE i.
    ENDCLASS.
    CLASS counter IMPLEMENTATION.
      METHOD set.
        count = set_value.
      ENDMETHOD.
      METHOD increment.
        ADD 1 TO count.
      ENDMETHOD.
      METHOD get.
        get_value = count.
      ENDMETHOD.
    ENDCLASS.
    DATA: cnt_1 TYPE REF TO counter,
          cnt_2 TYPE REF TO counter,
          cnt_3 TYPE REF TO counter,
          cnt_tab TYPE TABLE OF REF TO counter.
    DATA number TYPE i.
    START-OF-SELECTION.
      CREATE OBJECT: cnt_1,
                     cnt_2.
      MOVE cnt_2 TO cnt_3.
      CLEAR cnt_2.
      cnt_3 = cnt_1.
      CLEAR cnt_3.
      APPEND cnt_1 TO cnt_tab.
      CREATE OBJECT: cnt_2,
                     cnt_3.
      APPEND: cnt_2 TO cnt_tab,
              cnt_3 TO cnt_tab.
      CALL METHOD cnt_1->set EXPORTING set_value = 1.
      CALL METHOD cnt_2->set EXPORTING set_value = 10.
      CALL METHOD cnt_3->set EXPORTING set_value = 100.
      DO 3 TIMES.
        CALL METHOD: cnt_1->increment,
                     cnt_2->increment,
                     cnt_3->increment.
      ENDDO.
      LOOP AT cnt_tab INTO cnt_1.
        CALL METHOD cnt_1->get IMPORTING get_value = number.
        WRITE / number.
      ENDLOOP.

Maybe you are looking for

  • Using Internal Table in ABAP OO.

    Hi,      I am using a internal table, I am calling a FM, which require Internal table as its parameter. Since Internal table with header line is not supported in ABAP OO. How to attain this. Thanq For Ur time. Cheers, Sam

  • HT4847 iCloud Storage still full even have emptied the Mail trash

    Hi all.. I have problem with my iCloud Storage. I've deleted all the messages in Mail Application on iCloud.com and empty the trash also. But my iCloud storage still full, and the information from "Manage Storage", there are 4.2 GB data still on my M

  • WRT330N: Security settings error periodically

    Here's what I'm doing, step by step: 1) Set the WRT330N to WPA security, and set a passcode. 2) Set the security settings for that connection on several computers with the correct passcode. Everything works fine. 3) A period of time later (not sure h

  • Voice recognition in labview

    Hy Everyone I am new to labview. My project consists of voice recognition elevator system. my first task is to go ahead with voice recognition. I really need help. Regards kunal Solved! Go to Solution.

  • Creating an applet instance

    Hi I am using Schulmberger Smart Card Tool Kit in order to create applet and applet instances. I have created the applet inside the card but I couldn't create an applet instance. Because when I am going to create the applet instance by using the soft