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: 

Data fetching problem

debdatta_panda
Participant
0 Kudos

Hi Experts,

                 I have faced one problem.I want to fetch data from table COEP where VRGNG ne KOA*.It means I want that data whose VRGNG not starting with KOA.I have written the code which is written under..

SELECT *  INTO CORRESPONDING FIELDS OF TABLE wcoep2             

                 FROM coep             

                 INNER JOIN zpm_cost             

                 on coep~kstar = zpm_cost~kstar             

                 FOR ALL ENTRIES IN waufk             

                 WHERE coep~objnr = waufk-objnr             

                 AND coep~vrgng NOT IN ('KOA%')             

                 AND coep~kokrs = 'SRL1'             

                 AND zpm_cost~ACTIVITY = 'PARTS'             

                 AND TIMESTMP > ld_timestmp.

But,unfortunately this code is triggering KOA* data also.

                                                            Please have a look and give me the solution..

3 REPLIES 3

ipravir
Active Contributor
0 Kudos

Hi Deb,

I would suggest, create a range table for VRGNG field.

and update like below and pass the same in query.

ranges: SO_VRGNG for coep-vrgng

SO_VRGNG-SING = 'I'.

SO_VRGNG -OPTION = 'NE'.

SO_VRGNG-LOW = 'KOA*'.

APPEND SO_VRGNG.

SELECT *  INTO CORRESPONDING FIELDS OF TABLE wcoep2            

                 FROM coep            

                 INNER JOIN zpm_cost            

                 on coep~kstar = zpm_cost~kstar            

                 FOR ALL ENTRIES IN waufk            

                 WHERE coep~objnr = waufk-objnr            

                 AND coep~vrgng IN SO_VRGNG

                 AND coep~kokrs = 'SRL1'            

                 AND zpm_cost~ACTIVITY = 'PARTS'            

                 AND TIMESTMP > ld_timestmp.

regards,

Praveer.

Former Member
0 Kudos

HI,

Try this,

SELECT *  INTO CORRESPONDING FIELDS OF TABLE wcoep2            

                 FROM coep            

                 INNER JOIN zpm_cost            

                 on coep~kstar = zpm_cost~kstar            

                 inner join waufk   on  waufk~objnr  = coep~objnr      

                 AND coep~vrgng ne 'KOA%'           

                 AND coep~kokrs = 'SRL1'            

                 AND zpm_cost~ACTIVITY = 'PARTS'            

                 AND TIMESTMP > ld_timestmp.

Thanks,

Ashish

satvik_panchal
Participant
0 Kudos

hello,

   u can code as :

.............

WHERE coep~objnr = waufk-objnr            

AND coep~vrgng NOT LIKE  'KOA%'......... 

Also u can refer this site for help :

Negative Conditions: NOT - Tutorials - SAP Library