2007 Mar 22 9:21 AM
Hello.
I'm trying to use this Bapi to delete one item of one delivery. I'm fillling all the fields with the delivery number and the item position, and the delete flag with the 'X' in the respective position.
When I see the delivery, the item is not delete. The Bapi return me an error without information, only the position and the delivery which I'm using.
Can you help me to solve this problem??
I don´t know if I'm using correctly this Bapi. I think that I can delete several items of the deliveries. This is OK??
Thank you.
2007 Mar 22 9:27 AM
What did you pass to the tables parameter:
ITEM_CONTROL-DEL_ITEM?
Did you pass 'X'?
Regards,
Ravi
2007 Mar 22 9:35 AM
Yes. I passed the 'X' to the ITEM_CONTROL-DEL_ITEM.
This is how I used it:
SELECT *
FROM VBFA
WHERE vbelv EQ it_zprent-vbeln
AND vbtyp_n EQ 'J' "Solo las entregas
ORDER BY erdat DESCENDING erzet DESCENDING.
EXIT.
ENDSELECT.
Seleccionamos todas las posiciones de la última entrega creada
SELECT *
INTO CORRESPONDING FIELDS OF TABLE lt_lips
FROM lips
WHERE vbeln EQ vbfa-vbeln.
Rellenamos los datos de la cabecera
L_HEADER_CONTROL-DELIV_NUMB = L_HEADER_DATA-DELIV_NUMB = L_DELIVERY = vbfa-vbeln.
LOOP AT lt_lips.
CHECK lt_lips-pstyv EQ 'ZNON'. "Sólo borramos las líneas no imputadas
Rellenamos los datos de las posiciones
L_ITEM_DATA-DELIV_NUMB = L_ITEM_CONTROL-DELIV_NUMB = vbfa-vbeln.
L_ITEM_DATA-DELIV_ITEM = L_ITEM_CONTROL-DELIV_ITEM = lt_lips-posnr.
L_ITEM_CONTROL-DEL_ITEM = 'X'. "Marcamos el flag para borrar la línea
APPEND l_item_data.
APPEND l_item_control.
ENDLOOP.
IF L_HEADER_DATA IS NOT INITIAL AND
L_HEADER_CONTROL IS NOT INITIAL AND
L_ITEM_DATA IS NOT INITIAL AND
L_ITEM_CONTROL IS NOT INITIAL AND
L_DELIVERY IS NOT INITIAL.
Bapi para cambiar la entrega utilizada para borrar líneas
CALL FUNCTION 'BAPI_OUTB_DELIVERY_CHANGE'
EXPORTING
header_data = L_HEADER_DATA
header_control = L_HEADER_CONTROL
delivery = L_DELIVERY
tables
ITEM_DATA = L_ITEM_DATA[]
ITEM_CONTROL = L_ITEM_CONTROL[]
return = BAPI_RETURN[].
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ENDIF.
Thank you.
Regards.
2007 Mar 22 9:36 AM
Hi,
Even i have used the same BAPI to Delete Delivery Items and i was successful in doing it. You just need to fill the Header data, Item data and Item Control data.
Just to be sure, have you used BAPI_TRANSACTION_COMMIT after this BAPI to actually delete the Items.
regards,
Mahesh
2007 Mar 22 9:59 AM
thankyou.
I fill Header data, Item data and Item Control data.
I have you used BAPI_TRANSACTION_COMMIT after BAPI.
But with these parameteers it is not OK.
Regards.
Thankyou.
2007 Mar 22 10:38 AM
Mahesh Ramakrishnappa.
Can you show me an example where this bapi works correctly??.Please.
Thank you.
Regards.
2007 Mar 22 10:57 AM
Hi,
Below is the code which is working.
DATA: HEADER_DATA like BAPIOBDLVHDRCHG,
HEADER_CONTROL like BAPIOBDLVHDRCTRLCHG,
DELIVERY like BAPIOBDLVHDRCHG-DELIV_NUMB,
ITEM_DATA like BAPIOBDLVITEMCHG occurs 0 with header line,
ITEM_CONTROL like BAPIOBDLVITEMCTRLCHG occurs 0 with header line,
RETURN like BAPIRET2 occurs 0 with header line.
HEADER_DATA-DELIV_NUMB = S_VBELN.
HEADER_CONTROL-DELIV_NUMB = S_VBELN.
DELIVERY = S_VBELN.
LOOP AT it_final INTO wa_final.
ITEM_DATA-DELIV_NUMB = wa_final-vbeln.
item_data-DELIV_ITEM = wa_final-posnr.
item_data-MATERIAL = wa_final-matnr.
item_data-DLV_QTY = wa_final-lfimg.
item_data-FACT_UNIT_NOM = '1'.
item_data-FACT_UNIT_DENOM = '1'.
item_data-CONV_FACT = '1'.
append item_data.
ITEM_CONTROL-DELIV_NUMB = wa_final-vbeln.
ITEM_CONTROL-DELIV_ITEM = wa_final-POSNR.
IF WA_FINAL-LFIMG = 0.
ITEM_CONTROL-DEL_ITEM = 'X'.
ELSE.
ITEM_CONTROL-CHG_DELQTY = 'X'.
ENDIF.
APPEND ITEM_CONTROL.
ENDLOOP.
CALL FUNCTION 'BAPI_OUTB_DELIVERY_CHANGE'
EXPORTING
HEADER_DATA = HEADER_DATA
HEADER_CONTROL = HEADER_CONTROL
DELIVERY = DELIVERY
TABLES
ITEM_DATA = ITEM_DATA
ITEM_CONTROL = ITEM_CONTROL
RETURN = RETURN.
READ TABLE RETURN WITH KEY TYPE = 'E'.
IF NOT SY-SUBRC IS INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ENDIF.
regards,
Mahesh
2007 Mar 22 11:42 AM
Thank you.
Finally I solve the problem with a BI with the transaction VL02 deleting the position.
Thank you.
Regards
2015 Jun 16 7:17 AM
hi,
se37 to BAPI_OUTB_DELIVERY_CHANGE ,then goto->documentation,there is an example that
change dn quantity ,be sure enter every entries.
Thank you.
Regards.