Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
sujeet2918
Active Contributor

I searched on SCN and found there are so many threads we have asked for User Ext/Badi which updates the Batch Number when doing Goods Movement of Production Order, Non of the thread I found marked as Resolved/Answered.. :shock:

I thought to share my past experience when I had come across similar requirement of customer and Implemented one Badi to update the Batch Number.

Requirement was when we create Production Order (Transaction Code CO01 ), SAP  Proposes Batch Number or you can Enter any batch number Manually.

After releasing production order, we normally Enter Time Ticket for Production Order( Transaction Code CO11N) and do the Goods Movement.

After Creating time ticket for production order When you try to do Goods Movement (As shown in Screen below), same batch number reflects against created production order.

But, here we want to update custom batch number with below posting date entered in below screen in CO11N :

Example: Batch Number should be always posting date of production order in YYMMDD format, so that user can easily identify the batches against which materials production is confirmed.

We will use BADI definition “WORKORDER_GOODSMVT” to update the Batch Number.

Step 1: Go to Transaction code SE19 and create Implementation for  BADI WORKORDER_GOODSMVT.

Step 2: Enter BADI Defination Name.

Step 3: Go to Interface Tab and select Method “GOODS_RECEIPT” to Write the Logic.

Step 4: Write the below Sample Code:

DATA: ls_confirmations LIKE LINE OF it_confirmations,
ix_tabix
TYPE sy-tabix.

IF sy-tcode = 'CO11N'.

READ TABLE it_confirmations INTO ls_confirmations INDEX 1.
IF sy-subrc = 0.
WRITE ls_confirmations-budat TO ls_confirmations-budat YYMMDD.
ENDIF.
CLEAR ix_tabix.
LOOP AT ct_goods_receipt INTO ls_goods_receipt.
ix_tabix
= ix_tabix + 1.
ls_goods_receipt
-charg = ls_confirmations-budat.

MODIFY ct_goods_receipt FROM ls_goods_receipt INDEX ix_tabix.
ENDLOOP.
ENDIF.

Step 5: Activate the Badi and Test the Scenario.

Note: Above Logic will not update custom batch in Production order transaction code (CO01/CO02/CO03). :!:


In Transaction Code CO11N in Goods Movement Tab we can see the updated batch number.

Now Go to Production Order and see the “Documented Goods Movement”, you will get the updated batch number there too. :razz:

Thanks for reading this short document.