Skip to Content
0
May 24, 2016 at 04:27 PM

TAW12-01, lesson: Dynamic Programming whit Field Symbols and References.

55 Views

On unit 6: Dynamic programming, use the sample program: SAPBC402_DYND_DATADECL

On description about this program, says:

if you Knew the components names, you could display the files directly using WRITE <fs_wa>-…. In most cases, however, you will not normally know the names of the components, or how many of them there are. As result, you have to use the ASSING-COMPONENT variant for output:… ”

However, I try to modify the program and the compiler not permit...

Is an error on the book ?

The data object "<FS_WA>" has no structure and therefore no component called "MAKTG". called "MAKTG".

But if I debug … its true…

Any suggestion?

Program CODE

______________________________________________________________________________

*&---------------------------------------------------------------------*

*& Report SAPBC402_DYND_DATADECL

*&

*&---------------------------------------------------------------------*

*&

*&

*&---------------------------------------------------------------------*

REPORT sapbc402_dynd_datadecl.

*----------------------------------------------------------------------*

DATA:

gr_itab TYPE REF TO data,

gr_wa TYPE REF TO data.

*----------------------------------------------------------------------*

FIELD-SYMBOLS:

<fs_itab> TYPE ANY TABLE,

<fs_wa> TYPE ANY,

<fs_comp> TYPE ANY.

*----------------------------------------------------------------------*

PARAMETERS

pa_tab TYPE dd02l-tabname DEFAULT 'SPFLI'.

*----------------------------------------------------------------------*

START-OF-SELECTION.

CREATE DATA gr_itab TYPE STANDARD TABLE OF (pa_tab)

WITH NON-UNIQUE DEFAULT KEY.

ASSIGN gr_itab->* TO <fs_itab>.

SELECT * FROM (pa_tab)

INTO TABLE <fs_itab>

UP TO 100 ROWS.

CREATE DATA gr_wa LIKE LINE OF <fs_itab>. "or: TYPE (pa_tab).

ASSIGN gr_wa->* TO <fs_wa>.

LOOP AT <fs_itab> ASSIGNING <fs_wa>.

DO.

ASSIGN COMPONENT sy-index OF STRUCTURE <fs_wa> TO <fs_comp>.

IF sy-subrc NE 0.

NEW-LINE.

EXIT.

ENDIF.

WRITE <fs_comp>.

ENDDO.

ENDLOOP.