Technical Articles
Maintain customer field with Fast Change in ME22N
Hi Experts,
Requirement : Customer field in Fast Change purchase order
I saw several requests with the requirement of adding a customer field in the fast change functionality in ME22N, struggling without final solution. For I need the same, I ‘ve done it as described here.
Realization by implizit enhancement
I realized that requirement, as follows:
The field should have item-character, i.e. each item line could have different values for your customer field:
<img />Here you can select and then fill your field together with regular standards fields
Example:
<img />Subsequent save will change all or only marked positions.
My solution works with the following 3 adoptions:
[ Add your field* in CI_EKPODB ( you should have done this yet, otherwise your field cannot be saved ) By that your field automatically should be visible in MEPOITEM, as this should contain the CI_EKPODB. ]
)* means the appended field hast to be name ident with your customer – field in CI_EKPODB
- Add your field via append in the structure: MEGUI_MASSCH_ALLOWED_FIELDS with the same type as your new field.
- Add your field* via append in structure : MEPOITEMX, with the data type BAPIUPDATE
- Now create an Code enhancement in report LMEGUICJQ and there in CLASS cl_mass_change_view_mm IMPLEMENTATION and there in METHOD transport_to_model. Start at the first implizit enhancement after the method – command.:
Now create an Code enhancement in report LMEGUICJQ and there in CLASS cl_mass_change_view_mm IMPLEMENTATION and there in METHOD transport_to_model. Start at the first implizit enhancement after the method – command.:
CLASS lcl_mass_change_view_mm IMPLEMENTATION / METHOD transport_to_model:
CLASS lcl_mass_change_view_mm IMPLEMENTATION.
METHOD transport_to_model.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""$"$:(1) Klasse LCL_MASS_CHANGE_VIEW_MM, Methode TRANSPORT_TO_MODEL, Anfang A
*$*$-Start: (1)---------------------------------------------------------------------------------$*$*
ENHANCEMENT 1 <your enhancement name>. "active version
* M.Hapke; 02-11-2018 ; process customer field :
DATA: zl_item TYPE REF TO cl_po_item_handle_mm,
zl_header TYPE REF TO cl_po_header_handle_mm,
zl_item_data TYPEmepoitem,
zl_item_datax TYPEmepoitemx,
zl_item_data_temp TYPE mepoitem.
DATA: zls_modelLIKE LINE OF my_value_models,
za_value_model TYPE REF TO cl_value_model_mm,
za_clear_model TYPE REF TO cl_value_model_mm,
zl_datatype TYPEstring40,
zl_feld TYPE string40.
DATA: zl_dynpro_fieldLIKE LINE OF my_dynpro_fields,
zl_fieldselection LIKE LINE OF my_fieldselection,
zl_field_status TYPE char1,
zl_clear_items TYPEmegui_range-clear_items.
DATA ld_go_on value ' ' .
* Test if customer field is selected:
LOOP AT my_value_models INTOzls_model.
mmpur_dynamic_cast za_value_model zls_model-model.
CHECK NOT za_value_model IS INITIAL.
CALL METHOD za_value_model->get_datatype
IMPORTING
ex_datatype = zl_datatype.
if zl_datatype eq 'MEGUI_MASSCH_ALLOWED_FIELDS-<put your fieldname here>'. "
ld_go_on = 'X' .
exit.
endif.
ENDLOOP.
* prerequesite retrieved
clear: zls_model, za_value_model, zl_datatype.
if ld_go_on eq 'X' .
FIELD-SYMBOLS: <zsrc> TYPE ANY,
<zdst> TYPE ANY,
<zdstx> TYPE ANY.
CHECK NOT im_model IS INITIAL.
zl_item ?= im_model.
zl_header ?= zl_item->my_parent.
CALL METHOD fs_get( im_model= im_model ).
CALL METHOD zl_item->get_data
IMPORTING
ex_data = zl_item_data.
CALL METHOD zl_item->get_datax
IMPORTING
ex_data = zl_item_datax.
LOOP AT my_value_models INTOzls_model.
mmpur_dynamic_cast za_value_model zls_model-model.
CHECK NOT za_value_model IS INITIAL.
CALL METHOD za_value_model->get_datatype
IMPORTING
ex_datatype = zl_datatype.
SHIFT zl_datatype UP TO'-'.
SHIFT zl_datatype LEFT BY 1 PLACES.
READ TABLE my_dynpro_fields INTO zl_dynpro_field
WITH KEY fieldname = zl_datatype.
CHECK sy-subrc IS INITIAL.
READ TABLE my_fieldselection INTO zl_fieldselection
WITH KEY metafield = zl_dynpro_field-metafield.
IF sy-subrc IS INITIAL.
zl_field_status = zl_fieldselection-fieldstatus.
ELSE.
zl_field_status = default_field_status.
ENDIF.
* BEGIN deviation towards standard ; if your customer field is mass-changed:
FIELD-SYMBOLS <z_modify> type bapiupdate.
if zl_datatype eq '<put your fieldname here>'.
zl_field_status = '.' .
ASSIGN COMPONENT '<put your fieldname here>' of STRUCTURE zl_item_datax to <z_modify> .
if <z_modify> is ASSIGNED.
<z_modify> = 'X'.
endif.
endif.
* End of deviation towards standard
IF zl_field_status EQ '.' OR
zl_field_status EQ '+'.
ASSIGN COMPONENT zl_datatype OF STRUCTURE zl_item_data TO <zdst>.
CHECK sy-subrc EQ 0.
ASSIGN COMPONENT zl_datatype OF STRUCTURE zl_item_datax
TO <zdstx>.
CHECK sy-subrcEQ 0.
ASSIGN COMPONENT zl_datatype OF STRUCTURE zl_item_data_temp
TO <zsrc>.
CHECK sy-subrcEQ 0.
CALL METHOD za_value_model->get_value
IMPORTING
ex_value = <zsrc>.
mmpur_dynamic_cast za_clear_model zls_model-clear.
CHECK NOT za_clear_model IS INITIAL.
CALL METHOD za_clear_model->get_value
IMPORTING
ex_value = zl_clear_items.
IF zl_clear_items EQ mmpur_yes OR
NOT <zsrc> IS INITIAL.
<zdst> = <zsrc>.
<zdstx> = mmpur_yes.
ENDIF.
ENDIF.
ENDLOOP.
zl_item_data-ebeln = zl_header->po_number.
zl_item_data-id = zl_item->id.
CALL METHOD zl_item->set_data
EXPORTING
im_data = zl_item_data.
CALL METHOD zl_item->set_datax
EXPORTING
im_data = zl_item_datax.
Exit. " next block isn't processed
ELSE.
ENDIF.
** from here standard again:
ENDENHANCEMENT.
*$*$-End: (1)---------------------------------------------------------------------------------$*$*
DATA: l_item TYPE REF TO cl_po_item_handle_mm,
l_header TYPE REF TO cl_po_header_handle_mm,
l_item_data TYPE mepoitem,
l_item_datax TYPE mepoitemx,
l_item_data_temp TYPE mepoitem.
Conclusion
A relative simple way to achieve the funktion in question by adding enhancement coding at the a single place. Please leave notes / suggestions if you like to or coding doesn’t work for you.
Markus
Great Job done - perfect. This solved my huge challenge to enhance fast change with customer fields. Thanks a lot for the detailed description.
Thank your for your coding! But I didn't find the z-field in the items table? To I have to add the field to another structure too?
regards
Markus