Different ways to Find any String or Hard Coded Value in SAP ABAP Code

The different ways to search any String or Hard Coded Value within SAP ABAP Code including Reports, Includes and Classes Explained !

Reports to find String in SAP ABAP Program

The different methods to find any String in SAP ABAP Code are:

  • Report RPR_ABAP_SOURCE_SCAN 
  • Report RSRSCAN1
  • Standard Report RKCTSEAR
  • Report AFX_CODE_SCANNER (it requires at least one package name)
  • Custom Report

The recommend Report to search any string in ABAP Programs in RPR_ABAP_SOURCE_SCAN.
But it is not available in all SAP Version like (CRM, SRM,…). In this case, you may want to use RSRSCAN1.
( The RSRSCAN1 reachs its limits very quickly and may dumb, consider running it with a limited ABAP programs )

Check also   ABAP in Notepad++ ( ABAP Syntax Highlighting )

Transaction codes to find String in SAP ABAP Code

  • SE38 > Tools
  • Tcode CODE_SCANNER
  • and also Transaction Code EWK1

As RPR_ABAP_SOURCE_SCAN, you may not have the EWK1 Transaction codes in your system.

Search String in ABAP Report Tcode: CODE_SCANNER

And my preference to search for String in ABAP source is for the standard Transaction Code CODE_SCANNER.
In fact, the  CODE_SCANNER Tcodes is for “Scans Report/Funct. Group/Class Code” and it is based on the report AFX_CODE_SCANNER.

In the Search Criteria, the only parameters required are the package & the Search String 1.
You have also options to :

  • Ignore Comment lines
  • Display Objects Without Lines
  • Open Objects in Edit Mode

You can also restrict your string search to :

  • Programs ( Reports, Includes, Screen )
  • Function Groups
  • Classes

Custom Report to search for String or Hard coded in SAP Programs

An alternative to find a String or any hard coded value in SAP ABAP code / programs is to create your own report and take the control.
The main algorithm is :

Check also   Function Module SAP Tables and Interfaces

Read the SAP Dtabase View TRDIR

The TRDIR is  based on SAP Table REPOSRC.
The main field for TRDIR are:

  • NAME ABAP Program Name
  • SQLX Source code protection
  • EDTX Editor lock flag
  • VARCL Case-Sensitive
  • DBAPL Application database
  • DBNA Logical database
  • CLAS Program class
  • TYPE Selection screen version
  • OCCURS Automatically generated program
  • SUBC Program type
  • APPL Application
  • SECU Authorization Group
  • CNAM Author
  • CDAT Created on
  • UNAM Last changed by
  • UDAT Changed On
  • VERN Version number
  • LEVL Level
  • RSTAT Status
  • RMAND Client

Read Screen Souces from Table D020S

The SAP Tables D020S (System table D020S (screen sources)) stores the Screen Sources.

Search for String in ABAP Report & Classes

Use the ABAP statement READ REPORT in order to read the ABAP sources into an internal Table.
for example: read report gv_RepName into gt_SrcCode.

Search for String in DynPro (Screen)

For Screen and Dynpro, use rather IMPORT DYNPRO.
For example: import dynpro gs_DynHeader gt_DynFields gt_DynLines gt_DynParams id gs_DynPro.

You will find the whole Report here Search for Strings in ABAP Source Code

Check also   Trigger MATMAS IDoc using BTE event

Further Reading on ABAP Programming

If you want to go further and learn more about ABAP Programming or even refresh your ABAP knowlege, I recommend the following Books:

 

Sab125

Hi. I have been working as SAP Technical and functional for a decade. Through this blog, I am trying to share with you my experience. Hopefull, it makes your ways easier path ... Sab

Leave a Reply

Your email address will not be published. Required fields are marked *