Skip to Content

passing field symbols as internal table in export import parameters of methods in class

Hi,

Can we pass the Field symbol as a internal table to the method of class? I have requirement that in one method internal table will get create dynamically with help of field Catalog and that internal table I have to pass to other method for filling data into that internal table. please help me into this.

Thanks.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Oct 16, 2019 at 09:38 AM

    why it should not work ?

    CLASS lc_display DEFINITION FINAL.
    
    
      PUBLIC SECTION.
        METHODS display_marc
          IMPORTING
            it_table_marc    TYPE marc_tt
          RETURNING
            VALUE(rv_sucess) TYPE abap_bool.
    
    
    ENDCLASS.
    
    
    
    
    CLASS lc_display IMPLEMENTATION.
    
    
      METHOD display_marc.
        cl_demo_output=>display_data( it_table_marc ).
      ENDMETHOD.
    ENDCLASS.
    
    
    
    
    
    
    CLASS lc_data DEFINITION FINAL.
      PUBLIC SECTION.
        METHODS get_marc_entry
          IMPORTING
            iv_material_number TYPE matnr
          RETURNING
            VALUE(rv_success)  TYPE abap_bool.
    ENDCLASS.
    
    
    CLASS lc_data IMPLEMENTATION.
      METHOD get_marc_entry.
        DATA lt_marc_entries TYPE marc_tt.
        SELECT *
               INTO TABLE lt_marc_entries
               FROM marc
               WHERE matnr EQ iv_material_number.
        FIELD-SYMBOLS <lt_marc> TYPE table.
        ASSIGN lt_marc_entries TO <lt_marc>.
        CHECK <lt_marc> IS ASSIGNED.
        NEW lc_display( )->display_marc( <lt_marc> ).
    
    
      ENDMETHOD.
    ENDCLASS.
    
    
    
    
    
    
    
    
    START-OF-SELECTION.
      NEW lc_data( )->get_marc_entry( 'yourmaterialnumber' ).
    
    
    END-OF-SELECTION.
    
    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 16, 2019 at 09:24 AM

    As long as the field symbol is assigned to a internal table of the correct type, that should work.

    But if you'd post a code snippet, it will be easier to 'judge'..

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.