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

Function Module

Former Member
0 Likes
1,098

Hi,

I want to create a Function Module...

In my FM...

First, In Import insert value -


Parameter Name--Type--Associate Type

KUNNR--


LIKE----KNA1-KUNNR

Second, In Export insert values -


Parameter Name--Type Spec.--Associate Type

NAME1--


LIKE--


KNA1-NAME1

LAND1--


LIKE--


KNA1-LAND1

Now, I want that data should come respectively KUNNR...

When i insert KUNNR value, it show the NAME1 & LAND1 values according to KUNNR....

What should I do....

Here i use an Internal Table (in Tables) or not....

And, in Source Code....what i write....

Plz Explain.....

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
932

Hi,

U need not use the "Tables" to strore the NAME1 and LAND1 values. KUNNR is the only key field in KNA1 table. So it will return only one record for a KUNNR.

So u can declare the NAME1 and LAND1 in EXPORT parameter.

KUNNR in Import parameter.

select single NAME1 LAND1 from KNA1 into (NAME1, LAND1) where kunnr = KUNNR.

Now, u will have the output in NAME1 and in LAND1.

Kindly reward points if useful

Cheers,

Shanthi.

Edited by: shanthi ps on Feb 9, 2008 6:18 AM

4 REPLIES 4
Read only

Former Member
0 Likes
932

Hi,

if u want land1 and name1 depending on kunnr then

import parameters

kunnr

export parameters

land1

name1

tables

itab like kna1

source code

select land1 name1 from kna1 into table itab where kunnr = p_kunnr.

Regards

Read only

Former Member
0 Likes
932

Hi,

Go to source code of that funciton module.

write the below code in that.

select kunnr name1 land1 from kna1 into table itab where kunnr in s_kunnr.

********************************************************

then you call that function module in your program.

see the program is like this,

tables : kna1.

select-optiions : s_kunnr for kna1-kunnr.

types : begin of t_kunnr,

kunnr type kunnr,

name1 type name1,

land1 type land1,

end of t_kunnr.

data : wa_kunnr type t_kunnr,

itab type table of t_kunnr.

call function 'function module name'

exporting

kunnr = s_kunnr

importing

name1 = name1

land1 = land1

tables

t_outtab = itab,

regards,

swami

Read only

Former Member
0 Likes
933

Hi,

U need not use the "Tables" to strore the NAME1 and LAND1 values. KUNNR is the only key field in KNA1 table. So it will return only one record for a KUNNR.

So u can declare the NAME1 and LAND1 in EXPORT parameter.

KUNNR in Import parameter.

select single NAME1 LAND1 from KNA1 into (NAME1, LAND1) where kunnr = KUNNR.

Now, u will have the output in NAME1 and in LAND1.

Kindly reward points if useful

Cheers,

Shanthi.

Edited by: shanthi ps on Feb 9, 2008 6:18 AM

Read only

0 Likes
932

for a customer number kunnr if they are more names name1 then will ur select statement work?

select single NAME1 LAND1 from KNA1 into (NAME1, LAND1) where kunnr = KUNNR.