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

Bapi_Salesorder_Change

Former Member
0 Likes
1,056

Hello,

I need to be able to add, update or delete texts from a sales order line item. I created a sample program (below) to test out if I could do this with BAPI_SALESORDER_CHANGE. I get back a message that the order was saved but the texts are not created. If anyone has any suggestions I would appreciate it.

REPORT ZTEXTTEST.

data: wa_vbeln like vbak-vbeln.

data: it_BAPISDH1X type BAPISDH1X.

data: it_ordertext like BAPISDTEXT occurs 0 with header line.

data: it_BAPIRET2 type BAPIRET2 occurs 0 with header line.

wa_vbeln = '0000001081'.

it_BAPISDH1X-UPDATEFLAG = 'U'.

it_ordertext-doc_number = wa_vbeln.

it_ordertext-itm_number = '000100'.

it_ordertext-text_id = '0001'.

it_ordertext-langu = 'EN'.

it_ordertext-langu_iso = 'EN'.

it_ordertext-format_col = '* '.

it_ordertext-text_line = 'This is a test for text type 0001'.

it_ordertext-function = '009'.

append it_ordertext.

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

EXPORTING

SALESDOCUMENT = wa_vbeln

  • ORDER_HEADER_IN =

ORDER_HEADER_INX = it_BAPISDH1X

TABLES

RETURN = it_BAPIRET2

  • ORDER_ITEM_IN =

  • ORDER_ITEM_INX =

ORDER_TEXT = it_ordertext.

loop at it_bapiret2.

write:/ it_bapiret2-message.

endloop.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

WAIT = 'X'

  • IMPORTING

  • RETURN =

.

Thanks,

Bert

1 ACCEPTED SOLUTION
Read only

kalman_bognar
Discoverer
0 Likes
989

Hi!

Try with CREATE_TEXT, with DELETE_TEXT can you delete it.

DATA: lt_textlines TYPE TABLE OF tline.

DATA: ls_textline TYPE tline.

ls_textline-tdformat = '* '.

ls_textline-tdline = 'This is a test for text type 0001'.

APPEND ls_textline TO lt_textlines.

CALL FUNCTION 'CREATE_TEXT'

EXPORTING

fid = '0001'

flanguage = 'E'

fname = '0000001081000010'

fobject = 'VBBP' " VBBP Item VBBK Header

save_direct = 'X'

  • FFORMAT = '*'

TABLES

flines = lt_textlines

  • EXCEPTIONS

  • NO_INIT = 1

  • NO_SAVE = 2

  • OTHERS = 3

.

br

Kalman

Hello,

I need to be able to add, update or delete texts from a sales order line item. I created a sample program (below) to test out if I could do this with BAPI_SALESORDER_CHANGE. I get back a message that the order was saved but the texts are not created. If anyone has any suggestions I would appreciate it.

REPORT ZTEXTTEST.

data: wa_vbeln like vbak-vbeln.

data: it_BAPISDH1X type BAPISDH1X.

data: it_ordertext like BAPISDTEXT occurs 0 with header line.

data: it_BAPIRET2 type BAPIRET2 occurs 0 with header line.

wa_vbeln = '0000001081'.

it_BAPISDH1X-UPDATEFLAG = 'U'.

it_ordertext-doc_number = wa_vbeln.

it_ordertext-itm_number = '000100'.

it_ordertext-text_id = '0001'.

it_ordertext-langu = 'EN'.

it_ordertext-langu_iso = 'EN'.

it_ordertext-format_col = '* '.

it_ordertext-text_line = 'This is a test for text type 0001'.

it_ordertext-function = '009'.

append it_ordertext.

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

EXPORTING

SALESDOCUMENT = wa_vbeln

  • ORDER_HEADER_IN =

ORDER_HEADER_INX = it_BAPISDH1X

TABLES

RETURN = it_BAPIRET2

  • ORDER_ITEM_IN =

  • ORDER_ITEM_INX =

ORDER_TEXT = it_ordertext.

loop at it_bapiret2.

write:/ it_bapiret2-message.

endloop.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

WAIT = 'X'

  • IMPORTING

  • RETURN =

.

Thanks,

Bert

5 REPLIES 5
Read only

Former Member
0 Likes
989

Hi Bert,

Your coding seems ok .The only thing you should verify is this lines of code:

it_ordertext-itm_number = '000100'.

Check if you sales order has item 100 or item 10. If you trying to update item 10 then the value needs to be

'000010'.

The other thingg,which should not influence your outcome but just to note is langu is a one char field ,so you only need to pass 'E' and not 'EN'. Ofcourse in the assignment below SAP will truncate it anyways.

it_ordertext-langu = 'EN'.

it_ordertext-langu_iso = 'EN'.

Regards,

Neil.

Read only

kalman_bognar
Discoverer
0 Likes
990

Hi!

Try with CREATE_TEXT, with DELETE_TEXT can you delete it.

DATA: lt_textlines TYPE TABLE OF tline.

DATA: ls_textline TYPE tline.

ls_textline-tdformat = '* '.

ls_textline-tdline = 'This is a test for text type 0001'.

APPEND ls_textline TO lt_textlines.

CALL FUNCTION 'CREATE_TEXT'

EXPORTING

fid = '0001'

flanguage = 'E'

fname = '0000001081000010'

fobject = 'VBBP' " VBBP Item VBBK Header

save_direct = 'X'

  • FFORMAT = '*'

TABLES

flines = lt_textlines

  • EXCEPTIONS

  • NO_INIT = 1

  • NO_SAVE = 2

  • OTHERS = 3

.

br

Kalman

Read only

Former Member
0 Likes
989

Hi,

Also populate the structure:ORDER_ITEM_IN and check

Also check thread :

Regards,

Himanshu

Read only

0 Likes
989

HI,

Check OSS Note 426980

Rgds,

Swetha

Read only

Pranil1
Participant
0 Likes
989

Hi,

Use FM Create_text and then use FM Save_text.

Let me know if u face any difficulty.

Regards,

Pranil Shinde.