Quantcast
Channel: Tweaks
Viewing all articles
Browse latest Browse all 66

SAP ABAP Checkpoint Group – Chase the Mysterious SAP Issues with a Smile

$
0
0

T-Code SAAB for SAP ABAP Checkpoint Group

If changes are made to the code, then there is no guarantee that previous assumptions are satisfied. SAP ABAP checkpoints can be used for making sure that program correctness is maintained. Under checkpoints, we consider Assertions, Breakpoint, and Log points.

Assertions can be used for improving the quality of software. Breakpoint and Log point are used for investigating program behavior in case of problems. They help in understanding and maintaining the code.

The transaction SAAP has been there for quite some time but it is a pity not many ABAPers are aware of it. Therefore we thought our SAPYard family members should know about this useful tool. Better late than never. It is such a handy tool, which might even be useful in the real production environment.

Checkpoint Group
The activation state of all checkpoints which can be activated is controlled by the checkpoint group.

Assertion
Let us consider a scenario where money is transferred from one account to another. Here, the sum of both balances must be equal before and after transfer. Simple Finance. Right? 🙂 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.

syntax 1 – ASSERT logical expression.

During program execution, if expression fails, execution can be stopped. Program execution can be stopped by raising ASSERTION_FAILED.

syntax 2 – ASSERT ID checkpoint group CONDITION logical expression.

If ID statement is used then assertion activation and its behavior is controlled from outside the program by checkpoint group otherwise it is always active.

How to create Checkpoint group?

Checkpoint group can be created using SAAB transaction.

SAAB

Enter Name and click on create. Save it.

Please note – By default Assertion is Inactive as shown below in the Assertions frame.

How to create checkpoint group?

Also Read – Lazy and Smart ABAPers

Let us write a very basic program and execute it in SE38.

REPORT ZSAPYardCheckPoint.

DATA : lv1 TYPE c VALUE 'A'.
DATA : lv2 TYPE c VALUE 'B'.

INITIALIZATION.

  LOG-POINT ID zcheck_pt FIELDS: lv1,lv2.

START-OF-SELECTION .

  lv1 = 'X'.
  lv2 = 'Y'.

  LOG-POINT ID zcheck_pt FIELDS: lv1,lv2.

  WRITE 'Run.. Done'.

 ASSERT ID zcheck_pt CONDITION lv1 EQ lv2.

 BREAK-POINT ID zcheck_pt.

Execute the program. It would run successfully and write the output “Run.. Done”.

Case 1 – Abort

Now, go to transaction SAAB. Select radio button Abort in Assertions frame and save the Checkpoint Group.

How to activate Assert

Now, execute the program again. You will get a dump describing the position where Assertion is violated.

Assertion is violated

Did you check? Playing Sherlock Holmes to detect CONVT_CODEPAGE runtime error mystery

You can no doubt see the dump in the regular t-code ST22. But our aim in this article is to see the Log in SAAB T-code where we created the Checkpoint.

Case 2 – Log

In order to start logging, we need let the SAAB T-Code know about our intention.  We need to choose the Log radio button (as shown below) in the Assertions (Foreground) section.

Log radio button

You can see the log details with Variable values, which would be very useful in cases where we can’t replicate the scenarios in Quality or Development box – to chase the mysterious missing values.

Assert log

PS: If you do not see the above log, choose the Log radio button in Assertions frame and re-run your program.

Case 3 – Break

When you select Break option you will get following pop up which is just an information.

What does the above information mean?

Ans: In the normal case, the program is interrupted and the debugger is started. In case of background processing, there are two choices. It will behave like Log mode or Abort mode depending on what is selected in the above pop up. By default it is Log, so in Background processing mode, the program would not go into debug mode, but checkpoint group would log the issues.

Just like Assertions; Breakpoints and Logpoints can be activated by selecting Break and Log respectively.

break and log

BREAK-POINT:
Break Point can be activated by writing following code in your program.

BREAK-POINT ID <Checkpoingroup>.

breakpoint activation

Active breakpoint behaves same as an Always Active breakpoint. In case of background processing, activatable breakpoints are simply ignored. Run the Program in the foreground, you can see the program stop by at line 30.

LOG-POINTS:
Log Point can be made active 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 the developers can analyze those values.

You can add in your program statement LOG-POINT ID ZCHEECK_PT. You can also use the following syntax.

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.

Above statement log the value of field ‘log’. We can log up to 32 fields.

You can use SUBKEY addition to prevent the production of a huge amount of data in the log. All log occurrences will produce one record for the same SUBKEY. Only last occurrence can be seen but the counter will be incremented.

LOG_POINT ID ZTRY SUBKEY ‘TEST’ FIELDS log.

Also Read – DELETING rows of the internal table within the LOOP. Is it a Taboo? A big NO NO?

Checkpoint group activation can be done with three levels

  1. Personal Activation – Checkpoint group will be active for current user only.

2. User Level activation – Checkpoint group will be active for all defined users.

User Level Activation of Log

3. Server level Activation – The Same way we can define servers for which it will be active.

This was my humble effort to bring your notice to this simple yet very powerful tool which every ABAPer should make use of. I know, this transaction SAAB should have been introduced years ago. But every day you find something new in SAP. Please start using it and let me know if you face any issue. I would try to answer your queries.

If there any other useful tool which you use in your project?

Please share with us if you have some smart way to tackle production issues or identify dumps. If you have some custom tools which can be shared, do send it to us. We would be happy to share it in our portal.

Now, we want to hear from you. Please leave your feedback and comments below.

We have a very active Telegram (App) SAP Technical Group with more than 1440+ SAP Technical Practitioners from 6 Continents of the SAP World. Please join it using below link.
Telegram SAP Technical Discuss Group. You need to install the Telegram App first on your mobile device. Once you have it on your mobile, you can join the group and also access it from the Web on your computer and laptop.

Check Step by Step Tutorials on SAP HANA-ABAP


Viewing all articles
Browse latest Browse all 66

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>