I found out that when trying to call RFC function from plugin I made ISapRfcConnection->InitFunction does only initialize import parameters that are type using structure (or table) field. If RFC function has import parameter type directly with data element, using the parameter does not work or even crash the application. Example:
ISapRfcFunctionPtr l_RFC = m_RFC->GetFunction(L"RHF4_RFC_SELECT_GENERIC",VARIANT_FALSE);
l_RFC->Field("TABNAME")->String = L"T002";
l_RFC->Field("FIELDNAME")->String = L"SPRAS";
l_RFC->Field("SORT")->String = L"X"; <--this will crash the application.
The reason for this is that EasyDMS uses function RFC_GET_FUNCTION_INTERFACE to initialize function interface. If we look at what this function returns:
P PARAMETER TABNAME FIELDNAME E POSITION E MAXROWS_EXCEEDED BOOLE_D C 0 I FIELDNAME DD03V FIELDNAME C 2 I MAXROWS SYINDEX I 0 I SORT BOOLE_D C 0 I TABNAME DD02V TABNAME C 1
We can see that this standard sap function return the dataelement in the TABNAME field. I did wild guess that EasyDMS checks the fieldname to determine if parameter is single field or structure (which is not the case, EXID field is "u" when field is structure). So I put a break point in the RFC_GET_FUNCTION_INTERFACE and reseted the rfc cache. When retrieving the interface for the RHF4_RFC_SELECT_GENERIC, I set also the FIELDNAME as BOOLE_D.
After this trick, code above worked..So there is bug at least in the 6.0.0.0: SP14 Patch 02 (Non-Unicode) and some 7.0 versions.
So how then use the parameter when referring using field is impossible? EasyDMS thinks that parameter is a structure so it can be accessed as structure data:
l_RFC->Struct("SORT")->GetDataChunk()->Data = L"X";