abapsap-hr

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). 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.

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):

Syntax error: Names may only consist of the characters "A-Z", "0-9" and "_". 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?


Solution

  • 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. 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).

    REPORT ZZZ.
    
    INCLUDE rpcblo00.      """  <---
    INCLUDE rpcbdt00.      """  <---
    
    CLASS lcl_infotypaenderungen DEFINITION.
    
    " ...