This blog will explain how to scan ABAP coding in search of a specific keyword or string. Many times older or badly written programs contain hard code logic like system ID’s, plant codes, movement types, order types etc. When a larger business change happens you need to find these codes in your ABAP code and act on them. This blog will explain how to do this search.
Questions that will be answered are:
- How does the scan program work?
- How to search for certain strings?
- How to search for words in the comments?
ABAP search tool
You can start the ABAP search tool with tcode code_scanner:
For testing 2 simple programs are written:
REPORT zscantest1. IF syst-sysid EQ 'S4H'. WRITE: 'development system'. ELSEIF syst-sysid EQ 'S4P'. WRITE: 'production system'. ENDIF.
REPORT zscantest2. DATA zt001w TYPE t001w. SELECT SINGLE werks FROM t001w INTO zt001w. IF zt001w-werks EQ 'DE01'. WRITE: 'German plant'. ELSEIF zt001w-werks EQ 'US01'. * USA plant WRITE: 'US plant'. ELSE. WRITE: 'diffferent plant'. ENDIF.
If we now start a search with the word ‘S4H’ we get this result:
A hard coded SID.
If we search with ‘US01’ we get this result:
A hard coded plant.
If we search with ‘USA’ we get this result:
The word we were looking for is in the comment lines.