cancel
Showing results for 
Search instead for 
Did you mean: 

fill data into fieldsymbol

Former Member
0 Kudos

Hallo,

I have created an fieldsymbol "<itabui>".

"generate table from dynamic structur "lr_struct_descr"

lr_table_descr = cl_abap_tabledescr=>create( lr_struct_descr ).

" and create table

CREATE DATA lr_table_ref TYPE HANDLE lr_table_descr.

ASSIGN lr_table_ref->* TO <itabui>.

" read from databasetable the requested data:

SELECT * FROM (name) INTO CORRESPONDING FIELDS OF TABLE <itabui>.

and now I want to write data in one field of <itabui> like a ID.

regards

Matthias

Accepted Solutions (1)

Accepted Solutions (1)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

If you also want the field access to be very dynamic you can use a construct like the following:

field-symbols: <tab>         type index table,
                         <struct>      type any,
                         <wa>          type any,
                         <option>      type char2,
                         <sign>        type char1,
                         <high>        type any,
                         <low>         type any,
                         <wa_values>   type any.
      assign lt_range_table->* to <tab>.
      append initial line to <tab> assigning <wa>.
      assign component 'OPTION' of structure <wa> to <option>.
      <option> =  'EQ'.

You can be very dynamic and supply the ASSIGN COMPONENT value dynamically via a variable as well. There is also the variant of the command that allows you to assign the component via the index offset. That is very useful if you must access all the fields in a structure:

field-symbols: <tab>         type table,
                 <wa>          type any,
                 <wa2>         type any,
                 <f>           type any.
*****Loop through the Data Table
  loop at <tab> assigning <wa>.
****For each component (field) in the table -Output the data
    loop at struct assigning <wa_desc>.
      assign component sy-tabix of structure <wa> to <f>.
      check sy-subrc = 0.
      if <wa_desc> is assigned and <wa_desc>-convexit is not initial.
****Process any output conversion routines
        concatenate 'CONVERSION_EXIT_' <wa_desc>-convexit '_OUTPUT' into str.
        call function str
          exporting
            input  = <f>
          importing
            output = s.
    endif.
  endloop.

Former Member
0 Kudos

Hallo Thomas,

thanks you for your fast answer.

regards

Matthias

Answers (0)