I am using a BADI for PO creation definition is ME_PROCESS_PO_CUST and method PROCESS_ITEM
if material number in the Line item is blank, create a material number(BDC or BAPI) and fill it in the line item.
I am not very conversant in Objects...
i seek help on the correctness of the method iam referring to for this purpose and also how to pass values to field matnr in the line item of the PO.
i have used Get_Data for getting all the values and am using set_Data for changing the value of matnr if it is blank. but if i set the value of matnr it doesnt seem to change and am not able to figure out where i am wrong.
Thanks in advance,
If I got your process design correct, then it reads like following:
- Starting of PO creation
- (sometimes) inside a BADI a material creation (MM01)
- go on in PO maintenance
This is not possible for consistency reasons. You can't (should not) start new transactions (with DB changes) inside a transaction - what if user press cancel, how to delete the material?
But there are also more technical reasons (check key word 'logical unit of work'.
Instead you might create a report (or FM), which first checks all inputs, creates missing materials, creates the PO. Then all inputs would go to the report and be confirmed to go for the creation.
Thanks for the reply.
Well its True about SAP LUW what you have mentioned but i would like to address the issue more in terms of how to assign a material number(may be a standard one )using badi mentioned or any other BADI'S.
The reason would be we can use METHOD POST of the same definiton for material creation instead of using the Material creation in METHOD PROCESS ITEM.
but the issue i am facing is assigning a changed material in METHOD PROCESS ITEM doesnt seem to work
where as if i change NETPR it seems to WORK
Then you are aware of the comment of SAP to process_item:
"Under no circumstances make any changes to the database within this method. On no account use Commits."
But also method post is commented like this: "On no account use Commits in this method."
And you need a commit before you can use any created data in your PO.
Nevertheless, you tried to change a value in process_item. I guess, you use method set_data of the interface, which is import parameter of this method. I had a look into the method set_item: there is just a update to an internal (hashed) table. So technically it should be changed. But if further checks will prohibit changes of special fields - who knows.
I'm not surprised, that line checks can't change the matnr any longer, but at least online it's possible to change the material.
Maybe you can debug, what happens when doing you changes. It might be already after a view steps, where the changes get lost.
P.S.: Do you also use method set_datax - or I'm in a totally wrong area?
Message was edited by: Christian Wohlfahrt
Thanks again For your reply.
Well i got hold of the fact that we should not make any Commits inside those methods.
And iam Usng <b>set_data</b>
gv_poitem = im_item->get_data( ).
gv_poitem-netpr = '156.23'.
CALL METHOD im_item->set_data
im_data = gv_poitem.
so if I change the field NETPR value it does change but if i change the MATNR value it doesnt. any clues...
I never used the BADI in this way, so just some general remarks:
The two methods set_data and set_dataX look similar to BAPI handling, where you have a flag-structure for the changed fields. Prices are handled a little bit different sometimes (older release were very restricted in changing conditions), so maybe here a change without X-flag is still recognized.
At least, as final tip: make a test, where you also fill a 'X' for matnr via set_datax. I'm not sure, if a test with different fields might bring something (you would know, if you can change scheduling date or receiving plant or something else).
I hope this will work for you.