Skip to main content

Code: RFC Connection with C++

Coding snippet for C++ and NWRFCSDK
Working example to connect to SAP from C++ and NWRFCSDK

Download:

A screenshot of a computer

Description automatically generated

Add to PATH variable

A screenshot of a computer

Description automatically generated

 

Make sure compiler on machine

 

A close-up of a number

Description automatically generated

A screenshot of a computer

Description automatically generated

 

Add to PATH

A blue and white text on a white background

Description automatically generated

 

A screenshot of a computer

Description automatically generated

Run the “vcvars64.bat” below from command line 

 

A screenshot of a computer

Description automatically generated

A computer screen shot of a black screen

Description automatically generated

https://me.sap.com/notes/2573953

https://learn.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=msvc-170&redirectedfrom=MSDN

 

C:\nwrfcsdk\demo>set INCLUDE=%INCLUDE%;C:\nwrfcsdk\include

 

C:\nwrfcsdk\demo>cl.exe -DSAPonNT -D_CRT_NON_CONFORMING_SWPRINTFS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -D_AFXDLL -DWIN32 -D_WIN32_WINNT=0x0502 -DWIN64 -D_AMD64_ -DNDEBUG -DSAPwithUNICODE -DUNICODE -D_UNICODE -DSAPwithTHREADS -Inwrfcsdk/include -EHs -Gy -J -MD -nologo -W3 -Z7 -D_ATL_ALLOW_CHAR_UNSIGNED -GL -O2 -Oy- /we4552 /we4700 /we4789 -c -FosflightClient.obj sflightClient.c


C:\nwrfcsdk\demo>set LIB=%LIB%;C:\nwrfcsdk\lib

C:\nwrfcsdk\demo>link.exe -OUT:sflightClient.exe -PDB:sflightClient.pdb -NXCOMPAT -STACK:0x2000000 -SWAPRUN:NET -DEBUG -OPT:REF -DEBUGTYPE:CV,FIXUP -MACHINE:amd64 -nologo -LTCG  ole32.lib oleaut32.lib uuid.lib kernel32.lib advapi32.lib user32.lib gdi32.lib winspool.lib ws2_32.lib comdlg32.lib shell32.lib sflightClient.obj sapnwrfc.lib libsapucum.lib

A screenshot of a computer

Description automatically generated

 

A computer screen with blue writing

Description automatically generated