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

SELECT with problems

Former Member
0 Likes
480

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 ?

3 REPLIES 3
Read only

Former Member
0 Likes
439

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.

Read only

Former Member
0 Likes
439

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.

Read only

valter_oliveira
Active Contributor
0 Likes
439

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.