一段万能的ABAP报表,能读取Netweaver上任意数据库表的内容

半腔热情 提交于 2020-01-13 01:22:01
*&---------------------------------------------------------------------*
*& Report ZGENERATE_ACCESS
*&---------------------------------------------------------------------*
* 2016-12-04 16:48PM - perhaps this report is done by Wuji? at airplane 
* from Frankfort to Beijing
*&---------------------------------------------------------------------*
REPORT ZGENERIC_ACCESS.

PARAMETERS: name TYPE tadir-obj_name OBLIGATORY DEFAULT 'SFLIGHT'.

DATA: dyn_table TYPE REF TO DATA.

TRY.

CREATE DATA dyn_table TYPE TABLE OF (name).

FIELD-SYMBOLS: <table> TYPE ANY TABLE.

ASSIGN dyn_table->* TO <table>.

ASSERT sy-subrc = 0.


SELECT * INTO TABLE <table> FROM (name) UP TO 10 ROWS.

CATCH cx_root INTO data(cx_root).
   WRITE: / cx_root->get_text( ).
   RETURN.
ENDTRY.

FIELD-SYMBOLS: <row> TYPE ANY,
               <wa>  TYPE ANY.
LOOP AT <TABLE> ASSIGNING <row>.
   DO.
     ASSIGN COMPONENT sy-INDEX OF STRUCTURE <row> TO <wa>.
     IF sy-SUBRC = 0.
       WRITE <wa>.
     ELSE.
      SKIP.
      EXIT.
     ENDIF.
   ENDDO.
ENDLOOP.

要获取更多Jerry的原创文章,请关注公众号"汪子熙":

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!