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

problem in the select statement

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?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Dec 04, 2007 at 09:23 AM

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

    Regards,

    Satish

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 04, 2007 at 09:26 AM

    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').

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 04, 2007 at 09:28 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 04, 2007 at 09:30 AM

    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

    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.