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

Nested select

Former Member
0 Likes
976

Hi,

Is there any way I can do something like:

SELECT

MATNR

(SELECT MAKTX FROM MAKT WHERE MATNR = M~MATNR AND LANG = 'PT') as PT

(SELECT MAKTX FROM MAKT WHERE MATNR = M~MATNR AND LANG = 'ES') as ES

FROM

MARA as M

I want to return only 1 record instead of 2...

Thanks

Hugo

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
955

Thanks for the replies guys but i think you didn't undestand my question

I want to know if there's a way where the result of the select is something like:

MATNR LANG_PT LANG_ES LANG_FR

000000000000000001 Mat PT Mat ES

The result of the select must be only 1 record with the several languages I choose in the select of course.

Thanks again, you will be rewarded

Hugo

8 REPLIES 8
Read only

Former Member
0 Likes
955

Hi,

You can do as below :



select matnr from mara into itab where matnr = 'some value'.

if not itab [ ]  is initial.

select matnr maktx from makt into it_final for all entries in 
                        itab where matnr = itab-matnr
                                and   lang = 'PT' or
                                        lang = 'ES'.

endif.


"Write to output list.

Thanks,

Sriram Ponna.

Read only

Former Member
0 Likes
955

hi ,

select matnr from mara into table it_tab where matnr = ' userinput'.

select single MAKTX from makt into

V_MAKTX for all entries in

it_tab where matnr = it_tab-MATNR

and lang = 'PT' or

lang = 'ES'.

Read only

Former Member
0 Likes
955

hi,

plz try using "for all entries" ....

regards,

srishti

Read only

Former Member
0 Likes
955

You can use JOINS to achieve the same functionality.

Select maraMatnr amaktx a~spras

into table itab

from mara inner join makt as a on amatnr = maramatnr where

a~spras in ('E', 'P').

itab will have all matnr and material description in both the languages.

Thanks and Regards,

Lakshmi.

Read only

Former Member
0 Likes
955

hii

SELECT matnr                       " Material Number
           werks                       " Plants
           lgort                       " Storage Location
      FROM mard
      INTO TABLE i_mard
       FOR ALL ENTRIES IN i_marc
     WHERE matnr EQ i_marc-matnr
       AND werks EQ i_marc-werks
       AND lgort IN s_lgort.


SELECT matnr                         " Material Number
         maktx                         " Material Description
    FROM makt
    INTO TABLE i_makt
     FOR ALL ENTRIES IN i_mard
   WHERE matnr = i_mard-matnr
     AND spras = lc_lang.

you can use like this in your program.

thx

twinkal.

Read only

Former Member
0 Likes
956

Thanks for the replies guys but i think you didn't undestand my question

I want to know if there's a way where the result of the select is something like:

MATNR LANG_PT LANG_ES LANG_FR

000000000000000001 Mat PT Mat ES

The result of the select must be only 1 record with the several languages I choose in the select of course.

Thanks again, you will be rewarded

Hugo

Read only

0 Likes
955

Join MARA to MAKT twice using a different language for each - you'll need to use table aliases to do this.

Read only

0 Likes
955

Thanks Christine!

Problem solved