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: 

Difficulty in FM.

former_member506713
Participant
0 Kudos

Hi Experts,

I want to prepare a FM, in which user gives few letters of a material descrioption.

And I have to fetch material and material description from MAKT table containing same letters.

For eg,

If user giving material description as

u201CELOVACu201D.

All materials containing ELOVAC will display.

ELOVAC-B 5 ml

ELOVAC-B 0.5 ml

ELOVAC-B 5 ml

ELOVAC B I.P. 5 ML (EPI)

ELOVAC B B.P. 0.5 ML

ELOVAC B B.P. 1 ML

Can experts please tell how to go about this?

Thanks in Advance.

Lucky

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

You can use like the following:

data: begin of wa_makt,

matnr type matnr,

maktx like makt-maktx,

end of wa_makt.

data: it_makt like table of wa_makt.

Ranges: ra_description for wa_makt-maktx.

parameters: p_maktx like wa_makt-maktx.

ra_description-sign = 'I'.

ra_description-option = 'CP'.

ra_description-low = p_maktx.

append ra_description.

select matnr maktx from makt into corresponding fields of table it_makt where spras = sy-langu and maktx in ra_description.

if sy-subrc = 0.

loop at it_makt into wa_makt.

write: / wa_makt-matnr, wa_makt-maktx.

endloop.

else.

write: / 'No record found'.

endif.

Best Regards,

Suresh

7 REPLIES 7

Former Member
0 Kudos

Hello,

if i understand right u want to make a search help for material,

for example user enters ELOVAC and gets material list with materials that have name with "ELOVAC" in it?

0 Kudos

Hi Rimantas,

Thanks for ur quick response.

In function module the input should be some part of material description ( like ELOVAC ).

And output should be material description containing ELOVAC in it and material.

Former Member
0 Kudos

Hi,

Check this.



Concatenate '%' i_desc '%' into gv_description.

Select * from MAKT into itab where maktx like gv_description.

Here i_desc is the string you are passing to the FM.

Regards,

Bhupal

Former Member
0 Kudos

Hi,

You can use like the following:

data: begin of wa_makt,

matnr type matnr,

maktx like makt-maktx,

end of wa_makt.

data: it_makt like table of wa_makt.

Ranges: ra_description for wa_makt-maktx.

parameters: p_maktx like wa_makt-maktx.

ra_description-sign = 'I'.

ra_description-option = 'CP'.

ra_description-low = p_maktx.

append ra_description.

select matnr maktx from makt into corresponding fields of table it_makt where spras = sy-langu and maktx in ra_description.

if sy-subrc = 0.

loop at it_makt into wa_makt.

write: / wa_makt-matnr, wa_makt-maktx.

endloop.

else.

write: / 'No record found'.

endif.

Best Regards,

Suresh

Former Member
0 Kudos

Hi Lucky,

Try using the following logic.

Go to SE37 ->Create a fumction Module assigned to a function group.

1.Now in the Import parameters, declare a variable i.e what the user has to gie in your case there are few letters like (elovac) of material description.

2.Declare a field of the material description type(you find it from F1) and assign it to your import parameters.

3.In the export parameters you want to display the materials with those letters, so declare a field with the material type.

4. In the source code, try this logic.

5. In the field what you have declared in the Import parameters write a select statment and verify using 'CA' or 'CO'.

Refer the code attached.

*"--------------------------------------------------------------------*
**                       INITIALIZATION                                *
**"--------------------------------------------------------------------*
initialization.

  clear s_devcl.
  s_devcl-sign = 'I'.
  s_devcl-option = 'CP'.
  s_devcl-low = 'Y*'.
  append s_devcl.

  s_devcl-sign = 'I'.
  s_devcl-option = 'CP'.
  s_devcl-low = 'Z*'.
  append s_devcl.

*&--------------------------------------------------------------------*
*At Selection Screen.
*&--------------------------------------------------------------------*
at selection-screen.

  if not s_devcl[] is initial.
    select single devclass
      into tdevc-devclass
      from tdevc
      where devclass in s_devcl.

    if sy-subrc ne 0.
      message e012.
    endif.
  endif.

Much Regards,

Amuktha.

Edited by: Amuktha Naraparaju on Apr 7, 2009 2:27 PM

Former Member
0 Kudos

Hi,

Use the field MAKTG instead of MAKTX as MAKTG stored the description in the uppercase where as MAKTX stores as user entered..so in case of search you need to enter in same case as data exists in the MAKT table. If you use the MAKTG then you will be searching everything upper case.

Ranges : r_maktg FOR makt-maktg.

r_maktg-sign = 'I'.
r_maktg-option = 'CS'.
TRANSLATE p_maktg to uppercase.
CONCATENATE '*' p_maktg '*' INTO r_maktg-low.
Append r_maktg.
  
Select * from MAKT into itab where spras EQ sy-langu and  MAKTG IN r_maktg.

0 Kudos

Thanks Experts.

I got the solution.

Closing the thread.