This function retrieves text of the OK code text field.
SapGui.bdh
SapGuiGetOkCode( ) : string;
transaction TMain var sText : string; sConnID : string; begin// Connecting to SAP sConnID := SapGuiOpenConnection(" /SAP_CODEPAGE=1100 /FULLMENU 10.5.2.132 0 /3"); SapGuiSetActiveConnection(sConnID); SapGuiSetActiveSession("ses[0]"); // SAP SapGuiSetActiveWindow("wnd[0]", "SAP", SAPGUI_MATCH_ExactNoCase); SapGuiWindowAction(SAPGUI_WND_MAXIMIZE); SapGuiLogon("ddic", "*******", "000", ""); sText := SapGuiGetOkCode(); end TMain;