Skip to Content
Feb 27, 2013 at 03:11 PM

SWT2DB - Does "Main Program" refer to SY-CPROG or SY-REPID?



I'm planning to use SWT2DB to accelerate a custom ABAP report.

  • I want to configure it so that in a particular custom transaction, when the user executes a search, the respective JOIN is executed against the HANA sidecar via secondary database connection.
  • The actual search is performed by a global search class named /GKV/CM00_CL_ICLESRCH_ALLG.
  • I want to know how the program name that I enter in the configuration of SWT2DB is evaluated. Does ist use SY-REPID or SY-CPROG?

Here's the difference:


At the time of the SELECT, SY-REPID has the value of the current main program, in this case the main program of the class pool, /GKV/CM00_CL_ICLESRCH_ALLG====CP.

See the documentation (

"SY-REPID - Name of current ABAP program. With externally called procedures this is the name of the procedure’s main program."


At the same time, SY-CPROG has the value of the first main program, which in this case is a report named /GKV/CM00ICLE. (I think SY-CPROG changes when CALL TRANSACTION and SUBMIT are executed but not when CALL FUNCTION, CALL METHOD, and PERFORM IN PROGRAM are executed. Special variants of CALL FUNCTION might form an exception.)

See the documentation:

"SY-CPROG - In externally called procedures, the name of the calling program, otherwise the name of the current program. If an externally called procedure calls another external procedure, SY-CPROG keeps the name of the first main program and is not given the name of the main program of the further caller."


  • If the system uses SY-REPID, then I have to configure it using /GKV/CM00_CL_ICLESRCH_ALLG====CP, and the search class will always use the secondary database connection in online scenarios.
  • If the system uses SY-CPROG, then I have to configure it using /GKV/CM00ICLE, which would be okay here (but problematic in other cases, where ten or twenty different transactions use the same report and SY-TCODE is evaluated at run time to decide where to actually go - but that's another story).

Bonus points 😉

I'm aware of note 1696402 ( about the installation of SWT2DB but not of any further documentation of the tool, report RDA_MAINTAIN, and so on. Are you aware of any further documentation?