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

SELECT with problems

Hi guys, I need a help.

I need to have a SELECT with primary key WERKS but one of my tables don't have WERKS, but it's possible with LIPS make a "Join" and have a link between all tables that i have. I made two select's but something is wrong, because the result isn't what i exepect.

This is part of the code:

SELECT * FROM zsd_qmel_lips

INTO CORRESPONDING FIELDS OF TABLE lt_itens

FOR ALL ENTRIES IN lt_qmnum

WHERE qmnum EQ lt_qmnum-qmnum AND

matnr IN s_matnr AND

motiv IN s_motiv.

  • RP/HP (04.0608): Restricção por Centro

SELECT ivbeln iposnr kkunnr imatnr inetpr kwerks

FROM likp AS k INNER JOIN lips AS i

ON kvbeln = ivbeln

INTO TABLE lt_lips

FOR ALL ENTRIES IN lt_itens

WHERE k~vbeln EQ lt_itens-vbeln AND

i~posnr EQ lt_itens-posnr AND

k~werks EQ l_werks.

Could you help me ?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jun 05, 2008 at 04:28 PM

    hi,

    Check out in this way ...

    SELECT * FROM zsd_qmel_lips

    INTO CORRESPONDING FIELDS OF TABLE lt_itens

    FOR ALL ENTRIES IN lt_qmnum

    WHERE qmnum EQ lt_qmnum-qmnum AND

    matnr IN s_matnr AND

    motiv IN s_motiv.

    if sy-subrc = 0.

    loop at lt_itens.

    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

    EXPORTING

    input = lt_itens-vbeln

    IMPORTING

    output = lt_itens-vbeln.

    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

    EXPORTING

    input = lt_itens-posnr

    IMPORTING

    output = lt_itens-posnr.

    modify lt_itens index sy-tabix transporting vbeln posnr.

    endloop.

    endif.

    if not lt_itens[] is initial.

    • RP/HP (04.0608): Restricção por Centro

    SELECT ivbeln iposnr kkunnr imatnr inetpr kwerks

    FROM likp AS k INNER JOIN lips AS i

    ON kvbeln = ivbeln

    INTO TABLE lt_lips

    FOR ALL ENTRIES IN lt_itens

    WHERE k~vbeln EQ lt_itens-vbeln AND

    i~posnr EQ lt_itens-posnr AND

    k~werks EQ l_werks.

    endif.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 05, 2008 at 04:43 PM

    Hi, I trie with new lines but the select by WERKS doesn't work. In result i have all records, and what i want is records for a special werks that i pass as parameter.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 05, 2008 at 04:52 PM

    Hello.

    Are you getting werks in the correct table? In most of entries in LIKP, field werks is empty.

    SELECT ivbeln iposnr kkunnr imatnr inetpr kwerks

    FROM likp AS k INNER JOIN lips AS i

    ON kvbeln = ivbeln

    INTO TABLE lt_lips

    FOR ALL ENTRIES IN lt_itens

    WHERE k~vbeln EQ lt_itens-vbeln AND

    i~posnr EQ lt_itens-posnr AND

    i~werks EQ l_werks.

    Regards.

    Valter Oliveira.

    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.