SAP Logo

SAP: Finding text strings across ABAP programs (UPDATED)

As an SAP consultant focusing on functional configuration, I am not required to know much about ABAP.  If you’re lucky, there’s a developer within arm’s reach for handling technical efforts.  However, part of growing in your field is reaching out beyond your functional area to explore new avenues.  This ultimately makes you a better consultant.  I’m on a project currently — a divestiture of sorts — which must explore breaking apart Company Codes, Sales Organizations, and other elements.  One thing to consider — especially for mature systems — is what custom objects may be tailored for the existing organization.  This helps determine what the impact will be when creating a new Sales Organization, for instance.  But, how do you find those elements?  More importantly, how can you find references to a specific value you’re trying to change? UPDATE: Thanks to input from commenter Pavel, I’ve added a new section at the very bottom of the article with updates in ECC 6.0.  Check it out. ABAP-STRING-001 The Program SAP provides a couple of tools that you can use to search for text strings inside of ABAP code.  Both are quite similar in how they present their results.  I find one to be more flexible in its execution criteria, so I will focus primarily on that option:  Program RPR_ABAP_SOURCE_SCAN. Calling up program RPR_ABAP_SOURCE_SCAN in either SE38 or SA38 will present the ‘Scan ABAP Report Sources’ screen.  The most important selection criterion will probably be ‘Program Name’.  You can maintain a single program, range of values, or SAP’s standard Multiple Selection option. The ‘Search Criteria’ section title is a bit misleading in my opinion.  Apart from the ‘ABAP String’, where you input the text you’re searching for, this section contains attributes for your search results.  The ‘Found location +/- lines’ setting will allow you to display the surrounding lines of code when a result is found providing some additional context for your analysis.  You may also wish to use the ‘Ignore comment lines’ option to only display results in executable code. To run the program, input your “Find string” value, specify the programs you wish to include in the scope of the search and hit execute. What To Look For Being an SD consultant, I am primarily interested in finding SD-related impacts.  Here is what I recommend for a good starting point:

  • Z* Programs (programs beginning with the letter “z”) If you’re completely unfamiliar with your client’s system, this can always be a daunting task.  There’s no telling how many Z objects may be lurking around the next corner.  Though this will return all the client’s programs, you may wish to bounce this up against a month or two worth of ST03n results to find a list of which programs are actually used in the system.  Contact your Basis resource for that information.
  • MV* Programs As you may know, the MV* programs are primarily where you will find SAP user exits.  For example, program MV45AFZZ is a popular one for Sales order related enhancements.  If overlooked, these can often become the “gotachas” you discover shortly after go-live.
  • RV* Programs These programs are were you will find many of the routines maintainable in the VOFM transaction — copy control routines, pricing formulas, calculation routines, credit control enhancements, etc.  The programs with the “RV” prefix are the customer maintained programs.  Though, I suppose it is possible that standard routines have been customized as well.

As I said, this is more of a starting point than a comprehensive list.  There are always BAPIs, Smartforms, and other hidden gems that may be more difficult to find.  Contact a development resource if you need some deeper analysis performed on those. Report Results ABAP-STRING-010Back to our report…  I’m going to search for some standard values inside the MV45AFZ* programs.  In my example, I am going to search for “ZZFIELD”, which is a dummy value included in all SAP installations.  I input ‘MV45AFZ*’ into my ‘Program Name’ field and ‘ZZFIELD’ into the ‘Find string’ field.  I execute the program to perform the search. This limited run returns it results fairly quickly:  32 Hits.  In the case of this program, a “Hit” represents one line in a program.  The value ‘ZZFIELD’ may exist more than once for each “Hit”.  The results return other useful bits of information:ABAP-STRING-012

  • Program Name
  • Date and time stamp of when the report was run
  • Line numbers for each returned line

Single-clicking anywhere on the returned code will take you right into the program in the ABAP Editor window. You can save the report results to a local file through the List –> Save/send –> File… menu option. Tips Here are a couple of tips to keep in mind:

  • Limit your scope of programs.  Include too many programs, and you’ll cause the system to timeout.  Instead, you may want to run each subset of programs as a stand-alone run.  Or, you also have the option to run the program in the background.
  • When searching for specific values, keep in mind that you may find other variables with that same value.  For instance, let’s say you want to search for Sales Organization ‘BP01’, so you input ‘BP01’ in your ‘Find string’ field and execute.  The search may also return results for Company Code ‘BP01’, or Sales Office ‘BP01’, or Purchasing Organization ‘BP01’.

Wrap-up That’s about it.  Oh.  There’s another option to the above program for searching.  It’s called ‘Global Search in Programs’ and is accessible through Transaction EWK1.   The ‘Global Search in Programs’ screen offers fewer options, but from my experience returns similar results.  As always, please leave a comment if you have some thoughts around this topic. UPDATE (4/24/2014):

RS_ABAP_SOURCE_SCAN in SAP ERP 6.0
RS_ABAP_SOURCE_SCAN in SAP ERP 6.0

In SAP ERP 2005, the program RPR_ABAP_SOURCE_SCAN that I originally wrote about appears to have been replaced by RS_ABAP_SOURCE_SCAN.  In ERP 6.0, the ‘RPR’ report has been completely commented out and, instead, calls the ‘RS’ report.  The newer ‘RS’ report seems to work very much like the older ‘RPR’ report I documented above, but with additional selection criteria. Depending on the version of SAP you’re working with, you may need to resort to the older program. For more information, please see SAP Note 1492058, titled “Problems with variants for the report RPR_ABAP_SOURCE_SCAN”. Thanks, Pavel!

SAP: Finding text strings across ABAP programs (UPDATED) was last modified: April 24th, 2014 by michael

7 thoughts on “SAP: Finding text strings across ABAP programs (UPDATED)”

  1. Hi Michael! It was good to find that article after manual search of 500 reports 🙂 Just wanted to share one more report RS_ABAP_SOURCE_SCAN with very similar selection screen but with some more options on it. Not sure if it is the most modern one. Cheers!

  2. Pavel,

    I am trying to use your program in an report to look for programs as part of a job and it seems to not like running in the background. It doesn’t seem to accept parameters. Anythoughts?

What say you?

This site uses Akismet to reduce spam. Learn how your comment data is processed.