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.

Similar Messages

  • 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

  • Pass the internal table with different structures to the class module

    Hi ,
    I have created a class method to fill up the data in XML format. the method can be called from various programs with internal table with different structures. I want to pass it as dynamic How can I do that.
    I tried to declare that as type any.
    but not working.
    regards,
    Madhuri

    Hi,
    You could work with data reference.
    Use GET REFERENCE OF itab INTO data_ref for passing the internal table to your method, and dereference it within the method with ASSIGN statement...
    DATA: lr_data TYPE REF TO data.
    GET REFERENCE OF itab INTO lr_data.
    CALL METHOD meth EXPORTING pr_data = lr_data.
    METHOD meth.
      FIELD-SYMBOLS <fs> TYPE ANY TABLE
      ASSIGN pr_data->* TO <fs>.
    ENDMETHOD.
    Kr,
    Manu.

  • Passing an internal table WITH HEADER LINE to abap object

    Hi. In another thread, it was explained how to pass an internal table to an abap object method. Is it possible to pass an internal table that has a header line, and RETAIN the header line once the table has been passed?
    My problem is, that I can pass the table, update it, but the read buffer is not populated when returning from the object's method. This is the result of being able to pass a STANDARD TABLE type, but not a STANDARD TABLE WITH HEADER LINE.
    This means that I have to read the table into a work area instead of doing a READ TABLE LKNA1 within the method, which is what I need to do.
    Thanks.

    Please check this sample program, notice that it is modifing the internal table and passing it back modified as well as passing the "work area" or "header line" back thru the exporting parameter.
    report zrich_0001.
    *       CLASS lcl_app DEFINITION
    class lcl_app definition.
      public section.
        types: t_t001 type table of t001.
        class-data: it001 type table of t001.
        class-data: xt001 like line of it001.
        class-methods: change_table
                                    exporting ex_wt001 type t001
                                    changing im_t001 type t_t001.
    endclass.
    data: w_t001 type t001.
    data: a_t001 type table of t001 with header line.
    start-of-selection.
      select * into table a_t001 from t001.
      call method lcl_app=>change_table
                 importing
                     ex_wt001 = w_t001
                 changing
                     im_t001  = a_t001[] .
      check sy-subrc  = 0.
    *       CLASS lcl_app IMPLEMENTATION
    class lcl_app implementation.
      method change_table.
        loop at im_t001 into xt001.
          concatenate xt001-butxt 'Changed'
               into xt001-butxt separated by space.
          modify im_t001 from xt001.
        endloop.
        ex_wt001 = xt001.
      endmethod.
    endclass.
    Regards,
    Rich Heilman

  • Error Passing an internal table between BSP pages

    Any time there is data in the internal table and I try to pass it from one BSP page to the next I get an Web error.  I've heard that it is possible to pass an internal table from one page to the next.  can anyone point me in the right direction here?

    You can do this with the navigation object only if the table is very small. Overwise it overflows 2+KB limitation of URLs.
    Alternative ideas is to use server side cookies (search forum for many examples).
    If stateful, just hang stuff of your application class.

  • 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.

  • Passing an Internal Table as parameter to a method

    Hi,
       Can we pass an internal table as a parameter to a method.if so how can we do that?i am new to abap objects..

    Hi Matt,
            Here is the code that i am trying to execute.I am extracting the data in the method "Extract" and passing it to the method "Display" to produce a report output.When i execute this it is giving me an error saying that t_mara is not an internal table since i just refered it with x_mara in the class definition.So how can i modify this code to pass t_mara as an internal table from the method "Extract".Please help me.
    *& Report  ZOBJ_PRAC                                      *
    REPORT  zobj_prac                                                   .
          CLASS example DEFINITION
    CLASS example DEFINITION.
      PUBLIC SECTION.
            TYPES : BEGIN OF x_mara,
                  matnr TYPE matnr,
                  ersda TYPE ersda,
               END OF x_mara.
        METHODS : extract EXPORTING t_mara TYPE x_mara,
                          display IMPORTING it_mara TYPE x_mara.
    ENDCLASS.                    "example DEFINITION
    "example IMPLEMENTATION
          CLASS example IMPLEMENTATION
    CLASS example IMPLEMENTATION.
      METHOD extract.
        DATA :lt_mara TYPE STANDARD TABLE OF x_mara INITIAL SIZE 0,
                  lw_mara TYPE x_mara.
        SELECT matnr ersda FROM mara INTO TABLE lt_mara UP TO 10 ROWS.
        t_mara[]  =  lt_mara[].
      ENDMETHOD.                    "extract
      METHOD display.
        DATA :lt_mara TYPE STANDARD TABLE OF x_mara INITIAL SIZE 0,
              lw_mara TYPE x_mara.
        lt_mara[]  =  it_mara[].
        LOOP AT lt_mara INTO lw_mara.
          WRITE:/ lw_mara-matnr,
                20 lw_mara-ersda.
        ENDLOOP.
      ENDCLASS.                    "example IMPLEMENTATION
    START-OF-SELECTION.
      DATA :  b1 TYPE REF TO example.
    CREATE OBJECT b1 TYPE example.
      TYPES : BEGIN OF x_mara,
                  matnr TYPE matnr,
                  ersda TYPE ersda,
               END OF x_mara.
    data : t_mara type standard table of x_mara initial size 0,
           it_mara type standard table of  x_mara initial size 0.
      call method b1->extract
        importing
         t_mara = t_mara.
         it_mara[]  =  t_mara[].
      call method b1->display
        exporting
         it_mara = it_mara.
    Edited by: Sai Chaitanya on Dec 2, 2008 5:30 AM

  • Passing a internal table from method

    Hi All,
       I am using Object Oriented Programming in my program.
       I want to pass a Internal Table from a method calling statement written in a start-of-selection.
       Can any one give me the syntax for
    1. Declaring a method with importing parameter as internal table.
    2. Syntax for Method Implementation
    3. Syntax for calling the method from start-of-selection.
    helpful answers are rewarded.
    Regards,
    Azaz Ali.

    Hi,
      Calling Method is similar to calling function Module.
    CALL METHOD cl_gui_frontend_services=>gui_download
       exporting
          filename    =
    IMPORTING
       FILELENGTH                =
      changing
        data_tab                  = <b>( this is ur internal table name )</b>*  EXCEPTIONS
       FILE_WRITE_ERROR          = 1.
    <b>In OO ABAP u avoid creating table with header line</b>
    Best way to call method is to use <b>PATTERN</b> Button  
    1) Click Pattern Button
    2) Select Abap Object Pattern
    3) Enter
    4) Select Call Method
    5) Enter instance name ( i. e  used for create object ) ( No need for static method like gui_download )
    6) Enter Class / Interface name
    7) Enter Method Name
    done.
    <b>passing value to method is similar to FM.
    Creating internal table for Method
    any TYPE ........SAY  TY_Intern
    Then Syntax Should Be
    DATA : OO_INTERNAL_TABLe type table of TY_Intern.
    pass this to the Method.
    Hope This will solve ur problem.
    Please Mark Helpful Answers</b>
    Message was edited by: Manoj Gupta

  • How to Pass the Internal table of a report to Smart Form

    Hi Experts,
    I have one report in which from selection screen i am getting the values from the users, and upon that values i am filling data in to the internal table.
    Now i want to pass that internal table data to the smart form
    and print that data in the smart form.
    So could you pls give me some pseudo code or any steps to achieve it.
    Thanks & Regards,
    DS

    Hi DS,
    First of all you need to create a SF and then need to call the FM generated by the FM in your report.
    In the SF in the form interface>tables tab>mention the name of the table and its type structure.
    Pls note that a new structure has to be created as the same type of your internal table which holds the data.
    And the import and export parameters as just the same as in a FM.
    Now after you create and activate your SF a FM will be generated (wen u execute your SF you will be taken to this SE37 screen with the name of FM so no probs..)
    You can call this FM in your report. Hope this helps.
    Ex:
    say itab has your final data, and you also want to export a variable var1 to the SF.
    after your normal report operations end, call the FM and pass on these data.
    say your FM name is FM1.
    call function FM1
    exporting
    var1 = var1
    tables
    itab1 = itab1.
    pls note that in the SF also i gave the same names, it is not mandatory to give the same names.
    and as you want to print a table in the smartforms, you need to create a table in the smart forms and then display the data which is quite simple.
    Hope this helps...
    if you need any further explanations, pls revert...
    Regards,
    Narendra.
    Reward points if helpful!!!

  • How to export internal table and pass the internal table to another screen?

    Hi,
    I have a sql SELECT statement that select data from table into internal table. I would like to export out the internal table and pass to another screen and display the data in ALV list. How to export it out? I try but the error given was " The type of "OUT_SELECT_ITAB" cannot be converted to the type of  "itab_result".
    Another question is, how to pass the internal table that i export out from the function module to another screen?
    Here is the code
    ==============================================================
    FUNCTION ZNEW_SELECT_ZSTUD00.
    ""Local Interface:
    *"  IMPORTING
    *"     REFERENCE(IN_SELECT_YEAR) TYPE  ZSTUD00-EYEAR
    *"  EXPORTING
    *"     REFERENCE(OUT_RESULT) TYPE  CHAR9
    *"     REFERENCE(OUT_SELECT_ITAB) TYPE  ZSTUD00
    *& Global Declarations
    DATA: itab TYPE ZSTUD00,
          itab_result TYPE TABLE OF ZSTUD00.
    *& Processing Blocks called by the Runtime Environment
    itab-eyear = IN_SELECT_YEAR.
    SELECT *
    FROM ZSTUD00
    INTO TABLE itab_result
    WHERE eyear = IN_SELECT_YEAR.
    IF sy-subrc = 0.
      out_result = 'Success'.
      OUT_SELECT_ITAB = itab_result.
    ELSE.
      out_result = 'Fail'.
    ENDIF.
    ENDFUNCTION.
    ===============================================================
    Please advise. Thanks
    Regards,
    Rayden

    Hi Nagaraj,
    I try to change it in Tables tab page but it state that TABLES parameters are obsolete. when i "Enter". I try to "Enter" again. it seem to be ok but it stil give me the same error.
    ================================================================
    FUNCTION ZNEW_SELECT_ZSTUD00.
    ""Local Interface:
    *"  IMPORTING
    *"     REFERENCE(IN_SELECT_YEAR) TYPE  ZSTUD00-EYEAR
    *"  EXPORTING
    *"     REFERENCE(OUT_RESULT) TYPE  CHAR9
    *"  TABLES
    *"      OUT_SELECT_ITAB STRUCTURE  ZSTUD00
    *& Global Declarations
    DATA: itab TYPE ZSTUD00,
          itab_result TYPE TABLE OF ZSTUD00.
    *& Processing Blocks called by the Runtime Environment
    itab-eyear = IN_SELECT_YEAR.
    SELECT *
    FROM ZSTUD00
    INTO TABLE itab_result
    WHERE eyear = IN_SELECT_YEAR.
    IF sy-subrc = 0.
      out_result = 'Success'.
      OUT_SELECT_ITAB = itab_result.
    ELSE.
      out_result = 'Fail'.
    ENDIF.
    ENDFUNCTION.
    ===============================================================
    regards,
    Rayden

  • How to pass the internal table defined in program to ALV

    Hi Friends,
    I have a doubt regaring the ALV's,
    How can we pass the internal table defined in the program to ALV by not filling the attribute (I_STRUCTURE_NAME) in the REUSE_ALV_LIST_DISPLAY.
    I have tried many ways but unable to pass the structure of the internal table. I am getting the error message "Field Catalog Not Specified......" and its terminating and when i am giving the I_STRUCTURE_NAME = 'INTERNAL-TABLE-NAME' then its displaying a blank screen with all the tool-bars and icons...(No output of internal table data is seen on the screen) .
    and when i am passing the DDIC table or structure ( for eg. LFA1) to I_STRUCTURE_NAME then its displaying with any error.
    Plaese help in resolving this problem....
    Regards
    Pradeep Goli

    Hi,
    Check this thread which gives example of ALV. This will give you an idea.
    Interactive ALV
    ashish

  • How to pass the internal table data to smartforms

    Hi Gurus,
    I have a problem in passing the internal table data to the smartforms. In the print program
    I get the data into one internal table "LT_PRDLBL1". I am passing this internal table to the other in print program by calling the FM_NAME.
    CALL FUNCTION fm_name
      EXPORTING
      ARCHIVE_INDEX              =
      ARCHIVE_INDEX_TAB          =
      ARCHIVE_PARAMETERS         =
        CONTROL_PARAMETERS         = T_SSFCTRLOP
      MAIL_APPL_OBJ              =
      MAIL_RECIPIENT             =
      MAIL_SENDER                =
        OUTPUT_OPTIONS             = T_SSFCOMPOP
        USER_SETTINGS              = ' '
    IMPORTING
      DOCUMENT_OUTPUT_INFO       =
      JOB_OUTPUT_INFO            =
      JOB_OUTPUT_OPTIONS         =
      TABLES
        LT_PRDLBL                 = LT_PRDLBL1
    EXCEPTIONS
       FORMATTING_ERROR           = 1
       INTERNAL_ERROR             = 2
       SEND_ERROR                 = 3
       USER_CANCELED              = 4
       OTHERS                     = 5
    In the print program I had defined the internal tables like
    Data: lt_prdlbl  type standard table of zprdlbl.
    Data: Begin of lt_prdlbl1 occurs 0.
            include structure zprdlbl.
    Data: End of lt_prdlbl1.
    How do I define the internal table in the smartform to get the values printed in the smartform?.
    <REMOVED BY MODERATOR>
    Thanks,
    Edited by: Alvaro Tejada Galindo on Apr 21, 2008 1:01 PM

    Nehal,
    Thanks for quick response.
    In the smartform under the Form Interface->Tables tab
    I had defined
    LT_PRDLBL LIKE ZPRDLBL. If I define TYPE instead of LIKE I get the error message saying "FLAT TYPES may only be referenced using LIKE for table parameters".
    In the main window I have created LOOP, in which I have ticked the internal table and
    LT_PRDLBL INTO LT_PRDLBL. In the text node I am passing the values of this internal table
    &LT_PRDLBL-XXXX&.
    I am able to get the print but the data is not printing.
    Please help me with this.
    Thanks,

  • 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.-

  • How to pass a internal table used in one method to another method in a view

    hi all,
    Is it possible to pass a internal table from one method to another method in a view??
    If so , kindly help me.

    Hi Bala,
    If you want to pass this internal table between different methods of the same view then write the contents of this internal table to a context node of your view using BIND_TABLE. You can then read the contents of this internal table from the other method using the reference of that node & the GET_STATIC_ATTRIBUTES_TABLE method.
    However if you want to pass the internal table between methods of different views then create a context node at the COMPONENTCONTROLLER level & then do a context mapping of this node to your local views context in both your views. You can follow the same BIND_TABLE & GET_STATIC_ATTRIBUTES_TABLE methods approach.
    Regards,
    Uday

  • How to pass a internal table into Java Bean

    Hi Experts,
    I created a JSPDyn page to display Sales orders form R/3 using bapi_sales_order_getlist.
    I used JCO to establish connectivity between JSP Dynpage and R/3. I executed the bapi successfully, i want to move the sales orders retrieved from the Bapi to a Java Bean. So that i can use the bean to populate the value as a table.
    with regards,
    James.
    Valuable answers will be rewarded.....

    Hi Bala,
    If you want to pass this internal table between different methods of the same view then write the contents of this internal table to a context node of your view using BIND_TABLE. You can then read the contents of this internal table from the other method using the reference of that node & the GET_STATIC_ATTRIBUTES_TABLE method.
    However if you want to pass the internal table between methods of different views then create a context node at the COMPONENTCONTROLLER level & then do a context mapping of this node to your local views context in both your views. You can follow the same BIND_TABLE & GET_STATIC_ATTRIBUTES_TABLE methods approach.
    Regards,
    Uday

