Application Development 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: 

Select all records that correspond internal table and fail if one not found

Former Member
0 Kudos

Hi,

I want to Select all records from Z_table into i_table for all entries in i_control where matnr = i_control-matnr but I wish for the sy-subrc to fail if one(or more) of the entries in i_control is not found on Z_table.

i.e.

z_table has matnr : abc, Def,

i_control has matnr: abc, Def, ghi

since 'ghi' is not found on z_table I'd like the select to fail/ return sy-subrc different from 0.

5 REPLIES 5

SuhaSaha
Advisor
Advisor
0 Kudos

You cannot manipulate the value set in SY-SUBRC if the SELECT returns some table rows. But can build custom logic to fulfill this requirement!

Former Member
0 Kudos

Hi

why u want such a requirement.? please explain what u want to do in that select statement.

Usually the query which you have posted will fetch only the matnr which are available.

In specific for particular value we cant control sy-subrc in select statement.

Thanks

Hariharan

Former Member
0 Kudos

I don't want the program to continue /throw an error if every entry on i_control (matnr) does not have 1 or more corresponding values on z_table.

ie.

I_control: abc, abc, def, hij, hji,

Z_table possible valid content:

1.abc, abc, def, hij, hji

2.abc, abc, abc, def, def hij, hji

Z_table possible INVALID content:

1. abc, def, hij

2. abc, def, hij, hji

3. abc, abc, def, hij

4. abc, abc, def

etc

basically for each and every entry on i_control(even repeated ones) , there must be the ammount or more of entries on the Z_table

0 Kudos

Hi

Note:The scenario which you are asking is not possible.

The Select statement itself control the valid entries and it will fetch accordingly based on where condition provided.

It will fetch all the available values.

even though it does

if you want to pass only the valid material in select query you need to validate the material with z_table before using in for all entries.

1) fetch all the matnr from z_table based on input condition which you give. fill it in a internal table. ex : i_mat

2) use this i_mat internal table in for all entires .

By this way u will have only valid entries.

Thanks

Hariharan

Former Member
0 Kudos

FAE does not work this way. Simply loop at the table and do a SELECT...APPEND...ENDSELECT.

Rob