Skip to Content
0
Former Member
May 06, 2010 at 06:51 PM

Field symbol and reference into an ITAB

21 Views

- Internal ref: E60063 Twan -

Hi, I have this problem to solve: A Function Module will be called with a table as parameter. The structure of the table is given in another parameter. A field name is given in yet another variable. I have to do a check on the given field in each record of the table.

The header of the FM looks like this:

FUNCTION zbw_bp_validate_table.
*"----------------------------------------------------------------------
*"*"Lokale interface:
*"  IMPORTING
*"     VALUE(I_STRUCT_NAME) TYPE  RSBKSRCNM
*"  CHANGING
*"     REFERENCE(C_T_SRCPAK) TYPE  ANY TABLE
*"----------------------------------------------------------------------

Next I define field-symbols to address the table and its records.

FIELD-SYMBOLS:
    <dpak_itab>   TYPE ANY TABLE,
    <dpak_fields> TYPE any,
    <s_bp>        TYPE /bi0/oibpartner.
  DATA dpak_ref TYPE REF TO data.
  GET REFERENCE OF c_t_srcpak INTO dpak_ref.
  ASSIGN dpak_ref->* TO <dpak_itab>.

  data line_ref type ref to data.
  loop at <dpak_itab> into line_ref.
    assign line_ref->* to <dpak_fields> casting type (I_STRUCT_NAME).

So far it looks ok. Then I want to address a field in the record:

    ASSIGN COMPONENT '/BIC/T01CZPAFD' OF STRUCTURE <dpak_fields> TO <s_bp>.
  ENDLOOP.

Now I get an error that <dpak_fields> has no structure and therefore no components. I was expecting that casting would do the trick but appearently it doesn't.

Any tips on how to approach this?