cancel
Showing results for 
Search instead for 
Did you mean: 

how to Developed user defined functions to call function modules in SAP R/3

Former Member
0 Kudos

• how to Develope user defined functions to call function modules in SAP R/3 system

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member556603
Active Contributor
0 Kudos

Hello Raja,

Go through this V.imp Link...

http://download.oracle.com/docs/cd/B10464_05/integrate.904/b10408/rfc.htm

Steps to crate FM..

Follow these steps..

Go to the T: code SE37

First You Create Function Group

On That u specify

Function Group Name..............

Short Text..............................

save...

Go to SE 37

Specify the Function Module Name: Eg: Z_Bapi_Materialmaster

Short Text.......

Save...

Next Go to Attributes..

Select Radio button : Remote enabled model

Go to Parameters..

Click Import...

Give Parameter Type Associate type S.t

next Click Export...

Give Parameter Type Associate type S.t

Next Click Tables Button..

Specify tables..

Next click source code button..

Write Source code here..

Eg : Select statements Etc..

Finally we should be select the Radio button Enable remorely

https://www.sdn.sap.com/irj/sdn/wiki?path=/pages/viewpage.action?pageId=39728

https://www.sdn.sap.com/irj/sdn/wiki?path=/display/abap/bapi%2bstep%2bby%2bstep

Hope this information is useful to you..

Thanks ,

Satya Kumar..

GabrielSagaya
Active Contributor
0 Kudos

/people/alessandro.guarneri/blog/2006/03/27/sap-xi-lookup-api-the-killer

/people/sravya.talanki2/blog/2005/12/21/use-this-crazy-piece-for-any-rfc-mapping-lookups

import java.io.;sap.aii.mapping.lookup.;

function myudf(String a, Container container)

{

String content = "";

MappingTrace importanttrace;

importanttrace = container.getTrace();

// filling the string with our RFC-XML (with values)

String m = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><p2:BAPI_PO_GETDETAIL xmlns:p2=\"urn:sap-com:document:sap:rfc:functions\"><PURCHASEORDER>4500014790</PURCHASEORDER></p2:BAPI_PO_GETDETAIL>";

RfcAccessor accessor = null;

ByteArrayOutputStream out = null;

try

{

// 1. Determine a channel (Business system, Communication channel)

Channel channel = LookupService.getChannel("BCS_800","rfc_channel");

// 2. Get a RFC accessor for a channel.

accessor = LookupService.getRfcAccessor(channel);

// 3. Create a xml input stream representing the function module request message.

InputStream inputStream = new ByteArrayInputStream(m.getBytes());

// 4. Create xml payload

XmlPayload payload = LookupService.getXmlPayload(inputStream);

// 5. Execute lookup.

Payload result = accessor.call(payload);

InputStream in = result.getContent();

out = new ByteArrayOutputStream(1024);

byte[] buffer = new byte[1024];

for (int read = in.read(buffer); read > 0; read = in.read(buffer)) {

out.write(buffer, 0, read);

}

content = out.toString();

}

catch(LookupException e)

{

importanttrace.addWarning("Error while lookup " + e.getMessage() );

}

catch(IOException e)

{

importanttrace.addWarning("Error " + e.getMessage() );

}

finally

{

if (out!=null) {

try {

out.close();

} catch (IOException e) {

importanttrace.addWarning("Error while closing stream " + e.getMessage() );

}

}

// 7. close the accessor in order to free resources.

if (accessor!=null) {

try {

accessor.close();

} catch (LookupException e) {

importanttrace.addWarning("Error while closing accessor " + e.getMessage() );

}

}

}

//returning the result – RFC-XML.response

return content;

}

Former Member
0 Kudos