2022 Feb 25 1:09 PM
Hi guys ;
I have a question about ME32K. When ı enter transaction via purchase document number to me32k. I see a lot of item.
Example; When i enter the program and i select just item_no "9810" and "9870" , program will delete flag just 9810 and 9870 in ME32K. The picture is like that;
First of ; ı use to BAPI_CONTRACT_GET_DETAIL bapi and ı get all of item_no and details for my Purchase document.
After ı use to BAPI_CONTRACT_CHANGE bapi . But nothing gonna be changed.
My code part like this basically ;
call function 'BAPI_CONTRACT_GETDETAIL'
exporting
purchasingdocument = ld_purchasingdocument
item_data = 'X'
condition_data = 'X'
importing
header = ld_header
tables
item = it_item
item_condition = t_item_condition_s
return = t_return
.
commit work and wait .
check sy-subrc eq 0.
read table t_item_condition_s index 1.
read table t_item_cond_validity index 1.
t_item_cond_validityx-serial_id = t_item_condition_s-serial_id.
t_item_cond_validityx-item_no = 9810.
append t_item_cond_validityx.
t_item_condition-item_no = 9810.
t_item_condition-deletion_ind = 'X'.
t_item_condition-serial_id = t_item_condition_s-serial_id.
t_item_condition-cond_count = t_item_condition_s-cond_count.
t_item_condition-change_id = 'U'.
append t_item_condition.
t_item_conditionx-item_no = 9810.
t_item_conditionx-serial_id = t_item_condition_s-serial_id.
t_item_conditionx-cond_count = t_item_condition_s-cond_count.
t_item_conditionx-cond_value = 'X'.
append t_item_conditionx.
call function 'BAPI_CONTRACT_CHANGE'
exporting
purchasingdocument = ld_purchasingdocument
tables
item = it_item
item_condition = t_item_condition
item_conditionx = t_item_conditionx
return = t_return.
.
commit work and wait.
check sy-subrc eq 0.
2022 Feb 25 2:27 PM
2022 Feb 25 9:11 PM
Actually, i didn' t check my return table. I check that items in ME32k and ME3M after when i run bapi_contract_change and i get sy-subrc eq 0. After my control in that transaction, i saw nothing change
2022 Feb 28 8:24 AM
Well, first step is to check return table: it contains all the messages (informative, warnings, errors and so on).
I'm not sure about this piece of code, because it looks to me you are adding flag/removing flag.
t_item_cond_validityx-serial_id = t_item_condition_s-serial_id.
t_item_cond_validityx-item_no = 9810.
append t_item_cond_validityx.
t_item_condition-item_no = 9810.
t_item_condition-deletion_ind = 'X'.
t_item_condition-serial_id = t_item_condition_s-serial_id.
t_item_condition-cond_count = t_item_condition_s-cond_count.
t_item_condition-change_id = 'U'.
append t_item_condition.
t_item_conditionx-item_no = 9810.
t_item_conditionx-serial_id = t_item_condition_s-serial_id.
t_item_conditionx-cond_count = t_item_condition_s-cond_count.
t_item_conditionx-cond_value = 'X'.
append t_item_conditionx.
Why are you passing t_item_conditionx-cond_value = 'X'. ?
2022 Mar 09 7:28 AM
Hi Simone;
:Why are you passing t_item_conditionx-cond_value = 'X'. ?
Because when i search about this bapi , some developer use like this and he get success. So ı used to.
Actually ; I just want to put a deletion mark in the specific area I specified in the picture.
2022 Mar 09 8:39 AM
Hello!
Before putting flags, it's better to understand what they do 🙂
The 'X' on ...X structures are usually used to tell the system which field you want to update: in your case, you are not trying to update the value, correct?
You are passing
t_item_condition-deletion_ind = 'X'.
so you have to fill the corresponding
t_item_conditionX-deletion_ind = 'X'.
Get rid of useless lines like
t_item_cond_validityx-serial_id = t_item_condition_s-serial_id.
t_item_cond_validityx-item_no = 9810.
append t_item_cond_validityx.
because they mean nothing then try in the following way
t_item_condition-item_no = 9810.
t_item_condition-deletion_ind = 'X'.
t_item_condition-serial_id = t_item_condition_s-serial_id.
t_item_condition-cond_count = t_item_condition_s-cond_count.
t_item_condition-change_id = 'U'.
append t_item_condition.
t_item_conditionx-item_no = 9810.
t_item_conditionx-serial_id = t_item_condition_s-serial_id.
t_item_conditionx-cond_count = t_item_condition_s-cond_count.
t_item_conditionx-deletion_ind = 'X'.
append t_item_conditionx.
And check the table returns to see if you have any error and rollback the work or commit if all ok.
2022 Mar 09 9:15 AM
Thanks your comment and attention 🙂
What is your suggest code piece for solving problem ?
2022 Mar 09 11:13 AM
With my last reply you should be able to delete 1 condition on item 9810.
If you want to delete the item you have to work with ITEM table instead of ITEM_CONDITION
2022 Mar 09 4:28 PM
I tried item table in bapi but i guess , i didn't get result.
So ı guess ; according to your comment;
when i define to item_no = 9819 and put to delete_ind = 'X' in item table
i can get result; ????
call function 'BAPI_CONTRACT_CHANGE'
exporting
purchasingdocument = ld_purchasingdocument
tables
item = it_item
return = t_return.
commit work and wait.
check sy-subrc eq 0.
thanks for your help 🙂
2022 Mar 10 11:09 AM
Hello,
As thumb rule, BAPIs that change data (like this one) usually (there are exceptions!!!) rely on tables working in couples.
In your case, you have ITEM and ITEMX:
They have the same field list, if you check, but, as i explained in my previous replies, the...X table's fields are all flags, key fields apart, and they are used to tell the system which fields you are updating.
So, no, your example is not working because you are invoking the BAPI without ITEMX table.
2022 Sep 02 7:13 AM
Thanks to your comment simone.milesi
(As thumb rule, BAPIs that change data (like this one) usually (there are exceptions!!!) rely on tables working in couples.
In your case, you have ITEM and ITEMX:
They have the same field list, if you check, but, as i explained in my previous replies, the...X table's fields are all flags, key fields apart, and they are used to tell the system which fields you are updating.
So, no, your example is not working because you are invoking the BAPI without ITEMX table.)
My Problem is solved thanks to you.