Application Development 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: 

Long text update in MM02 based on change in Short text & Classification fields

vinay_pasalkar
Participant
0 Kudos

Hi Experts,

My requirement is whenever short text field or any of the classification fields are changed manually in SAP, the changes should be reflected in the Basic Data Long Text. I need to concatenate the short text with all classification fields & update the same into the basic data long text.

Also the requirement is the long text can be more than 40 characters.

Could you please let me know if there is any user exit for updating the basic data long text based on the short text & classifications fields change in MM02.

And also how we can modify the standard length of the long text which is 40 characters.

Thanks

Vinay

1 ACCEPTED SOLUTION

eduardo_hinojosa
Active Contributor
0 Kudos

Hi Vinay,

You can try for updating any long text the BAPI BAPI_MATERIAL_SAVEDATA (with the structure MATERIALLONGTEXT in the interface for this FM). You can try to set an implicit enhancement where you can write in a customer table (where you will save the data you need) and after, with a periodic job, call the BAPI for updating the long text. It's an idea.

Regards,

Eduardo

4 REPLIES 4

madhu_vadlamani
Active Contributor
0 Kudos

Hi Vinay,

If you increase the text that will impact on other places where ever this field called.Other option is keep one more filed in makt and push this filed there.

0 Kudos

It's allways better to Read the records first and update again if you are modifying the long text...


DATA: ls_text LIKE LINE OF zcl_mm_material_massupdate=>gt_display,
ls_headdata TYPE bapimathead,
ls_return TYPE bapiret2,
lt_materiallongtext1 TYPE STANDARD TABLE OF bapi_mltx,
ls_materiallongtext1 TYPE bapi_mltx,
* lt_return type bapiret2,
lt_matdesc TYPE TABLE OF bapi_makt,
ls_matdesc TYPE bapi_makt,
lt_retmsg TYPE TABLE OF bapi_matreturn2,
lt_txwnote TYPE TABLE OF txw_note,
ls_txwnote TYPE txw_note,
lv_string TYPE string,
ls_clientdata TYPE bapi_mara_ga,
ls_plantdata TYPE bapi_marc_ga,
ls_plantdata1 TYPE bapi_marc,
ls_forecastparameters TYPE bapi_mpop_ga,
ls_planningdata TYPE bapi_mpgd_ga,
ls_slocdata TYPE bapi_mard_ga,
ls_valuationdata TYPE bapi_mbew_ga,
ls_warehousenumberdata TYPE bapi_mlgn_ga,
ls_salesdata TYPE bapi_mvke_ga,
ls_storagetypedata TYPE bapi_mlgt_ga,
ls_prtdata TYPE bapi_mfhm_ga,
ls_lifovaluationdata TYPE bapi_myms_ga,
ls_is_mp_clientdata TYPE /sapmp/bapi_mara,
lt_materialdescription TYPE STANDARD TABLE OF bapi_makt_ga,
ls_materialdescription TYPE bapi_makt_ga,
lt_unitsofmeasure TYPE STANDARD TABLE OF bapi_marm_ga,
ls_unitsofmeasure TYPE bapi_marm_ga,
lt_internationalartnos TYPE STANDARD TABLE OF bapi_mean_ga,
ls_internationalartnos TYPE bapi_mean_ga,
lt_materiallongtext TYPE STANDARD TABLE OF bapi_mltx_ga,
ls_materiallongtext TYPE bapi_mltx_ga,
lt_taxclassifications TYPE STANDARD TABLE OF bapi_mlan_ga,
ls_taxclassifications TYPE bapi_mlan_ga,
lt_extensionout TYPE STANDARD TABLE OF bapiparex,
lt_return TYPE STANDARD TABLE OF bapireturn,
ls_head TYPE bapimathead,
lt_prtdata TYPE STANDARD TABLE OF bapi_mfhm,
ls_clientdata1 TYPE bapi_mara,
ls_forecastparameters1 TYPE bapi_mpop,
ls_planningdata1 TYPE bapi_mpgd,
ls_slocdata1 TYPE bapi_mard,
ls_valuationdata1 TYPE bapi_mbew,
ls_warehousenumberdat1 TYPE bapi_mlgn,
ls_salesdata1 TYPE bapi_mvke,
ls_storagetypedata1 TYPE bapi_mlgt,
lt_materialdescription1 TYPE STANDARD TABLE OF bapi_makt,
ls_materialdescription1 TYPE bapi_makt,
lt_unitsofmeasure1 TYPE STANDARD TABLE OF bapi_marm,
ls_unitsofmeasure1 TYPE bapi_marm,
lt_internationalartnos1 TYPE STANDARD TABLE OF bapi_mean,
ls_internationalartnos1 TYPE bapi_mean,
lt_taxclassifications1 TYPE STANDARD TABLE OF bapi_mlan,
ls_taxclassifications1 TYPE bapi_mlan,
* lt_return2 TYPE STANDARD TABLE OF bapiret2,
ls_return2 TYPE bapiret2,
lt_returnmessages TYPE STANDARD TABLE OF bapi_matreturn2,
ls_returnmessages TYPE bapi_matreturn2,
ls_plantdatax TYPE bapi_marcx,
ls_forecastparametersx TYPE bapi_mpopx,
ls_planningdatax TYPE bapi_mpgdx,
ls_slocdatax TYPE bapi_mardx,
ls_clientdatax TYPE bapi_marax,
lt_unitsofmeasurex TYPE STANDARD TABLE OF bapi_marmx,
ls_unitsofmeasurex TYPE bapi_marmx,
ls_valuationdatax TYPE bapi_mbewx,
lv_row TYPE c.





