‎2014 Feb 19 7:07 AM
Hi All,
I have an internal table which has consolidated records from several tables.
Now I want to READ only those records where the coloumn : OBJNR starts with ZZ.
Now, we cannot use LIKE 'ZZ*' in READ statements like we can use in SELECT statements.
Other option for me is using offset.
READ t_itab into w_itab.
if w_itab-objnr+0(2) eq 'ZZ'.
something like this.
IS there any other better way?
REgards,
Faiz
‎2014 Feb 19 7:12 AM
Hi,
Use LOOP & CP ( contains pattern ) statements as below
LOOP AT t_tab INTO w_itab WHERE objnr CP 'ZZ*'.
" Here you can collect into other internal table, or exit if u need only 1 record
ENDLOOP.
Hope this helps you.
Regards,
Rama
‎2014 Feb 19 7:39 AM
This will fetch all those records which contain the substring 'ZZ' at any position in the string.In my case it should be right at the beginning .I will try 'ZZ*' .
‎2014 Feb 19 7:44 AM
Hi,
as suggested in my previous reply, it gets you all records which starts from ZZ......
Example:
let us say internal table is having records as below
ZZ123
ZX123
ZY123
ZZ222
ZX222
ZY222
Now,
LOOP AT t_tab INTO w_itab WHERE objnr CP 'ZZ*'.
" we get only ZZ123 & ZZ222
ENDLOOP
.
Regards,
Rama
‎2014 Feb 19 8:34 AM
‎2014 Feb 19 8:41 AM
Hi Karthi,
Karthi Mrvk wrote:
what will happen if suppose column name is AAZZBBC? , it will consider it or not ? can you clarify me please?
Well, if your column contains a value AAZZBBC, it will not consider this record as we are looking for only ZZ*....
To consider your value we need to be like this AA* or *ZZ*
Regards,
Rama
‎2014 Feb 19 9:35 AM
‎2014 Feb 19 7:47 AM
Hi Faizur,
LOOP AT t_tab INTO w_itab WHERE objnr CP 'ZZ*' from 1 to 1.
endloop.
Now you will get only one record.
Arivazhagan S
‎2014 Feb 19 9:39 AM
WRONG FOR TWO REASONS!
1. The syntax should be LOOP AT t_tab INTO w_itab FROM 1 TO 1 WHERE objnr CP 'ZZ*'.
2. Unless the first record begins ZZ, you'll get nothing.
‎2014 Feb 19 8:05 AM
‎2014 Feb 19 8:49 AM
hi Faizur,
LOOP t_itab into w_itab.
FIND ALL OOCUREENCES OF REGEX 'ZZ*'
IN w_itab-objnr
MATCH OFFSET moff.
if moff eq 0.
.....
ENDLOOP.
Another way is move all objnr data to it_itab that only have one field 'OBJNR'.
FIND ALL OOCURRENCES OF REGEX 'ZZ*'
IN TABLE it_itab
RESULTS result_tab.
the result_tab is what you wanted, which start will 'ZZ'.
regards,
Archer
‎2014 Feb 19 9:22 AM