You notice that something is not right with the output of your code. In particular, the console displays the same number for maximum seats and occupied seats although the number of free seats is larger than zero. You create a check variant for the ABAP test cockpit and use it to analyze your code.
Task 1: Create a Check Variant
In your package, create a new check variant (suggested name: Z##_VARIANT, where ## is your group number). Configure the check variant to perform all checks of category Extended Program Check (SLIN).
Hint
By default, Extended Program Check (SLIN) only performs a subset of selected checks.Steps
Create a new ATC check variant.
In the Project Explorer on the left, right click your package and choose New → Other ABAP Repository Object.
In the filter field, type atc.
Choose ATC Check Variant and choose Next >.
Enter Z##_VARIANT for Name and Extended Program Check for Description, and choose Next >.
Confirm your Transport Request and choose Finish.
Choose check Extended Program Check (SLIN).
In the Checks view on the left, expand node Syntax and activation.
Set check Extended Program Check (SLIN) as selected.
Edit the parameters of check Extended Program Check (SLIN). Set the value of parameter StandardOrCustom to 2 and the value of all other parameters to true.
Left-click on Extended Program Check (SLIN) to open the check in the Check Details view on the right.
In the Check Details view, choose the Parameters tab to display the input parameters for this check.
Edit the source code on the Parameters tab, and change the value of the StandardOrCustom parameter from 1 to 2.
Scroll down the list, and set the value of all other parameters to true.
Activate the check variant.
Press Ctrl + F3 to activate the check variant.
Task 2: Improve Code
Using your check variant Z##_VARIANT, perform a static code check of class ZCL_##_SOLUTION, which you created during the previous exercise. Analyze the findings and make corrections to the code where necessary.
Steps
Perform a check of class ZCL_##_SOLUTION, using your check variant Z##_VARIANT.
Right-click anywhere in the source code of your class, and choose Run as → ABAP Test Cockpit With ....
Enter the name of your check variant (Z##_VARIANT) and choose OK.
Note
The check is performed asynchronously. Wait for the green bar in the lower right corner to disappear.Choose the ATC Problems tab below the editor view to display the check result.
Analyze the result and fix the warning related to this field: SEATS_OCC.
Hint
You know that if the code was correct, attributes SEATS_MAX, SEATS_OCC, and SEATS_FREE would be used in the same places.Find the warning that reads No reads performed on field SEATS_OCC.
Double-click on the warning to navigate to the source code.
Place the cursor on attribute SEATS_MAX and choose Get Where-Used List from the toolbar. Alternatively, you can press Ctrl + Space + G.
From the where-used list, you can see that one of the append statements falsely uses the SEATS_MAX attribute instead of the SEATS_OCC attribute.
On the where-used list, double-click the APPEND statement that includes literal text Occupied Seats: to navigate to the statement.
In this append statement, replace SEATS_MAX with SEATS_OCC to fix the issue.
Analyze the result and fix the warning related to CURRENCY_CODE field.
Hint
You know that the CURRENCY_CODE attribute is not used yet, but you want to keep it for future developments. Therefore, you hide this warning using a pragma.Return to the ATC Problems view.
Find the warning that reads No reads performed on field CURRENCY_CODE.
Choose the warning to display the warning details.
On the Details area on the right, find the sentence starting with Finding can be suppressed with ....
Double-click the warning to navigate to the source code.
Place the cursor on the CURRENCY_CODE attribute and choose Get Where-Used List from the toolbar. Alternatively, you can press Ctrl + Space + G.
Adjust the DATA statement as follows:
1
DATA currency_code TYPE /dmo/currency_code .
Activate your class and repeat the code check to verify that the two warnings have gone.
Note
For the moment, we will ignore the other findings. They will be covered in later sections of this course.Press Ctrl + F3 to activate the class.
Return to the ATC Problems view.
Right-click any of the findings to open the context menu.
From the context menu, choose Recheck.