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 write an rfc funtion ?

Former Member
0 Kudos
81

Hi,

Can I know how to Write RFC function ?

Suppose i have to take a customer number and i have to print the details ?

How can i declare all the varialble in the function module itself or where ?

in the FM source code i am writing like this.

FUNCTION ZRFC_TEST1.

*"----


""Local interface:

*" IMPORTING

*" VALUE(REVID) LIKE kna1-kunnr

*" TABLES

*" IT_kna1 STRUCTURE kna1"----


select kunnr from kna1 into table it_kna1 WHERE kunnr = REVID.

WRITE : / it_kna1-kunnr.

ENDFUNCTION.

5 REPLIES 5

Chaitanyat
Participant
0 Kudos
46

Hi,

You have to declare IMPORTING , EXPORTING and TABLES Parameters in FM.

and in Attributes you have to tick the RFC enabled radiobutton.

in this case You declare TABLES parameter as:

IT_KNA1 like KNA1.

Then populate this internal table. When you execute the fun Module the values will be displayed from it_kna1 table.

Regards,

Chaitanya

former_member404244
Active Contributor
0 Kudos
46

Hi,

plz chek the below example..

suppose i have two clients as 100,200

now iwant to know the customer datails of client 200..

So in client 200 i will create the FM and write the source code..

Hi,

Can I know how to Write RFC function ?

Suppose i have to take a customer number and i have to print the details ?

How can i declare all the varialble in the function module itself or where ?

in the FM source code i am writing like this.

FUNCTION ZRFC_TEST1.

*"----


""Local interface:

*" IMPORTING

*" p_kunnr LIKE kna1-kunnr

*" TABLES

*" IT_kna1 STRUCTURE kna1"----


select kunnr from kna1 into table it_kna1 WHERE kunnr = p_kunnr.

WRITE : / it_kna1-kunnr.

ENDFUNCTION.

Now in client 100 i will write like this..

parameters : p_kunnr like KNA1-KUNNR

data : i_kna1 type table of KNA1.

CALL FUNCTION ' ZRFC_TEST1' DESTINATION <give logical system name of Client 200>.

Exporting

kunnr = p_kunnr

tables

IT_kna1 = i_kna1..

Now u will get the details in i_kna1.

Regards,

Nagaraj

Former Member
0 Kudos
46

Make sure that in <b>Attributes u have checked to choose the "Remote Enabled Function Module"</b> when u create an RFC FM.

0 Kudos
46

Hi,

One more thing, while calling the remote function module, call in this way

CALL FUNCTION 'function_module_name'

DESTINATION destination_server_name

EXPORTING

IMPORTING

TABLES

Hope this will be useful.

Rgds,

Vijayalakshmi

former_member187255
Active Contributor
0 Kudos
46

Check this...

1) Goto SE37 and give some name and press create.

It willa sk you to enter function group name if

you have already function grioup defined use that

or lese in the menu Goto -> Function group ->Create

group. Come back and use the same group here.

2) In the attributes screen Seelct Radio button Remote

enable func.

3) If you want to update multiple entries in the table

go to tabe Tables and

in that Parameter name - i_tab

Type - Like

reference type - Your table name (MARA).

4) Now goto Source code tab and do the below.

if not i_tab[] is initial.

MODIFY MARA FROM TABLE I_tab.

endif.

Then save it and activate.

Regards,

rCm