Posted: Fri Sep 14, 2007 3:54 pm Post subject: Screen elements | Элементы экрана
SELECT_OPTIONS_RESTRICT - Make use of SELECT-OPTIONS easier on the selection screen
Powerful function module to control SELECT-OPTIONS (see FM documentation).
E.g. fully forbids intervals in SELECT-OPTIONS:
Code:
report Z_SO_RESTRICT.
tables: usr02.
type-pools: sscr.
select-options: usrbnam for usr02-bname no intervals,
creator for usr02-aname no intervals.
data: restrict type sscr_restrict,
opt_list type sscr_opt_list,
ass type sscr_ass.
clear: ass.
ass-kind = 'S'.
ass-name = 'USRBNAM'.
ass-sg_main = 'I'.
ass-sg_addy = ' '.
ass-op_main = 'EQAL'.
ass-op_addy = 'EQAL'.
append ass to restrict-ass_tab.
call function 'SELECT_OPTIONS_RESTRICT'
exporting
restriction = restrict
exceptions
too_late = 1
repeated = 2
selopt_without_options = 3
selopt_without_signs = 4
invalid_sign = 5
empty_option_list = 6
invalid_kind = 7
repeated_kind_a = 8
others = 9.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
start-of-selection.
select * from usr02 where bname in usrbnam
and aname in creator.
write: / usr02-bname, usr02-aname.
endselect.
ICON_CREATE - Transfer Icon Name and Text to a Screen Field
Combines into one character field: icon, text, additional text that will appear on mouse over event. This field can be used for screen field or for list output field as well.
Code:
report z_icon_create.
include .
data xyz(70) type c.
write: / icon_plant as icon, 'This is plant'.
call function 'ICON_CREATE'
exporting
name = icon_plant
text = 'This is plant'
info = 'Plant xyz' "on mouse over text
add_stdinf = 'X'
importing
result = xyz
exceptions
icon_not_found = 1
outputfield_too_short = 2
others = 3.
write: / 'sy-subrc =', sy-subrc.
write: / xyz,
/ xyz as icon.
VRM_SET_VALUES - Transfer values to listbox parameter
Populates listbox parameter (like value 1 value 2 value 3 value 4 ) with values for selection. Example
Code:
report z_set_values.
type-pools: vrm.
data: it_val type vrm_values,
w_line like line of it_val.
parameters p_bukrs like t001-bukrs as listbox
visible length 25 obligatory.
initialization.
select bukrs butxt from t001 into (w_line-key, w_line-text).
append w_line to it_val.
check p_bukrs is initial.
p_bukrs = w_line-key.
endselect.
at selection-screen output.
call function 'VRM_SET_VALUES'
exporting
id = 'P_BUKRS'
values = it_val.
RS_SET_SELSCREEN_STATUS - Sets own GUI status on selection screens
Can be called while INITIALIZATION to set needed PF-STATUS before selection screen output.
Code:
DATA itab TYPE TABLE OF sy-ucomm.
PARAMETERS test AS CHECKBOX.
AT SELECTION-SCREEN OUTPUT.
APPEND: 'PRIN' TO itab,
'SPOS' TO itab.
CALL FUNCTION 'RS_SET_SELSCREEN_STATUS'
EXPORTING
p_status = sy-pfkey
TABLES
p_exclude = itab.
RPY_DYNPRO_READ - Read dynpro, including screen flow
DYNP_VALUES_UPDATE - Change screen field contents w/o PBO
Code:
*Internal table to store dy dynpro fields and values
DATA: dynpfields LIKE dynpread OCCURS 5 WITH HEADER LINE.
DATA: l_stepl LIKE sy-stepl.
REFRESH dynpfields.
CLEAR dynpfields.
dynpfields-fieldname = 'SCREENFIELD1-COL1'. "Screen field name
dynpfields-fieldvalue = 10. "New value
dynpfields-stepl = l_stepl. "Step loop for table controls
APPEND dynpfields.
CALL FUNCTION 'DYNP_VALUES_UPDATE'
EXPORTING
dyname = 'SAPLBDT_GMGR' "Program name
dynumb = '0270' "Screen number
TABLES
dynpfields = dynpfields
EXCEPTIONS
OTHERS = 0.
DYNP_VALUES_READ - Read screen field values before PAI field transport
Code:
REPORT DYNP_VALUES.
tables tcurt.
DATA DYFIELDS LIKE DYNPREAD OCCURS 1 WITH HEADER LINE.
PARAMETERS: P_WAERS LIKE TCURT-WAERS, "Currency
P_LTEXT LIKE TCURT-LTEXT, "Long Text
P_KTEXT LIKE TCURT-KTEXT. "Short Text
*-----------------------------------------------------------------------
*--- Example of updating value of another field on the screen ----------
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_WAERS.
CLEAR: DYFIELDS[], DYFIELDS.
*--- select currency
CALL FUNCTION 'HELP_VALUES_GET'
EXPORTING
fieldname = 'WAERS'
tabname = 'TCURT'
IMPORTING
SELECT_VALUE = P_WAERS.
*--- get long text for the selected currency
SELECT SINGLE LTEXT FROM TCURT
INTO DYFIELDS-FIELDVALUE
WHERE SPRAS = SY-LANGU
AND WAERS = P_WAERS.
IF SY-SUBRC <> 0.
CLEAR DYFIELDS-FIELDVALUE.
ENDIF.
*--- update another field
DYFIELDS-FIELDNAME = 'P_LTEXT'.
APPEND DYFIELDS.
CALL FUNCTION 'DYNP_VALUES_UPDATE'
EXPORTING
DYNAME = SY-CPROG
DYNUMB = SY-DYNNR
tables
dynpfields = DYFIELDS .
*-----------------------------------------------------------------------
*--- Example of reading value of another field -------------------------
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_KTEXT.
*--- read another field
CLEAR: DYFIELDS[], DYFIELDS.
DYFIELDS-FIELDNAME = 'P_WAERS'.
APPEND DYFIELDS.
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
DYNAME = SY-CPROG
DYNUMB = SY-DYNNR
TABLES
DYNPFIELDS = DYFIELDS .
READ TABLE DYFIELDS INDEX 1.
*--- get short text and update current field
SELECT SINGLE KTEXT FROM TCURT
INTO P_KTEXT
WHERE SPRAS EQ SY-LANGU
AND WAERS EQ DYFIELDS-FIELDVALUE.
RS_REFRESH_FROM_SELECTOPTIONS - Current contents of selection screen
Code:
Selection table as a variant:
So after example, in a report for mass updates an extensive selection delimitation was to be made before or after the selection process this as a variant will be to restore them later on.
* Variant
DATA:
Seltab TYPE OF TABLE rsparams HEADER WITH LINE,
G_repid LIKE sy-repid.
D_text varit TYPE OF TABLE WITH HEADER LINE,
D_varid LIKE varid,
D_variant LIKE rsvar-variant. "14 Chartier
*------------------------------------------------- --------------------*
* Form selektionstabelle_sichern
*------------------------------------------------- --------------------*
FORM selektionstabelle_sichern.
* Variant names are
CONCATENATE 'TO'
Sy-date +2 (6) sy-uzeit INTO d_variant. "Max 14
* Variant table fill
MOVE:
G_repid TO d_varid report,
D_variant TO d_varid-variant,
'F' TO d_varid transport,
'A' TO d_varid-environmnt,
'X' TO d_varid-protected,
'1 'TO d_varid version,
Sy uname-TO-d_varid ename,
Sy-date TO d_varid-edat,
Sy-uzeit TO d_varid-etime,
Sy-langu TO d_varid-mlangu.
*'20 'To d_varid-xflag1,
*'00 'To d_varid-xflag2.
* Description text fill
MOVE: sy-langu TO d_text-langu,
G_repid TO d_text report,
D_variant TO d_text-variant.
CONCATENATE uname-sy sy sy-date uzeit
INTO d_text-vtext SEPARATED BY space.
APPEND d_text.
*&--------------------------------------------------------------------*
*& Form GET_DYNAMIC_SELECTION
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
form GET_DYNAMIC_SELECTION.
data: g_repid like sy-repid.
data: rt_dyn_trange type rsds_trange.
DATA: it_dyn_texpr type rsds_texpr with header line.
data: ld_rsds_expr type rsds_expr,
ld_rsdsexpr type rsdsexpr.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.