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: 

Doubt on simple select query

Former Member
0 Kudos

Hello experts,

please check this code.

CHECK NOT T_DELIVERIES[] IS INITIAL.

SELECT MANDT VBELV POSNV VBELN POSNN INTO TABLE T_VBFA FROM VBFA

FOR ALL ENTRIES IN T_DELIVERIES

WHERE VBELN EQ T_DELIVERIES-VBELN

AND POSNN EQ T_DELIVERIES-POSNR

*{ INSERT DE1K903920 2

AND VBELV EQ T_OUTPUT-VBELV

AND POSNV EQ T_OUTPUT-POSNV

*} INSERT

AND ( VBTYP_V EQ 'C' OR VBTYP_V 'H' ). "AO03

SORT T_VBFA BY VBELN VBELV.

Check the inserted lines and let me know whether it is correct or not.

1 ACCEPTED SOLUTION

former_member708410
Contributor
0 Kudos

CHECK NOT T_DELIVERIES[] IS INITIAL.

SELECT MANDT VBELV POSNV VBELN POSNN INTO TABLE T_VBFA FROM VBFA

FOR ALL ENTRIES IN T_DELIVERIES

WHERE VBELN EQ T_DELIVERIES-VBELN

AND POSNN EQ T_DELIVERIES-POSNR

*{ INSERT DE1K903920 2

AND VBELV EQ T_OUTPUT-VBELV

AND POSNV EQ T_OUTPUT-POSNV

*} INSERT

AND VBTYP_V IN ( 'C', 'H' ). "AO03

12 REPLIES 12

Former Member
0 Kudos

how should we know if this is correct?

all i can tell you that the syntax you used is correct, but since i have no clue what kind of data you have in t_output i canmnot tell you if this is logically correct.

Former Member
0 Kudos

Hi

it is not correct the itab T_OUTPUT-VBELV is not mentioned in the same

look for the same fields in T_DELIVERIES

CHECK NOT T_DELIVERIES[] IS INITIAL.

SELECT MANDT VBELV POSNV VBELN POSNN INTO TABLE T_VBFA FROM VBFA

FOR ALL ENTRIES IN T_DELIVERIES

WHERE VBELN EQ T_DELIVERIES-VBELN

AND POSNN EQ T_DELIVERIES-POSNR

*{ INSERT DE1K903920 2

AND VBELV EQ T_DELIVERIES-VBELV

AND POSNV EQ T_DELIVERIES-POSNV

*} INSERT

AND ( VBTYP_V EQ 'C' OR VBTYP_V 'H' ). "AO03

SORT T_VBFA BY VBELN VBELV.

regards

Shiva

0 Kudos

You mean, I cant use t_output since I am selecting for all entries of t_deliveries?

0 Kudos

you can not use ither table

also leave the remaining primary keys if they are not available

try to use them in your select

select vbeln posnr vbelv e

regards

Shiva

0 Kudos

Thanku for the reply Shiva.

But I am facing performance issue if I do not use all the primary keys in condition query.

Former Member
0 Kudos

Hi,

You are using FOR ALL ENTRIES.But in your inserted lines is having the condition to match T_OUTPUT values. You should use only the values of T_DELIVERIES.

*{ INSERT DE1K903920 2

AND VBELV EQ T_OUTPUT-VBELV

AND POSNV EQ T_OUTPUT-POSNV

*} INSERT

SORT T_VBFA BY VBELN VBELV.

Use T_DELIVERIES not T_OUTPUT.

Regards,

Sankar.

former_member708410
Contributor
0 Kudos

CHECK NOT T_DELIVERIES[] IS INITIAL.

SELECT MANDT VBELV POSNV VBELN POSNN INTO TABLE T_VBFA FROM VBFA

FOR ALL ENTRIES IN T_DELIVERIES

WHERE VBELN EQ T_DELIVERIES-VBELN

AND POSNN EQ T_DELIVERIES-POSNR

*{ INSERT DE1K903920 2

AND VBELV EQ T_OUTPUT-VBELV

AND POSNV EQ T_OUTPUT-POSNV

*} INSERT

AND VBTYP_V IN ( 'C', 'H' ). "AO03

Former Member
0 Kudos

HI,

Correct this code it will work.

Regards,

S.Nehru

0 Kudos

Ya, I didnt get any error for this query.But I doubt using two internal table fields in condition query.

So, are you very much sure that this way of code doesnt cause any issues?

Former Member
0 Kudos

Divya,

The inserted code is wrong.

Because in a select query u can check for all entries option only on one internal table where as in ur query it is checking against two internal table ( T_DELIVERIES, T_OUTPUT), which is wrong.

0 Kudos

If this is wrong,please help me hw can I check for the other primary keys of vbfa(t_deliveries contains only vbeln n posnr)

former_member708410
Contributor
0 Kudos

hI,

Instead of select query use this code.

pass ur vbeln to this FM,

data: IT_VB1 LIKE VBFAVB OCCURS 0 WITH HEADER LINE,

IT_VBF1 LIKE VBFAVB OCCURS 0 WITH HEADER LINE,

CALL FUNCTION 'WB2_VBFA_READ_WITH_VBELN'

EXPORTING

I_VBELN = WA_VBRK-VBELN

TABLES

ET_VBFAVB = IT_VB1

ET_VBFA = IT_VBF1.

REWARD POINTS IF HELPFUL.