Technical Articles
Missed or stuck with openSAP week 4 ? Generate your RAP object
For whom did I wrote this class?
If you have not been able to attend week 4 of the openSAP course and you do not have to time to type all the code yourself.
Another target group might be those participants whose RAP business object in week 4 does not work as expected.
What do you have to do?
- Create two new packages
- ZRAP_#### within ZLOCAL
- ZRAP_TRAVEL_U_#### as a sub package of ZRAP_####
- Create a class zcl_generate_week4_#### within the package ZRAP_TRAVEL_####
- Replace the source code of the template with the source code that you can find on our github repository
- Replace all occurrences of #### with an own unique number or unique combination of numbers and characters (for example 5678)
(You will find #### in line 1, 13, 14 and 45) - Run the class as a console application using F9
Result
The class does the following:
- It creates all objects that have been created in week 4 beside the behavior implementation classes.
What is left to do
- Open the behavior definition and click on the names of the behavior implementation classes and use the quick fix to generate both classes as described in step 4 and step 6 of my script:Create behavior implementation class for travel
- Change the code in the behavior implementation class for Travel zbp_i_rap_travel_u_#### and Booking zbp_i_rap_booking_u_####.This is necessary since in the script I named the control structures zsrap_travel_x_#### and zbp_i_rap_booking_#### whereas the generator also adds a ‘_u’ into the name of the control structures.
So the two lines of code that have to be changed should now read as follows in zbp_i_rap_booking_u_####
legacy_entity_x-_intx = CORRESPONDING zsrap_booking_x_u_####( <entity> MAPPING FROM ENTITY ).
and in zbp_i_rap_travel_u_####
legacy_entity_x-_intx = CORRESPONDING zsrap_travel_x_u_####( <entity> MAPPING FROM ENTITY ).
- Add the following statement to your service definition
expose /DMO/I_Airport as Airport;
- Activate the service binding
Hi André
Thanks for all the work you've done.
It shall ne provided by the standard !!!
However I could not directly work with your work, I had to réinject the code and recopy the handler.
I had an autorisation error, I have checked tour https service and it contained an autorisation object. Without it on my package everything works like a charm, combined with the uploader this are great tools.
Thanks again
Hi Andre
Completing week 4, I noticed my app wasn't working as expected, so I used the RAP generator and it works brilliantly well!
Now I can see where I went wrong in my own code so it helps to deepen my understanding of the objects and SAP RAP architecture.
So, many thanks!
Cheers
Ged
P.S. SAP RAP sounds good together
Hey, Andre,
Thanks for providing the code!
I wanted to test it, and I noticed there've been some changes in the RAP generator API, so it needed a bit of adaptation. Also, currently, for the trial environment, the relevant classes are in the /DMO/ namespace.
In case it's of interest to anyone, I've put the adapted code in this GitHub repo.
Best,
Stoyko
Thanks for the hint.
I have updated my code as well ;-).
Great!
Since the official repo now has the updated code, I'll just delete the one linked in my comment.