Skip to Content
avatar image
Former Member

fill data into fieldsymbol

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

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • Best Answer
    Jan 08, 2009 at 02:58 PM

    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.

    Add comment
    10|10000 characters needed characters exceeded