Thursday 4 August 2022

App Extensibility for Create Sales Orders – Automatic Extraction: Custom Proposal for Sales Order Request Fields (Using BAdI)

In the Create Sales Orders – Automatic Extraction app, the system starts data extraction and data proposal for sales order requests immediately after your purchase order files are uploaded. If SAP pre-delivered proposal rules do not satisfy your business needs, key users can create custom logic to implement your own proposal rules.

Here is an example procedure. In your custom logic, you want the system to set the sales area to 0001/01/01 if the company code is 0001, and set the request delivery date to the current date plus seven days if this date is initial. In case ML can not extract the date from file or date is not exist in the file.

Creating Custom Logic

1. Open the Custom Logic app (administrator role) under the Extensibility

SAP HANA Exam, SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Guides, SAP HANA Career, SAP HANA Skills, SAP HANA News

2. On the Custom Logic tab, choose the + (Create) icon.

SAP HANA Exam, SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Guides, SAP HANA Career, SAP HANA Skills, SAP HANA News

3. Select Sales: Sales Order Request from the business context dropdown list, and choose the BAdI description as well. Specify your implementation description. Then the implementation ID is generated automatically. Choose Create.

SAP HANA Exam, SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Guides, SAP HANA Career, SAP HANA Skills, SAP HANA News

The window for creating your own implementation is displayed. The UI includes 3 parts: Input parameters, example code and output parameters. You can refer to the example code to write your own code.

Note: In our case, the custom logic will affect both header and item fields. So the output parameters include salesorderrequestheaderchanged (for header) and salesorderrequestitemschanged (for items).

SAP HANA Exam, SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Guides, SAP HANA Career, SAP HANA Skills, SAP HANA News

4. In your code for the sales order request header, specify “company code = 0001” as the condition, and “sales area = 0001/01/01” as the result.

SAP HANA Exam, SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Guides, SAP HANA Career, SAP HANA Skills, SAP HANA News

In your code for sales order request items, specify “requested delivery date = initial” as the condition, and “requested delivery date = current date + 7 days” as the result. Note that the current system date is retrieved from class cl_abap_context_info  and method get_system_date.

SAP HANA Exam, SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Guides, SAP HANA Career, SAP HANA Skills, SAP HANA News

Tips: The code editor support auto-completion, you can press “Ctrl + Space” to get the suggestion and press “Shift + Enter” to insert full signature.

SAP HANA Exam, SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Guides, SAP HANA Career, SAP HANA Skills, SAP HANA News

5. Once the code is done, click “Save Draft” button. We recommend that you test your logic before publishing it.

Testing Custom Logic

To do the test in the Custom Logic app, you need to provide test data in import parameters manually.

1. Input test data “0001” to company code in importing parameter sales order request header.

SAP HANA Exam, SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Guides, SAP HANA Career, SAP HANA Skills, SAP HANA News

2. Input 1 row of test data in the import parameter for the sales order request items source. Specify a sales order request ID and an item ID.

SAP HANA Exam, SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Guides, SAP HANA Career, SAP HANA Skills, SAP HANA News

3. Input 1 row of test data in the import parameter for sales order request items. Enter the same sales order request ID and item ID, with an empty request delivery date.

SAP HANA Exam, SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Guides, SAP HANA Career, SAP HANA Skills, SAP HANA News

4. Check the test result in output parameters. The system should have set the sales area and the request delivery date to expected values.

SAP HANA Exam, SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Guides, SAP HANA Career, SAP HANA Skills, SAP HANA News

Publish implementation:

Click “Publish” button, once the implementation is published successfully, you can see the status become “Published“.

SAP HANA Exam, SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Guides, SAP HANA Career, SAP HANA Skills, SAP HANA News

In conclusion, you can use the BAdl to modify sales order request data after by your needs. I hope this blog can give you a quick understanding for BAdl implementation.

No comments:

Post a Comment