2010 Oct 19 4:17 PM
Hi folks,
we want to create orders by program: The program will set some header and item data and the user will continue working in ME21N.
After some research we came over FUNCTION 'WB2_PO_PROCESS_AND_MAINTAIN'. We are able to transfer some data and enter ME21N successfully.
BUT: After leaving the transaction and returning to our program, any second call leads to an empty ME21N frame with no controls or subscreens.
Is there any other way to transfer data and then enter ME21N, or, even better, what can we do to allow a second call of FUNCTION 'WB2_PO_PROCESS_AND_MAINTAIN'.
All hints welcome except Batch Input (Call transaction using...).
Thanks a lot,
Clemens
2010 Oct 19 5:18 PM
It looks like the FM WB2_PO_PROCESS_AND_MAINTAIN destroys PO's framework while existing for the first time. So, if you do the LEAVE TO TRANSACTION or SUBMIT PROGRAM ... VIA SELECTION SCREEN, would instantiate the PO framework and displays on the screen.
Regards,
Naimesh Patel
Hi folks,
we want to create orders by program: The program will set some header and item data and the user will continue working in ME21N.
After some research we came over FUNCTION 'WB2_PO_PROCESS_AND_MAINTAIN'. We are able to transfer some data and enter ME21N successfully.
BUT: After leaving the transaction and returning to our program, any second call leads to an empty ME21N frame with no controls or subscreens.
Is there any other way to transfer data and then enter ME21N, or, even better, what can we do to allow a second call of FUNCTION 'WB2_PO_PROCESS_AND_MAINTAIN'.
All hints welcome except Batch Input (Call transaction using...).
Thanks a lot,
Clemens
2010 Oct 19 5:18 PM
It looks like the FM WB2_PO_PROCESS_AND_MAINTAIN destroys PO's framework while existing for the first time. So, if you do the LEAVE TO TRANSACTION or SUBMIT PROGRAM ... VIA SELECTION SCREEN, would instantiate the PO framework and displays on the screen.
Regards,
Naimesh Patel
2010 Oct 19 10:40 PM
OK, but LEAVE TO TRANSACTION or SUBMIT PROGRAM ... VIA SELECTION SCREEN would make it difficult to transfer all my data I want to pass.
Or is there any other way to transfer header and item data into ME21N?
I'm stuck a bit.
Regards,
Clemens
2010 Oct 20 5:02 PM
PO Framework is using Singleton Design pattern but it hasn't given us the option to clear the singleton objects, if we wish. So, to get rid of the Singleton object, ME21N/22n/23n also uses the Leave Program. It creates different header / item instances when we press the Create Icon or Display another document.
As a workaround you may try to open a new session with the data and close it once done.
Regards,
Naimesh Patel
2010 Oct 20 5:27 PM
Naimesh,
thank you for the effort of analysis. I think this is really promising: Call the function in new task (we used to do this using DESTINATION 'NONE') and pass the required parameters.
This implies opening a new screen session - still OK if the maximum number (shabby 6) is not exceeded. But then: After creation of PO I'd like to inform the origination program to do something, at least to refresh the list.
How can I transfer this information back, will I have to use shared object?
Alternative: I could access dynamically the document header and clear/free those singleton objects, hopefully getting rid of container objects in my way.
Still needs some trying, I'd prefer the latter (dynamic clear).
By the way: Is there any method to free object instances in debugger?
Thanks again,
Clemens
2010 Oct 19 5:23 PM
Hi,
Second call means you call it again explicitly..?
Regards
Nabheet
2010 Oct 20 9:12 PM
Hello!
Why not to create an order with BAPI (I guess BAPI_PO_CREATE*) and then call the transaction me22n passing the order number to it ?
2010 Oct 20 11:01 PM
Thanks, Stani. Yes, we considered this earlier but there are good reasons not to create the order: We must save if we want or not, and, certain data can not be changed at all after saving,. i.e. the order type - the user must be able to change the order type (and other data) before saving.
Sorry.
Further ideas except batch input and save&edit welcome.
Regards,
Clemens
2010 Oct 22 6:47 AM
Hi!
I think If a user must decide to save or not to save the order it's not necessary to start me21n at all.
Show him all the relevant information on a separate screen, then he will choose to proceed/do some changes and proceed (OK button->call BAPI and me22n) or cancel the work (Cancel button).
2010 Oct 23 8:46 PM
Stani, imagine this: The user sits at the keyboard, monitor in front and headset on negotiating real-time deals. Looking at relevant data in a grid on the screen, enter quantities in one or more editable cells, pressing 'order' button, continuing in ME21N. In ME21N the user has some header and item data according to what he entered/selected in the ALV grid. In case of error he just wants to return and try again later.
We need a fast and reliable solution without any data garbage.
Regards,
Clemens
2010 Oct 25 7:52 AM
Hello, Clemens!
This is my point of view.
When the user press the 'Order' button, a screen apears where he can observe all the info about the order to be created (order type, quantities, etc.). Then he must confirm or cancel. If he decides to confirm, the program starts the BAPI.
1. If errors occur, the user gets messages from BAPI (e.g. via application log or listing) and makes corrections or postpone the work. The user can continue his work with alv grid.
Update: order is not created here (because of errors).
2. If everything is OK then he gets ME22N with his order.
Should he cancel the work being in the correctly saved order? I don't understand why. I think he must make a decision before processing.
Edited by: Stanislav Usatov on Oct 25, 2010 1:15 PM
2010 Nov 04 5:52 PM
Perfect:
Just use FUNCTION 'WB2_PO_PROCESS_START' and it works smooth and alright.
We had some discussion if we really can use this function from Global Trade module because the calles function WB2_PO_PROCESS_AND_MAINTAIN has been changed recently (May 2010) and nothing is released yet. But the function group is 8 years old and there are (only) 3 SAP notes since then.
There will be much effort for any kind of alternative, so we are happy to have found a good way of pre-setting any kind and any number of PO data to be maintained in the transaction ME21N.
Thanks for all valuable input.
Regards,
Clemens