Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

User Exit during Sales Order Creation - New Line Item needed

Former Member
0 Kudos

I have a situation during the process of sales order creation. If a Material in a line item has say 27 EA and the Base Unit is EA. But the Sales Unit is CSE. Then whenever the user enters 27 EA and presses enter he should get two line items.

The first line item needs to convert to maximum number of CSE posible and the rest will be the second line item with the remaining EA. The order isn't important but that is what is needed. Question is how do I approach this problem and code my user exit accordingly and where do I code it.

I was looking at SAPMV45A and saw the program MV45AIZZ which is meant as a user exit for any PAI event handling. If anybody has encountered this kind of requirement can you please share your view on this.

I will definitely reward points for useful answers.

Clark

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Clark,

We had a some-what similar kind of requirement earlier. That was in Creating Credit Note (BAPI_CUSTOMERRETURN_CREATE).

Here, we had to create a new entry in the items internal table, if there are any free items.

The coding for this was like:

IF it_data-free_qty > '0.000'.

*- Increment Item counter.

l_itemno = l_itemno + 10.

it_item-itm_number = l_itemno.

it_item-material = l_matnr.

it_item-item_categ = 'RENN'.

it_item-target_qty = it_data-free_qty.

APPEND it_item.

CLEAR it_item.

ENDIF.

Since you are trying similar kinda thru userexit, identify the correct userexit where you can access the table with item data (and important that this table doesnt change later in the flow), check the UOMs (both Base Unit and Sales Unit), accordingly upddate current record and create a new record for the remaining.

Hope this comes handy.

Regards,

Raj

8 REPLIES 8

Former Member
0 Kudos

Hi Clark,

We had a some-what similar kind of requirement earlier. That was in Creating Credit Note (BAPI_CUSTOMERRETURN_CREATE).

Here, we had to create a new entry in the items internal table, if there are any free items.

The coding for this was like:

IF it_data-free_qty > '0.000'.

*- Increment Item counter.

l_itemno = l_itemno + 10.

it_item-itm_number = l_itemno.

it_item-material = l_matnr.

it_item-item_categ = 'RENN'.

it_item-target_qty = it_data-free_qty.

APPEND it_item.

CLEAR it_item.

ENDIF.

Since you are trying similar kinda thru userexit, identify the correct userexit where you can access the table with item data (and important that this table doesnt change later in the flow), check the UOMs (both Base Unit and Sales Unit), accordingly upddate current record and create a new record for the remaining.

Hope this comes handy.

Regards,

Raj

0 Kudos

Thank You for your answer. While it does not exactly answer my question I appreciate your help in this regard.

Thank You

Former Member
0 Kudos

MV45AFZZ is correct user exit. Use form userexit_move_field_to_vbap. Here you will get compplete line of Order. Then read Material Master (MARA). Create a new line if your condition matces. But make sure for the same line it should not create duplicate lines.

Pl let us know if u need further informations.

Thanks & Regards

Mahendra

0 Kudos

Hello Mahendra

My concern though is if the user wants to see the changes while creating the Sales Order upon pressing enter which is what is desirable. But I am not usre if it is possible.

Hence I was looking at placing my code in the PAI

INCLUDE MV45AOZZ. " User-modules PBO

INCLUDE MV45AIZZ. " User-modules PAI

But I haven't succeeded. I think you are right. And I am coding my logic in a perform create_new_lineitem. which is in and include in MV45AFZZ.

The original need to see this happening right when the qty in EA exceeds 1 or more cse and the split happens when user presses enter would be ideal.

But this also needs to happen at the time of consolidation of all Sales orders for the same material to the same customer on the same day. So the batch program which consolidates the line items say for 5 Sales Orders due for delivery the next day might have similar materials across different sales orders. And this needs to be consolidated into one sales order for that material.

0 Kudos

I am not clear with your requirement.

Pl specify more clearly.

Regards

Mahendra

0 Kudos

Hello Mahendra

The requirement is as follows :

PART 1:

Sales Order Enter:

1. When a line item is entered on a sales order (VA01 or VA02), at enter, check the sales unit of measure (VBAP-VRKME).

• Do not check line items where item category (VBAP-PSTYV) = TANN, TAPS or ZTAP. TANN are free goods that should not be considered for consolidation. TAPS & ZTAP are lower level materials as a result of product selection. They will be attached to a higher-level material with an item category of TAX, which is relevant for consolidation.

• Do not check items where VRKME <> EA

2. If VRKME = EA, go to MARM for MATNR.

3. Go to record where alternate unit of measure (MEINH) = CSE, get the value from the numerator field (UMREZ).

4. Divide the order quantity (VBEP-WMENG) by UMREZ.

5. If the result is greater than 1.0, the customer has ordered more than one case and a new line item needs to be added to the sales order for the case quantity.

6. Add a new line to VBAP for the same material with the case quantity. If not a whole value, the remainder of eaches (bottles) should update the qty on the first item on VBAP.

• Part 1 is relevant for order types ZCA, ZOR, ZSO, RE, ZSM

PART 2:

Batch Job to run prior to the Delivery Due List:

1. Read VBUK for Delivery Status (LFSTK) = A (delivery not processed). Get all of the document numbers (VBELN).

2. Go to VBEP for those document numbers to get the goods issue date for the order. There will be many records in VBEP for the same sales order. Look at all orders with a goods issue date (WADAT) of next day.

3. Go to VBAK for those document numbers to see if there are multiple sales orders for the same Sold To party (KUNNR).

4. For customers who have more than one order in VBAK, search all line items (for all orders). If there are no duplicate materials across sales orders, do nothing.

• Do not check line items where item category (VBAP-PSTYV) = TANN, TAPS or ZTAP. TANN are free goods that should not be considered for consolidation. TAPS & ZTAP are lower level materials as a result of product selection. They will be attached to a higher-level material with an item category of TAX, which is relevant for consolidation.

• Do not check line items where reason for rejection (VBAP-ABGRU) is not blank

5. If there are duplicate materials, go through the same logic as in part 1. If the quantity across the sales orders adds up to greater than one case, add the appropriate quantity to a new line item on the first sales order. If there is a remainder qty, update the line item on the first sales order with this qty. In this case, the quantities on the second sales order needs to be closed out with a reason for rejection code of 50, ‘Line Item Consolidation’. If there is no remainder, update the qty on this item directly.

• Part 2 is relevant for order types ZOR, ZCA, ZSM

• This batch job will have to be run manually for Day Pick orders. The end of this program should automatically kick off the delivery due list for Day Pick orders, shipping condition 02.

Business Justification:

The business requires that like order line items be consolidated to one line item prior to the order going to the warehouse for picking. This will aid in picking at the warehouse as well as result in the customer invoice not reflecting more than one line item for the same material. In the case where the customer has truly ordered more than a case, i.e;, 1 case, 2 bottles, the documents in SAP will still reflect 2 lines.

Former Member
0 Kudos

If you create new line items that the user can change, what happens in the following situation?

Say a CSE contains 10 EA.

The user enters 15 EA and presses enter.

Two items are created: one for 1 CSE and one for 5 EA.

The user changes the 5 EA item to 25 EA and presses enter.

Do you need to consolidate that as well? What if the user changes 5 EA to 5 CSE?

I'm suggesting that you may not want the user to see this, but do it at save time. Financial transactions do it this way. You enter one debit and one credit and the transaction creates a third line item for taxes.

Rob

Former Member
0 Kudos

Hi,

Rob has suggested a good point. If we study your requirement then the logic should be added at userexit_save_document_prepare.

For Part 2. It should be under another user exit under Delivery Due List.

Thanks & Regards.

Mahendra