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: 

how to get the descrption

Former Member
0 Kudos

Hi all

am retriving the matnrs from mara table into an internal table it_mara

then what i need is

A description of each relevant material should be retrieved from the Material Descriptions table (MAKT).

To retrieve the records, select from the table according to the following criteria:

MAKT-MATNR (Material) IN Material (Note 5 selection)

MAKT-SPRAS (Language key) EQ SY-LANGU (User’s logon language)

Retrieve the Material description field (MAKTX). If a description is not found, a default text should be substituted indicating no material description.

what should i do.

10 REPLIES 10

former_member699750
Participant
0 Kudos

Try like this..

data: begin of itab occurs 0,

matnr like makt-matnr,

maktx like makt-maktx,

end of itab.

select matnt maktx into corresponding fields of table itab from makt for all entries in itab where matnr = itab-matnr and spras = 'E'.

loop at itab.

if itab-maktx is initial.

itab-maktx = 'UR DESCRIPTION'.

endif.

modify itab.

clear:itab.

endloop.

Reward if usefull...

Regards

Sugumar G

Edited by: Sugumar Ganesan on Mar 31, 2008 12:17 PM

Edited by: Sugumar Ganesan on Mar 31, 2008 12:36 PM

matt
Active Contributor
0 Kudos

The specification tells you precisely what to do, doesn't it?

"To retrieve the records, select from the table (MAKT) according to the following criteria:

MAKT-MATNR (Material) IN Material (Note 5 selection)

MAKT-SPRAS (Language key) EQ SY-LANGU (User’s logon language)"

I'm not sure how it can be clearer than that. Try reading the help on the ABAP keyword "SELECT".

matt

Former Member
0 Kudos

see my problem is not for the slection part

the problem is while selecting for the corresponding materials if one materila does not have the description then i have to update it by writing "no description" and then update that internal table

now how to do it ahile doing the selection process not after the selection

Former Member
0 Kudos

once you get the data in your internal table, you can do as follows

loop at itab into wa.

if wa-maktx is initial.

wa-maktx = <some default text>

endif.

modify itab from wa transporting maktx.

endloop.

0 Kudos

Hi,

Try the following,

loop at it_mara.

select single maktx from makt where matnr = it_mara-matnr and

spras = 'EN'.

if sy-subrc = 0.

it_mara-maktx = makt-maktx.

else.

it_mara-maktx = 'default text'.

endif.

modify it_mara index sy-tabix.

endloop.

Former Member
0 Kudos

Hi,

Loop at itab.

select single * from makt where matnr = itab-matnr and
                                               spras = sy-langu.
if sy-subrc eq 0.
 move : makt-maktx to itab-maktx.
else.
 move : 'no text found' to itab-maktx.
endif.

modify itab iindex sy-tabix.
endloop.

Regards,

Morris Bond.

Former Member
0 Kudos

HI,

Tables: mara, makt.

data: begin of itab occurs 0,
matnr like mara-matnr,
maktx like makt-maktx,
end of itab.
select-options: s_matnr for mara-matnr.
Select * from mara into corresponding fields of table itab where matnr in s_matnr.

loop at itab.
select single * from makt where matnr = itab-matnr 
                                       and  spras = SY-LANGU .

if makt-maktx is initial.

itab-maktx = 'defauld description'.
else.
itab-maktx = makt-maktx.
endif.
modify itab.
clear itab.

Write:/ itab-matnr , itab-maktx.
endloop.

Regards,

S.Nehru.

0 Kudos

Hi

the solution you provided will owrk fine

but as per selection is considered it is always advised not to do the selection inside a loop

so what should i do now in order to avoid my performance issues here

0 Kudos

Hi,

Try This code,

Tables: mara, makt.

data: begin of it_mara occurs 0,
  matnr like mara-matnr,
  end of it_mara.

data: begin of it_makt occurs 0,
  matnr like makt-matnr,
  maktx like makt-maktx,
  end of it_makt.

data: begin of itab occurs 0,
matnr like mara-matnr,
maktx like makt-maktx,
end of itab.


select-options: s_matnr for mara-matnr.

Select  matnr  from mara into  table it_mara where matnr in s_matnr.

  if not it_mara[] is initial.

    select maktx from makt into table it_makt for all ENTRIES IN it_mara
      WHERE matnr = it_mara-matnr
       and  spras = SY-LANGU .
  endif.


loop at it_mara.

READ TABLE it_makt WITH KEY matnr = it_mara-matnr.

itab-matnr = it_mara-matnr.
if it_makt-maktx is initial.
itab-maktx = 'defauld description'.
else.
itab-maktx = it_makt-maktx.
endif.
APPEND itab.
clear itab.


endloop.

LOOP at itab.
  Write:/ itab-matnr , itab-maktx.
  endloop.

Regards,

Brown.

matt
Active Contributor
0 Kudos

I'd do an outer join on MARA and MAKT into the internal table. Then sort the itab by description, and loop through it, setting the default description so long as the description is blank.

matt