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

Former Member
0 Likes
744

In Table 1 I have two fields f1 & f2

In Table 2 I have field f3

i want to display f1 f2 & f3...

My select options s1 based on table1

s2 based on table1

s3 based on table3

how should my selcet query for this ?

5 REPLIES 5
Read only

Former Member
0 Likes
726

select table1f1 table1f2 table2-f3 into table itab

from table1 inner join table2 on <join condition of table1 and table 2>

where table1~f1 in s1

and table1~f12in s2

and table2~f3 in s3.

Read only

Former Member
0 Likes
726

hi,

select table1f1 table1f2 table2-f3 into table itab

from table1 inner join table2 on <join condition of table1 and table 2>

where table1~f1 in s1

and table1~f12in s2

and table2~f3 in s3.

try like this

Read only

Former Member
0 Likes
726

Hi Abap Fan,

Is there any common field between table 1 and table 2 if so then ...

select t1f1 t1f2 t2~f3 from table1 innerjoin table2 on commonfiled1 = common field2 into itab where .....

Hope it helps..

Reagrds,

Kaveri

Read only

Former Member
0 Likes
726

hi

sample one

select vbakvbeln vbakvkorg vbakkunnr vbakvsbed vbap~matnr

vbaparktx vbapwerks into table itab from vbak inner join

vbap on vbakvbeln = vbapvbeln

where vbak~vbeln in salesdoc

and vbak~vkorg in salesorg

and vbak~erdat between tdate and fdate.

here i am using vbak and vbap tables, saledoc,salesorg,fdate, tdate are selection variables.

regards,

pavan

Read only

former_member386202
Active Contributor
0 Likes
726

Hi,

Dont use joins it affect on performance better to use FOR ALL ENTRIES

Refer this code

&----


*& Form SUB_READ_VBRK

&----


  • text

----


FORM sub_read_vbrk.

SELECT vbeln

rplnr

bukrs

FROM vbrk

INTO TABLE it_vbrk

WHERE vbeln IN s_vbeln

AND rplnr NE ' '.

IF sy-subrc EQ 0.

SORT it_vbrk BY rplnr.

ENDIF.

ENDFORM. " SUB_READ_VBRK

&----


*& Form SUB_READ_FPLTC

&----


  • text

----


FORM sub_read_fpltc.

IF NOT it_vbrk[] IS INITIAL.

SELECT fplnr

fpltr

ccnum

FROM fpltc

INTO TABLE it_fpltc

FOR ALL ENTRIES IN it_vbrk

WHERE fplnr EQ it_vbrk-rplnr

AND ccins EQ 'GIFC'.

IF sy-subrc EQ 0.

SORT it_fpltc BY fplnr.

ENDIF.

ENDIF.

ENDFORM. " SUB_READ_FPLTC

&----


*& Form SUB_COLLECT_DATA

&----


  • text

----


FORM sub_collect_data.

*--Local variables

DATA : lv_count(3) TYPE c.

IF NOT it_fpltc[] IS INITIAL.

LOOP AT it_fpltc INTO wa_fpltc.

lv_count = wa_fpltc-fpltr+3(3).

wa_final-ccnum = wa_fpltc-ccnum.

wa_final-rfzei = lv_count.

CLEAR : wa_vbrk.

READ TABLE it_vbrk INTO wa_vbrk WITH KEY rplnr = wa_fpltc-fplnr

BINARY SEARCH.

IF sy-subrc EQ 0.

wa_final-vbeln = wa_vbrk-vbeln.

wa_final-bukrs = wa_vbrk-bukrs.

ENDIF.

APPEND wa_final TO it_final.

CLEAR : wa_vbrk,

wa_fpltc,

lv_count.

ENDLOOP.

ENDIF.

ENDFORM. " SUB_COLLECT_DATA

Regards,

PRashant