Have you even thought about why you could operate on ABAP backend system using ADT?
This document just gives a brief introduction about how does the ADT backend infrastructure respond your operation done in Eclipse. It contains a hands-on exercise which you could finish in your own ABAP system.
Explore ADT by switching on ABAP
In order to explore what has happened when we do operations in Eclipse, we need to switch on ABAP communication log.
Click Windows->show view. Make view “ABAP Communication Log” is displayed.
Then click button “Start Logging”:
Try to create one report:
And then you could observe several logs for this report creation. The latest log appears in the topmost of the table.
Now you could know that your operation in Eclipse is sent to ABAP backend system via HTTP Get and HTTP Post with dedicated url and gets processed in ABAP backend. Double click on each line to get the detail view.
In the report creation scenario, the request sent to ABAP backend are just the same as normal what you have done in SAP GUI to create one report:
(1) a query is sent via to check whether the report ZTEST_REPORT_JERRY already exists or not.
(2) Do transport checks based on the package name we have specified.
(3) once all checks pass, send the report creation request via HTTP post.
An example to understand how does ADT infrastructure responds
And how these HTTP request are handled in ABAP backend? Just set breakpoint on the function module SADT_REST_RFC_ENDPOINT, which acts as the central dispatcher and the entry point for all request sent from Eclipse. You should observe that this FM will be called again and again, once you have done something in Eclipse.
If you are patient enough, you could start debugging from this FM to learn how different handlers within the ADT backend infrastructure orchestrate to respond Eclipse front-end.
I write a simple report to simulate the HTTP request sent from Eclipse:
The url ‘/sap/bc/adt/crm/product/STAB_PROD_01’ has prefix /sap/bc/adt/ and is passed into the central dispatcher FM, so it could be processed by the ADT infrastructure. After we have studied how this simple program does work, we have already know the magic of the ADT processing logic.
After report execution, we could get the description of the product specified in url, ‘STAB_PROD_01’, from the variable lv_response.
And below are steps how to build this sample in your system.
(1) Create a BAdI implementation on BAdI definition BADI_ADT_REST_RFC_APPLICATION
You could find lots of standard implementation already created on this BAdI definition, each for their specific use case.
maintain the filter value as below, so that the very url containing the filter value will be handled by this BAdI implementation.
Implement method register_workspaces by just copying below code:
For method get_application_title, you can just hard code something.
Implement method register_resources:
We will create and implement handler class ZCL_ADT_RES_PRODUCT in next step.
(2) Create resource class ZCL_ADT_RES_PRODUCT
In this example, resource class is responsible for retrieve the product description for the product whose id is passed in via url and serialize the description via content handler class ( which will be created in step3 ) and set response accordingly.
Set CL_ADT_REST_RESOURCE as super class and only redefine method GET:
(3) create content handler class ZCL_ADT_RES_PRO_CONTENT_HANDLE
Set CL_ADT_REST_ST_HANDLER as super class, implement CONSTRUCTOR as below:
Define three attributes as below. CO_ST_NAME just contains the technical name of transformation ID which you could find in transaction STRANS, and co_root_name contains the name of root node in XML response.
Create two public types:
Test the sample
(1) our BAdI implementation is returned by GET BADI according to the correct filter value:
(2) Our resource class get called. And the redefined method GET will be executed:
(3) our content handler class is called to transforma the ABAP data into XML using the standard transformation “ID”:
Hope this sample gives you a better understanding on how does ADT work.
来自 “ ITPUB博客 ” ，链接：http://blog.itpub.net/24475491/viewspace-2707055/，如需转载，请注明出处，否则将追究法律责任。