You are on page 1of 9

Assistance class in Web Dynpro ABAP

By Archana Pawar, Infosys Scenario: Generally in Web Dynpro ABAP, we write all the required logic within the component itself but we can write the necessary logic outside the component that is in a class and we can use that class as the assistance class in our Web Dynpro component. So, in this BOK we demonstrate how to create assistance class for Web Dynpro application and use it to get the desired details. We will take example of displaying the flights available and bookings displayed in ALV where Departure and Destination City and country are input. Procedure: A. Creating class and coding the desired logic 1. Go to transaction se24 and create a class named as ZCL_WDABAP_FLIGHT_MODEL.

2. Give Instantiation as Public and class type as Usual ABAP Class. And save it.

3. Class will be created as shown in the below screenshot.

4. Create a public method GET_BOOKINGS and press ENTER.

5. Go to parameters and give IM_CARRID, IM_CONNID and IM_FLDATE as importing parameters. These are the details that we get from the 1st ALV in the Web Dynpro application where we display the flights available for the provided departure and destination city/country.

6. Give LT_BOOKINGS as Exporting parameter.

7. Now, go to code editor and we need to write the logic to fetch the desired details from table SBOOK.

8. Select all values from table SBOOK where CARRID, CONNID and FLDATE are from the flight details. Result will be stored in exporting parameter LT_BOOKING.

9. Activate the class.

A. Using assistance class in Web Dynpro component

1. Create a Web Dynpro Component ZZ_00_BOOKINGS, with input as Departure City/Country and destination City/Country. 2. Create logic to display the flights available meeting the input criteria and display the flight details in ALV format. 3. Create another table in MAIN view to display the flight bookings. 4. Now, go to the web Dynpro component, ZZ_00_BOOKINGS. 5. In assistance class, put the name of the class we created

ZCL_WDABAP_FLIGHT_MODEL and save.

6. Also, include the ALV component as shown in the below screenshot as we will be displaying the flights bookings in ALV format.

After saving the Web Dynpro Component, you can see Assistance class folder is generated under the component as shown in the below screenshot.

7. Go to Component controller and open the attributes tab. Check if WD_ASSIST attribute is created or not. This is the reference attribute of the assistance class which will be used to access the logic written in the class.

8. Go to context tab and make sure you have created additional subnode called Bookings to display the flights bookings. We will be displaying the below fields in the flight bookings ALV.

9. Now, go to the methods tab and double click on method GET_BOOKINGS. We will use the assistance class we have created in this method to get the details of the booked flight. These details will be stored in the internal table ITAB_BOOKINGS. 10. Bind internal table ITAB_BOOKINGS with the sub node .

B. Activation and Execution of the Web Dynpro Application 1. Save and execute the Web Dynpro Component. 2. Enter the Departure city as Berlin/Germany and destination city as Frankfurt/Germany. Press button Search Flights. 3. It will display the available flights in the first ALV and bookings of the flights in the second ALV.

You might also like