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

RE : prob with select statment

Former Member
0 Likes
695

Hi all,

I have written a code like this.

SELECT

AUFNR

AEDAT

WERKS

GAMNG

GMEIN

PLNBEZ

DISPO

OBJNR

FROM CAUFV

INTO TABLE IT_CAUFV

WHERE CAUFV~AEDAT IN S_AEDAT

AND CAUFV~AUFNR = '000001000932'.

SORT IT_CAUFV BY OBJNR.

SELECT coep~MATNR

COEP~WTGBTR

COEP~MEGBTR

COEP~MEINH

COEP~OBJNR

MARA~MTART

FROM COEP INNER JOIN MARA

ON COEPMATNR = MARAMATNR

INTO TABLE IT_RESB

FOR ALL ENTRIES IN IT_CAUFV

WHERE

coep~OBJNR = IT_CAUFV-OBJNR

AND MARA~MTART IN ('YFLM','YCHE','YRAW').

Here my prob is in my 2nd select statement.

My 2nd select is not fetching all the records frm coep table.

Can anyone explain y this happens and pls suggest me a solution.

Thanks in advance.

alex

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
665

Hi alex,

In your second select you need to fetch all the primary keys (data) also to get the exact data..

give the primary key fields also in the select statement..

See for eg: Take MARD.. you have three primary keys..(MATNR ,WERKS,LGORT)

and if you are fetching onlt matnr and werks some data would be missing when fetching them/.

see the CODE INSPECTOR of your program you will know the problem..

rewards if useful,

regards,

nazeer

4 REPLIES 4
Read only

Former Member
0 Likes
665

hi Alex,

do this way

IF NOT IT_CAUFV[] IS INITIAL.

SELECT coep~MATNR

COEP~WTGBTR

COEP~MEGBTR

COEP~MEINH

COEP~OBJNR

MARA~MTART

FROM COEP INNER JOIN MARA

ON COEPMATNR = MARAMATNR

INTO <b>CORRESPONDING FIELDS OF</b> TABLE IT_RESB

FOR ALL ENTRIES IN IT_CAUFV

WHERE

coep~OBJNR = IT_CAUFV-OBJNR

AND MARA~MTART IN ('YFLM','YCHE','YRAW').

ENDIF.

Message was edited by:

Santosh Kumar Patha

Read only

Former Member
0 Likes
666

Hi alex,

In your second select you need to fetch all the primary keys (data) also to get the exact data..

give the primary key fields also in the select statement..

See for eg: Take MARD.. you have three primary keys..(MATNR ,WERKS,LGORT)

and if you are fetching onlt matnr and werks some data would be missing when fetching them/.

see the CODE INSPECTOR of your program you will know the problem..

rewards if useful,

regards,

nazeer

Read only

Former Member
0 Likes
665

add in whare caluse

and mara-matnr = coep-matnr

Read only

dev_parbutteea
Active Contributor
0 Likes
665

HI,

Actually if there are duplicate entries when comparing the fields that you are retreiving, the select statements will not retrieve tha duplicates entries but the first one!

Try by retreiving more fields like buzei , even if you are not using them!

Hope that this helps you,