Looks like something that could go into a package. If you don't want to do
that, it'd be nice if you could add a license to your code, so others could
use it as a starting point.
On Jul 10, 2016 4:45 PM, "Stefan Schnell" <[email protected]> wrote:

> Hello community,
>
> here an include how to use Julia with SAP via NetWeaver RFC library - but
> only with a few functions, not the complete set of the SAP NetWeaver RFC
> library:
>
> #-Begin-----------------------------------------------------------------
>
>   #-User Defined Types--------------------------------------------------
>     type RFC_CONNECTION_PARAMETER
>       nameASHost::Ptr{UInt16}
>       valueASHost::Ptr{UInt16}
>       nameSysNr::Ptr{UInt16}
>       valueSysNr::Ptr{UInt16}
>       nameClient::Ptr{UInt16}
>       valueClient::Ptr{UInt16}
>       nameUser::Ptr{UInt16}
>       valueUser::Ptr{UInt16}
>       namePassWd::Ptr{UInt16}
>       valuePassWd::Ptr{UInt16}
>       nameLang::Ptr{UInt16}
>       valueLang::Ptr{UInt16}
>     end
>
>     type RFC_ERROR_INFO
>       code::Int32
>       group::Int32
>       key::Ptr{UInt16}
>       message::Ptr{UInt16}
>       abapMsgClass::Ptr{UInt16}
>       abapMsgType::Ptr{UInt16}
>       abapMsgNumber::Ptr{UInt16}
>       abapMsgV1::Ptr{UInt16}
>       abapMsgV2::Ptr{UInt16}
>       abapMsgV3::Ptr{UInt16}
>       abapMsgV4::Ptr{UInt16}
>     end
>
>   #-Constants-----------------------------------------------------------
>     const sapnwrfc = "sapnwrfc.dll"
>
>   #-Main----------------------------------------------------------------
>     cd("C:\\Projects\\SAP\\RFC\\Julia")
>
>     code = 0
>     group = 0
>     key = ""
>     message = ""
>     abapMsgClass = ""
>     abapMsgType = ""
>     abapMsgNumber = ""
>     abapMsgV1 = ""
>     abapMsgV2 = ""
>     abapMsgV3 = ""
>     abapMsgV4 = ""
>     RfcErrorInfo = RFC_ERROR_INFO(
>      code, group, pointer(utf16(key)), pointer(utf16(message)),
>      pointer(utf16(abapMsgClass)), pointer(utf16(abapMsgType)),
>      pointer(utf16(abapMsgNumber)), pointer(utf16(abapMsgV1)),
>      pointer(utf16(abapMsgV2)), pointer(utf16(abapMsgV3)),
>      pointer(utf16(abapMsgV4))
>     )
>
>   #-RfcGetVersion-------------------------------------------------------
>     function RfcGetVersion()
>       majorVersion = Ref{UInt32}(0)
>       minorVersion = Ref{UInt32}(0)
>       patchLevel = Ref{UInt32}(0)
>       ptrVersion = ccall((:RfcGetVersion, sapnwrfc), stdcall,
>         Ptr{UInt16}, (Ptr{UInt32}, Ptr{UInt32}, Ptr{UInt32}),
>         majorVersion, minorVersion, patchLevel)
>       return utf16(ptrVersion), majorVersion[], minorVersion[],
>         patchLevel[]
>     end
>
>   #-RfcOpenConnection---------------------------------------------------
>     function RfcOpenConnection(ashost::AbstractString,
>       sysnr::AbstractString, client::AbstractString,
>       user::AbstractString, passwd::AbstractString,
>       lang::AbstractString = "EN")
>       nameASHost = "ASHOST"
>       valueASHost = ashost
>       nameSysNr = "SYSNR"
>       valueSysNr = sysnr
>       nameClient = "CLIENT"
>       valueClient = client
>       nameUser = "USER"
>       valueUser = user
>       namePassWd = "PASSWD"
>       valuePassWd = passwd
>       nameLang = "LANG"
>       valueLang = lang
>       RfcConnectionParameter = RFC_CONNECTION_PARAMETER(
>         pointer(utf16(nameASHost)), pointer(utf16(valueASHost)),
>         pointer(utf16(nameSysNr)), pointer(utf16(valueSysNr)),
>         pointer(utf16(nameClient)), pointer(utf16(valueClient)),
>         pointer(utf16(nameUser)), pointer(utf16(valueUser)),
>         pointer(utf16(namePassWd)), pointer(utf16(valuePassWd)),
>         pointer(utf16(nameLang)), pointer(utf16(valueLang))
>       )
>       return ccall((:RfcOpenConnection, sapnwrfc), stdcall,
>         UInt32, (Ref{RFC_CONNECTION_PARAMETER}, UInt32,
>         Ref{RFC_ERROR_INFO}), RfcConnectionParameter, 6, RfcErrorInfo)
>     end
>
>   #-RfcGetFunctionDesc--------------------------------------------------
>     function RfcGetFunctionDesc(rfcHandle::UInt32,
>       funcName::AbstractString)
>       return ccall((:RfcGetFunctionDesc, sapnwrfc), stdcall,
>         UInt32, (UInt32, Ptr{UInt16}, Ref{RFC_ERROR_INFO}),
>         rfcHandle, utf16(funcName), RfcErrorInfo)
>     end
>
>   #-RfcCreateFunction---------------------------------------------------
>     function RfcCreateFunction(funcDescHandle::UInt32)
>       return ccall((:RfcCreateFunction, sapnwrfc), stdcall,
>         UInt32, (UInt32, Ref{RFC_ERROR_INFO}),
>         funcDescHandle, RfcErrorInfo)
>     end
>
>   #-RfcInvoke-----------------------------------------------------------
>     function RfcInvoke(rfcHandle::UInt32, funcHandle::UInt32)
>       return ccall((:RfcInvoke, sapnwrfc), stdcall,
>         UInt32, (UInt32, UInt32, Ref{RFC_ERROR_INFO}),
>         rfcHandle, funcHandle, RfcErrorInfo)
>     end
>
>   #-RfcDestroyFunction--------------------------------------------------
>     function RfcDestroyFunction(funcHandle::UInt32)
>       return ccall((:RfcDestroyFunction, sapnwrfc), stdcall,
>         UInt32, (UInt32, Ref{RFC_ERROR_INFO}),
>         funcHandle, RfcErrorInfo)
>     end
>
>   #-RfcCloseConnection--------------------------------------------------
>     function RfcCloseConnection(rfcHandle::UInt32)
>       return ccall((:RfcCloseConnection, sapnwrfc), stdcall,
>         UInt32, (UInt32, Ref{RFC_ERROR_INFO}),
>         rfcHandle, RfcErrorInfo)
>     end
>
> #-End-------------------------------------------------------------------
>
>
>
> <https://lh3.googleusercontent.com/-uMqz_luyKsU/V4KzHts6R1I/AAAAAAAAAao/iHI9alfQQ_siR1viA9gfAEMjYwXesgvnACLcB/s1600/JuliaMeetsSAP2.jpg>
>
> In the example above you see loading of the include and a sequence of SAP
> NetWeaver RFC commands to invoke the RFC_PING function module.
>
> After the RfcOpenConnection command you see the connected Julia in the
> Gateway Monitor (TAC SMGW):
>
>
> <https://lh3.googleusercontent.com/-t9d6TjAMaqA/V4KzSv8QhwI/AAAAAAAAAas/nporM7SU9AI8RuNPWNcrW6aRjJpiXmlxgCLcB/s1600/JuliaMeetsSAP.JPG>
>
>
>
> Enjoy it.
>
> Cheers
> Stefan
>

Reply via email to