" method for saving the material data..

LOOP AT zcl_mm_material_massupdate=>gt_display INTO ls_text .

CLEAR: lt_txwnote.

* ls_headdata-material_long = ls_text-matnr.
* ls_headdata-basic_view = abap_true.
* ls_headdata-matl_type = ls_text-mtart.
* ls_headdata-ind_sector = ls_text-mbrsh.
* ls_headdata-account_view = abap_true.
** ls_matdesc-matl_desc = 'MATERIAL'.
** ls_matdesc-text_id = 'GRUN'.
* ls_matdesc-langu = sy-langu.
* ls_matdesc-langu_iso = 'EN'.

* * Kundenfelder



lv_string = ls_text-text.
CALL FUNCTION 'SOTR_SERV_STRING_TO_TABLE'
EXPORTING
text = lv_string
* FLAG_NO_LINE_BREAKS = 'X'
line_length = '132'
langu = sy-langu
TABLES
text_tab = lt_txwnote.





CALL FUNCTION 'BAPI_MATERIAL_GET_ALL'
EXPORTING
* plant = p_werks
* stge_loc =
material_long = ls_text-matnr
IMPORTING
clientdata = ls_clientdata
plantdata = ls_plantdata
forecastparameters = ls_forecastparameters
planningdata = ls_planningdata
storagelocationdata = ls_slocdata
valuationdata = ls_valuationdata
warehousenumberdata = ls_warehousenumberdata
salesdata = ls_salesdata
storagetypedata = ls_storagetypedata
prtdata = ls_prtdata
lifovaluationdata = ls_lifovaluationdata
is_mp_clientdata = ls_is_mp_clientdata
TABLES
materialdescription = lt_materialdescription
unitsofmeasure = lt_unitsofmeasure
internationalartnos = lt_internationalartnos
materiallongtext = lt_materiallongtext
taxclassifications = lt_taxclassifications
extensionout = lt_extensionout
return = lt_return.


* LOOP AT lt_materiallongtext1 INTO ls_materiallongtext.
* MOVE-CORRESPONDING ls_materiallongtext TO ls_materiallongtext1.
* APPEND ls_materiallongtext1 TO lt_materiallongtext1.
* CLEAR ls_materiallongtext1.
* ENDLOOP.

