Disconnecting from R/3 


If you are connected to R/3, follow this procedure to disconnect:

  1. Check if SAPGUI Front is running, by checking the value of the EVT_FRONT_RUNNING bit in the eventtype member of IT_EVENT.

Note that your program may have started SAPGUI in one of two ways:

  1. If you SAPGUI Front is running, then stop it by using the It_StopSapGui function.
  2. Use the It_Logoff function to disconnect from the R/3 server.
  3. Free the connection handle, by using the It_FreeConnection function.


The following example shows a cleanup function that closes the SAPGUI Front it it is open, logs the user off and closes the connection.

//Parameters: hConn - A handle to the server connection

loginflag - A flag which tells whether login succeeded or not

void Cleanup(HANDLE hConn, int loginflag)


PIT_EVENT pEvt = 0;



if(It_GetEventEx((HANDLE)hConn, &pEvt, GV_ISSAPGUIRUNNING))


if (It_StopSapGui(hConn) == 0)


printf("It_StopSapGui failed!");