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

Select Statement..SQL

Former Member
0 Likes
721

Hello Experts,

Can any one tell me how to

print the exception list of fields for which a match is not found in the below select statement.

SELECT b.fieldnm

FROM YRDBFH010 a, RSOSFIELDMAP b

where 1=1

and a.SOURCESYSTEM = b.LOGSYS

and a.datasource = b.oltpsource

and b.objvers = 'A'

and rtrim(a.sourcesystem)||rtrim(a.datasource) = :p_src_ds and a.psa_id like :p_psa_id

and b.iobjnm in ('0MATL_TYPE','0STOR_LOC','0SALESORG','0SHIP_TO', '0MATERIAL', 'YRDBMUG1', '0PLANT', '0COMP_CODE', '0SOLD_TO', '0DISTR_CHAN', '0DIVISION')

Points will be rewarded.

Thanks,

Varun

6 REPLIES 6
Read only

Former Member
0 Likes
686

Hi Varun

try with follows,


SELECT fieldnm
FROM YRDBFH010
WHERE fieldnm NOT IN (SELECT b.fieldnm
FROM YRDBFH010 a, RSOSFIELDMAP b
where 1=1
and a.SOURCESYSTEM = b.LOGSYS
and a.datasource = b.oltpsource
and b.objvers = 'A'
and rtrim(a.sourcesystem)||rtrim(a.datasource) = :p_src_ds and a.psa_id like :p_psa_id
and b.iobjnm in ('0MATL_TYPE','0STOR_LOC','0SALESORG','0SHIP_TO', '0MATERIAL', 'YRDBMUG1', '0PLANT', '0COMP_CODE', '0SOLD_TO', '0DISTR_CHAN', '0DIVISION'))

I DONT HAVE YOUR FIELDS AND TABLE

SELECT WHAT YOU WANT IN THE TABLE AND USE WHERE CONDITION WITH NOT IN THEN PUT YOUR SELECT STATEMENT

REWARDS IF HELPFUL

Read only

0 Likes
686

Still I am not able to understand..could u please explain me still more clearly.

Read only

Former Member
0 Likes
686

If i understand correctly...your requirement is to run a select statement....and then after the execution, you want to know for which fields did you select statement did not find a match and failed.

you can't know this directly from the select statement. Probably the best way to do it will be to select the data in the program (in an internal table) and then loop on that internal table (or read it as the case may be) to see if it contains the values you want to check.

if this is not your requirement...request you to please re-phrase it and make it a bit clearer

Read only

Former Member
0 Likes
686

Hi

Try this...

SELECT b.fieldnm

FROM YRDBFH010 a, RSOSFIELDMAP b into wa_fieldnm

where 1=1

and a.SOURCESYSTEM = b.LOGSYS

and a.datasource = b.oltpsource

and b.objvers = 'A'

and rtrim(a.sourcesystem)||rtrim(a.datasource) = :p_src_ds and a.psa_id like :p_psa_id

and b.iobjnm in ('0MATL_TYPE','0STOR_LOC','0SALESORG','0SHIP_TO', '0MATERIAL', 'YRDBMUG1', '0PLANT', '0COMP_CODE', '0SOLD_TO', '0DISTR_CHAN', '0DIVISION')

if sy-subrc <> 0

append wa_fieldnm.

endif.

endselect.

Where wa_fieldnm has a field which is of type b.fieldnm

Regards

Abaper

Read only

Former Member
0 Likes
686

Hi

Try this...

SELECT b.fieldnm

FROM YRDBFH010 a, RSOSFIELDMAP b into wa_fieldnm

where 1=1

and a.SOURCESYSTEM = b.LOGSYS

and a.datasource = b.oltpsource

and b.objvers = 'A'

and rtrim(a.sourcesystem)||rtrim(a.datasource) = :p_src_ds and a.psa_id like :p_psa_id

and b.iobjnm in ('0MATL_TYPE','0STOR_LOC','0SALESORG','0SHIP_TO', '0MATERIAL', 'YRDBMUG1', '0PLANT', '0COMP_CODE', '0SOLD_TO', '0DISTR_CHAN', '0DIVISION')

if sy-subrc <> 0 .

append wa_fieldnm.

endif.

endselect.

Where wa_fieldnm has a field which is of type b.fieldnm

Regards

Abaper

Read only

0 Likes
686

Still not getting anything..Please help

Edited by: Varun prasad on Jul 8, 2008 1:44 PM