Application Development and Automation 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: 
Read only

String comparision and matching

Former Member
0 Likes
886

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

7 REPLIES 7
Read only

Venkat_Sesha
Product and Topic Expert
Product and Topic Expert
0 Likes
816

Hi

Have you done any research before posting?

Please tell us that what you have done. Since Requirement dumping is against Forum Rules

Read only

0 Likes
816

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}

Read only

Venkat_Sesha
Product and Topic Expert
Product and Topic Expert
0 Likes
816

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

Read only

RaymondGiuseppi
Active Contributor
0 Likes
816

So you have to

  • Split the input text to identify individaul words
  • Buil a range table to check if material text is like or contains those words
  • Use this range in selection from database or loop at an internal table already loaded
  • Use F1 on Abap source editor
  • Read the Rules of Engagement

Regards,

Raymond

Read only

former_member392866
Active Participant
0 Likes
816

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.

Read only

Former Member
0 Likes
816

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.

Read only

Former Member
0 Likes
816

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..