3

所以我需要使用INCLUDES rpcblo00 and rpcbdt00来获取信息类型更改的类型(创建、更新、删除)。事先我使用了一个对包含没有问题的子例程,但我无法将它们纳入我的生活中。

如果我尝试按照此处所述将包含放入方法中(它甚至与 HR 包含相同),我会收到以下错误(因为 中的减号lo-key):

语法错误:名称只能包含字符“AZ”、“0-9”和“_”。此外,它们可能不以数字开头。

最小的可重现示例:

CLASS lcl_infotypaenderungen DEFINITION.

  PUBLIC SECTION.

    TYPES: tty_aenderungs_operationen TYPE STANDARD TABLE OF pc403.

    METHODS:

      constructor 
          IMPORTING is_aenderungs_kopf TYPE pldoc_key,

      get_aenderungs_operationen 
          RETURNING value(rt_aenderungs_operationen) TYPE tty_aenderungs_operationen.

  PRIVATE SECTION.

    DATA: s_aenderungs_kopf        TYPE pldoc_key,
          t_aenderungs_operationen TYPE tty_aenderungs_operationen.

    METHODS:

      select_aenderungs_operationen.

ENDCLASS.                    "lcl_infotypaenderungen DEFINITION

*----------------------------------------------------------------------*

TYPE-POOLS: abap.

DATA: lo_infotypaenderungen     TYPE REF TO lcl_infotypaenderungen,
      lv_fehler                 TYPE sy-subrc,
      lt_log_kopf               TYPE pldoc_key_tab WITH HEADER LINE,
      lt_log_felder             TYPE TABLE OF hrinftylog_fields,
      lt_infotyp_vorher         TYPE prelp_tab,
      lt_infotyp_nachher        TYPE prelp_tab,
      lt_aenderungs_operationen TYPE STANDARD TABLE OF pc403.

FIELD-SYMBOLS: <log_kopfzeile>  TYPE pldoc_key.

*----------------------------------------------------------------------*

CALL FUNCTION 'HR_INFOTYPE_LOG_GET_LIST'
  EXPORTING
    tclas              = 'A'
    begda              = '20190315'
    endda              = '20190315'
  IMPORTING
    subrc              = lv_fehler
  TABLES
    infty_logg_key_tab = lt_log_kopf.

  CLEAR lv_fehler.
  SORT lt_log_kopf DESCENDING BY infty bdate btime pernr.

  LOOP AT lt_log_kopf ASSIGNING <log_kopfzeile>.

    CALL FUNCTION 'HR_INFOTYPE_LOG_GET_DETAIL'
      EXPORTING
        logged_infotype  = <log_kopfzeile>
      IMPORTING
        subrc            = lv_fehler
      TABLES
        infty_tab_before = lt_infotyp_vorher
        infty_tab_after  = lt_infotyp_nachher
        fields           = lt_log_felder.

      CREATE OBJECT lo_infotypaenderungen
        EXPORTING
            is_aenderungs_kopf = <log_kopfzeile>.

      REFRESH lt_aenderungs_operationen.
      lt_aenderungs_operationen = lo_infotypaenderungen->get_aenderungs_operationen( ).

  ENDLOOP.

*----------------------------------------------------------------------*

CLASS lcl_infotypaenderungen IMPLEMENTATION.

  METHOD constructor.

    me->s_aenderungs_kopf = is_aenderungs_kopf.
    me->select_aenderungs_operationen( ).

  ENDMETHOD.                    "constructor

  METHOD select_aenderungs_operationen.

    INCLUDE rpcblo00.      """  <--- 
    INCLUDE rpcbdt00.      """  <---

    lo-key-tclas = me->s_aenderungs_kopf-tclas.
    lo-key-pernr = me->s_aenderungs_kopf-pernr.
    lo-key-infty = me->s_aenderungs_kopf-infty.
    lo-key-bdate = me->s_aenderungs_kopf-bdate.
    lo-key-btime = me->s_aenderungs_kopf-btime.
    lo-key-seqnr = me->s_aenderungs_kopf-seqnr.
    IMPORT header TO me->t_aenderungs_operationen FROM DATABASE pcl4(la) ID lo-key.

  ENDMETHOD.                    "select_aenderungs_operationen

  METHOD get_aenderungs_operationen.

    rt_aenderungs_operationen = me->t_aenderungs_operationen.

  ENDMETHOD.                    "get_aenderungs_operationen

ENDCLASS.                    "lcl_infotypaenderungen IMPLEMENTATION

有谁知道一个好的解决方案?提前致谢

编辑:包含有一些声明和一个从数据集群读取的宏。当然,我可以直接将它们放入方法中,但我想避免这种情况(现在我这样做了)。

或者,是否有人知道每个信息类型行获取更改操作的不同方法?

4

2 回答 2

4

如果您将您的课程用作本地课程,那么使用这些包含的唯一方法是将它们放在程序的最开始。缺点当然是那里的变量变成了全局变量,但不幸的是没有其他方法可以做到这一点,如果你想使用全局类肯定不会(不确定你的最小工作示例是否只是简化为使用本地类而不是全局或不是)。

REPORT ZZZ.

INCLUDE rpcblo00.      """  <---
INCLUDE rpcbdt00.      """  <---

CLASS lcl_infotypaenderungen DEFINITION.

" ...
于 2019-11-19T12:41:05.313 回答
1

感谢 Jagger,我可以使它与本地类一起工作,但如果以后有人想知道您需要如何更改包含代码以便能够在全局方法中使用它,您基本上只需要摆脱INCLUDE STRUCTURE声明和交换表带有标题行。

所以

DATA BEGIN OF LO-KEY.
       INCLUDE STRUCTURE PC400.
DATA END OF LO-KEY.

变成

DATA: lo_key TYPE pc400.

DATA BEGIN OF BELEGE_00 OCCURS 100.
  DATA:
  SPLKZ(01) TYPE X,              
  FIELD(10) TYPE C,               
  FTYPE(04) TYPE C,             
  FLENG(03) TYPE N,        
  DECIM(02) TYPE N,          
  OLDDT(50) TYPE C,             
  NEWDT(50) TYPE C.            
DATA END OF BELEGE_00.

变成

TYPES: BEGIN OF ty_belege,
      splkz(01) TYPE x, 
      field(10) TYPE c,   
      ftype(04) TYPE c,  
      fleng(03) TYPE n,  
      decim(02) TYPE n,  
      olddt(50) TYPE c,   
      newdt(50) TYPE c,   
    END OF ty_belege.

DATA: belege_00 TYPE STANDARD TABLE OF ty_belege.

宏可以保持不变(或者我猜你可以重写它)。

于 2019-11-19T14:21:41.327 回答