This code provides logic to remove the Header generated by TOP-OF-PAGE from the Last Page.
| CODE Snippet |
*&---------------------------------------------------------------------* |
This code provides logic to remove the Header generated by TOP-OF-PAGE from the Last Page.
| CODE Snippet |
*&---------------------------------------------------------------------* |
I was wondering if it is possible to have the same functionality of the Excel: Press Enter and cursor will move to next row.
As OO ABAP using the class CL_GUI_ALV_GRID provides so many methods for the processing at the Cell Levels. After looking to all the methods of the CL_GUI_ALV_GRID, I found there are so many methods which can do the processing at the Cell level. I have started to give the try. After certain tries, I was able to achieve what I was looking for.
| Code Snippet for the Class handler for ALV Grid Call |
*&---------------------------------------------------------------------* |
| Code Snippet for the Class handler definition and Implementation |
*&---------------------------------------------------------------------* |
Today we will try to explore the design patterns in the ABAP Objects. We will start with the Singleton design pattern, which is the simplest of its family of design patterns.
| Code Snippet to check instance |
|

| Code Snippet for Design Patterns: Singleton |
|

Sometimes we need to modify the subtotals on the ALV, specially when we have to give the average of the percentages or something like that. To change the subtotal we need to follow certain steps:
1. we need to get the ALV object form the ALV function module. We can use the FM GET_GLOBALS_FROM_SLVC_FULLSCR to get the Global data of the ALV. From this FM we will get the ALV object.
2. After getting the ALV object, we need to get the subtotal using the method GET_SUBTOTALS of the ALV object. We will get the first level subtotal using the parameter EP_COLLECT01.
3. Now, we need to modify the subtotal. Here we need to take help of Field-symbols since the EP_COLLECT01 is reference to data.
4. We need to refresh the Table display. For this purpose we can use the method REFRESH_TABLE_DISPLAY.
Here is the code snippet which performs all the steps mentioned above:| Code Snippet to change the Subtotal |
|
Whenever we generate the table maintianence, SAP generates some new code and use the Shared code for the Table maintainence generator. Since long time, I was wondering how can I add my own custom PF buttons in the table maintainence screen which comes in SM30. Today, this discussion in the SDN form raised this point in my mind again - Adding Custon button on Maintainance View.
I have started searching the GUI status in the Function Group which I have provided in the Table maintainence generator, but I didn't find it in the object browser (SE80) of the Function group. So, I thought this must be taken care by the Events in the Table maintainence. I searched the list and I found suitable one - ST (GUI Menu Main Program Name). Follow this link for mor information on Table maintenace events - Extended Table Maintenance Events
To add a custom button we need to follow couple of steps:
1. Create Table Maintainence.
Obviously today's discussion is based on the Table maintaince, we must have that before we start it. For a information purpose, I will attach a screen shot of the Table maintaince.
2. Copy user Interface of program SAPLSVIM to our FG
We will copy all the user interface of the main table maintainence program to our Fuction Group. Table maintainence runtime uses the user interface from the program SAPLSVIM. So, we are unable to find any user interface in our FG.
There will be one popup of language compatability, which you can pass it on by pressing Enter.
3. Add Custom Button in the PF-Status
Here we need to identify the proper PF-Status from all the statues. We will use the EULG pf-status which is being called when you enter in SM30 with Change mode. We will add the button with code "0POPUP" We can simply check which pf-status is being used in the each screen of the SM30 by going System > Status > GUI status. We will activate the changed status.
4. Add Event ST in the Table modification Events
Open the table maintainence generator screen and follow: Environment -> Modification -> Events. Select ST from the values and enter the FG main program name. For this example SAPLZTEST_TABLES.
5. Add PAI module in the Screen
Now, we need to create a new PAI module in the Screen flow. We will create the module 0CUSTOM_PF_BUTTON in the Screen. We will create this module in a New Custom include by selecting it from the popup.
In this code snippet, I am showing how to handle our user command. Here I am just giving information popup when user interact with the button in the change mode.
| Code Snippet for Handling custom button |
*----------------------------------------------------------------------* |
After pressing button, it will react like this:
When we assign the instance of the Superclass to the Subclass, than it is called the Widening Cast, because we are moving to the "More Specific View" from the "Less specific view". Due to this reason it is also called the "Down Casting".
Everytime it is not possible to move the Superclass reference to the Subclass, because subclass will(or might) have always more functionality compare to the Superclass. So, we need to be more careful when we use the down casting.
We will use the same ANIMAL Superclass and LION subclass as per the blog post - ABAP Objects: Narrowing Cast
When this Widening Cast is used?
Widening cast can be used when we need to access the Specific functionality of the subclass from the Superclass.
In ABAP, it is necessary to catch the exception CX_SY_MOVE_CAST_ERROR while doing the widening cast to avoid the short-dump.
| Code Snippet for Widening Cast (Downcasting) |
|

| Code Snippet for Class ANIMAL & LION |
|
| Code Snippet |
|
Output from this code snippet:
Today in the SALV model tutorial series, we will see how we can change the Column properites. You can find all the previous discussion in this series can be found at Tutorials > SALV Table Display.
To change the propeties of the Columns first we need to get the Column object from the SALV Object. The reference of the column object would be CL_SALV_COLUMNS. This object reference would provide us the access to the properties of all the columns. For example, if we need to set the column width optimization for the table, we can set using this columns reference.
To change the individual column properties, we need to get the individual column reference from the reference created using the CL_SALV_COLUMNS. The individual column property can be changed by the getting the reference of CL_SALV_COLUMN. Like, to change the column heading, we need to first get the column from the Columns object and than we need to set specific property.
Here is the code snippet to which provides the ADD-ON code to our Base program. The base program can be found in the SALV Model 1: Normal ALV Table Display.
UML Diagram would be like:
| Code Snippet |
|
In the series of the SALV Simple Model, we will see how we can set the Display Settings to the entire ALV. You can find the previous discussions in this blog series at Tutorials > SALV Table Display
To set the display settings, we need to use the reference of the class CL_SALV_DISPLAY_SETTINGS. We will ask the reference of the Display settings from our ALV object created using the CL_SALV_TABLE. By using the dispaly settings, we can set the Zebra style, Title of the ALV etc.
Here is the code snippet to which provides the ADD-ON code to our Base program. The base program can be found in the SALV Model 1: Normal ALV Table Display.
UML diagram for this example is like:
| Code Snippet |
|
We have discussed in post SALV Model 1: Normal ALV Table Display to generate an ALV using new the SALV Model. It is a true object oriented way to generate an ALV.
Today, we will see how to add standard PF Status (GUI Status) in this Standard ALV created using the class CL_SALV_TABLE. The object created with reference to CL_SALV_TABLE contains the method which can be helpful to add the PF-Status in the ALV.
Here is the code Snippet which provides the ADD-ON code. This ADD-ON code can be replaced with the relevent section from this code snippet in the base program. You can find the base program code snippet in the post SALV Model 1 : Normal ALV Table Display. Adding code to base program is like adding the code correction from the OSS Note.
The new UML diagram of our application is like:
| Code Snippet to add Default PF Status |
|