Using the Event Structure (It_Event)
The program using the GUI Library can:
Your program does so by getting an event using the It_GetEvent (or It_GetEventEx) and sending an event using It_SendEvent (or It_SendEventEx) functions respectively, as illustrated in the following diagram.
If your application is controlling or recording the interaction of an end user with the standard SAPGUI screens, your program can also:
Your program uses the It_SendEvent and It_GetEventEx with special flags for sending or getting the data from Front (as opposed to from the R/3 application server)
The following illustration summarizes the flow of screen data between the R/3 application server, the event structure, and Front.
You mustestablish a connection to R/3 before getting or sending data to R/3.
The program calling It_GetEvent and It_GetEvent Ex waits until a DYNP event arrives. It_GetEvent and It_GetEvent Ex then return the result in a pointer to the It_Event structure.
If any error occurs, then these functions return FALSE; otherwise they return TRUE.
If no error occurs, It_SendEvent processes the It_Event structure and prepares a packet to be sent to the application server.
It_SendEvent then frees up the It_Event and zeros out the It_Event pointer.
After this point, the client application should not access the event structure, as this event is already sent and is no longer valid.
To send a modified event to the server, you can also use:
Making a Copy of the Event Structure
You can keep a copy of the event structure for later use or for off-line processing, by callingIt_Dup.
This function returns a copy of the event structure, which should not be used for communicating data to the application server, meaning that you should not use it with It_SendEvent.
When you are done with the copied structure, you should callIt_FreeEvent to free the structure.
Peeking at the Event StructureIt_PeekEvent performs similar function to the It_GetEvent, only it allows you to see the contents of the same event several times before you actually get the event with an It_GetEvent* call.
This is especially useful if two procedures need to access the same event information.
In the example below, the program uses the It_PeekEvent as a way to handle possible errors. It uses the It_PeekEvent to check that the event returned no error. Only if no error occurred does it use It_GetEvent.
Since the It_PeekEvent fills the event structure, you need to useIt_FreeEvent to free the event structure after using the It_PeekEvent.
The flexibility of this architecture can be demonstrated by looking at the code ofIt_Login, which is implemented using It_GetEvent and It_SendReturn, (a variant of It_SendEvent).
DWORD DLEX It_Login (HANDLE hMerlin, char* client, char* name,
char* passwd, char* lang)
PIT_EVENT pEvt = 0;
if (It_GetEvent(hMerlin, &pEvt))
ItEv_SetValue(pEvt, 1, client);
ItEv_SetValue(pEvt, 3, name);
ItEv_SetValue(pEvt, 5, passwd);
ItEv_SetValue(pEvt, 7, lang);
if(pEvt->eventtype & EVT_MESSAGE)
// Bypass copyright screen