Skip to Content
author's profile photo Former Member
Former Member

Doubt on Joins and for all entries

Hi,

In my report I have selected some sales orders from vbak table into an internal table.

Now I have selected all items for the above sales order from vbap table.

My requirement is to

Access MVKE table with matnr = vbap-matnr,

vkorg = vbak-vkorg,

vtweg = vbak-vtweg.

and take mvke-prat4.

How to achieve this?

Thanks,

Sandeep.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

7 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Dec 22, 2008 at 04:27 AM

    Hi,

    First get the data from VBAK table to ur internal table i.e itab.

    If itab is not initial.

    Select data from VBAP into table JTAB for all entries in itab where vbeln = itab-vbeln.

    Endif,

    If JTAB is not initial .

    Access MVKE table into KTAB for all entries in JTAB where matnr = JTAB-matnr

    vkorg = vbak-vkorg,

    vtweg = vbak-vtweg.

    Endif.

    Edited by: Upender Verma on Dec 22, 2008 5:27 AM

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 22, 2008 at 04:31 AM

    hi,

    use the following code :

    select * from vbak into table g_t_vbak where....
    
    if g_t_vbak is not initial.
    select * from vbap into table g_T_vbap  for all entires 
    where matnr = g_t_vbak-matnr.....
    
    select prat4 from mvke into g_t_mvke
    for all entries in g_T_vbak
    where matnr = g_t_vbak-matnr
    and vkorg = g_t_vbak-vkorg,
    vtweg = g_t_vbak-vtweg.
    
    endif.
    
    

    Regards,

    Mansi

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 22, 2008 at 04:42 AM

    hi

    first select from vbak tablle

    select field1 field2 from vbak into tableit_vbak where....

    then if record found select from vbap for all entries in vbak.

    if it_vbak is not initial.

    select field1 field2 from vbap into table it_vbap for all entires

    where matnr = it_vbak-matnr.....

    then select from mvke table

    select prat4 from mvke into it_mvke

    for all entries in it_vbak

    where matnr = it_vbak-matnr

    and vkorg = it_vbak-vkorg,

    vtweg = it_vbak-vtweg.

    endif.

    thanks

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 22, 2008 at 04:43 AM

    hi

    first select from vbak tablle

    select field1 field2 from vbak into tableit_vbak where....

    then if record found select from vbap for all entries in vbak.

    if it_vbak is not initial.

    select field1 field2 from vbap into table it_vbap for all entires

    where matnr = it_vbak-matnr.....

    then select from mvke table

    select prat4 from mvke into it_mvke

    for all entries in it_vbak

    where matnr = it_vbak-matnr and

    vkorg = it_vbak-vkorg and

    vtweg = it_vbak-vtweg.

    endif.

    thanks

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 22, 2008 at 05:02 AM

    Hello Sandeep,

    Your qn has been answered by SDNers & i do not want to add to their posts.

    My qn is whats your doubt: to use JOINS or FOR ALL ENTRIES(FAE) ?

    If so plz refer to this famous blog on FAE, it will help definitely 😊)

    [https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/4241] [original link is broken] [original link is broken] [original link is broken];

    My personal opinion unless you write the code & check the metrics you cannot come to any conclusion.

    BR,

    Suhas

    Edited by: Suhas Saha on Dec 22, 2008 6:05 AM

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 22, 2008 at 06:11 AM

    Hi,

    first.

    select matnr from vbap into it_vbak.

    second.

    if not it_vbap[] is initial.

    select matnr vkorg vtweg prat4 from mvke

    for all entries in it_vbak

    where matnr = it_vbak-matnr.

    endif.

    Third,

    select vkorg vtweg from vbak into table it_vbak.

    fourth.

    loop at it_vbak.

    read table it_mvke with key

    vkorg = it_vbak-vkorg

    vtweg = it_vbak-vtweg.

    if sy-subrc = 0.

    it_final-prat4 = it_mvke-prat4.

    append it_final.

    endif.

    endloop.

    mow it_final contains the req result.

    Thanks,

    Krishna..

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 22, 2008 at 06:31 AM

    Hi,

    You can use this select query where it_vbap contains items from vbap table.

    SELECT a~prat4
              INTO TABLE it_mvke
              FROM mvke AS a INNER JOIN vbak AS b
              ON a~vkorg = b~vkorg AND
                 a~vtweg = b~vtweg
              FOR ALL ENTRIES IN it_vbap
              WHERE a~matnr = it_vbap-matnr AND
                           b~vbeln = it_vbap-vbeln.

    Regards,

    Manoj Kumar P

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.