Procedure
If you are connected to R/3, follow this procedure to disconnect:
Note that your program may have started SAPGUI in one of two ways:
Example
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(hConn)
{
if(It_GetEventEx((HANDLE)hConn, &pEvt, GV_ISSAPGUIRUNNING))
{
if (It_StopSapGui(hConn) == 0)
{
printf("It_StopSapGui failed!");
}
}
if(loginflag)
It_Logoff(hConn);
It_FreeConnection(hConn);
}
}