본문 바로가기
ERP-SAP/ABAP

<ABAP> 동적 생성 정리

by 행복한워니의 기록 2013. 12. 4.
728x90
반응형

  *&---------------------------------------------------------------------*
*& Report  ZCONRAD_TMP04
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  zconrad_tmp04.


DATA:
  lv_seq   TYPE num2,
  lv_tabnm TYPE tabnm,
  lr_data  TYPE REF TO data,
  lr_exception TYPE REF TO cx_root,
  lv_ex_text   TYPE string,

  lr_table TYPE REF TO cl_salv_table.

FIELD-SYMBOLS:
  <data>  TYPE ANY TABLE,
  <line>  TYPE ANY,
  <field> TYPE ANY.

lv_seq 20.

lv_tabnm 'SFLIGHT'.

TRY .
    CREATE DATA lr_data TYPE TABLE OF (lv_tabnm).
  CATCH cx_root INTO lr_exception.
    lv_ex_text lr_exception->get_text).
    MESSAGE s000(dbWITH lv_ex_text DISPLAY LIKE 'E'.
    RETURN.
ENDTRY.

IF lr_data IS BOUND.
  ASSIGN lr_data->TO <data>.

  IF sy-subrc 0.

    SELECT *
      INTO TABLE <data>
      FROM (lv_tabnm).

    IF sy-subrc 0.
*      LOOP AT <data>
*        ASSIGNING <line>.
*
*        ASSIGN COMPONENT 2 OF STRUCTURE <line> TO <field>.
*        IF sy-subrc = 0.
*          WRITE:/ <field>.
*        ENDIF.
*      ENDLOOP.
      TRY.
          cl_salv_table=>factory(
*          exporting
*            r_container    = custom_container
*            container_name = 'BCALVC_EVENT1_CONT1'
            IMPORTING
              r_salv_table   lr_table
            CHANGING
              t_table        <data> ).

          lr_table->display).

        CATCH cx_salv_msg.                              "#EC NO_HANDLER
      ENDTRY.

    ENDIF.
  ENDIF.

ENDIF.

728x90
반응형