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

Comparing strings

Former Member
0 Likes
933

Hi Gurus,

Please solve this problem.

Hi One internal table with field message,This table having 20 or 30 lines of text.

I have to compare this text with one data base table having field message having text.

if the text that is matches first, i want to display that in output.

how i comepare these texts.

THanks/radha.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
911

Hi Radha,

For this type of scenario lets say suppose we have populated two internal table

itab1 ---> messages contains 20 to 30 lines.

Itab2 -


> fetch from the database.

Now what you have to do is


Loop at itab2.
 Read table itab1 with key message = < message>
 If sy-subrc = 0.
  write:/ itab2-message.
 endif.
Endloop.

9 REPLIES 9
Read only

Former Member
0 Likes
911

Hi,

loop at itab1 into wa.

read table db_table with key text = wa-msg.

if sy-subrc = 0.

write: wa-msg.

endif.

endloop.

Regards,

Subramanian

Read only

Former Member
0 Likes
911

Hi Radha,

For this type of scenario lets say suppose we have populated two internal table

itab1 ---> messages contains 20 to 30 lines.

Itab2 -


> fetch from the database.

Now what you have to do is


Loop at itab2.
 Read table itab1 with key message = < message>
 If sy-subrc = 0.
  write:/ itab2-message.
 endif.
Endloop.

Read only

Former Member
0 Likes
912

Hi Radha,

For this type of scenario lets say suppose we have populated two internal table

itab1 ---> messages contains 20 to 30 lines.

Itab2 -


> fetch from the database.

Now what you have to do is


Loop at itab2.
 Read table itab1 with key message = < message>
 If sy-subrc = 0.
  write:/ itab2-message.
 endif.
Endloop.

Read only

0 Likes
911

Hi Chidanad,

My problem is the text in internal table having 255 characters like that.

but the text in database table having part of internal table text may be 120 characters.

and the text in data base table is started in internal table in middile.

please give me solution urgently.

Thanks/Radha.

Read only

0 Likes
911

Hi,

Then try comparing like this:

IF int_table_str CS db_table_str.

write:.....

endif.

Regards,

Subramanian

Read only

0 Likes
911

hi,

use the string comparing function 'CS'

if itab-field CS dbtab-field.

write itab-field.

endif.

regards

prasanth

Read only

0 Likes
911

Hi Subramaninan,

with write statement we are writing text to list but it is having space infront of the text,

How we delete the space infront of text before write statement.

eg: -


rama.

here assume '----


' this is pace.

Read only

0 Likes
911

hi,

try the statemnt CONDENSE text [NO-GAPS].

or

write addition left-justified

regards

Read only

0 Likes
911

hi,

Use CONDENSE fld1 no-gaps.

Regards,

Subramanian