Copyright 2020 - BV TallVision IT

This article describes how to retrieve program documentation as text.

Program documentation can be maintained for each ABAP via the transaction SM38, "program development". This text can be reproduced on the screen via a function building block:

Example: Retrieve documentation text for a program  

Program documentation can be maintained for each ABAP via the transaction SM38, "program development". This text can be reproduced on the screen via a function building block:

DATA: DOCU_OBJECT(60),
      PROGRAM(8).

PROGRAM = 'REPNAME'.
DOCU_OBJECT = PROGRAM.

CALL FUNCTION 'DOCU_CALL'
  EXPORTING
    DISPL = 'X'
    DISPL_MODE = 2
    ID = 'RE'
    OBJECT = DOCU_OBJECT
    TYP = 'E'
    LANGU = SY-LANGU.

The parameter DISPL_MODE  is 1 for display via the SapScript editor (not very useful for end users), and 2 is for display on screen.

When calling these function building blocks the text is reproduced in the intended format and font type. With DISPL_MODE 1 (default) the text is reproduced without layout. When calling with DISPL = ' ' (default), without DISPL_MODE the text can be modified. For a series of program documentation oriented function building blocks, I refer to function group SDOC, "R/3 documentation".

Retreive a programs description, which are also stored in a TEXTPOOL. This "pool" contains data of column headings, numbered texts, program title (description) selection texts and the report header. An example: collecting a program description from a Dutch text pool:

Example: Retrieve selection texts for a program

Collecting a program description from a Dutch text pool:

 DATA: BEGIN OF TTAB OCCURS 50.
         INCLUDE STRUCTURE TEXTPOOL.
 DATA: END OF TTAB.
 
 * A FORM routine: fetch a program's title
 FORM READ_TITLE USING PROGNAAM CHANGING PROGTITEL.
 
   REFRESH TTAB.
   CLEAR TTAB.
 
   READ TEXTPOOL PROGNAAM INTO TTAB LANGUAGE 'N'.
   READ TABLE TTAB WITH KEY 'R'.
   PROGTITEL = TTAB-ENTRY.
 
 ENDFORM.

The textpool for programs contain more that just the program description, that's why the TTAB table is searched for the key 'R'. Please note the on line documentation on READ TEXTPOOL.