0% found this document useful (0 votes)
50 views

Loop at It - 9010 Where Flag Eq 'X'.: 'Conversion - Exit - Matn1 - Input'

This document contains an ABAP program that updates material descriptions in SAP. It uses BAPI functions to read existing material data, modify description fields, and save the changes. The program loops through a table of materials, calls the BAPI functions to update each one, and commits or rolls back the transaction depending on whether errors occur.

Uploaded by

Max Dos Anjos
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views

Loop at It - 9010 Where Flag Eq 'X'.: 'Conversion - Exit - Matn1 - Input'

This document contains an ABAP program that updates material descriptions in SAP. It uses BAPI functions to read existing material data, modify description fields, and save the changes. The program loops through a table of materials, calls the BAPI functions to update each one, and commits or rolls back the transaction depending on whether errors occur.

Uploaded by

Max Dos Anjos
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

FORM atualizar_descricao .

DATA: i_bapimathead LIKE bapimathead,


i_bapimara LIKE bapi_mara,
i_bapimarax LIKE bapi_marax,
it_bapi_makt LIKE bapi_makt OCCURS 0 WITH HEADER LINE,
it_bapi_marc LIKE bapi_marc OCCURS 0 WITH HEADER LINE,
it_bapi_marcx LIKE bapi_marcx OCCURS 0 WITH HEADER LINE,
it_bapi_mpop LIKE bapi_mpop OCCURS 0 WITH HEADER LINE,
it_bapi_mpopx LIKE bapi_mpopx OCCURS 0 WITH HEADER LINE,
it_return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.

*LOOP AT IT_9010 WHERE FLAG EQ 'X'.

READ TABLE it_9010 WITH KEY matnr = g_matnr.


IF sy-subrc EQ 0.
REFRESH: it_return, it_bapi_makt, it_bapi_marc, it_bapi_mpop.
CLEAR: it_return, i_bapimathead, it_bapi_makt, it_bapi_marc, it_ba
pi_mpop.
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
input = it_9010-matnr
IMPORTING
output = it_9010-matnr.

MOVE it_9010-matnr TO i_bapimathead-


material. "Código do Material
MOVE g_mfrpn TO i_bapimara-
manu_mat. "Código do Material no Fornecedor
MOVE 'X' TO i_bapimarax-manu_mat.

MOVE 'PT' TO it_bapi_makt-langu.


MOVE 'PT' TO it_bapi_makt-
langu_iso. "Idioma da Descrição
MOVE it_9010-maktx TO it_bapi_makt-
matl_desc. "Descrição do Material

TRANSLATE it_bapi_makt-matl_desc TO UPPER CASE.


APPEND it_bapi_makt.

MOVE it_9010-werks TO it_bapi_marc-plant. "Centro


MOVE g_dismm TO it_bapi_marc-mrp_type. "Tipo de MRP
MOVE g_plifz TO it_bapi_marc-
plnd_delry. "Prazo de entrega previsto em dias
APPEND it_bapi_marc.

MOVE it_9010-werks TO it_bapi_marcx-plant.


MOVE 'X' TO it_bapi_marcx-mrp_type.
MOVE 'X' TO it_bapi_marcx-plnd_delry.
APPEND it_bapi_marcx.

MOVE it_9010-werks TO it_bapi_mpop-plant. "Centro


MOVE g_peran TO it_bapi_mpop-
hist_vals. "Núm.dos períodos históricos
APPEND it_bapi_mpop.

MOVE it_9010-werks TO it_bapi_mpopx-plant.


MOVE 'X' TO it_bapi_mpopx-hist_vals.
APPEND it_bapi_mpopx.

CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'


EXPORTING
headdata = i_bapimathead
clientdata = i_bapimara
clientdatax = i_bapimarax
plantdata = it_bapi_marc
plantdatax = it_bapi_marcx
forecastparameters = it_bapi_mpop
forecastparametersx = it_bapi_mpopx
IMPORTING
return = it_return
TABLES
materialdescription = it_bapi_makt.
READ TABLE it_return WITH KEY type = 'E'.
IF sy-subrc EQ 0.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
MESSAGE i001(zz) WITH 'Erro ao modificar cadastro de material!'.
ELSE.
IF it_return-type NE 'E'.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
MOVE g_mfrpn TO it_9010-mfrpn.
MOVE g_dismm TO it_9010-dismm.
MOVE g_plifz TO it_9010-plifz.
MOVE g_peran TO it_9010-peran.
MODIFY it_9010 TRANSPORTING mfrpn dismm plifz peran WHERE matn
r EQ g_matnr
AND werk
s EQ it_9010-werks.
MESSAGE s001(zz) WITH 'Informações alterada com sucesso!'.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
MESSAGE i001(zz) WITH it_return-message.
ENDIF.
ENDIF.
ENDIF.
*ENDLOOP.
ENDFORM. " ATUALIZAR_DESCRICAO

You might also like