Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Finding constants and text element in report programs and includes

sanjana_lingras
Active Participant
0 Kudos

Hi ,

I want to write report program to read constants and text elements from includes,report programs and function modules.

Input should be program,include or FM name and output should give list of text elements and constants.

Please let me know how this can be developed.

Thank you.

5 REPLIES 5

mateuszadamus
Active Contributor
0 Kudos

Hello sanjana.lingras

If I were in your shoes, I'd first see how SE38 transaction works, when the Text Elements options is selected.

As to the constants, I'd check how RPR_ABAP_SOURCE_SCAN report works. You could basically copy and tweak its logic.

Kind regards,
Mateusz

0 Kudos

I need to scan 21,000 objects for constants and text elements, also it should scan into the FMs and includes called inside program if possible.

0 Kudos

I don't mean you should go to SE38 and manually check for text elements. No. I meant to debug the transaction and check its logic.

Better yet, use your favorite search engine and search for "sap abap function to list text elements of program". In one of the results of my favorite search engine I found function READ_TEXT_ELEMENTS.

As to the includes and functions, in this case you will need to look for INCLUDE and CALL FUNCTION keywords in the source code. Then get the include/function name and add it to the list of objects to be processed. Run your report's logic for the found objects.

Kind regards,

Mateusz

michael_piesche
Active Contributor
0 Kudos

I would go with Mateusz suggestion, and copy the report RS_ABAP_SOURCE_SCAN (which is the report that is actually called from RPR_ABAP_SOURCE_SCAN as well), and adapt it to your need.

First get acquainted and try the report with searching for "CONSTANTS" in a subset of programs or packages you want to analyse.

For your program you will have to do the following for constants:

  • The result will have to be analyzed from the term CONSTANTS until the first '.' (end of statement)
  • CONSTANTS should not be part of comments and before CONSTANTS there should be another '.' (end of statement) or nothing (ignoring spaces and line breaks)
  • The value of a constant might be fixed, or 'dynamic', if it is 'dynamic' it will be harder to get the actual value, which might be only available at initialisation of the runtime and depend on other values.
CONSTANTS: const_fixval TYPE char1 VALUE '1',
           const_dynval TYPE char1 VALUE const_fixval.

For text you will have to do at leas this:

  • Text elements can be either written as text-001 or as 'text'(001)
  • To get the value of the text you use the READ TEXTPOOL statement and access the table with the key, eg. 001
  • If you combine the ABAP SOURCE SCAN with the READ TEXTPOOL, you definitely know, whether defined text are also being used by the program, if you just care about text-elements that are defined, a SOURCE SCAN would be not necessary
DATA: prog TYPE PROGNAME VALUE 'PROGRAM_NAME',
      itab TYPE STANDARD TABLE OF TEXTPOOL.
READ TEXTPOOL prog INTO itab LANGUAGE sy-langu.

Be aware, that there can be lots of different implementations, that might not adhere to how you would expect constants and text to be implemented. As always, there are many roads that lead to Rome.

Sandra_Rossi
Active Contributor
0 Kudos

ABAP statements READ REPORT and READ TEXTPOOL