Application Development 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: 

SELECT

Former Member
0 Kudos
290

Hi all,

I have an internal table which contains PLANT,MATNR and some other fields.

Now I have to get the material description for the matnr.

And I need to place the description in the internal table based on matnr.

Can u please help me regarding this.

Vkr.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
265

<b>select single maktx from makt into table itab_mat

where matnr = matnr(selection)

and spras = sy-langu. </b>

You can select any number of fields from MAKT table...

Regards,

Pavan.

16 REPLIES 16

Former Member
0 Kudos
266

<b>select single maktx from makt into table itab_mat

where matnr = matnr(selection)

and spras = sy-langu. </b>

You can select any number of fields from MAKT table...

Regards,

Pavan.

0 Kudos
265

Hi friends i know the SELECT stmt...

what i need is how to map that discription to my internal table based on MATNR.

VKR.

0 Kudos
265

Hi VKR,

Please check my post...

That is optimised code..

0 Kudos
265

Hi ARJUN,

in mY internal table matnr is repeated.

how to display the same discription multiple times.

VKR.

0 Kudos
265

Hi VKR,

Even if matnr is repeated the code will work fine..

Arjun

Former Member
0 Kudos
265

HI,

TRY LIKE THIS,

select single maktx from makt into table itab_mat

where matnr = matnr(selection) and spras = sy-langu.

IF HELPFUL REWARD SOME POINTS.

WITH REGARDS,

SURESH. ALURI

Former Member
0 Kudos
265

Let itab1 be the table u have....it has fields matnr , plant and maktx (mat desc)

then do the follwing.

data : begin of itab2 occurs 0,

matnr type makt-matnr,

maktx type makt-maktx,

end of itab2 .

check not itab1 is initial.

select matnr maktx from makt into table itab2

for all entries in itab1

where matnr = itab1-matnr .

loop at itab1.

read table itab2 with key matnr = itab1-matnr.

if sy-subrc = 0.

itab1-maktx = itab2-maktx.

mOdify itab1.

endif.

endloop.

Former Member
0 Kudos
265

hi,

tables : makt , marc.

data : begin of itab_marc,

matnr like marc-matnr,

werks like marc-werks,

end of itab_marc.

data : begin of itab_makt,

matnr like makt-matnr,

maktx like makt-maktx,

end of itab_makt.

data : begin of itab_final,

matnr like marc-matnr,

werks like marc-werks,

maktx like makt-maktx,

end of itab_final.

selection-screen : begin of block blk1 with frame title text-001.

parameters : p_matnr like marc-matnr.

selection-screen : end of block blk1.

select matnr maktx from makt into corresponding fields of itab_final where matnr = p_matnr.

loop at iatb_final.

write 😕 maktx.

endloop.

Reward with points if helpful.

Former Member
0 Kudos
265

Hi,

Initially first fetch descp for matnr for all the entries in internal table.

IF ITAB1[] IS NOT INITIAL.

SELECT MAKTX FROM MAKT

INTO TABLE ITAB2

FOR ALL ENTRIES IN ITAB1

WHERE MATNR EQ ITAB1-MATNR.

ENDIF.

IF SY-SUBRC EQ 0.

LOOP AT ITAB1 INTO WORK AREA1.

READ TABLE ITAB2 INTO WORK AREA1 WITH KEY MATNR = WORKAREA2-MATNR.

IF SY-SUBRC EQ 0.

APPEND ITAB1.

ENDIF

ENDLOOP.

Thanks

Srinivas

kesavadas_thekkillath
Active Contributor
0 Kudos
265

loop at itab.

select maktx into itab-maktx from makt client specified

where mandt = sy-mandt

and matnr = itab-matnr.

modify itab transporting maktx.

clear itab.

endloop.

0 Kudos
265

sorry a small correction:

sort itab by matnr.

loop at itab.

at new matnr.

select single maktx into itab-maktx from makt client specified

where mandt = sy-mandt

and matnr = itab-matnr.

modify itab transporting maktx where matnr = itab-matnr.

endat.

clear itab.

endloop.

if the above doesnt work tyr this...

loop at itab.

select single maktx into itab-maktx from makt client specified

where mandt = sy-mandt

and matnr = itab-matnr.

modify itab transporting maktx.

clear itab.

endloop.

0 Kudos
265

Hi,

If i use transporting maktx its going for short dump.

vkr.

0 Kudos
265

try the second one....it will work.....if not plz wait ill come back shortly

kesavadas_thekkillath
Active Contributor
0 Kudos
265

hi vkr try this ....sorry for the inconvenience.

data:wk_maktx like makt-maktx.

sort itab by matnr ascending.

loop at itab.

at new matnr.

select single maktx into wk_maktx from makt

where matnr = itab-matnr.

endat.

itab-maktx = wk_maktx.

modify itab.

clear itab.

endloop.

Former Member
0 Kudos
265

Hi VKR,

Here is the simple way to meet your requirement.

TABLES MAKT.

LOOP AT ITAB.

SELECT SINGLE *

FROM MAKT

WHERE MATNR EQ ITAB-MATNR.

ITAB-DESCRIPTION = MAKT-MAKTX.

MODIFY ITAB.

ENDLOOP.

Hope this helps you.

Reegards,

Rama chary.Pammi

Former Member
0 Kudos
265

hi VKR

try this i have tried it will definitely work.....

tables : makt,marc.

types : begin of ty_marc,

matnr type matnr,

werks type werks_d,

end of ty_marc.

types : begin of ty_makt,

matnr type matnr,

maktx type maktx,

end of ty_makt.

types : begin of ty_final,

matnr type matnr,

werks type werks_d,

maktx type maktx,

end of ty_final.

types : tt_marc type standard table of ty_marc,

tt_makt type standard table of ty_makt,

tt_final type standard table of ty_final.

data : wa_marc type ty_marc,

wa_makt type ty_makt,

wa_final type ty_final.

data : itab_marc type tt_marc,

itab_makt type tt_makt,

itab_final type tt_final.

selection-screen : begin of block blk1 with frame title text-001.

parameters : p_matnr like mara-matnr oblogatory.

selection-screen : end of block blk1.

select matnr werks from marc into table itab_marc where matnr = p_matnr.

if not itab_marc initial.

select matnr matkx from makt into table itab_makt where matnr = p_matnr.

endif.

loop at itab_mara into wa_mara.

wa_final-matnr = wa_mara-matnr.

wa_final-werks = wa_mara-werks.

append wa_final to itab_final.

clear wa_final.

endloop.

loop at itab_final into wa_final.

read table itab_final from wa_final with key matnr = wa_final-matnr.

if sy-subrc = 0.

wa_final-maktx = wa_makt-maktx.

modify itab_final from wa_final transporting maktx.

endif.

endloop.

loop at itab_final into wa_final.

write : wa_final-maktx.

endloop.

REWARD IF USEFUL....