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

updating values in mara table through bapi

Former Member
0 Likes
7,448

Hi friends,

I am very new to ABAP , just now i have started my carrier in SAP-ABAP.

I have to update these three fields MSTAE, EXTWG, MTPOS_MARA in MARA table through bapi. I need to give these values from selection screen followed by Material no.

I already found some program in the forum  but that programs are very lenthy , i am not able to understand.

Can anyone help me by giving some idea or sample program so that i can learn how to do this thing.

Thankx in advance...

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
4,479

Hi Ritesh,

Use BAPI_MATERIAL_SAVEDATA to update the entries MSTAE, EXTWG and MTPOS_MARA by passing the following fields:

DATA: ls_headdata     TYPE  bapimathead,

       ls_clientdata   TYPE  bapi_mara,

       ls_clientdatax  TYPE  bapi_marax,

       ls_return       TYPE  bapiret2.

CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'

   EXPORTING

     input        = ls_material-matnr

   IMPORTING

     output       = ls_headdata-material

   EXCEPTIONS

     length_error = 1

     OTHERS       = 2.

IF sy-subrc <> 0.

   CLEAR: ls_headdata-material.

ENDIF.

ls_clientdata-extmatlgrp  = ls_material-extwg.

ls_clientdata-pur_status  = ls_material-mstae.

ls_clientdata-item_cat    = ls_material-mtpos_mara.

ls_clientdatax-extmatlgrp  = 'X'.

ls_clientdatax-pur_status  = 'X'.

ls_clientdatax-item_cat    = 'X'.

CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'

   EXPORTING

     headdata    = ls_headdata

     clientdata  = ls_clientdata

     clientdatax = ls_clientdatax

   IMPORTING

     return      = ls_return.

IF ls_return-type = 'E' OR ls_return-type = 'A'.

   CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.

ELSE.

   CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

     EXPORTING

       wait = 'X'.

ENDIF.


Thanks & Regards,

Prasanna


Hi friends,

I am very new to ABAP , just now i have started my carrier in SAP-ABAP.

I have to update these three fields MSTAE, EXTWG, MTPOS_MARA in MARA table through bapi. I need to give these values from selection screen followed by Material no.

I already found some program in the forum  but that programs are very lenthy , i am not able to understand.

Can anyone help me by giving some idea or sample program so that i can learn how to do this thing.

Thankx in advance...

6 REPLIES 6
Read only

Former Member
0 Likes
4,480

Hi Ritesh,

Use BAPI_MATERIAL_SAVEDATA to update the entries MSTAE, EXTWG and MTPOS_MARA by passing the following fields:

DATA: ls_headdata     TYPE  bapimathead,

       ls_clientdata   TYPE  bapi_mara,

       ls_clientdatax  TYPE  bapi_marax,

       ls_return       TYPE  bapiret2.

CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'

   EXPORTING

     input        = ls_material-matnr

   IMPORTING

     output       = ls_headdata-material

   EXCEPTIONS

     length_error = 1

     OTHERS       = 2.

IF sy-subrc <> 0.

   CLEAR: ls_headdata-material.

ENDIF.

ls_clientdata-extmatlgrp  = ls_material-extwg.

ls_clientdata-pur_status  = ls_material-mstae.

ls_clientdata-item_cat    = ls_material-mtpos_mara.

ls_clientdatax-extmatlgrp  = 'X'.

ls_clientdatax-pur_status  = 'X'.

ls_clientdatax-item_cat    = 'X'.

CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'

   EXPORTING

     headdata    = ls_headdata

     clientdata  = ls_clientdata

     clientdatax = ls_clientdatax

   IMPORTING

     return      = ls_return.

IF ls_return-type = 'E' OR ls_return-type = 'A'.

   CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.

ELSE.

   CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

     EXPORTING

       wait = 'X'.

ENDIF.


Thanks & Regards,

Prasanna


Read only

0 Likes
4,479

Hi Prasanna,

Thankyou very much for replying ,,,

I want to ask u Is it the whole program for updation?

And i am not getting what is "ls_material" is here , i have to insert the values of the three fields from selection screen..

Thanku...

Read only

0 Likes
4,479

Hello Ritesh,

ls_material is work area of internal table which is upload through excel.if u want pass the screen fields

in the FM "CONVERSION_EXIT_MATN1_INPUT" Just pass the screen fields value in new internal table .

under that loop use the FM and pass the work area values as input to the FM.

I hope this solve u r issue.

Regards,

Ameya Karadkhedkar

Read only

0 Likes
4,479

Hi Ritesh,

As said by Ameya Karadkhedkar, if you are going to pass the values using selection screen, then pass those screen fields instead of ls_material.

Parameters: p_matnr type matnr,

                   p_extwg type extwg,

                   p_mstae type mstae,

                   p_mtpos type mtpos_mara.

Replace:  ls_material-matnr -> p_matnr

               ls_material-extwg -> p_extwg

               ls_material-mstae -> p_mstae

               ls_material-mtpos_mara -> p_mtpos

Thanks & Regards,

Prasanna

Read only

0 Likes
4,479

Thankyou very much ,,,,now i got the desired output....

Read only

0 Likes
4,479

Thanks, Good one