‎2007 Mar 13 7:47 AM
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?
‎2007 Mar 13 8:11 AM
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
‎2007 Mar 13 7:51 AM
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
‎2007 Mar 13 8:03 AM
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
‎2007 Mar 13 7:53 AM
hi,
use LDB AAV.
-> fetch customizing and MD into internal table and use command read table
A.
‎2007 Mar 13 7:59 AM
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^
‎2007 Mar 13 8:09 AM
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.
‎2007 Mar 13 8:11 AM
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
‎2007 Mar 13 8:19 AM
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.
‎2007 Mar 13 8:44 AM
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