Application Development 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: 

Delete longtext with BAPI_MATERIAL_SAVEDATA

Former Member
0 Kudos

Hi,

can anybody explain me, how to fill the fuba BAPI_MATERIAL_SAVEDATA, if I wan to delete the existing longtext.

Is MATERIALLONGTEXT-DEL_FLAG the right way?

I tried it with

MATERIALLONGTEXT-APPLOBJECT = MATERIAL

MATERIALLONGTEXT-TEXT_NAME = 96312103

MATERIALLONGTEXT-TEXT_ID = GRUN

MATERIALLONGTEXT-LANGU = DE

MATERIALLONGTEXT-FORMAT_COL = /

MATERIALLONGTEXT-TEXT_LINE

MATERIALLONGTEXT-DEL_FLAG = 'X'

If I insert a text inside MATERIALLONGTEXT-TEXT_LINE without the del_flag the system works correct and change the datas.

Regards

Nicole

1 ACCEPTED SOLUTION

former_member188685
Active Contributor
0 Kudos
MATERIALLONGTEXT-TEXT_NAME = 96312103

Text name = 'Material number with 18chars'

check that once.

If you still having the problem Post your code once.

5 REPLIES 5

Former Member
0 Kudos

hii

yes for deleting long text it is needed to set MATERIALLONGTEXT-DEL_FLAG = 'X'.

regards

twinkal

former_member188685
Active Contributor
0 Kudos
MATERIALLONGTEXT-TEXT_NAME = 96312103

Text name = 'Material number with 18chars'

check that once.

If you still having the problem Post your code once.

0 Kudos

Hi,

the relevant coding is

&----


*& Form change text

&----


FORM text_aendern.

data: ltext LIKE bapi_mltx OCCURS 0 WITH HEADER LINE,

lhead like BAPIMATHEAD,

dreturn like BAPIRET2.

clear ltext[].

loop at xtxt.

move: xtxt-tdformat to ltext-FORMAT_COL, "xtxt-tdformat = /

xtxt-tdline to ltext-TEXT_LINE. "xtxt-tdline = INITIAL

ltext-APPLOBJECT = pa_objec. "Pa_objec = MATERIAL

ltext-TEXT_NAME = dmatnr. "dmatnr = 96312103

ltext-TEXT_ID = pa_id. "pa_id = GRUN

ltext-LANGU = xeing-spras. "ltext-langu = DE

ltext-del_flag = 'X'.

append ltext.

endloop.

lhead-material = dmatnr. "dmatnr = 96312103

CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'

EXPORTING

HEADDATA = lhead

IMPORTING

RETURN = dreturn

TABLES

MATERIALLONGTEXT = ltext.

clear xtxt_read.

if dreturn ne space.

if dreturn-type eq 'E' or dreturn-type eq 'W'.

move: ltext-TEXT_NAME to imail-matnr,

ltext-LANGU to imail-spras,

dreturn-message to imail-text.

append imail.

endif.

endif.

eNDFORM. " text_aendern

0 Kudos

Fine tuned and Corrected code ....

REPORT  ztest_material_text.

DATA: head TYPE  bapimathead.
DATA: return TYPE bapiret2.
DATA: text TYPE TABLE OF bapi_mltx WITH HEADER LINE.

head-material = '000000000000000084'.
head-basic_view = 'X'.      "<----This is missing 
text-text_id = 'GRUN'.
text-applobject = 'MATERIAL'.
text-langu = sy-langu.
text-text_name = head-material.
text-del_flag = 'X'.
APPEND text.
"when you are deleting the text no need to pass the text
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
  EXPORTING
    headdata         = head
  IMPORTING
    return           = return
  TABLES
    materiallongtext = text.
IF return-type NE 'E'.
  "This is also must. Explicit commit required.
  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

ENDIF.

Former Member
0 Kudos

Hi,

I hope the below link will help you.

Thanks,

Khushboo.