The following example explains how to auto-select the batch numbers ins a delivery, based on the Expiry date.
Function button
First, we create the function button in the window.
Line Loop
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')
BEGIN
SELECT 'EJEMPLO' FOR BROWSE
END
If this condition is met, then another universal function is executed.
Macro
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
Comments
2 comments
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.?
Thx again
Hello Rafi,
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.