17.08.2013 Views

Data Interfaces

Data Interfaces

Data Interfaces

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

RFC Example in Visual Basic<br />

© SAP AG<br />

Declare Function RfcOpenExt Lib "librfc.dll" ...<br />

Declare Sub RfcClose Lib "librfc.dll" ......<br />

hRfc = RfcOpenExt(destination, mode, host, sysnr, ...)<br />

...<br />

hSpace = RfcAllocParamSpace(3, 0, 1)<br />

rc% = RfcAddExportString(hSpace, 0, "COMPANY", 7, 0, 4, MyCompany)<br />

rc% = RfcAddExportString(hSpace, 1, "CUSTOMER", 8, 0, 10, MyCustomer)<br />

rc% = RfcAddExportString(hSpace, 2, "YEAR", 4, 6, 4, MyYear)<br />

thSales = ItCreate("SALES", 20 , 0, 0)<br />

rc% = RfcAddTable(hSpace, 0, "SALES", 5, 0, 20, thSales)<br />

RfcRc = RfcCallExt(hRfc, hSpace, "GET_SALES_BY_MONTH")<br />

...<br />

If RfcRc = 0 Then<br />

RfcRc = RfcReceiveExt(hRfc, hSpace, xException)<br />

End If<br />

If RfcRc = 0 Then<br />

MsgBox "Function Call Failed !"<br />

RfcClose(hRfc)<br />

End If<br />

The above example shows RFC calls in a Visual Basic program fragment. Many details have been<br />

omitted, including the access to the results of the function calls, but you the fragment does contain the<br />

code for the following tasks:<br />

Declaring RFC calls<br />

Logging on to the R/3 System<br />

Defining the parameters and calls<br />

Error handling

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!