Maybe you are looking for

  • Multiple speakers off single Airport Express

    Dudes, I have an Airport Express (AX) hooked up to my stereo. Is it possible to run multiple speakers off it (using a splitter, or some such thing)so that I can have a little set of speakers in the kitchen as well as the living room? Thanks, JC

  • Read infotype using HR_READ_INFOTYPE

    Hi all, I Try to read infotype (pa0021) using HR_READ_INFOTYPE. Its getting fine. Im using Web Dynpro ABAP Interactive form. I want to insert some value in infotype pa0021, so i used HR_INFOTYPE_OPERATION. Data's are Inserting. The problem is if i pr

  • Help w Adobe Reader not installing

    Hey everyone, I'm looking to get some insight on why my Adobe Reader will not install anymore on my Macbook Pro, 2013 Retina Display, utilizing Mavericks OS. I recently uninstalled Adobe Reader, disliking the fact that since I had installed the progr

  • MMS messages with WiFi on

    I just assisted in the purchase of 2 Lumia 925 on T-Mobile US a day or after the purchase, both users noticed that they weren't able to send or recieve MMS messages. I called TMo, and they instructed me to turn off the wifi ... Lo n behold the MMS's

  • Photos taken on my iphone are white/blank?

    I'm having trouble viewing the photos I've taken as well as my sister's Iphone. What happens is the photo are there but there are white and are white on the photo stream but when you access the photos through instagram the photos can be viewed. Why a