cancel
Showing results for 
Search instead for 
Did you mean: 

Custom fields in sales order to fetch details from quotation

Former Member
0 Kudos

Hi,

We have a requirement. We will first be creating a quotation. the quotation can have any number of line items. We will then create a stand alone sales order (with out ref to quot ).

In the sales order, we will have two custom fields on the screen at In the first custom field at item level. we will enter the quotation number and the quotation item number for which we are creating a sales order (we can create the SO with ref to Quot but we do not want to due to business reasons )

1) We want, as soon as user enters the quotation number and quotation item number in sales order custom fields above, we want system to check whether the material number in sales order line item matches with that of the material number in the quotation. How to achieve this ? Do we need to use BAPI to call Quotation ? I mean how to call quotation on entering quotation number in custom fields from sales order create mode ? if BAPI needs to be called, then can BAPI be called during sales order create mode only when entering information in custom fields from quotation ?

2) We want to compare some data in quotation with that of the sales order being created. How to enhance this ?

3) As soon as we enter the quotation number/item in sales order custom field, we want that the qty in sales order item be subtracted from the quotation qty ? for eg, if quotation is of 100 kg, then when sales order is created for 30 kg. Then the balance left in quotation should be 70 kg ?

regards

Pamela

Accepted Solutions (0)

Answers (2)

Answers (2)

shashi_thakur
Contributor
0 Kudos

Hi Pamela,

The above requirement is possible but will need fair bit of changes at technical level. The new fields will have to be added in the append structure in VBAP, say VBAP-ZQUOTNO and VBAP-ZQUOTPOS for the Quotation number and Position number. You will also have to get the screen for Sales Order modified- and therefore need to decide as to which tab you want it to be displayed. Inlcuding whether you want these new columns to  be displayed based on certain conditions only-else it will be visible globally for all the users.

Then the validation will have to be added based on the FCODE assigned to the new field and when the Quotation number is entered and user presses Enter, the PAI Module modifications will be needed to verify few things before fetching the details from the Quotation. For example-the Sold-to-Party, Sales Area, etc. And then the screen fields will have to be populated.

Now regarding the reducing of the quantity from the Quotation-you will have to call a BAPI for Quotation change in the Update Task to ensure that the quantity is reduced only when the Sales order has been saved successfully. Which also means that you will have to add logic to trigger this even if some user reduces or increases this quantity. So calling the BAPI in create mode only is not an option. In order to ensure consistency-you will also have to code to Lock the Quotation the moment it has been referred and keep the lock till the time the sales Order has not updated it as else some other user referencing to the same Quotation will have incorrect results.

Regards,

Shashi

Former Member
0 Kudos

Hi Shashi,  Thanks for the reply. But I could not understand the below part of yours

"Then the validation will have to be added based on the FCODE assigned to the new field and when the Quotation number is entered and user presses Enter, the PAI Module modifications will be needed to verify few things before fetching the details from the Quotation. For example-the Sold-to-Party, Sales Area, etc. And then the screen fields will have to be populated."

what is FCODE. How can we access quotation data i.e quotation material number (to be checked with SO material no ) based on this. The moment user enters quotation number in custom field, don't we have to pass this  quotation number to VBAK/VBAP to fetch the quotation data into the program.

And lastly where do we have to do all the coding

for the Fcode ?

for BAPI ?

what modifications are you proposing in PAI module. What validations ?

regarrds

Pamela

Message was edited by: Pamela Pilch

shashi_thakur
Contributor
0 Kudos

Hi Pamela,

Those are technical terms which your ABAP team will understand. In functional terms let me explain what it means. Say for example that the new fields have been added to the VBAP table and also the screen of Sales Order entry has been modified to display them. Now when you enter the Quotation Number and Item number in the new fields and press enter-then this action initiates activities in the background program which checks which input fields have been populated and what steps are needed to be carried out. In our case it will to use the Quotation Number and fetch the data from VBAK by passing the Quotation number in VBELN. Once we have the data we need to verify that the Sold-to-party (KUNNR) is same for both our Order and the one found in the table followed by Sales Area. Once the verification is done- the data needs to be fetched from VBAP again by passing the Quotation number in the VBELN field and position number in the POSNR field. Then the concerned internal structures need to be populated in the run time order. All this is technical activities and you will have to ask your Development team to debug and verify.

As regards the BAPI to modify the Quotation -this can be called in MV45AFZZ, in userexit_save_document_prepare. But please note to add the BAPI in a Custom update function module (have to create one) and call it in Update Task.

If you would like to see how the PAI module works and where they get called-then simply go-to VA01-enter the sold-to-Party details and then type /h and enter the material number in the material number column and press enter-it will go into Debug mode and you can see the PAI (Process after Input) activities which get carried out. That location is where the coding for your new fields will also happen although please note that it would be a modification.

Pass the information to your ABAP team and I am sure they will know what needs to be done.

Regards,

Shashi

Former Member
0 Kudos

Hi Shashi,

We have implemented the code and the qty is getting redcued in quotation through BAPI sales order change.

But we have an issue. When the qty is getting reduced in Quotation, the availability check is not gettign trigerred.  why ?

for eg, in the original quotation, 100 kg was the qty  with  requested delivery date of 16.10.13 and confirmed  date of 20.10.13 in the schedule lines. so we have two schedule lines , one eith zero confirmed qty and the other with 100 kg.

As soon as the qty is reduced in quotation by BAPI to 80 kg, we have   80 kg shown in schedule line for requested delivery date with a confiremd qty of 0 and a confirmed qty of 100 kg in the 2nd schedule line which is wrong . We should have 80 kg in the confirmed schedule line too.

Clearly that means the availibility check is not happening ?

Other question is which standard code in SD triggers availability check ?

any suggestion ?

Regards

Pamela

moazzam_ali
Active Contributor
0 Kudos

Hi Pamela

This can be done through modifications and enhancements. If you are ABAPER then you should know this and if you are not ABAPER then discuss this with your ABAPER.

For entering new custom fields you can use append structure and add fields in VBAP, VBEP  and VBAK tables.

For validating material number, quotation number and quantity etc you can use MV45AFZZ program and USEREXIT_MOVE_FIELD_TO_VBAP to validate material number and quotation number/ item number. I think this can be done without calling any BAPI. Abaper will select the quotation  number from VBAK table and validate this with XVBAP quotation number. Same will be done with material, quantity etc. For quantity you need to add your logic in USEREXIT_MOVE_FIELD_TO_VBEP.

I have done this before and it should work. Please test and update.

Thank$