LOOP AT lt_txwnote INTO ls_txwnote.
ls_materiallongtext1-applobject = 'MATERIAL'.
ls_materiallongtext1-text_name = ls_text-matnr.
ls_materiallongtext1-text_id = 'GRUN'.
ls_materiallongtext1-langu = sy-langu.
ls_materiallongtext1-langu_iso = 'EN'.
ls_materiallongtext1-format_col = '*'.
ls_materiallongtext1-text_line = ls_txwnote-line.
APPEND ls_materiallongtext1 TO lt_materiallongtext1.
CLEAR ls_materiallongtext1.
ENDLOOP.

*--- CREATE material
MOVE-CORRESPONDING ls_clientdata TO ls_head.
ls_head-material_long = ls_text-matnr.

* if ls_prtdata is not initial.
* append ls_prtdata to lt_prtdata.
* endif.
MOVE-CORRESPONDING:
ls_clientdata TO ls_clientdata1,
* ls_forecastparameters to ls_forecastparameters1,
* ls_planningdata to ls_planningdata1,
* ls_slocdata to ls_slocdata1,
ls_valuationdata TO ls_valuationdata1,
* ls_valuationdata1 TO ls_valuationdatax,
* ls_warehousenumberdata to ls_warehousenumberdat1,
ls_salesdata TO ls_salesdata1,
* ls_storagetypedata to ls_storagetypedata1,
ls_plantdata TO ls_plantdata1,
ls_clientdata1 TO ls_clientdatax,
ls_plantdata1 TO ls_plantdatax.
* ls_forecastparametersx-plant = ls_forecastparameters1-plant.
* ls_planningdatax-plant = ls_planningdata1-plant.
* ls_slocdatax-plant = ls_slocdata1-plant.
* ls_slocdatax-stge_loc = ls_slocdata1-stge_loc.
ls_clientdata1-var_ord_un = '2'.
ls_clientdatax-var_ord_un = '2'.


CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
headdata = ls_head
clientdata = ls_clientdata1
clientdatax = ls_clientdatax
plantdata = ls_plantdata1
plantdatax = ls_plantdatax
* forecastparameters = ls_forecastparameters1
* forecastparametersx = ls_forecastparametersx
* planningdata = ls_planningdata1
* planningdatax = ls_planningdatax
* storagelocationdata = ls_slocdata1
* storagelocationdatax = ls_slocdatax
valuationdata = ls_valuationdata1
valuationdatax = ls_valuationdatax
* warehousenumberdata = ls_warehousenumberdat1
* WAREHOUSENUMBERDATAX =
salesdata = ls_salesdata1
* SALESDATAX =
* storagetypedata = ls_storagetypedata1
* STORAGETYPEDATAX =
* FLAG_ONLINE = ' '
* FLAG_CAD_CALL = ' '
* NO_DEQUEUE = ' '
* NO_ROLLBACK_WORK = ' '
* CLIENTDATACWM =
* CLIENTDATACWMX =
* VALUATIONDATACWM =
* VALUATIONDATACWMX =
IMPORTING
return = ls_return2
TABLES
materialdescription = lt_materialdescription1
unitsofmeasure = lt_unitsofmeasure1
unitsofmeasurex = lt_unitsofmeasurex
internationalartnos = lt_internationalartnos1
materiallongtext = lt_materiallongtext1
taxclassifications = lt_taxclassifications1
returnmessages = lt_returnmessages
prtdata = lt_prtdata
* PRTDATAX =
extensionin = lt_extensionout

eduardo_hinojosa
Active Contributor
0 Kudos

Hi Vinay,

You can try for updating any long text the BAPI BAPI_MATERIAL_SAVEDATA (with the structure MATERIALLONGTEXT in the interface for this FM). You can try to set an implicit enhancement where you can write in a customer table (where you will save the data you need) and after, with a periodic job, call the BAPI for updating the long text. It's an idea.

Regards,

Eduardo

0 Kudos

solved using BADI implementation which will get triggered only after the change in Short text or Classification field.