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

Internal table value checking in custom table using SQL...

Former Member
0 Likes
377

I have a table which has following fields:

X1 TABLE (ZCONfig table) X2 TABLE: (Internal table)

LIFNR land1 LIFNR:

123 br 234

234 br 567

456 br 123

567 Gr

Now I want to see if all the field values of LIFNR in internal table X2 (X2-LIFNR) are present in X1 or not.

Raise error if it is not.

How do I do this using SQL ? I guess I have to use read statement.

Please help. Points will be awarded.

Thanks.

Regards

2 REPLIES 2
Read only

Former Member
0 Likes
360
select *
       from ztable
       into table it_ztable.
if sy-subrc = 0.
loop at it_x2table.
read table it_ztable with key lifnr = it_x2table-lifnr.
if sy-subrc <> 0.
raise error.....
endif.
endloop.

endif.
Read only

0 Likes
360

Hi,

As Vijay suggested,you can do.But with slight modififcation.Instead of raising error message every time,just collect the error message in an internal table and then display it finally.That will be good.

types : begin of ty,

message(20) type c,

end of ty.

data : itab type standard table of ty,

wa type ty.

select *

from ztable

into table it_ztable.

if sy-subrc = 0.

loop at it_x2table.

read table it_ztable with key lifnr = it_x2table-lifnr.

if sy-subrc <> 0.

concatenate it_x2table-lifnr not present ' into wa-message.

append wa to itab.

endif.

endloop.

endif.

loop at itab into wa.

write : / wa-message.

endloop.