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

validate Internal table

Former Member
0 Likes
516

I have Internal table having 2000 entries.

Itab has four fields

MATNR werks desc priority.

The four column field priority has values u20181u2019 u20182u2019 and u20183u2019.

In the Internal table i need to check if value u20181u2019 does not exist in the internal table need to show as error.

I am using read table itab into wa_tab where priority NE u20181u2019.

If sy-subrc NE 0.

Write u2018Erroru2019.

Endif.

In the loop can we can use or any method do let me know.

Edited by: Rob Burbank on Jun 22, 2010 10:24 AM

3 REPLIES 3
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
455
SORT ITAB.

READ TABLE ITAB WITH KEY PRIORITY = '1' 
TRANSPORTING NO FIELDS.

IF SY-SUBRC NE 0.
  WRITE: / 'Error'.
ENDIF.
Read only

Former Member
0 Likes
455

You can use:

LOOP AT itab WHERE priority EQ '1'.

IF sy-subrc NE 0.
* error
ENDIF.

Rob

But I like Suhas' solution better

Edited by: Rob Burbank on Jun 22, 2010 10:31 AM

Read only

Former Member
0 Likes
455

Hi, try this.

SORT itab By priority.

READ TABLE itab INDEX 1.

IF itab-priority <> '1'.

MESSAGE ..... TYPE 'E'.

ENDIF.