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

Fetching Material Description based on Language.

Former Member
0 Likes
3,337

Hi All,

I have the following Selection query fetching data from different tables using joins:

SELECT a~aufnr " Process Order

a~auart " Process Order Type

a~werks " Plant

b~plnbez " Material Code

b~gltri " Actual Finish Date

b~gamng " Qty Planned Consumption

b~gmein " Base UoM

b~igmng " Target Consumption

b~stlbez

b~rsnum " Number of reservation/dependent requirements

c~posnr

c~ltrmi

c~charg " Batch Number

m~meins " Material base UoM

m~mtart " Material Type

m~extwg " External Material Group

k~maktx " Material description

INTO TABLE i_aufk_afko_afpo

FROM aufk AS a INNER JOIN afko AS b ON aaufnr = baufnr

INNER JOIN afpo AS c ON baufnr = caufnr

INNER JOIN mara AS m ON bstlbez = mmatnr

INNER JOIN makt AS k ON bstlbez = kmatnr

WHERE a~aufnr IN s_aufnr

AND a~auart IN s_auart

AND a~werks IN s_werks

AND b~stlbez IN s_stlbez

AND c~ltrmi IN s_ltrmi

AND m~mtart IN s_mtart.

    • AND k~spras EQ sy-langu.

I am reading it as shown below:

LOOP AT i_aufk_afko_afpo.

i_final-werks = i_aufk_afko_afpo-werks. " Plant

i_final-plnbez = i_aufk_afko_afpo-plnbez. " Material Code

i_final-maktx = i_aufk_afko_afpo-maktx. " Material Description

i_final-mtart = i_aufk_afko_afpo-mtart. " Material Type

i_final-extwg = i_aufk_afko_afpo-extwg. " External Material Group

i_final-aufnr = i_aufk_afko_afpo-aufnr. " Process Order

Now instead of fetching the material Description in the join of table,

I want to select it separately using for all entries,

And read its internal table based on Sy-Langu

If the language is De or PT or FR it should display that description else if no description exists it should display the Description as maintained in EN.

How do I go About this?

Thanks Debrup.

8 REPLIES 8
Read only

Former Member
0 Likes
1,731

You can use Select Query as

SELECT MATNR

SPRAS

MAKTX

FROM MAKT INTO TABLE T_MAKT

WHERE MATNR = Internal table matnr and

SPRAS = sy-langu or

SPRAS = 'EN'

When populating the Final internal table Read the entry from T_MAKT with Matnr and SPRAS = sy-langu

If this contains the entry fill the Final internal table else read the entry from T_MAKT with Matnr and SPRAS = 'EN'.

Thanks

Read only

Former Member
0 Likes
1,731

hI,

Try this

select maktx from makt FOR ALL ENTRIES IN i_aufk_afko_afpo WHERE spras in (sy-langu, 'EN')

Vasavi

Read only

Former Member
0 Likes
1,731

Hi Debrup,

you can achieve in this way

write a select query as

SELECT SPRAS MAKTX FROM MAKT INTO I_TAB2

FOR ALL ENTRIES IN I_TAB1

WHERE MATNR = I_TAB1-MATNR AND

((SPRAS EQ 'DE' OR

SPRAS EQ 'PT' OR

SPRAS EQ 'FR' ) OR

SPRAS EQ 'EN).

In the above query it will select the description in all the languages given in select criteria provided if it is maintained.

now you loop it and based on material no. and language and read the description from i_tab2.

if sy-subrc NE 0.

read with key spras = 'EN'.

i think this solves your problem.

Read only

Former Member
0 Likes
1,731

Hi,

The code written below will help you to get the material description.

CLEAR wa_aufk_afko_afpo

LOOP AT i_aufk_afko_afpo INTO wa_aufk_afko_afpo.

SELECT SINGLE maktx INTO wa_aufk_afko_afpo-maktx

FROM makt

WHERE matnr = wa_aufk_afko_afpo-matnr AND

spras = sy-langu.

MODIFY i_aufk_afko_afpo FROM wa_aufk_afko_afpo INDEX sy-tabix

TRANSPORTING maktx.

ENDLOOP.

( Declar maktx also in the structure)

Best Regards,

Deepa Kulkarni

Read only

Former Member
0 Likes
1,731

Hi,

You can do like this:

select matnr spras maktx 
      into i_maktx
     from makt
     for all entries....
     where matnr = <from int table>
               spras = sy-langu.
if sy-langu = 'DE' or 'PT' or 'FR'.
    loop at i_maktx into wa_maktx.
         if wa_maktx-maktx is initial.
              select single matnr spras maktx
                 from makt
                  into wa_maktx_temp
                  where matnr = wa_maktx-manr
                      and spras = 'EN'.
               if sy-subrc  = 0.
                     modify i_maktx from wa_maktx_temp transporting maktx.
               endif.
         endif.
    endloop.
endif.

Regards,

Neha

Edited by: Neha Shukla on Jan 6, 2009 7:22 PM

Read only

Former Member
0 Likes
1,731

Hi ,

Tyr this,

SELECT SPRAS MAKTX FROM MAKT INTO I_TAB2

FOR ALL ENTRIES IN I_TAB1

WHERE MATNR = I_TAB1-MATNR AND

((SPRAS EQ 'DE' OR

SPRAS EQ 'PT' OR

SPRAS EQ 'FR' ) OR

SPRAS EQ 'EN).

In the above query it will select the description in all the languages given in select criteria provided if it is maintained.

you loop it and based on material no. and language and read the description from i_tab2.

Read only

tushar_shukla
Active Participant
0 Likes
1,731

This message was moderated.

Read only

Former Member
0 Likes
1,731

Hi All,

Thanks for the input,

My problem is resolved.

I have added the following code:

IF i_aufk_afko_afpo[] IS NOT INITIAL.

REFRESH: i_makt1.

CLEAR: i_makt1.

SELECT matnr spras maktx

FROM makt

INTO TABLE i_makt1

FOR ALL ENTRIES IN i_aufk_afko_afpo

WHERE matnr = i_aufk_afko_afpo-stlbez.

IF sy-subrc EQ 0.

SORT i_makt 1BY matnr.

ENDIF.

ENDIF.

And read as:

READ TABLE i_makt1 WITH KEY matnr = i_final-plnbez

spras = sy-langu

BINARY SEARCH.

IF sy-subrc = 0 AND i_makt1-maktx IS NOT INITIAL.

i_final-maktx = i_makt1-maktx.

ELSE.

READ TABLE i_makt1 WITH KEY matnr = i_final-plnbez

spras = 'EN'

BINARY SEARCH.

IF sy-subrc = 0.

i_final-maktx = i_makt1-maktx.

ENDIF.

Thanks:

Debrup.