Posts

Exception Class in Object Oriented Programming

Image
  Exception is a problem that arises during execution of the program. The purpose of exception class is to raise and handle the exception. We use try block to raise a exception and catch block to handle a exception. The exception class name must start with CX. CX_ROOT is the global class ( parent class ) for all the exceptions. There are 3 subclasses of parent class CX_ROOT. CX_STATIC_CHECK :- It is checked by both the compiler and runtime system. CX_DYNAMIC_CHECK :- It is checked only at runtime system. CX_NO_CHECK :- It is not checked either during compile time and runtime. Note :- While creating the exception class, system by default provides CX_STATIC_CHECK as the super class. Ways to Create Exception Class :- There are 2 ways to create the exception class. Exception class with messages of message class. Exception class without messages of message class. Creating Exception Class without using messages :- Step 1 :- Go to transaction code SE24....

Persistence Class

Image
  Persistence Class is one of the four classes in Object Oriented Programming in ABAP. The purpose of persistence class is to perform database operations like insert, update, delete. The persistence class name must start with CL. While creating the persistence class, 2 helper class creates automatically. Those helper classes are CA and CB. CA is called as actor class or agent class. CB is called base class. Creating Persistence Classes :- Step 1 :- Go to SE24 and give a suitable name to the class. Step 2 :- Click on create button. Step 3 :- Click on save and Provide Package and transaction requests Step 4 :- We will get automatic one interface and one friend class as we can see below. Requirement :- How to create getter and setter method for a particular table using Persistence Class. Solution :- Step 1 :- Click on go to. → Persistence Representation It will ask for table name. Step 2 :- Provide the table name. Press enter. Step 3 :-...

PF Status and User Command Using CL_SALV_TABLE Class

Image
  In the previous part, we achieved a requirement using double click. Lets understand today’s requirement, Our requirement, is that User will provide a range of Sales Document number as input. We will display details of that Sales Document number as output from VBAK table in one ALV. I will create a custom button on the ALV. Then I will select one row of ALV and when I will click on the button, It will show the item details from VBAP table for the same selected rows. Solution :- Step 1 :- Create a executable program in ABAP Editor ( Se38 ). Step 2 :- Create a type structure from VBAK and VBAP table and then create a corresponding internal table for the same Step 3 :- Define a select option for user input. Step 4 :- In start of selection, write a select query from VBAK table. Step 5 :- Now we need to get object of CL_SALV_TABLE by using its factory method. Step 6 :- Then we will use display method to display first ALV. Step 7 :- Now we...

Double Click Event Using CL_SALV_TABLE_CLASS in OOPS ALV

Image
 The class CL_SALV_TABLE in ABAP (Advanced Business Application Programming) is used to create ALV (ABAP List Viewer) reports. One of the features of ALV reports is the ability to handle user actions like double clicking on a row of the report. This is achieved using the CL_SALV_TABLE class. To implement the double click functionality, you need to first create an instance of the CL_SALV_TABLE class and then get the event object for the table using the GET_EVENT( ) method. Once you have the event object, you can register a handler method for the double click event. let’s take a requirement. Requirement :- User wants to give a range of Sales Document Number as a input on the selection screen. We will display ALV for the Header details of Sales Document Number from VBAK table. When user will double click on any row, then it will display the Item details from VBAP table. Solution :- Step 1 :- Create a executable program in ABAP Editor ( Se38 ). Step 2 :- Create a ty...

Sorting in ALV using CL_SALV_TABLE Class

Image
 let’s understand this concept by taking a requirement. Requirement :- Use want to give a range of Sales document number as input to the selection screen and wants to see details of sales document of number from VBAK table in the descending order of Sales Document number. Solution :- Step 1 :- Create a executable program in ABAP Editor ( SE38 ). Step 2 :- Create a type structure and a corresponding internal from VBAK table. Step 3 :- We need to create a select option and then we will write a select query to fetch data into the internal table. Step 4 :- We will call the factory method of CL_SALV_TABLE class to get the object of the class. Step 5 :- Now, we need to call the method GET_SORT of CL_SALV_TABLE to get the object of CL_SALV_SORTS class. Here, we have got the object for our CL_SALV_SORTS class. Step 6 :- Call method ADD_SORTS from CL_SALV_SORTS of class. Step 7 :- then we call display method through the object of CL_SALV_TABLE class. *...