Saturday, January 9, 2016

How to programmatically activate ABAP report

Recently I wrote blog post about topic of syntax checking from ABAP reports. Now as next logical step let’s talk about an activation of the ABAP report programmatically from the ABAP. Usually every dictionary object has to be activated before it can be used. The ABAP reports are not an exception.

By activation process a source code of the ABAP report is being checked for syntax errors and afterwards active version of the report is generated. As last step of the activation process a load version is generated.

There is also a process of the ABAP report generation. Unlike activation process this one only generates a new load version of the program. So no activation part takes place.

Below I’m providing to simple program for the ABAP report activation.


1. Activation leveraging FM REPS_OBJECT_ACTIVATE:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
REPORT zmm_abap_activate01.

PARAMETERS: p_prg  TYPE e071-obj_name,
            p_otyp TYPE sewor_working_area-object DEFAULT 'REPS'. "REPS=report, METH=method

CALL FUNCTION 'REPS_OBJECT_ACTIVATE'
  EXPORTING
    object_name = p_prg
    object_type = p_otyp
 EXCEPTIONS
   not_executed = 1
   others       = 2.

Source code available: here

2. Activation via statement “INSERT REPORT”:


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
REPORT zmm_abap_activate02.

PARAMETERS: p_prgsrc TYPE sy-repid, "report where source code is read from
            p_prgtgt TYPE sy-repid. "target report that will be created

DATA: lt_source  TYPE TABLE OF string,
      ls_type(1) TYPE c VALUE '1'. "1=Executable program

READ REPORT p_prgsrc INTO lt_source.

INSERT REPORT p_prgtgt FROM lt_source PROGRAM TYPE '1' UNICODE ENABLING 'X'.

Source code available: here

Related posts:
How to programmatically check syntax of ABAP report

No comments: