简体   繁体   English

如何将旧 HR INCLUDE 添加到本地 class 中?

[英]How to add old HR INCLUDE into local class?

So I need to use the INCLUDES rpcblo00 and rpcbdt00 to get the type of infotype change (create, update, delete).所以我需要使用INCLUDES rpcblo00 and rpcbdt00来获取信息类型更改的类型(创建、更新、删除)。 Beforehand I used a subroutine that had no problem with the includes, but I cannot get them into a class for the life of me.之前我使用了一个对包含没有问题的子例程,但我终生无法将它们放入 class 中。

If I try to put the include into the method as described here (it's even about the same HR include) , I get the following error (because of the minus in lo-key ):如果我尝试将 include 放入这里描述的方法中(它甚至与 HR include 相同) ,我会收到以下错误(因为lo-key中的减号):

Syntax error: Names may only consist of the characters "AZ", "0-9" and "_".语法错误:名称只能包含字符“AZ”、“0-9”和“_”。 In addition, they may not begin with a number.此外,它们可能不以数字开头。

minimal reproducible example:最小的可重现示例:

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

Anyone know a good solution?有谁知道一个好的解决方案? Thanks in advance提前致谢

Edit: The includes have some declarations and a makro reading from a data cluster.编辑:包含有一些声明和一个从数据集群读取的宏。 Of course I could just put those directly into the method, but I would like to avoid that (for now I did that).当然,我可以直接将它们放入方法中,但我想避免这种情况(现在我这样做了)。

Alternatively, does someone know of a different way to get the change operation per infotype line?或者,是否有人知道每个信息类型行获取更改操作的不同方法?

If you use your class as a local one then the only way to use these includes is to put them at the very beginning of the program.如果您将 class 用作本地,那么使用这些包含的唯一方法是将它们放在程序的最开始。 The downside is of course that the variables there become global but unfortunately there is no other way to do that and for sure not if you want to use a global class after all (not sure if your minimal working example is just simplified to use a local class instead of global or not).缺点当然是那里的变量变成了全局变量,但不幸的是没有其他方法可以做到这一点,如果你想使用全局 class 肯定不会(不确定你的最小工作示例是否只是简化为使用本地class 而不是全局或不)。

REPORT ZZZ.

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

CLASS lcl_infotypaenderungen DEFINITION.

" ...

Thanks to Jagger I can make it work with a local class, but in case anyone later wonders how you need to change the include code to be able to use it in a global method, you basically just need to get rid of INCLUDE STRUCTURE declarations and exchange tables with a header line.感谢 Jagger,我可以使它与本地 class 一起工作,但如果以后有人想知道您需要如何更改包含代码才能在全局方法中使用它,您基本上只需要摆脱INCLUDE STRUCTURE声明和使用 header 线交换表。

So所以

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

becomes变成

DATA: lo_key TYPE pc400.

And

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.

becomes变成

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.

The macro can stay the same (or I guess you could rewrite it).宏可以保持不变(或者我猜你可以重写它)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM