以下程序运行正常,但SELECT..ENDSELECT部分只运行一次,而它应该为表中的每一行多次调用类方法lcl_util一次?为什么会这样?
*&---------------------------------------------------------------------*
*& Report ZDYNAMIC_PROG2
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZDYNAMIC_PROG2.
PARAMETER:
p_from(30) TYPE c DEFAULT 'T001L',
p_where(255) TYPE c
DEFAULT 'WERKS = ''PL01'' AND LGORT = ''SL01'' '.
* ----------------------------------------------------------------------*
* CLASS lcl_util DEFINITION
* ----------------------------------------------------------------------*
*
* ----------------------------------------------------------------------*
CLASS lcl_util DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
write_struct IMPORTING p_struct TYPE any.
ENDCLASS. "lcl_util DEFINITION
* ----------------------------------------------------------------------*
* CLASS lcl_util IMPLEMENTATION
* ----------------------------------------------------------------------*
*
* ----------------------------------------------------------------------*
CLASS lcl_util IMPLEMENTATION.
METHOD write_struct.
FIELD-SYMBOLS:
<field> TYPE any.
WRITE / '('.
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE p_struct TO <field>.
IF sy-subrc <> 0.
EXIT.
ENDIF.
WRITE /4 <field>.
ENDDO.
WRITE / ')'.
ENDMETHOD. "write_struct
ENDCLASS. "lcl_util IMPLEMENTATION
DATA:
data_ref TYPE REF TO data,
where_tab LIKE TABLE OF p_where.
FIELD-SYMBOLS:
<line> TYPE any.
START-OF-SELECTION.
CREATE DATA data_ref TYPE (p_from).
ASSIGN data_ref->* TO <line>.
* APPEND p_where TO where_tab.
SELECT * FROM (p_from) INTO <line> WHERE (p_where).
CALL METHOD lcl_util=>write_struct
EXPORTING
p_struct = <line>.
ENDSELECT.