Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Problem with appending PO-header text

Former Member
0 Likes
848

Hi friends,

With th following code im able to append the text in different lines to Po-Header.If i want to change the text for another PO,then the old of PO is also getting appended.To avoid this what i have to do ::

&----


*& Report Z_PO_CHANGE

*&

&----


*&

*&

&----


REPORT z_po_change.

DATA : i_poheader LIKE bapimepoheader OCCURS 0 WITH HEADER LINE.

DATA : i_poheaderx LIKE bapimepoheaderx OCCURS 0 WITH HEADER LINE.

DATA : i_result LIKE bapimepoheader OCCURS 0 WITH HEADER LINE.

*DATA : po_num(15) TYPE n VALUE '4500008083'.

DATA : t_text TYPE STANDARD TABLE OF bapimepotext with header line.

DATA : t_res TYPE STANDARD TABLE OF bapimepotext WITH HEADER LINE.

DATA : e_text TYPE bapimepotext.

DATA return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.

PARAMETER v_text(100) TYPE c.

      • To read the text *****

CALL FUNCTION 'READ_TEXT'

EXPORTING

id = 'F02'

language = sy-langu

name = 'Append'

object = 'EKKO'

TABLES

lines = t_res.

*

e_text-po_number = '4500008082'.

e_text-text_id = 'F02'.

e_text-text_form = '*'.

e_text-text_line = v_text.

APPEND e_text TO t_res.

CLEAR e_text.

clear t_res.

          • Sav the new text in a tabe *****

CALL FUNCTION 'CREATE_TEXT'

EXPORTING

fid = 'F02'

flanguage = sy-langu

fname = 'Append'

fobject = 'EKKO'

TABLES

flines = t_res.

            • To change the PO-Header *****

clear t_res.

CALL FUNCTION 'BAPI_PO_CHANGE'

EXPORTING

purchaseorder = '4500008082'

TABLES

return = return

potextheader = t_res.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'.

LOOP AT return.

WRITE : return-message.

ENDLOOP.

1 ACCEPTED SOLUTION
Read only

Pawan_Kesari
Active Contributor
0 Likes
790

remove below code from your program


CALL FUNCTION 'READ_TEXT'
EXPORTING
id = 'F02'
language = sy-langu
name = 'Append'
object = 'EKKO'
TABLES
lines = t_res.

Hi friends,

With th following code im able to append the text in different lines to Po-Header.If i want to change the text for another PO,then the old of PO is also getting appended.To avoid this what i have to do ::

&----


*& Report Z_PO_CHANGE

*&

&----


*&

*&

&----


REPORT z_po_change.

DATA : i_poheader LIKE bapimepoheader OCCURS 0 WITH HEADER LINE.

DATA : i_poheaderx LIKE bapimepoheaderx OCCURS 0 WITH HEADER LINE.

DATA : i_result LIKE bapimepoheader OCCURS 0 WITH HEADER LINE.

*DATA : po_num(15) TYPE n VALUE '4500008083'.

DATA : t_text TYPE STANDARD TABLE OF bapimepotext with header line.

DATA : t_res TYPE STANDARD TABLE OF bapimepotext WITH HEADER LINE.

DATA : e_text TYPE bapimepotext.

DATA return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.

PARAMETER v_text(100) TYPE c.

      • To read the text *****

CALL FUNCTION 'READ_TEXT'

EXPORTING

id = 'F02'

language = sy-langu

name = 'Append'

object = 'EKKO'

TABLES

lines = t_res.

*

e_text-po_number = '4500008082'.

e_text-text_id = 'F02'.

e_text-text_form = '*'.

e_text-text_line = v_text.

APPEND e_text TO t_res.

CLEAR e_text.

clear t_res.

          • Sav the new text in a tabe *****

CALL FUNCTION 'CREATE_TEXT'

EXPORTING

fid = 'F02'

flanguage = sy-langu

fname = 'Append'

fobject = 'EKKO'

TABLES

flines = t_res.

            • To change the PO-Header *****

clear t_res.

CALL FUNCTION 'BAPI_PO_CHANGE'

EXPORTING

purchaseorder = '4500008082'

TABLES

return = return

potextheader = t_res.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'.

LOOP AT return.

WRITE : return-message.

ENDLOOP.

4 REPLIES 4
Read only

Former Member
0 Likes
790

hi,

clear this 't_res' after the write statement.

reward points if helpful,

regards,

seshu.

Read only

0 Likes
790

Hi,

Still im unable to change the other PO header text.

Thanks,

Asmitha.

Read only

Pawan_Kesari
Active Contributor
0 Likes
791

remove below code from your program


CALL FUNCTION 'READ_TEXT'
EXPORTING
id = 'F02'
language = sy-langu
name = 'Append'
object = 'EKKO'
TABLES
lines = t_res.

Read only

Former Member
0 Likes
790

Thanks all,This helps me a lot.But i had given points to more than one person.I dont know wethet it works or not.shall i assign the points to more than one person.