`
JerryWang_SAP
  • 浏览: 1025980 次
  • 性别: Icon_minigender_1
  • 来自: 成都
文章分类
社区版块
存档分类
最新评论

ABAP Development Tool前后台交互的原理

阅读更多

在S/4HANA系统里,SE16,查看表PRGN_CORR2的内容:

 

 

REL_NAME(release name)指定成751:

 

 

S_TCODE是ECC里的事务码,而T_TCODE是对应的S/4HANA的新事务码。

 

 

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

communication log

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:

DATA: lv_request  TYPE sadt_rest_request,
      lv_response TYPE sadt_rest_response,
      lv_header   LIKE LINE OF lv_request-header_fields.
lv_request-request_line-method = 'GET'.
lv_request-request_line-uri = '/sap/bc/adt/crm/product/STAB_PROD_01'.
lv_request-request_line-version = 'HTTP/1.1'.
CALL FUNCTION 'SADT_REST_RFC_ENDPOINT'
  EXPORTING
    request  = lv_request
  IMPORTING
    response = lv_response.

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:

method if_adt_discovery_provider~register_workspaces.
    data workspace type ref to if_adt_discovery_workspace.
    data discovery type ref to if_adt_disc_rest_rc_registry.
    workspace = registry->register_workspace( me->get_application_title( ) ).
    discovery = lcl_discovery=>create_instance(
        workspace   = workspace
        static_path = me->if_adt_rest_rfc_application~get_static_uri_path( ) ).
    me->register_resources( discovery ).
    workspace->finalize( ).
  endmethod.

For method get_application_title, you can just hard code something.

Implement method register_resources:

method REGISTER_RESOURCES.
    registry->register_resource(
      template      = '/crm/product/{product_id}'
      handler_class = 'ZCL_ADT_RES_PRODUCT' ).
endmethod.

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:

METHOD get.
  DATA:     lv_product_id   TYPE comm_product-product_id,
            lv_product_type TYPE comm_product-product_type,
            lv_description  TYPE comm_prshtext-short_text,
            lv_text         TYPE comm_prshtext,
            lv_product      TYPE comm_product,
            lv_data         TYPE zcl_adt_res_pro_content_handle=>ty_product,
            content_handler TYPE REF TO if_adt_rest_content_handler.
  request->get_uri_attribute(
    EXPORTING
      name      = 'product_id'
      mandatory = abap_true
     IMPORTING
      value     = lv_product_id ).
  SELECT SINGLE * FROM comm_product INTO lv_product WHERE product_id = lv_product_id.
  IF sy-subrc = 4.
    RAISE EXCEPTION TYPE cx_adt_res_not_found.
  ELSE.
  lv_data-product_id = lv_product-product_id.
  lv_data-product_type = lv_product-product_type.
  SELECT SINGLE * INTO lv_text FROM comm_prshtext WHERE product_guid = lv_product-product_guid.
  lv_data-description = lv_text-short_text.
  CREATE OBJECT content_handler TYPE zcl_adt_res_pro_content_handle.
  response->set_body_data( content_handler = content_handler
                             data            = lv_data ).
  ENDIF.
ENDMETHOD.

(3) create content handler class ZCL_ADT_RES_PRO_CONTENT_HANDLE

Set CL_ADT_REST_ST_HANDLER as super class, implement CONSTRUCTOR as below:

super->constructor( st_name = co_st_name root_name = co_root_name content_type = co_content_type ).

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:

 

 

types:
    BEGIN OF ty_product,
      product_id type comm_product-product_id,
      product_type  type comm_product-product_type,
      description   type COMM_PRSHTEXT-SHORT_TEXT,
     END OF ty_product .
  types:
    tt_product TYPE STANDARD TABLE OF ty_product .

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.

要获取更多Jerry的原创文章,请关注公众号"汪子熙":

0
0
分享到:
评论

相关推荐

    HANA STUDIO ABAP DEVELOPMENT TOOL本地插件下载-ADT

    标题中的“HANA STUDIO ABAP DEVELOPMENT TOOL”是指SAP HANA Studio中的一个特定模块,专门用于ABAP(Advanced Business Application Programming)开发。SAP HANA Studio是SAP HANA平台的一个集成开发环境(IDE)...

    SAP ABAP Development tool

    SAP ABAP Development工具是SAP软件中的一个集成开发环境(IDE),专门用于开发和维护SAP系统的ABAP(Advanced Business Application Programming)语言编写的程序和对象。ABAP是SAP在其软件产品中使用的编程语言,主要...

    ABAP Development for SAP HANA epub

    ABAP Development for SAP HANA 英文epub 本资源转载自网络,如有侵权,请联系上传者或csdn删除 查看此书详细信息请在美国亚马逊官网搜索此书

    MBC40_Managing ABAP Development Projects.pdf

    根据提供的文档信息,我们可以深入探讨《MBC40_Managing ABAP Development Projects》这一主题,主要聚焦于ABAP开发项目的管理。以下是对该文档标题、描述及部分内容中的关键知识点进行的详细解读: ### 标题:MBC...

    ABAP Development Tools for HANA无水印原版.zip

    ABAP Development for SAP HANA 英文无水印原版pdf pdf所有页面使用FoxitReader、PDF-XChangeViewer、SumatraPDF和Firefox测试都可以打开 本资源转载自网络,如有侵权,请联系上传者或csdn删除 查看此书详细信息请在...

    ABAP Development for SAP HANA

    SAP HANA will soon celebrate its second birthday. Hard to believe, but this technology has been on the market for almost two years now. During this time, its use potential increased significantly: ...

    ABAP WorkBenchABAP WorkBench

    14. **ABAP Development Tools (ADT)**: ADT是基于Eclipse的现代ABAP开发环境,与ABAP WorkBench类似,但提供了更现代的用户体验和更强大的集成开发功能。 ABAP WorkBench的深度和广度远不止于此,它还包括对...

    ABAP Development for Financial Accounting.pdf

    在《ABAP Development for Financial Accounting》这本书中,作者Sergey Korolev向读者提供了深入的指导,关于如何在SAP ERP Financials Financial Accounting(6.0版本)中利用ABAP进行定制化增强,以满足特定的...

    Install SAP ABAP Development Tools in Eclipse.pdf

    Install SAP ABAP Development Tools in Eclipse

    如何在后台模式下调试程序ABAP程序的运行

    "如何在后台模式下调试程序ABAP程序的运行" ABAP程序调试是SAP系统中的一种重要功能,用于检测和解决程序中的错误。后台调试是ABAP程序调试的一种方式,指的是在后台模式下调试程序的运行。下面我们将详细介绍如何...

    手把手教你配置Eclipse开发SAP ABAP程序环境.docx

    从零开始,教授如何配置 Eclipse 开发 SAP ABAP 程序环境。2020 年最新版本操作...ABAP Development Tool的Java端实现就是Eclipse的一个扩展,使用JCO(Java Connector)连接ABAP后台的adt服务,实现对ABAP程序的操作。

    SAP标准课程:MBC40_Managing ABAP Development Projects

    《SAP标准课程:MBC40 - 管理ABAP开发项目》是一门针对SAP系统中ABAP开发管理...课程资料"Latest SAP Downloads.html"、"MBC40_Managing ABAP Development Projects.pdf"和"Read Me.txt"将提供更深入的学习资源和指导。

    ABAP workbench fundational

    同时,SAP提供了一些工具,如ABAP Development Tools(ADT),它是一款集成在Eclipse中的开发插件,提供了更现代的开发体验。 总之,ABAP工作台是SAP开发的核心,理解和掌握ABAP语法基础以及相关工具是成为有效SAP...

    Eclipse 安装 ABAP Development Tools.pdf

    从事SAP开发人员

    ABAP Development for SAP HANA.zip

    sap press doc 解压密码:abap_developer

    ABAP Development for Financial Accounting.zip

    sap press doc 解压密码:abap_developer

    sap 后台 常用表 abap

    sap 常用表 包含sd mm fi ps pp 等模块的关键表 以及 各个表的关键字段 关联关系

    abap学习资料abap

    16. **ABAP Development Tools (ADT)**:介绍现代的ABAP开发环境,如使用Eclipse集成开发环境进行ABAP编程。 17. **SAP HANA集成**:如果涉及,会讲解如何在ABAP中利用SAP HANA的高性能特性。 18. **ABAP on Cloud...

    ABAP Development for Sales and Distribution in SAP.zip

    sap press doc 解压密码:abap_developer

Global site tag (gtag.js) - Google Analytics