gpt4 book ai didi

abap - 如何将旧的 HR INCLUDE 添加到本地类(class)?

转载 作者:行者123 更新时间:2023-12-01 11:12:04 26 4
gpt4 key购买 nike

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

如果我尝试按照 here (it's even about the same HR include) 中的描述将 include 放入方法中,我收到以下错误(因为 lo-key 中的减号):

Syntax error: Names may only consist of the characters "A-Z", "0-9" and "_". In addition, they may not begin with a number.

最小可重现示例:

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

有人知道好的解决方案吗?提前致谢

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

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

最佳答案

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

REPORT ZZZ.

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

CLASS lcl_infotypaenderungen DEFINITION.

" ...

关于abap - 如何将旧的 HR INCLUDE 添加到本地类(class)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58931291/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com