2020 Jun 04 5:01 PM
data(lt_temp) = lt_data.
LOOP AT lt_temp ASSIGNING FIELD-SYMBOL(<fsl_temp>).
ls_poheader-po_number = <fsl_temp>-ebeln.
ls_poheaderx-po_number = 'X'.
READ TABLE lt_data INTO DATA(ls_data) WITH KEY ebeln = <fsl_temp>-ebeln BINARY SEARCH.
IF sy-subrc IS INITIAL.
ls_poitem-po_item = ls_data-ebelp.
ls_poitem-delete_ind = 'L'.
ls_poitemx-po_item = 'X'.
ls_poitemx-delete_ind = 'X'.
APPEND ls_poitem TO lt_poitem.
APPEND ls_poitemx TO lt_poitemx.
CLEAR: <fsl_temp>.
ENDIF.
CALL FUNCTION 'BAPI_PO_CHANGE'
EXPORTING
purchaseorder = ls_data-ebeln
* poheader = ls_poheader
* poheaderx = ls_poheaderx
TABLES
return = lt_return
poitem = lt_poitem
poitemx = lt_poitemx.
endloop.
READ TABLE lt_return INTO ls_return WITH KEY type = 'E'.
IF sy-subrc NE 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ENDIF.<br>
Hello.
I have fetched ebeln,ebelp and other fields using select query into table lt_data using select options given in selection screen.
Now I have multiple purchase orders & multiple line items.Need to call BAPI
"BAPI_PO_CHANGE".
How to fill the purchase order and its corresponding line items and pass it to BAPI.
This is the code i have written.
2020 Jun 04 5:13 PM
Hello vamshisaichand23
Your LT_TEMP has the same data as LT_DATA. So basically your changing all POs item by item. That's not very efficient. Have a look at the code below.
SORT lt_data BY ebeln ebelp.
LOOP AT lt_data ASSIGNING FIELD-SYMBOL(<ls_data>).
AT NEW ebeln.
CLEAR:
lt_return[],
lt_poitem[],
lt_poitemx[].
ENDAT.
ls_poitem-po_item = <ls_data>-ebelp.
ls_poitem-delete_ind = 'L'.
ls_poitemx-po_item = abap_true.
ls_poitemx-delete_ind = abap_true.
APPEND ls_poitem TO lt_poitem.
APPEND ls_poitemx TO lt_poitemx.
AT END OF ebeln.
CALL FUNCTION 'BAPI_PO_CHANGE'
EXPORTING
purchaseorder = <ls_data>-ebeln
TABLES
return = lt_return
poitem = lt_poitem
poitemx = lt_poitemx.
READ TABLE lt_return TRANSPORTING NO FIELDS
WITH KEY type = 'E'.
IF sy-subrc <> 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ENDIF.
ENDAT.
ENDLOOP.
Kind regards,data(lt_temp) = lt_data.
LOOP AT lt_temp ASSIGNING FIELD-SYMBOL(<fsl_temp>).
ls_poheader-po_number = <fsl_temp>-ebeln.
ls_poheaderx-po_number = 'X'.
READ TABLE lt_data INTO DATA(ls_data) WITH KEY ebeln = <fsl_temp>-ebeln BINARY SEARCH.
IF sy-subrc IS INITIAL.
ls_poitem-po_item = ls_data-ebelp.
ls_poitem-delete_ind = 'L'.
ls_poitemx-po_item = 'X'.
ls_poitemx-delete_ind = 'X'.
APPEND ls_poitem TO lt_poitem.
APPEND ls_poitemx TO lt_poitemx.
CLEAR: <fsl_temp>.
ENDIF.
CALL FUNCTION 'BAPI_PO_CHANGE'
EXPORTING
purchaseorder = ls_data-ebeln
* poheader = ls_poheader
* poheaderx = ls_poheaderx
TABLES
return = lt_return
poitem = lt_poitem
poitemx = lt_poitemx.
endloop.
READ TABLE lt_return INTO ls_return WITH KEY type = 'E'.
IF sy-subrc NE 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ENDIF.<br>
Hello.
I have fetched ebeln,ebelp and other fields using select query into table lt_data using select options given in selection screen.
Now I have multiple purchase orders & multiple line items.Need to call BAPI
"BAPI_PO_CHANGE".
How to fill the purchase order and its corresponding line items and pass it to BAPI.
This is the code i have written.
2020 Jun 04 5:05 PM
Hi,
Thank you for visiting SAP Community to get answers to your questions. I am here to help you to get the most out of it.
First of all, I recommend that you familiarize yourself with https://community.sap.com/resources/questions-and-answers (if you haven't already), as it provides tips for preparing questions that draw responses from our members.
For example you :
The more details you provide, the more likely it is that members will be able to assist you
Should you wish, you can revise your question by selecting Actions, then Edit (although once someone answers your question, you'll lose the ability to edit the question -- but if that happens, you can leave more details in a comment).
Finally, if you're hoping to connect with readers, please consider adding a picture to your profile. Here's how you do it: https://www.youtube.com/watch?v=F5JdUbyjfMA&list=PLpQebylHrdh5s3gwy-h6RtymfDpoz3vDS. By personalizing your profile with a photo of you, you encourage readers to respond.
Good Luck
Kati - SAP Community Moderator
2020 Jun 04 5:13 PM
Hello vamshisaichand23
Your LT_TEMP has the same data as LT_DATA. So basically your changing all POs item by item. That's not very efficient. Have a look at the code below.
SORT lt_data BY ebeln ebelp.
LOOP AT lt_data ASSIGNING FIELD-SYMBOL(<ls_data>).
AT NEW ebeln.
CLEAR:
lt_return[],
lt_poitem[],
lt_poitemx[].
ENDAT.
ls_poitem-po_item = <ls_data>-ebelp.
ls_poitem-delete_ind = 'L'.
ls_poitemx-po_item = abap_true.
ls_poitemx-delete_ind = abap_true.
APPEND ls_poitem TO lt_poitem.
APPEND ls_poitemx TO lt_poitemx.
AT END OF ebeln.
CALL FUNCTION 'BAPI_PO_CHANGE'
EXPORTING
purchaseorder = <ls_data>-ebeln
TABLES
return = lt_return
poitem = lt_poitem
poitemx = lt_poitemx.
READ TABLE lt_return TRANSPORTING NO FIELDS
WITH KEY type = 'E'.
IF sy-subrc <> 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ENDIF.
ENDAT.
ENDLOOP.
Kind regards,2020 Jun 04 6:19 PM
Solution:
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |