Previamente, hemos añadido un chek en el maestro de artículos ZCHEK en la tabla MARC (append)
Esto indicaremos que el artículo pertenecerá a la tienda
Implementamos la BADI:
BADI_ARTICLE_MASS_RT
Para ello actualizaremos sus dos métodos como sigue
BUILD_CUSTOMER_FIELDTAB
METHOD if_ex_badi_article_mass_rt~build_customer_fieldtab.
* BREAK-POINT.
DATA: wa_DDOBJNAME TYPE DDOBJNAME.
"Aquí meto todos los custom fields que creeemos para el maestro de artículos
clear wa_DDOBJNAME.
wa_DDOBJNAME = 'ZCHEK'.
APPEND wa_DDOBJNAME TO CUSTOMER_FIELDS.
ENDMETHOD.
MASS_SAVEDATA_RETAIL
METHOD if_ex_badi_article_mass_rt~mass_savedata_retail.
DATA: work TYPE dcobjdef-name,
wa_marc TYPE zzmarc.
MOVE-CORRESPONDING f_marc TO wa_marc.
t_plantext-material = f_marc-matnr.
t_plantext-plant = f_marc-werks.
t_plantext-field1 = wa_marc.
t_plantextx-material = f_marc-matnr.
t_plantextx-plant = f_marc-werks.
* Now fill up the X mark segments and set an X at the
* correct position where the data field take place
LOOP AT fieldtab-fieldnames INTO work.
CASE work.
WHEN 'ZCHEK'.
t_plantextx-field1(1) = 'X'.
* ...
* continue as many fields you have
ENDCASE.
ENDLOOP.
ENDMETHOD.
para que todo esto funcione necesitamos implementar la EXIT
EXIT_SAPL1001_003
INCLUDE ZXMGVU07
de la siguiente forma
DATA: BEGIN OF h_plantext, "Customer data
function LIKE bapie1marcextrt-function, "Key field
material LIKE bapie1marcextrt-material, "Key field
plant LIKE bapie1marcextrt-plant. "Key field
INCLUDE STRUCTURE zzmarc.
DATA: END OF h_plantext.
DATA: BEGIN OF h_plantextx, "Customer update information
function LIKE bapie1marcextrtx-function, "Key field
material LIKE bapie1marcextrtx-material, "Key field
plant LIKE bapie1marcextrtx-plant, "Key field
zchek TYPE c,
* zcust2 TYPE c,
* zcust3 TYPE c,
END OF h_plantextx.
CASE parameter_name.
WHEN c_parnam_plantext.
h_plantext = f_plantext.
h_plantextx = f_plantextx.
IF NOT h_plantextx-zchek IS INITIAL
OR NOT f_headdata-all_fields IS INITIAL.
* Corresponding data field is relevant for update
IF h_plantext-zchek IS INITIAL.
t_res_fields-feldname = 'MARC-ZCHEK'.
APPEND t_res_fields.
ENDIF.
ELSE.
CLEAR h_plantext-zchek.
ENDIF.
f_marc_ueb-zchek = h_plantext-zchek.
ENDCASE.
* Ha ocurrido un error en la actualización
IF sy-subrc NE 0.
MESSAGE e544(mg) WITH parameter_name RAISING application_error.
ENDIF.
con todo esto conseguimos que en la actualización mediante la transacción MASS, se actualice en la MARC ( o en cualquier tabla ) los valores de los campos Z que hemos añadido.
Esto indicaremos que el artículo pertenecerá a la tienda
Implementamos la BADI:
BADI_ARTICLE_MASS_RT
Para ello actualizaremos sus dos métodos como sigue
BUILD_CUSTOMER_FIELDTAB
METHOD if_ex_badi_article_mass_rt~build_customer_fieldtab.
* BREAK-POINT.
DATA: wa_DDOBJNAME TYPE DDOBJNAME.
"Aquí meto todos los custom fields que creeemos para el maestro de artículos
clear wa_DDOBJNAME.
wa_DDOBJNAME = 'ZCHEK'.
APPEND wa_DDOBJNAME TO CUSTOMER_FIELDS.
ENDMETHOD.
MASS_SAVEDATA_RETAIL
METHOD if_ex_badi_article_mass_rt~mass_savedata_retail.
DATA: work TYPE dcobjdef-name,
wa_marc TYPE zzmarc.
MOVE-CORRESPONDING f_marc TO wa_marc.
t_plantext-material = f_marc-matnr.
t_plantext-plant = f_marc-werks.
t_plantext-field1 = wa_marc.
t_plantextx-material = f_marc-matnr.
t_plantextx-plant = f_marc-werks.
* Now fill up the X mark segments and set an X at the
* correct position where the data field take place
LOOP AT fieldtab-fieldnames INTO work.
CASE work.
WHEN 'ZCHEK'.
t_plantextx-field1(1) = 'X'.
* ...
* continue as many fields you have
ENDCASE.
ENDLOOP.
ENDMETHOD.
para que todo esto funcione necesitamos implementar la EXIT
EXIT_SAPL1001_003
INCLUDE ZXMGVU07
de la siguiente forma
DATA: BEGIN OF h_plantext, "Customer data
function LIKE bapie1marcextrt-function, "Key field
material LIKE bapie1marcextrt-material, "Key field
plant LIKE bapie1marcextrt-plant. "Key field
INCLUDE STRUCTURE zzmarc.
DATA: END OF h_plantext.
DATA: BEGIN OF h_plantextx, "Customer update information
function LIKE bapie1marcextrtx-function, "Key field
material LIKE bapie1marcextrtx-material, "Key field
plant LIKE bapie1marcextrtx-plant, "Key field
zchek TYPE c,
* zcust2 TYPE c,
* zcust3 TYPE c,
END OF h_plantextx.
CASE parameter_name.
WHEN c_parnam_plantext.
h_plantext = f_plantext.
h_plantextx = f_plantextx.
IF NOT h_plantextx-zchek IS INITIAL
OR NOT f_headdata-all_fields IS INITIAL.
* Corresponding data field is relevant for update
IF h_plantext-zchek IS INITIAL.
t_res_fields-feldname = 'MARC-ZCHEK'.
APPEND t_res_fields.
ENDIF.
ELSE.
CLEAR h_plantext-zchek.
ENDIF.
f_marc_ueb-zchek = h_plantext-zchek.
ENDCASE.
* Ha ocurrido un error en la actualización
IF sy-subrc NE 0.
MESSAGE e544(mg) WITH parameter_name RAISING application_error.
ENDIF.
con todo esto conseguimos que en la actualización mediante la transacción MASS, se actualice en la MARC ( o en cualquier tabla ) los valores de los campos Z que hemos añadido.
Comentarios
Publicar un comentario