Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

processing the table of type table.

Former Member
0 Kudos
100

Hi All,

I have a table <table> which is declared as a field symbol of type table.

I would get the data into that table dynamically. i would not be knowing what data it has until runtime. While debugging I would be able to see the data along with the field names.

Now i would like to process that data. i have declared <row> as data.I can say loop at <table> to <row>. But if I say <row>-column1, it wont accept because <row> is not of type any structure. it is of type data.

So how would I process data in that <table>?

Please suggest.

Thank You,

Suresh.

1 ACCEPTED SOLUTION

former_member491305
Active Contributor
0 Kudos
64

Hi,

FIELD-SYMBOLS <mark_field>.

Use <b> Assign component <b>fieldname</b> of structure <ROW> into <mark_field>.</b> inside the loop statement to process the loop.

5 REPLIES 5

former_member491305
Active Contributor
0 Kudos
65

Hi,

FIELD-SYMBOLS <mark_field>.

Use <b> Assign component <b>fieldname</b> of structure <ROW> into <mark_field>.</b> inside the loop statement to process the loop.

Peter_Inotai
Active Contributor
0 Kudos
64

If you knwo the type during runtime you can create a work area dynamically with statement CREATE DATA.

It depends what you want to do.

Here is one example I used for dynamic programing recently:

  DATA:
    dref_table               TYPE REF TO data.

  FIELD-SYMBOLS:
    <lit_typed>    TYPE STANDARD TABLE.

*--------------------------------------------------------------------------------------------------

  IF column IS NOT INITIAL.

    CREATE DATA dref_table TYPE STANDARD TABLE OF (shlp_info-intdescr-selmethod).
    CHECK sy-subrc = 0.

    ASSIGN dref_table->* TO <lit_typed>.
    CHECK sy-subrc = 0.

*   Move to formatted itab
    <lit_typed> =  t_searchresult_internal[].

*   Sort
*   Note: check CL_HTMLB_TABLEVIEW METHOD if_htmlb_element_delegated~do_at_end
    SORT <lit_typed> STABLE BY (column) AS TEXT.

*   Move back SORTED itab
    REFRESH t_searchresult_internal[].
    t_searchresult_internal[] =  <lit_typed>.


  ENDIF.

Best regards,

Peter

0 Kudos
64

Hi Peter,

I will know the structure in runtime. For example in my case <table> has CARRID and CONNID.

Let me tell you my exact scenario.

CREATE DATA alv_data TYPE HANDLE alv_datatype.

(alv_datatype is of type ref to CL_ABAP_TYPEDESCR.)

ASSIGN alv_data->* TO <alvtable>.

lr_node->get_static_attributes_table( IMPORTING table = <alvtable> ).

After that statement(while debugging) I see that there are two fields CARRID and CONNID with data aswell. Now I would like to declare an internal table ITAB with those two fields and move the data from <alvtable> to ITAB so that I can process data in ITAB.

Is it possible? Pls Suggest.

Thank You,

Suresh.

Former Member
0 Kudos
64

Hi Suresh,

To process dynamic table need to create local structure and assign the data

to that. See the below code.


  data: l_row type sy-index.
  field-symbols: <ls_table>.
  field-symbols: <l_field>.

  assign local copy of initial line of <gt_table> to <ls_table>.

* Zeilen
  do n times.
    l_row = l_row + 1.
*   Spalten
    do n times.
      assign component sy-index of structure <ls_table> to <l_field>.
      <l_field> = sy-index + l_row.
    enddo.
    append <ls_table> to <gt_table>.
  enddo.

Hope this will help you.

Thanks&Regards,

Siri.

0 Kudos
64

Hi Siri,

My requirement is not just copy into a different table but i would like to change the field content aswell.

Thank You,

Suresh.