From an InputScript, you can use Call to call function modules of the SAP system, in particular the "BAPI" modules (Business API), which are provided by SAP for reading and saving data. In the case of the screen transactions described in the previous tutorial, you can also implement the saving of data by calling a BAPI in some cases instead of scripting the corresponding SAP transaction. This has advantages and disadvantages: Advantages
Disadvantages
|
GuiXT mask for quick entry of a fault message for equipment |
We use the BAPIs
In addition, the "Check" function then requires the equipment text to be read directly from the database; in the scripting solution, this text is taken from transaction IW21.
The GuiXT script for defining the fast entry interface is identical to the previous tutorial. The plausibility checks for the entered values are also identical. Saving itself is done by BAPI calls:
/ -----------------------------------------------------
// IW21 Fast data acquisition
(check/save)
// File "iw21_simple_save.txt"
// Solution via BAPI calls
//
-----------------------------------------------------
Parameter
MODE // C=Check S=Save// Plausibility checks
// Equipment specified?
if
not
V[iw21_equnr]
SetCursor
V[iw21_equnr]
Return
"E: Please enter the equipment
number"
-statusline
endif
// Short text specified?
// Date
specified?
//
Date format correct?
// Read equipment text
// Table
for returning the database values
CreateTable
V[eqkttab]
eqkt
Call
"/GUIXT/DBSELECT" cache="transaction" _//// Transfer equipment text
// found? otherwise error message
if
not
V[eqkttab.eqkt.1]
SetCursor
V[iw21_equnr]
Return
"E: Equipment &V[iw21_equnr] nicht
gefunden"
-statusline
enendif
// Notification type
//
Notification header
Set
V[iw21_notifheader.equipment] "&V[iw21_equnr]"//// Copy long text to BAPI format
//
Line index for long text lineslabel
copy_text_lineif
q[ok]/// Structures/tables for BAPI call with the required fields
Call
"BAPI_ALM_NOTIF_CREATE" _// Error messages from BAPI?
if
Q[ok]// Notification number
Set
// Save notification
Call
// Error messages from BAPI?
if
Q[ok]// Check only
Call
"BAPI_TRANSACTION_COMMIT"// Reset input data
// Stay on fast entry
Return
"S: Notification created: &V[qmnum]" -statusline