Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

access work area fields dynamically

Hi!

In my ABAP Report I'm uploading a csv file via function module. From that I get an internal table containing the rows as Strings which I have to split afterwards into the fields of the structure I'm using.

so what I do is something like:

loop at itab into wa.

  split wa-string at ';' into mystructure-field1 mystructure-field2 ... 

enloop.

my problem is that "mystructure" has 82 fields (BSIS). Do I really have to code all 82 field or is there an easier (faster) way to write that?

thanks,

Margit

Tags:
Former Member
Former Member replied

Check this example:

TYPES: BEGIN OF ty_data,
         string TYPE char255,
       END OF ty_data.

DATA: itab TYPE STANDARD TABLE OF ty_data.
DATA: fields TYPE STANDARD TABLE OF ty_data.
DATA: count TYPE i.
DATA: wa TYPE ty_data.
DATA: wa2 TYPE ty_data.
DATA: wa_bsis TYPE bsis.

FIELD-SYMBOLS: <fs> TYPE any.

wa-string = '100;INCM;20000001;...'. "mandt-bukrs-hkont-...
APPEND wa TO itab.

LOOP AT itab INTO wa.
  SPLIT wa-string AT ';' INTO TABLE fields.
  CLEAR count.
  LOOP AT fields INTO wa2.
    ADD 1 TO count.
    ASSIGN COMPONENT count OF STRUCTURE wa_bsis TO <fs>.
    <fs> = wa2-string.
  ENDLOOP.
  INSERT zbsis FROM wa_bsis.
ENDLOOP.

Regards,

Valter Oliveira.

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question