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

Problem in the select query

Former Member
0 Likes
636

Hi,

I am working on a code in which the duplicate values are getting repeated where there is no field and i came to know that it is bcoz of FOR ALL ENTIRES in the select statement. When i want to change the code it is not allowing me to change by giving error.

here's d code;-

SELECT

WERKS ARBPL KTSCH VERWE OBJTY OBJID

FROM CRHD

INTO TABLE T_CRHD

FOR ALL ENTRIES IN T_plpo

WHERE

OBJID = T_plpo-ARBID.

SELECT

KTEXT_UP OBJID

FROM CRTX

INTO TABLE T_CRTX

FOR ALL ENTRIES IN T_CRHD

WHERE

OBJID = T_CRHD-OBJID.

Instead of for all entires i want to write the statement.

plzz provide me guidelines for solving the problem.

5 REPLIES 5
Read only

Former Member
0 Likes
600

Hi,

Use like this..

Please check if the table used in FOR ALL ENTRIES is initial or not....


IF T_plpo[] IS NOT INITIAL.
  SELECT
  WERKS ARBPL KTSCH VERWE OBJTY OBJID
  FROM CRHD
  INTO TABLE T_CRHD
  FOR ALL ENTRIES IN T_plpo
  WHERE
  OBJID = T_plpo-ARBID.
ENDIF.

IF T_CRHD[] IS NOT INITIAL.
  SELECT
  KTEXT_UP OBJID
  FROM CRTX
  INTO TABLE T_CRTX
  FOR ALL ENTRIES IN T_CRHD
  WHERE
  OBJID = T_CRHD-OBJID.
ENDIF.

Edited by: Sukriti Saha on Nov 4, 2008 10:01 AM

Read only

Former Member
0 Likes
600

Hi,

try like this...


if T_plpo[] is not initial. " it will check if t_plpo has any values or not...
SELECT
WERKS ARBPL KTSCH VERWE OBJTY OBJID
FROM CRHD
INTO TABLE T_CRHD
FOR ALL ENTRIES IN T_plpo
WHERE
OBJID = T_plpo-ARBID.
endif.

IF T_CRHD[] IS NOT INITIAL.
SELECT
KTEXT_UP OBJID
FROM CRTX
INTO TABLE T_CRTX
FOR ALL ENTRIES IN T_CRHD
WHERE
OBJID = T_CRHD-OBJID.
endif.

regards

Debarshi

Read only

raja_narayanan2
Active Participant
0 Likes
600

Hi....

First check your internal table is initial or not....

if your using FOR ALL ENTIRES in your select query.. then you have to check this condition..... is internal table is initial only your select will work.... or else you will get error.

Hope this will help you ...

Regards

Raja

Read only

Former Member
0 Likes
600

Hi,

If u do not want to use FOR ALL ENTRIES write the below code:

SELECT WERKS ARBPL KTSCH VERWE OBJTY OBJID

FROM CRHD

INTO TABLE T_CRHD

WHERE OBJID = T_plpo-ARBID.

SELECT KTEXT_UP OBJID

FROM CRTX

INTO TABLE T_CRTX

WHERE OBJID = T_CRHD-OBJID.

In case u still get any error please give the error details.

Regards,

Saba

Read only

Former Member
0 Likes
600

Hi ,

U can use like this:-

SELECT

WERKS ARBPL KTSCH VERWE OBJTY OBJID

FROM CRHD

INTO TABLE T_CRHD.

Loop at T_plpo

l_index = sy-tabix.

Read table T_CRHD with key OBJID = T_plpo-ARBID.

If sy-subrc <> 0.

DELETE T_plpo index sy-tabix.

endif.

endloop.

Same for the second one...............

Thanks & Regards

Ruchi Tiwari