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

QUERY REGARDING FETCHING AND JOIN

Former Member
0 Likes
1,082

Hi All!

I am doing an assignment in which I take an input from user for the corresponding fields:

TVKO-VKORG

TVTW-VTWEG

TSPA-SPART

VBAK-ERDAT

VBAK-VBELN

KNA1-KUNNR

and after that, I print a list containing corresponding values from the following fields:

VBAP-VBELN

VBAP-POSNR

VBAP-MATNR

VBAP-ARKTX

VBAP-KWMENG

VBAP-VRKME

VBAP-NETWR

VBAK-WAERK

All the tables mentioned here have one key field MANDT in common. How do I map the input values with the values to be displayed in the final list? How do I determine if joining is necessary?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,023

TVKO-VKORG

TVTW-VTWEG

TSPA-SPART

VBAK-ERDAT

VBAK-VBELN

KNA1-KUNNR

all your input fields are available in vbak table then why are you going for tvko or tvtw or tspa?

give the input field

VBAK-VKORG

VBAK-VTWEG

VBAK-SPART

VBAK-ERDAT

VBAK-VBELN

VBAK-KUNNR

and use select query as told before it will give you the correct result.

regards

shiba dutta

8 REPLIES 8
Read only

Former Member
0 Likes
1,023

Hi,

Join the table VBAK and VBAP and give the input fields in where condn:

Select VBAK~VBELN

VBAP~POSNR

VBAP~MATNR

VBAP~ARKTX

VBAP~KWMENG

VBAP~VRKME

VBAP~NETWR

VBAK~WAERK

from vbak join vbap

on vbakvbeln = vbapvbeln

where vbak~VKORG in s_vkorg and

vbak~VTWEG in s_vtweg and

vbak~SPART in s_spart and

VBAK~ERDAT in s_erdat and

VBAK~VBELN in s_vbeln and

vbak~KUNNR in s_kunnr.

reward if useful.

Regards,

Anji

Read only

0 Likes
1,023

Hey Anji,

Thanks for a prompt response! Let me re-explain the situation. First I have taken user inputs for these fields:

TVKO-VKORG

TVTW-VTWEG

TSPA-SPART

VBAK-ERDAT

VBAK-VBELN

KNA1-KUNNR

Then depending on these inputs I will have to display. So, First, I will have to combine the input values to find a key value, which is MANDT field (it is present in every table TVKO, TVTW, TSPA, VBAK, KNA1). Now, when I have the value of MANDT, then I can think of joining and displaying.

So, kindly help me on the fetching section please! Once again, I am to take these field values from user:

VKORG from TVKO

VTWEG from TVTW

SPART from TSPA

ERDAT from VBAK

VBELN from VBAK

KUNNR from KNA1

Read only

andreas_mann3
Active Contributor
0 Likes
1,023

hi,

use LDB AAV.

-> fetch customizing and MD into internal table and use command read table

A.

Read only

Former Member
0 Likes
1,023

hi

good

try to get some field other than the MANDT,bcz MANDT is a kind of field which would be similar for all the table if the tables are client dependent tables.

than you can use the Join statement to get the data from these table .

Thanks

mrutyun^

Read only

0 Likes
1,023

Hello M.T.,

Thanks for your response! Let me tell you this is more detail. I have these fields to take input of:

for sales:

tvko-vkorg, tvtw-vtweg, tspa-spart

for sales order information:

vbak-erdat, vbak-vbeln, kna1-kunnr

now, as u said MANDT maynot take the same value for each of the tables used, how am I to cross-check them for common values? I understand it won't be a primary key.

Read only

Former Member
0 Likes
1,024

TVKO-VKORG

TVTW-VTWEG

TSPA-SPART

VBAK-ERDAT

VBAK-VBELN

KNA1-KUNNR

all your input fields are available in vbak table then why are you going for tvko or tvtw or tspa?

give the input field

VBAK-VKORG

VBAK-VTWEG

VBAK-SPART

VBAK-ERDAT

VBAK-VBELN

VBAK-KUNNR

and use select query as told before it will give you the correct result.

regards

shiba dutta

Read only

0 Likes
1,023

Thank you Shiba!

You have offered the most informative reply. 10 points awarded! Now, can you tell me where SELECT <...> FOR ALL ENTRIES is typically used? I am a little confused.

Read only

0 Likes
1,023

we are using select for all entries to avoid inner joins..

suppose

select vbeln from vbak into corresponding fields of table itab.

if not itab[] is initial.

select <fields> from vbap into corresponding fields of table itab1 for all entries in itab where vbeln = itab-vbeln.

endif.

it will fetch the data by comparing vbeln of itab and vbap but one thing you have to check itab is initial or not if it is not initial(not contain any data) then you should not use for all entries it will fetch all the values from vbap.

regards

shiba dutta