Showing posts with label SAP SD. Show all posts
Showing posts with label SAP SD. Show all posts

Saturday, 20 May 2017

SAP OTC Process: BAPI Quotation Create Extension - Part 1

SAP OTC (Order-to-Cash) process is the core process of SAP Sales and distribution module. SAP OTC process involves various steps. The first process is ‘ENQUIRY’ from the customers, then ‘QUOTATION’, next is the ‘SALES ORDER’ followed by ‘STANDARD ORDER’ , ‘SHIPPING’, ‘DELIVERY’ , ‘PICKING’ etc.

SAP BAPI (Business Application Programming Interfaces) are widely in SAP Environment for creating, updating and deleting business documents along with reading from the backend database as well. BAPIs are the API methods of SAP business object types, and stored in Business Objects Repository (BOR).

This blog discusses Extension for BAPIs which are part of OTC process. This document is part 1 of the SAP OTC Process extensions serious. Part 2 discusses Sales Order extension.

In Current blog , I am discussing Quotation extension scenario for BAPI_QUOTATION_CREATEFROMDATA2. As discussed earlier, QUOTATION is response to customer Inquiry.

Before we move on to the coding side. There are tables and structures, that must extended with the custom fields.

1) The first step is to add custom fields in the VBAP (Sales document Item level) . I am taking date and time fields, as part of the custom data as show in the below screen capture.

SAP Tutorials and Materials, SAP Certifications, SAP Modules, SAP Guides, SAP Learning, SAP SD

2) The next step is adjusting the following structures :

Adjust the following structures for customer enhancements to table VBAP:
  1. VBAPKOZ
  2. VBAPKOZX
  3. BAPE_VBAP
  4. BAPE_VBAPX
  5. VBAPKOM
  6. VBAPKOMX
SAP Tutorials and Materials, SAP Certifications, SAP Modules, SAP Guides, SAP Learning, SAP SD

SAP Tutorials and Materials, SAP Certifications, SAP Modules, SAP Guides, SAP Learning, SAP SD

SAP Tutorials and Materials, SAP Certifications, SAP Modules, SAP Guides, SAP Learning, SAP SD

Here , I have demonstrated adding custom fields in 3 out of 6 structures. Adjusting all structures are mandatory.

3) After adjusting required structures I move on to the coding part of BAPI API_QUOTATION_CREATEFROMDATA2 for the BAPI extension process.

(a) First we need to declare extension container to hold custom data as show below

SAP Tutorials and Materials, SAP Certifications, SAP Modules, SAP Guides, SAP Learning, SAP SD

This container needs to be filled and, then supplied at the ‘extensionin’ table for the BAPI_QUOTATION_CREATEFROMDATA2.

4) Now lets fill up some data using function module ‘BAPISDORDER_GETDETAILEDLIST‘ based on inquiry.

SAP Tutorials and Materials, SAP Certifications, SAP Modules, SAP Guides, SAP Learning, SAP SD

5) Schedule lines needs to be adjust for example transport planning date, Goods issue date ,scheduling lines date etc as show below.

SAP Tutorials and Materials, SAP Certifications, SAP Modules, SAP Guides, SAP Learning, SAP SD

6) For updating custom fields and creating quotations, i am using times and dates fields from table ‘AFVV‘ these fields need to be updating along with quotation creation as part of custom fields data. I am reading date and time fields and putting them in the internal table .

SAP Tutorials and Materials, SAP Certifications, SAP Modules, SAP Guides, SAP Learning, SAP SD

7) Next step is updating the extension container

SAP Tutorials and Materials, SAP Certifications, SAP Modules, SAP Guides, SAP Learning, SAP SD

8) Now we are ready to call the BAPI_QUOTATION_CREATEFROMDATA2 

SAP Tutorials and Materials, SAP Certifications, SAP Modules, SAP Guides, SAP Learning, SAP SD

9) I executed the program and check extension container.

SAP Tutorials and Materials, SAP Certifications, SAP Modules, SAP Guides, SAP Learning, SAP SD

extension container is ready ,

10) Now I have to check if I have the new quotation number in variable lv_new_sales_document_type

SAP Tutorials and Materials, SAP Certifications, SAP Modules, SAP Guides, SAP Learning, SAP SD

As you can see in the above screen capture, the BAPI returns the new quotation number indicating the successful execution of BAPI.

11) Finally I check the new quotation number in VBAP TABLE and check if custom fields are updated.

SAP Tutorials and Materials, SAP Certifications, SAP Modules, SAP Guides, SAP Learning, SAP SD

All the Custom fields are updated for the newly created Quotation.

Monday, 24 April 2017

SAP OTC Process: BAPI Sales Order Create Extension - Part 2

In Part 1 of SAP OTC Process, I discussed a demonstration for Creating Quotations with Extensions. In this part I am going to create Sales orders with customer extensions.

The process which i used is the same as in the Part 1, however there are certain considerations and customization which need to be considered for creating sales order based on customer requirements. In a usual process Sales Orders are created in response to a quotation.

Step 1:

Same structures are adjusted for the custom fields as i did in Part 1 and they are:
  • VBAPKOZ
  • VBAPKOZX
  • BAPE_VBAP
  • BAPE_VBAPX
  • VBAPKOM
  • VBAPKOMX
SD (Sales and Distribution), SAP All Module, Tutorial and Certification, SAP Live, SAP Material

Step 2:

After adding custom fields , next we need to fill up the required tables using the function module BAPISDORDER_GETDETAILEDLIST/

SD (Sales and Distribution), SAP All Module, Tutorial and Certification, SAP Live, SAP Material

Step 3: 

Next is again filling up the extension Container as discussed previously.

SD (Sales and Distribution), SAP All Module, Tutorial and Certification, SAP Live, SAP Material

Step 4:

Now the function module Call for creating the sales order is will be done:

SD (Sales and Distribution), SAP All Module, Tutorial and Certification, SAP Live, SAP Material

Step 5: 

Check if we get values in lv_new_sales_document_type and in ext_cont for the custom fields.

SD (Sales and Distribution), SAP All Module, Tutorial and Certification, SAP Live, SAP Material

SD (Sales and Distribution), SAP All Module, Tutorial and Certification, SAP Live, SAP Material

SD (Sales and Distribution), SAP All Module, Tutorial and Certification, SAP Live, SAP Material

The function module has returned new Sales Order number as mentioned above, and ext container is filled with the custom field values .

STEP 6: 

Now we check the VBAP table with new created sales order number to check if custom fields are updated.

SD (Sales and Distribution), SAP All Module, Tutorial and Certification, SAP Live, SAP Material