351课后练习题二

Define two PARAMETERs, one for a name of a database table and one for a WHERE-Condition.
Use the CREATE DATA statement to create an appropriate internal table as a destination for a SELECT on the database table.
Use the OpenSQL SELECT together with Dynamic Token Specification for the FROM and WHERE clause.
At the end, take the form WRITE_TABLE from „Exercise: Generic Internal Table List Writer“ to write the result of the SELECT to the ABAP list.

 

 REPORT zsolar.

PARAMETERS: p_table TYPE dd02l-tabname,
            p_condi TYPE string.

DATA dref TYPE REF TO data.
FIELD-SYMBOLS: <fs> TYPE ANY TABLE.

START-OF-SELECTION.
  CREATE DATA dref TYPE TABLE OF (p_table).
  ASSIGN dref->* TO <fs>.

  SELECT * FROM (p_table) INTO TABLE <fs> WHERE (p_condi).

  IF <fs> IS ASSIGNED.
    PERFORM frm_write_table USING <fs>.
  ENDIF.

*&---------------------------------------------------------------------*
*& Form frm_write_table
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM frm_write_table USING itab TYPE ANY TABLE.
  FIELD-SYMBOLS: <fs> TYPE ANY,
  <foo> TYPE ANY.
  LOOP AT itab ASSIGNING <fs>.
    DO.
      UNASSIGN <foo>.
      ASSIGN COMPONENT sy-index OF STRUCTURE <fs> TO <foo>.
      IF <foo> IS ASSIGNED.
        WRITE: <foo>, '|'.
      ELSE.
        EXIT.
      ENDIF.
    ENDDO.
    NEW-LINE.
  ENDLOOP.
ENDFORM"frm_write_table

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值