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: 

Please review this select statement

Former Member
0 Kudos

please see this,

I have to select Fname and value_old from CDPOS on given conditions plus from tables ADRC and ADR2. but sometime only ADRC table might be changed and ADR2 table may not be changed and sometime vice versa and some times both tables have changed .

anyway I have to select changes happened in both tables, if change is only in one table (either ADRC or ADR2), I have to pick from that table only, if both I have to pick from both tables. Please review this code.

SELECT FNAME VALUE_OLD

INTO CORRESPONDING FIELDS OF I_CDPOS

FROM CDPOS

WHERE CDPOS~OBJECTID = I_CDPOS-OBJECTID AND

CDPOS~OBJECTCLAS = I_CDPOS-OBJECTCLAS AND

CDPOS~CHANGENR = I_CDPOS-CHANGENR AND

( CDPOSTABNAME = 'ADRC' and CDPOSTABNAME = 'ADR2' ).

Thanks & Regards

Venkat

1 ACCEPTED SOLUTION

Former Member
0 Kudos

try this..

SELECT FNAME VALUE_OLD

INTO CORRESPONDING FIELDS OF I_CDPOS

FROM CDPOS

WHERE CDPOS~OBJECTID = I_CDPOS-OBJECTID AND

CDPOS~OBJECTCLAS = I_CDPOS-OBJECTCLAS AND

CDPOS~CHANGENR = I_CDPOS-CHANGENR AND

CDPOS~TABNAME <b>IN ( 'ADRC' , 'ADR2' ).</b>

5 REPLIES 5

Former Member
0 Kudos

try this..

SELECT FNAME VALUE_OLD

INTO CORRESPONDING FIELDS OF I_CDPOS

FROM CDPOS

WHERE CDPOS~OBJECTID = I_CDPOS-OBJECTID AND

CDPOS~OBJECTCLAS = I_CDPOS-OBJECTCLAS AND

CDPOS~CHANGENR = I_CDPOS-CHANGENR AND

CDPOS~TABNAME <b>IN ( 'ADRC' , 'ADR2' ).</b>

0 Kudos

Hi Seshu / Sekhar,

Thanks for your replies.

Sekhar, I tried your code !!!! it gives me syntax error, 'comma without preceding colon' Moreover I am using internal table i_cdpos in where clause so I think I can"t use <b>IN</b> Statement.

I guess I have to use

SELECT FNAME VALUE_OLD

INTO CORRESPONDING FIELDS OF I_CDPOS

FROM CDPOS

WHERE CDPOS~OBJECTID = I_CDPOS-OBJECTID AND

CDPOS~OBJECTCLAS = I_CDPOS-OBJECTCLAS AND

<b>CDPOS~CHANGENR = I_CDPOS-CHANGENR AND

( CDPOSTABNAME = 'ADRC' OR CDPOSTABNAME = 'ADR2' ).</b>

Seshu, Thanks for your advice, this is just a simple chang, So I would like to go with this change in code instead of using FM, I guess I have to change lot of code, If I use FM. I know that FM would be better solution.

Once again thanks for your replies.

Regards

Venkat

Message was edited by:

venkat Kumbham

0 Kudos

just remove the spaces after first bracket and before second bracket

SELECT FNAME VALUE_OLD

INTO CORRESPONDING FIELDS OF I_CDPOS

FROM CDPOS

WHERE CDPOS~OBJECTID = I_CDPOS-OBJECTID AND

CDPOS~OBJECTCLAS = I_CDPOS-OBJECTCLAS AND

CDPOS~CHANGENR = I_CDPOS-CHANGENR AND

CDPOS~TABNAME <b>IN ('ADRC' , 'ADR2').</b>

0 Kudos

Thanks Sekhar, I got it !!!

Closiing thread !!! Alloting points !1

Regards

Venkat

Former Member
0 Kudos

Hi Venkat,

Instead of writing select query on CDPOS ,use FM for Better performance

FM - CHANGEDOCUMENT_READ_POSITIONS

Thanks

Seshu