0
votes

I customized the table KNVV. The append structure includes a structure where I actually defined all my custom fields. Lets call it zz_knvv_app_s.

A function pool, used to get and set the custom fields, has a function called ZSD_FOO_GET_DATA. It is exporting structure es_knvv TYPE knvv.

My current solution works, but is kind of stupid:

FUNCTION ZSD_FOO_GET_DATA.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*"  EXPORTING
*"     REFERENCE(ES_KNVV) TYPE  KNVV
*"----------------------------------------------------------------------
  es_knvv-zzfoo = knvv-zzfoo.
  es_knvv-zzbar = knvv-zzbar.
  es_knvv-zzbaz = knvv-zzbaz.
 " there are actually many more fields...
ENDFUNCTION.

What I am looking for is something like that:

  • loop through KNVV
  • assign the custom fields that are defined in my dictionary structure zz_knvv_aps_s...
  • ... from KNVV to ES_KNVV
  • something similary is also required for ZSD_FOO_GET_DATA

I am kind of new to ABAP. I think about looping and field symbols, but cant get it right. How would you solve it?

1

1 Answers

3
votes

You could try to use a named include:

  • create a structure - let's say ZZ_MY_KNVV_FIELDS
  • KNVV has an append structure ZZ_KNVV_APP_S
  • ZZ_KNVV_APP_S has a single entry .INCLUDE ZZ_MY_KNVV_FIELDS with a group name ZZ_MY_FIELDS
  • same for any other output structure

You can then address all of your fields using KNVV-ZZ_MY_FIELDS as a structure of type ZZ_MY_KNVV_FIELDS