• [转]ABAP动态取得数据


    动态取得数据的方法

    ABAP动态查询的实现:可以完全实现动态查询,每个字段都可以动态。

    (1)         利用宏

    (2)         利用abap指针

    (3)         利用FIELD-SYMBOL

    具体实现:

    1.结构的动态查询

    DEFINE SELECT_DATA_TO_WA.

      SELECT &1

        FROM &2

        INTO CORRESPONDING FIELDS OF &3

       WHERE (&4).

        EXIT.

      ENDSELECT.

    END-OF-DEFINITION.

    2.变量的动态查询

    DEFINE SELECT_DATA_TO_VARIANT.

      SELECT &1

        FROM &2

        INTO &3

       WHERE (&4).

        EXIT.

      ENDSELECT.

    END-OF-DEFINITION.

    3.内表的动态查询

    DEFINE SELECT_DATA_TO_VARIANT.

      SELECT &1

        FROM &2

        INTO CORRESPONDING FIELDS OF TABLE &3

       WHERE (&4).

        EXIT.

      ENDSELECT.

    END-OF-DEFINITION.

     

     

    具体程序实现:

     

    Code

    DATA: L_FIELD(100) TYPE C,

           L_TABLE(10) TYPE C,

           L_COND(100) TYPE C.

    DATA: I_COND TYPE TALBE OF L_COND.

    FIELD-SYMBOLS <fs> TYPE  ANY.

     

    START-OF-SELECTION.

      CONCATENATE ‘CARRID’ ‘CONNID’ ‘CITYFROM’

                INTO L_S

       SEPARATE BY SPACE.

      CONCATENATE ‘CONNID = ‘ ‘’ ‘0123’ ‘’’’ INTO L_COND.

    APPEND COND TO I_COND.

    L_TABLE = ‘SPFLI’.

    IF <fs> IS ASSIGNED.

      UNASSIGN  <fs>.

      ASSIGN SPFLI TO <fs>.

    ELSE.

    ASSIGN SPFLI TO <fs>.

    ENDIF.

     

    SELECT_DATA_TO_WA (L_S) (L_TABLE) <fs> I_COND.

     

  • 相关阅读:
    好用的电脑软件
    Swoft HTTPServer 使用经验分享
    nginx location proxy_pass详解
    kafka文档
    es 安装
    rabbitmq 文档
    Mysql百万级数据迁移,怎么迁移?实战过没?
    用bat脚本在Windows上实现微信多开
    vscode保存时自动格式化
    引入bootstrap
  • 原文地址:https://www.cnblogs.com/wequst/p/1513891.html
Copyright © 2020-2023  润新知