Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to add custom logging to a specified SAP OData service by yourself

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article is about how to add custom logging to a specified SAP OData service. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Sometimes, the OData implementation of the SAP standard or related tools do not provide the logging function that we want to record, so we can make use of the powerful extended features of the SAP system to carry out the secondary development of the custom logging function.

Take the SAP CRM Fiori application "My Opportunity" as an example: we first set a dynamic breakpoint with the value of GET_BADI in the constructor method CONSTRUCTOR of its OData service CRM_OPPORTUNITY implementation class CL_CRM_OPPORTUNITY_IMPL, so that in debug mode, the ABAP debugger will automatically stop where the GET BADI keyword call occurs.

In this way, we quickly found a place where we could place our custom diary logic: the BAdI definition of line 85, CRM_OPPORTUNITY_ODATA_DB. In the read operation implemented by the SAP standard OData service, this BAdI is executed every time One Order API is called from the database to read Opportunity data.

This is the call stack that the BAdI executes:

The transaction code SE18 creates an enhanced implementation based on the BAdI definition we just found:

In this enhanced implementation class ZCL_JERRY_ODATA_TRACE, we can now write our logging logic.

First create a database table to hold our log records. For simplicity, I only record the user name, date and time of the request, and you can add relevant fields according to your actual needs.

The enhancement code is also simple:

DATA (ls_log) = VALUE zorder_guid (user_name = sy-uname req_date = sy-datum req_time = sy-timlo). CALL FUNCTION 'SYSTEM_UUID_CREATE' IMPORTING uuid = ls_log-guid. INSERT zorder_guid FROM ls_log.

After activating this enhancement, do a few random clicks on Fiori UI:

When we go back to our custom logging table, we find that some records have been populated, and this custom logging function is implemented.

Thank you for reading! This is the end of this article on "how to add custom logging to a specified SAP OData service". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report