If you are not familiar with the ABAP debugger or if you are just getting started using it, then you might find it challenging to locate the ABAP code that you have written in your SmartForms documents.
The purpose of this article is to provide some information and a few tips on using the debugger to help troubleshoot problems in the ABAP code in SmartForms documents.
There are many advantages to using SmartForms over traditional SAPScripts for your SAP documents. While the interface makes it easier to design and implement the overall layout of the document, you also have the ability to incorporate ABAP code at strategic places right in the SmartForm without having to modify the print program.
However, there are times when you need to debug the ABAP code that you have written within your SmartForms document.
Those who have used the ABAP debugger know that it can sometimes be difficult to find the specific lines of code that you are looking for. In fact, it can sometimes be like looking for a needle in a haystack. At the very least, you can spend a significant amount of time stepping through layer after layer of programs, includes and function modules.
However, by knowing a few simple tips you can stop document printing at just the right location so that you can find and debug the ABAP code that you have written in your SmartForms document.
SmartForms – Function Module Names
First of all, it is important to realize that all SmartForms documents are compiled into their final run-time programs when they are activated. SAP dynamically creates a unique program name with associated includes and function modules when the SmartForm is activated.
While in your SmartForms document go to the menu option Environment –> Function Module Name. There you will find the function module name that SAP created for your SmartForms document. The name of the function module will look something like: /1BCDWB/SF00000015.
SmartForms – Program Names
The next step is to find the name of the SmartForms program name which can be done by using transaction code SE37 – Function Builder and entering the Function Module Name that you found in the previous step.
Go to the Attributes Tab and there you will find the program name which looks something like this: /1BCDWB/SAPLSF00000015. Notice that the word SAP has been added to the Function Module Name to create the Program Name.
Where SAP stores your ABAP Code in SmartForms
To find the ABAP code that you have written inside your SmartForms document simply double-click on the program name which will take you inside the program. There you will see several include statements in two different sections:
1. System-defined Include-files /1BCDWB/LSF00000015TOP "Global Data /1BCDWB/LSF00000015UXX "Function Modules
2. User-defined Include-files /1BCDWB/LSF00000015F01 "User Code
Your ABAP code will be found within a FORM with near the end of the User-defined Include-files /1BCDWB/LSF00000015F01. A different FORM is generated for each section of code that you have written in the SmartForms document. Each FORM name is generated with the format %C##. For example your ABAP code will be located in a FORM that is named%C01, %C02, C03 and so forth.
Setting Breakpoints in the ABAP Debugger
Now that you know where to find your ABAP code in the SmartForms generated programs you are ready to get started using the ABAP Debugger. You can start by creating an output for your SmartForms document. At this point just before saving the document with the new output, simply enter /h and press execute. This will activate the debugger which will pop-up after saving the document.Note: If you happen to activate the debugger before the document is saved then the debugger will start placing you in the ABAP code before the document save code begins and not where the document printing begins. If this happens then simply press the Continue button so that it will jump past the document save code and stop again where the document print code begins. If the document prints without the debugger stopping at the document print code then you will have to begin again.
Once the debugger starts you can quickly set a breakpoint using the Program Name and the User-Include file so that the debugger will stop exactly at the point where your ABAP code is located in the SmartForms document.
Use the menu path Breakpoints –> Breakpoint at –> Source Code and enter the Program Name and Include file name you found earlier. You will also need to enter the program line in the Row field in order to specify the exact location where you want the debugger to stop.
Program Name: /1BCDWB/SAPLSF00000015 Include: /1BCDWB/LSF00000015F01 Row: #### - "Line number of your code where it appears in the include file
Once you have the breakpoint set, press the Continue button. This will stop the SmartForm execution at the exact point where you want to start debugging you ABAP code. At this point you can check values of variables, look at table contents and step through your ABAP code to find out where problems exist.
Without knowing a few basic tips about how to find your ABAP code in a SmartForms document, you can spend a lot of time stepping through standard ABAP code in SAP. While object oriented code has changed the world of programming, it can also present challenges when you don’t know where to look to find the specific code that you want to troubleshoot.Note: The Program Name and the Include File names of your SmartForms document will be different in each system in your SAP landscape since they will be dynamically recreated when they are transported to each system. Therefore, if you want to use the debugger on the same SmartForms document but in a different SAP system, you will have to lookup the Program Name and Include files names in that system.