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 statement

Former Member
0 Likes
634

I have to select the values of the fields BEZEI depending on tha sales order number vbeln. HOw can i write the select statement what will be the tables associated?

4 REPLIES 4
Read only

Former Member
0 Likes
605

You need to link VBAK & TKA01 based on KOKRS field.

Regards,

Satish

Read only

Former Member
0 Likes
605

Hi,

In these cases ,you will have to use joins to select data from different tables.I am sending a simple eg on how to do it.Plz go through it and implement in you case.Plz do reward points if useful.

Thankx.

SELECT aebeln bebelp aernam aekgrp a~bedat

btxz01 bnetwr bafnam beffwr

INTO CORRESPONDING FIELDS OF TABLE it_po

FROM ekpo AS b INNER JOIN ekko AS a

ON bebeln = aebeln

WHERE a~bukrs = s_bukrs AND

a~aedat LE p_date AND

a~ebeln IN s_ebeln AND

a~bedat IN s_bedat AND

a~ekgrp IN s_ekgrp AND

a~frgke NE 'E' AND

b~loekz NOT IN ('L', 'S', 'X').

Read only

former_member386202
Active Contributor
0 Likes
605

Hi,

Select vbeln

kokrs

from vbak into table it_vbak

where vbeln in s_vbeln.

if not it_vbak[] is initial.

select bezei

from tka01 into table it_tka01

for all entries in it_vbak

where kokrs eq it_vbak-kokrs.

endif.

Regards,

Prashant

Read only

Former Member
0 Likes
605

Hi,

tables: vbak.
types: begin of ty_vbak,
           vbeln type vbeln,
           kokrs type kokrs,
          end of ty_vbak,
          begin of ty_it_tka01,
            kokrs type kokrs,
            bezei type bezei,
          end of ty_tka01.

data: it_vbak type table of ty_vbak,
        wa_vbak type ty_vbak,
        it_tka01 type table of ty_tka01,
        wa_tka01 type ty_tka01.

Select-options: s_vbeln for vbak-vbeln.
Select VBELN KOKRS from VBAK into table it_VBAK where vbeln in s_vbeln.
if sy-subrc = 0.
 select KOKRS BEZEI from TKA01 into it_tka01 for all entries in it_vbak where kokrs = it_vbak-kokrs.
endif.

Loop at it_vbak into wa_vbak.
 read table it_tka01 into wa_tka01 with key kokrs = wa_vbak-kokrs.
 if sy-subrc = 0.
* Move data to final internal table.
 endif.
endloop.

Regards,

Satish