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

Select Query

Former Member
0 Likes
336

Hi Abapers,

There is a select query inside a loop below is the logic:

selct-options:s_vbeln for vbrk-vbeln

no-display.

select tknum exti1 exti2 dpabf upabf from vttk into table i_vttk

where exti1 in r_exti1 and " = P_EXTI1 AND

exti2 in r_exti2. " = P_EXTI2.

select tknum vbeln from vttp into table i_vttp

for all entries in i_vttk

where tknum = i_vttk-tknum.

if s_vbeln is initial.

loop at i_vttp.

select vbelv vbeln into (vbfa-vbelv, vbfa-vbeln)

from vbfa where vbelv = i_vttp-vbeln and

vbtyp_n = 'U'. "ProForma Invoice

s_vbeln-sign = 'I'.

s_vbeln-option = 'EQ'.

s_vbeln-low = vbfa-vbeln.

collect s_vbeln.

endselect.

endloop.

endif.

I have replaced this code by using below logic , could someone help me out is this, is it right or any modifications need to be done:

CLEAR :i_vttp.

REFRESH:i_vttp.

IF NOT i_vttk[] IS INITIAL.

SELECT tknum

tpnum

vbeln

INTO TABLE i_vttp

FROM vttp

FOR ALL ENTRIES IN i_vttk

WHERE tknum = i_vttk-tknum.

ENDIF.

IF NOT i_vttp[] IS INITIAL.

SELECT vbelv

posnv

vbeln

posnn

vbtyp_n

INTO TABLE gt_vbfa1

FROM vbfa

FOR ALL ENTRIES IN i_vttp

WHERE vbelv = i_vttp-vbeln

AND vbtyp_n = gc_vbtyp_n. "ProForma Invoice

IF sy-subrc EQ 0.

SORT gt_vbfa1 BY vbelv.

LOOP AT gt_vbfa1 INTO gk_vbfa1 WHERE vbelv = i_vttp-vbeln AND

vbtyp_n = gc_vbtyp_n.

s_vbeln-sign = 'I'.

s_vbeln-option = 'EQ'.

s_vbeln-low = gk_vbfa1-vbeln.

COLLECT s_vbeln.

CLEAR:gk_vbfa1.

ENDLOOP.

ENDIF.

ENDIF.

Please do the needful, its quite urgent.

Regards/Thanks,

Rizwana

1 REPLY 1
Read only

Former Member
0 Likes
308

Hi,

It is fine. Now you need to use Read statements inside the loop to get the values.

Regards,

Satish