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

Need code for a function module- Urgent

Former Member
0 Likes
587

Hi friends,

I have a requirement where I am giving material description as an import parameter in the function module. ( Material description could be a wild search -- say - Mat* ) I want a sub routine in the function module which should get all the materials from the database ( mara or makt..not sure ) for the user entered Material description.

I want this particular code to be written using a sub-routine using formal parameters inside this fm . Could any one send me the code for this.

Thanks in advance,

Vishnu.

5 REPLIES 5
Read only

naimesh_patel
Active Contributor
0 Likes
540

Why don't you first try with somecode? And if you stuck up in between, come up with proper question.

Regards,

Naimesh Patel

Read only

0 Likes
540

Hi Naimesh,

I got the code.I am including all the global data as well as the sub-routine in the top include.Is it a good way of programming to include the sub-routines also in the top include.

Regards,

Vishnu.

Read only

Former Member
0 Likes
540

use table MAKT and fetch matnr by passing maktx inside source code of function module....

Read only

0 Likes
540

Hello ,

Use BAPI_MATERIAL_GETLIST and Pass the Selection criteria for Material Description to the table parameter MATERIALSHORTDESCSEL. This is a table in which you will have to pass the data in range manners say for wild card search I CP Mat*.

The Output will be in the table MATNRLIST.

Regards

<b>Reward points if useful</b>

Saket Sharma

null

Read only

Former Member
0 Likes
540

Hi Vishvanath,,

Please find the below code.

DATA : BEGIN OF itab OCCURS 0,

matnr LIKE makt-MATNR,

MAKTX LIKE makt-MAKTX,

END OF itab.

DATA : BEGIN OF itab1 OCCURS 0,

matnr LIKE makt-MATNR,

MAKTX LIKE makt-MAKTX,

END OF itab1.

data : a(5) type c value 'TEST'.

perform mat_no using a.

form mat_no using p_a.

data : lv_temp(4) type c.

select matnr maktx from makt into table itab.

loop at itab.

lv_temp = itab-maktx+0(4).

if lv_temp = p_a.

move itab to itab1.

APPEND ITAB1.

endif.

endloop.

loop at itab1.

write 😕 itab1.

endloop.

endform. " mat_no

Thanks.

Amjad.