3

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?

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Legxis
  • 886
  • 7
  • 19

2 Answers2

4

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.

" ...
Jagger
  • 10,350
  • 9
  • 51
  • 93
  • Thank you, this will work, I probably won't make that class global. If I do, then I guess the only way is to make a copy of the include code and make it oo-compatible? – Legxis Nov 19 '19 at 13:21
  • 1
    Yep, there seems to be no other way. I tried to put it in every possible class section in SE24, well in fact I have not tried the one for unit tests, but nothing worked. – Jagger Nov 19 '19 at 22:21
  • Thank you for all your effort! – Legxis Nov 20 '19 at 09:03
1

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.

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

Legxis
  • 886
  • 7
  • 19