For certain tasks it is useful to
let the user enter additional data on a popup screen. GuiXT does not
provide its own popups, but we can use one of the standard SAP popup
screens.
Solution
In the InputScript we set a status variable and call up the
"Help settings" popup. Example
GuiXT
// indicate: scheduling popup active
Set V[me21n_scheduling_popup] "X"
Enter "?HF1C"
In the GuiXT script for the help settings popup, we query
the transaction and the status variable, and then include another
script with a suitable name. Example:
GuiXT
if Q[Transaction=ME21N] and V[me21n_scheduling_popup=X]
include "me21n_scheduling_popup.txt"
endif
In this included script we remove all existing elements,
set our own title and a suitable window size, remove the
standard functions and add our own elements. Example:
GuiXT
// remove existing elements
del S[USR_VALS] -withBox
// own title
Title "Delivery Schedule Assistant"
// suitable window size
WindowSize (20,80)
// remove standard functiona
del P[/0]
del P[/12]
On "Enter" Fcode="?"
On "/1" Fcode="?"
On "/4" Fcode="?"
// add own functions
Pushbutton (toolbar) "Copy delivery schedule" _
process="me21n_add_schedule.txt"
Pushbutton (toolbar) "@02\QCancel@" "/12" "F12"
// add own elements such as InputFeild, Table,...
....
In the GuiXT script of the underlying screen we reset the popup
indicator if no popup is shown. Example:
GuiXT
// deactivate popup indicator
if not Q[InactiveScreen]
Clear V[me21n_scheduling_popup]
endif
Please note the the script for the
underlying screen is also processed when a popup screen is shown, and
Q[InactiveScreen]is
fulfilled in this situation.
Example
In the purchase order transaction ME21N we add a pushbutton column
which allows the user to create schedule lines automatically, each with
quantity and delivery date.
Video
GuiXT Script, main screen "saplmegui.e0014.txt"
/GuiXT
/ deactivate scheduling popup indicator
if not Q[InactiveScreen]
Clear V[me21n_scheduling_popup]
endif
// item table on screen? then add a pushbutton column
if T[SAPLMEGUI_TC_1211]
Column "DS" table=T[SAPLMEGUI_TC_1211] position=2 size=3 -pushButton _
label="@6Q\QDelivery schedule assistant@" _
process="me21n_show_scheduling_popup.txt"
endif
InputScript "me21n_show_scheduling_popup.txt"
GuiXT
// show any errors
ProcessingOption returnOnError="off"
// enter on main screen
Enter
Screen SAPLMEGUI.0014
// save relevant cell values for display in popup
Set V[me21n_ematn] "&cell[SAPLMEGUI_TC_1211,MEPO1211-EMATN,&V[_tabrow]]"
Set V[me21n_txz01] "&cell[SAPLMEGUI_TC_1211,MEPO1211-TXZ01,&V[_tabrow]]"
Set V[me21n_menge] "&cell[SAPLMEGUI_TC_1211,MEPO1211-MENGE,&V[_tabrow]]"
Set V[me21n_eeind] "&cell[SAPLMEGUI_TC_1211,MEPO1211-EEIND,&V[_tabrow]]"
Set V[me21n_elpei] "&cell[SAPLMEGUI_TC_1211,MEPO1211-ELPEI,&V[_tabrow]]"
// save the selected row number
Set V[me21n_itemrow] "&V[_tabrow]"
// any order item data missing?
if not V[me21n_ematn] or not V[me21n_menge] or not V[me21n_eeind]
Message "E: Please enter material, quantity and delivery date" -statusline
Enter
Leave
endif
//quantity 1 ?
if V[me21n_menge=1]
Message "E: No scheduling for quantity 1" -statusline
Enter
Leave
endif
// other date formats (week/month) ?
if V[me21n_elpei=W] or V[me21n_elpei=M]
Message "E: Automatic scheduling not supported for week or month format"
-statusline
Enter
Leave
endif
// create table variable
CreateTable V[me21ndis] date quantity
// reset table display status
Clear V[me21ndis.stat.*]
//reset quantity
Clear V[me21n_distribute_each]
// indicate: scheduling popup active
Set V[me21n_scheduling_popup] "X"
// use the SAP help options popup
Enter "?HF1C"
GuiXT Script for the SAP help settings popup
"saplsr13.e0102.txt"
GuiXT
if Q[Transaction=ME21N] and V[me21n_scheduling_popup=X]
include "me21n_scheduling_popup.txt"
endif
// remove existing elements
del S[USR_VALS] -withBox
// own title
Title "Delivery Schedule Assistant"
// suitable window size
WindowSize (20,80)
// remove existing functions
del P[/0]
del P[/12]
On "Enter" Fcode="?"
On "/1" Fcode="?"
On "/4" Fcode="?"
// add own elements
Text (0,2) "Material &V[me21n_ematn] &V[me21n_txz01]" -proportional
Text (0,38) "Del.Date &V[me21n_eeind]"
Text (0,60) "Quantity &V[me21n_menge]"
Text (1,2) "----------------------------------------------"
Pushbutton (3,2) "Days" size=(1,16) process="me21n_distribution.txt"
using MODE = "D"
Pushbutton (4,2) "Weeks" size=(1,16) process="me21n_distribution.txt"
using MODE = "W"
Pushbutton (5,2) "Months" size=(1,16) process="me21n_distribution.txt"
using MODE = "M"
Pushbutton (6,2) "Quarters" size=(1,16) process="me21n_distribution.txt"
using MODE = "Q"
Pushbutton (7,2) "Years" size=(1,16) process="me21n_distribution.txt"
using MODE = "Y"
// default: 1
if not V[me21n_distribute_each]
Set V[me21n_distribute_each] "1"
endif
InputField (9,2) "Quantity (each)" (9,20) size=6 _
name="me21n_distribute_each" -numerical
Pushbutton (toolbar) "Copy delivery schedule" _
process="me21n_add_schedule.txt"
Pushbutton (toolbar) "@02\QCancel@" "/12" "F12"
Table (3,30) (20,68) title="Delivery schedule" _
="me21ndis" fixedColumns=2
Column "Date" size=16 name="date"
Column "Quantity" size=16 name="quantity"
Pushbutton (3,72) "@11\QRemove entries@" process="me21n_distribution.txt"
using MODE = "RESET"
InputScript "me21n_distribution.txt"
GuiXT
// -----------------------------
// suggest periodic distribution
// -----------------------------
Parameter MODE // D,W,M,Q,Y,RESET
if U[MODE=RESET]
Clear V[me21ndis]
Clear V[me21ndis.stat.*]
Return
endif
Set V[date] "&V[me21n_eeind]"
Set V[quantity] "&V[me21n_menge]"
if not V[me21n_distribute_each>0]
Set V[me21n_distribute_each] 1
endif
Set V[k] 1
Clear V[me21ndis]
label next_day
if V[quantity>0]
// remaining quantity
if V[quantity<&V[me21n_distribute_each]]
Set V[me21ndis.quantity.&V[k]] "&V[quantity]"
Set V[quantity] 0
else
Set V[me21ndis.quantity.&V[k]] "&V[me21n_distribute_each]"
Set V[quantity] &V[quantity] - "&V[me21n_distribute_each]"
endif
// next working day
Set V[factory_calendar] "01"
Call "DATE_CONVERT_TO_FACTORYDATE" _
export.DATE="date" _
export.FACTORY_CALENDAR_ID="factory_calendar" _
import.DATE="date2"
// set date
Set V[me21ndis.date.&V[k]] "&V[date2]"
// days
if U[MODE=D]
Set V[date] &V[date2] + 1
endif
// weeks
if U[MODE=W]
Set V[date] &V[date] + 7
endif
// months
if U[MODE=M] or U[MODE=Q] or U[MODE=Y]
Set V[months] 1
if U[MODE=Q]
Set V[months] 3 // quarter
endif
if U[MODE=Y]
Set V[months] 12 // year
endif
// add months
Call "RE_ADD_MONTH_TO_DATE" _
export.OLDDATE="date" _
export.MONTHS="months" _
import.NEWDATE="date"
endif
// next one
Set V[k] &V[k] + 1
goto next_day
endif
InputScript "me21n_add_schedule.txt"
GuiXT
// leave popup
Enter /12
// any scheduling? else no action
if not V[me21ndis.date.1]
Leave
endif
Screen SAPLMEGUI.0014
// we open the delivery scheduling with a double click on the quantity field
SetCursor cell[SAPLMEGUI_TC_1211,MEPO1211-MENGE,&V[me21n_itemrow]]
Enter /2
Screen SAPLMEGUI.0014
Set V[absrow] 1
Enter "=MEPO1320MALL" // Select existing entries
Screen SAPLMEGUI.0014
Set cell[SAPLMEGUI_TC_1320,0,1] " " // keep 1st one
Enter "=MEPO1320DELETE" // Delete entries
label new_screen
Screen SAPLMEGUI.0014
GetTableAttribute T[SAPLMEGUI_TC_1320] _
firstVisibleRow=minabsrow lastVisibleRow=maxabsrow
label new_row
if not V[absrow>&V[me21ndis.rowcount]]
Set V[relrow] &V[absrow] - &V[minabsrow ]
Set V[relrow] &V[relrow] + 1
if V[absrow>&V[maxabsrow]]
Enter "/scrollToLine=&V[maxabsrow]" table="T[SAPLMEGUI_TC_1320]"
goto new_screen
endif
Set cell[SAPLMEGUI_TC_1320,MEPO1320-EEIND,&V[relrow]] _
"&V[me21ndis.date.&V[absrow]]"
Set cell[SAPLMEGUI_TC_1320,MEPO1320-MENGE,&V[relrow]] _
"&V[me21ndis.quantity.&V[absrow]]"
Set V[absrow] &V[absrow] + 1
goto new_row
endif
Enter
Screen SAPLMEGUI.0014
Message "S: Delivery schedule entered" -statusline
Enter "/scrollToLine=1" table="T[SAPLMEGUI_TC_1320]"