‎2013 Jan 08 12:20 PM
Dear Experts,
I have a table in which i have materials and material description field.
I have to compare the material description with the description entered by the user and if the material description in the table contains any
matching word that is entered by the user then that material have to be considered .
For eg;-
ITAB:-
MATNR MAKTX
1000002 arti goods
1000003 ZACT-ALPRAZOLAM ip
1000004 ZACT ABCD
and user enters description as ZACT-ALPRAZOLAM USP
now i want to compare the description in the table matching the description entered by the user and in the above case i want to consider
material number .. 1000003 and 1000004 as it contains at least one word of the description entered by the user..
Regards,
Pavan
‎2013 Jan 08 12:24 PM
Hi
Have you done any research before posting?
Please tell us that what you have done. Since Requirement dumping is against Forum Rules
‎2013 Jan 08 12:34 PM
Hi,
I have looped at itab and tried to get the result using CP operator and CS operator.
but it didnt worked..
{Code}
LOOP AT it_makt INTO wa_makt.
IF wa_makt1-maktx CP wa_makt-maktx.
* IF wa_makt1-maktx CS wa_makt-maktx.
IF sy-subrc = 0.
ENDIF.
ENDIF.
ENDLOOP.
{Code}
‎2013 Jan 08 12:47 PM
Hi
Simply you can achieve this with the Keyword Search String.
Dont make things complex.
Check my example below.
LX_LINES Like line of your ITAB-FIELD.
LV_ABC is the value that use has entered.
Search LX_LINES For LV_ABC. Do F1 on this.
Hope this helps
‎2013 Jan 08 12:33 PM
So you have to
Regards,
Raymond
‎2013 Jan 08 12:36 PM
Pavan,
split user enters description by spaces and move to temporary variables like v_temp1,
v_temp2,v_temp3,v_temp4.
loop itab into wa.
if wa-maktx cs v_temp1 or v_temp2 or v_temp3.
get ur record and store in temp variable like v_mara.
exit.
endif.
endloop.
if v_mara is initial.
message 'description not found in the table' type 'e'.
else
write : v_mara.
endif.
Thank you.
Regards,
BALAJI.
‎2013 Jan 09 10:28 AM
Hi,
Also regular expression might help you.
Following your example, you would only need to find all occurences of (ZACT|ALPRAZOLAM|USP) in table itab...
Kr,
Manu.
‎2013 Jan 15 10:45 AM
Done ..
{Code}
SPLIT wa_makt1-maktx
AT space INTO TABLE it_txt. " It_TXT holds the description of matnr given by user
LOOP AT it_makt INTO wa_makt.
LOOP AT it_txt INTO wa_txt.
SEARCH wa_makt-maktx FOR wa_txt-str.
IF sy-subrc = 0.
wa_data-matnr = wa_makt-matnr.
wa_data-maktx = wa_makt-maktx.
APPEND wa_data TO it_data.
ENDIF.
CLEAR: wa_txt, wa_data.
ENDLOOP.
CLEAR: wa_makt.
ENDLOOP.
{Code}
Thanks all..