If changes are made to the code, then there is no guarantee that previous assumptions are satisfied. SAP ABAP checkpoints can be used to make sure that program correctness is maintained. Under checkpoints, we consider assertions, break point and log points.
Assertions can be used to improve the quality of software. BREAK-POINT and LOG-POINT are used to investigate program behavior in case of problems. They helps in understanding and maintain the code.
The activation state of all checkpoints which can be activated is controlled by the checkpoint group.
Let us consider a scenario where money is transferred from one account to another. Here, sum of both balances must be equal before and after transfer. With the help of assertion we can check this condition. It is a statement which we can put in the program describing a specific condition.
During program execution if statement is incorrect, execution can be stopped.Program execution can be stopped by raising ASSERTION_FAILED.
ASSER ID checkpointgroup CONDITION logicalexpr.
If ID statement is used then assertion is activatable otherwise it is always active.
How to create checkpoint group?
Checkpoint group can be created using SAAB transaction.
Enter Name and click on create. Save it and activate it.
By default Assertion is Inactive as below you can see in Assertions frame.
Write following code and execute.
data i type i.
assert id ztry condition i is not initial.
Program will run.
Then go to transaction SAAB, select radio button Abort in Assertions frame and activate checkpoint group.
Again run the program. You will get dump describing the position where assertion is violated.
When you select Log option the occurrence of assertion will be logged.
When you select Break option you will get following option.
In normal case program is interruption and debugger is started and in case of background processing it will behave like Log mode or Abort mode depending on what is selected.
Same way BREAK-POINT and LOG-POINT can be activated by selecting Break and Log.
Break Point can be activated by writing following code in your program.
BREAK-POINT ID Checkpoingroup.
Activatable break point behaves same as always active break point. In case of background processing activatable break points are simply ignored.
Log Point can be made activatable by writing following code in your program.
LOG-POINT ID Checkpoingroup.
Logs can be used to identify or analyze the system behavior. Variable values can be logged so that program developer can analyze those values.
You can add in your program statement LOG-POINT ID ZTRY.
Run the program and go to transaction SAAB. Go to tab ‘LOG’. You will see following details which will help you to analyze program’s behavior.
You can also use following syntax.
DATA: log (12) type c.
Log = ‘FILED VALUE’.
LOG_POINT ID ZTRY FIELDS log.
Run the program and check the Log in SAAB transaction.
Above statement log the value of field ‘log’. We can log upto 32 fields.
You can use SUBKEY addition to prevent production of huge amount of data in log. All log occurrences will produce one record for same SUBKEY. Only last occurrence can be seen but counter will be incremented.
LOG_POINT ID ZTRY SUBKEY ‘TEST’ FIELDS log.
Checkpoint group activation can be done with three levels
Personal Activation – Checkpointgroup will be active for current user only.
User Level activation – Checkpointgroup will be active for all defined users.
Server Level Activation. – Same way we can define servers for which it will be active.
In case you need assistance on SAP Support Services, please contact us. Please send us your questions, comments or assistance request and our team would be glad to assist you.
By Sareeka Bangar (on behalf of SAP Consulting Team)
SAP :: Streamlined
We offer variety of services including SAP ECC ,SAP HR,SAP BW,SAP CRM, SAP SCM,SAP BPM, Business Objects, SAP ABAP Development, SAP BASIS and SAP NetWeaver consulting. We have expertise in providing implementation,development, SAP Migration and SAP support services to SAP customers across diverse industries at a global level.
Have a question on SAP? Write to our SAP Architect.
(We promise a no-obligation consulting reply)