The following example explains how to auto-select the batch numbers ins a delivery, based on the Expiry date.
First, we create the function button in the window.
We need to create a universal function type LineLoop that will be executed when the button is clicked.
The line loop will include a validation to verify if the item is batch controlled.
IF($[$38.1.0] <> '') and ((SELECT T0.[ManBtchNum] FROM OITM T0 WHERE T0.ItemCode=$[$38.1.0]) = 'Y')
SELECT 'EJEMPLO' FOR BROWSE
If this condition is met, then another universal function is executed.
The following macro opens the Batch Number selection window, order by the column Expiry date and select the batch that corresponds.
Activate(); //Activate the window
Focus($[$38.11.0]); //Focus on quantity
Activate(5896); //Open Batch selection window
Activate(); //Activate new window
DoubleClick($[$4.15.DATE]); //Double clic on Expire date column
Click($[$16.0.0]); //Click Auto
AutoPressNextPopup($[$1.0.0]); //Yes in continue message
Click($[$1.0.0]); //Click update
Close(); //Close Window
Activate(); //Activate old window
Thx for the example
I'd like to know what should be added if there isn't enough quantity in the specific expiry date, and I have to deliver from the same e.d.?
In this example, we use SAP's standard functionality called Autoselect. You can change the functionality and use your own logic. =)
Please sign in to leave a comment.