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!

Former Member
0 Likes
636

Hi,

How to make changes to the Po text of a Material which we can see in the MM02 transaction in the Purchase order text view.

Does the BAPI_MATERIAL_SAVEDATA work??

If so, Any clues to start with??

Shekar.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
602

Hi,

Check this code...THis works fine for me..

DATA: text LIKE bapi_mltx OCCURS 0 WITH HEADER LINE.

DATA: header LIKE bapimathead.

DATA: t_return LIKE bapi_matreturn2 OCCURS 0 WITH HEADER LINE.

PARAMETERS: p_matnr TYPE matnr.

  • Header.

header-material = p_matnr.

header-purchase_view = 'X'.

  • Text

text-applobject = 'MATERIAL'.

text-text_name = p_matnr.

text-text_id = 'BEST'.

text-langu = sy-langu.

text-text_line = 'PO TEXT FROM BAPI'.

APPEND text.

  • Call BAPI.

CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'

EXPORTING

headdata = header

TABLES

materiallongtext = text

returnmessages = t_return.

COMMIT WORK.

Thanks,

Naren

5 REPLIES 5
Read only

Former Member
0 Likes
603

Hi,

Check this code...THis works fine for me..

DATA: text LIKE bapi_mltx OCCURS 0 WITH HEADER LINE.

DATA: header LIKE bapimathead.

DATA: t_return LIKE bapi_matreturn2 OCCURS 0 WITH HEADER LINE.

PARAMETERS: p_matnr TYPE matnr.

  • Header.

header-material = p_matnr.

header-purchase_view = 'X'.

  • Text

text-applobject = 'MATERIAL'.

text-text_name = p_matnr.

text-text_id = 'BEST'.

text-langu = sy-langu.

text-text_line = 'PO TEXT FROM BAPI'.

APPEND text.

  • Call BAPI.

CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'

EXPORTING

headdata = header

TABLES

materiallongtext = text

returnmessages = t_return.

COMMIT WORK.

Thanks,

Naren

Read only

0 Likes
602

Hi Naren!

This code seams to be working.

But the problem is when I am trying to execute the code in a loop for more than one material, it is updating juss one starting record of ITAB.

COuld you please help me like what could be the problem.

Actually Iam changing the Material description also for the same material along with the PO text.

When I try to update juss the Material description, it does work for all fields.

The problem is only when I try to do the change of PO text along with the Material description.

ANyways here is the code for your reference.

Data: ls_headdata like bapimathead ,

lt_makt like bapi_makt occurs 0 with header line ,

ls_return like bapiret2.

DATA: ls_text LIKE bapi_mltx OCCURS 0 WITH HEADER LINE.

DATA: ls_t_return LIKE bapi_matreturn2 OCCURS 0 WITH HEADER LINE.

Loop at I_Itab.

ls_headdata-purchase_view = 'X'.

  • Text

ls_text-applobject = 'MATERIAL'.

ls_text-text_name = I_ITab-matnr.

ls_text-text_id = 'BEST'.

ls_text-langu = 'EN'.

ls_text-text_line = 'FROM BAPImmmmm'.

append ls_text.

ls_headdata-material = I_Itab-matnr .

lt_makt-langu = 'EN'.

lt_makt-matl_desc = 'vvvvvv'.

append lt_makt.

CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'

EXPORTING

HEADDATA = ls_headdata

IMPORTING

RETURN = ls_return

TABLES

MATERIALDESCRIPTION = lt_makt

MATERIALLONGTEXT = ls_text

RETURNMESSAGES = ls_t_return

.

COMMIT WORK.

:::::::::OUTPUT:::::::

1. SMM-- success message the material 300000 has been created or extended.

2.EMM-- error message the field MATNR has been transfered inconsistently or is blank.

But I am sure it is not blank.

I think the loop is terminating for one record.

Please help me out!!!!!!!!!

Thank you,

Shekar.

Read only

0 Likes
602

One thing, you will want to refresh you internal tables each time through the loop, otherwise, you will keep appending.

Regards,

RIch Heilman

Read only

Former Member
0 Likes
602

Hi,

use edit_text function module

save_text

see tables stxh,stxl.

Regards

amole

Read only

Former Member
0 Likes
602

Hi,

Please reward for helpful answers...

Thanks,

Naren