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

Read Substring

Former Member
0 Likes
2,230

Hi All,

I have a calue Communication in the internal table .

When i use READ TABLE it into wa where name = 'Comm%' is not working.

How to use a substring for read table?

Thanks

Vijay

7 REPLIES 7
Read only

Former Member
0 Likes
1,396

This message was moderated.

Read only

0 Likes
1,396

Hello Gowtham,

Are you trying to ready first 4 characters of name filed in read statement.

Try like below

READ TABLE it into wa where name+0(4) = 'Comm'.  or

delete it where name+0(4) NE Comm'.

Thanks

Read only

0 Likes
1,396

sorry for the earlier reply

can we use where with read

Read only

0 Likes
1,396

Hello Gowtham

My mistake , I gave incorrect syntax.  use 'with key'

READ TABLE it into wa with key name+0(4) = 'Comm'.

Read only

rajkumarnarasimman
Active Contributor
0 Likes
1,396

Hi Vijay,

String Comparison won't work in Read statement, instead of that, we can use the same in Loop statement as shown below.



REPORT  zread_internal_table.

"Structure Declaration

TYPES: BEGIN OF ty_makt,

         matnr  TYPE matnr,

         maktx TYPE maktx,

        END OF ty_makt.

"Data Declaration

DATA: it_makt TYPE TABLE OF ty_makt"Internal Table

       wa_makt TYPE ty_makt.           "Work Area 

"Retrive the Records from Database Tabble

SELECT matnr

        maktx

        FROM makt

        INTO TABLE it_makt

        UP TO 10 ROWS.

"Compare String

LOOP AT it_makt INTO wa_makt WHERE maktx CA '%this%'.

  

   "Write Statment

   WRITE wa_makt-maktx.

  

   "Exit from the Loop after 1st Record Read from Internal Table

   EXIT.

  

ENDLOOP.


Regards

Rajkumar Narasimman

Read only

former_member730258
Participant
0 Likes
1,396

Try this:

READ TABLE itab WITH KEY low(4) = 'COMM' INTO l_val.

Read only

Former Member
0 Likes
1,396

Thanks for reply.. I found out that since READ can read a single value , we cannot use sub strings for READ .

Thanks

Vijay