SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Screen elements | Элементы экрана



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Function Modules | Функциональные модули
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1636

PostPosted: Fri Sep 14, 2007 3:54 pm    Post subject: Screen elements | Элементы экрана Reply with quote

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.

initialization.
clear: opt_list.
opt_list-name = 'EQAL'.
opt_list-options-eq = 'X'.
append opt_list to restrict-opt_list_tab.

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.

end-of-selection.
write: / 'Company Code:', p_bukrs.


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


  G_repid = sy-repid.

  * Selection table
  REFRESH seltab.
  CLEAR seltab.
  * Selections read and remember
  FUNCTION CALL 'RS_REFRESH_FROM_SELECTOPTIONS'
 EXPORTING
  Curr_report = g_repid
 TABLES
  Selection_table = seltab.


  PERFORM selektionstabelle_sichern.



  *------------------------------------------------- --------------------*
  * 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.

  * Variant.
  FUNCTION CALL 'RS_CREATE_VARIANT'
 EXPORTING
  Curr_report = g_repid
  Curr_variant = d_variant
  Vari_desc = d_varid
 TABLES
  Vari_contents = seltab
  Vari_text = d_text
  * = VSCREENS
 EXCEPTIONS
  Illegal_report_or_variant = 1
  Illegal_variantname = 2
  Not_authorized = 3
  Not_executed = 4
  Report_not_existent = 5
  Report_not_supplied = 6
  Variant_exists = 7
  Variant_locked = 8
  OTHERS = 9
  IF sy-subrc <> 0
  MESSAGE-ID sy sy-TYPE msgid msgty NUMBER sy-msgno
  WITH msgv1-sy sy-msgv2-msgv3 sy sy-msgv4.
 ENDIF.
 ENDFORM.  "Selektionstabelle_sichern


RS_REFRESH_FROM_DYNAMICAL_SEL - Returns values of dynamic selections (selection screen)

Code:

*"----------------------------------------------------------------------
*" Macro MAKE_RANGE &1
*"----------------------------------------------------------------------
*"*"Local interface:
*"    <= &1 first_date
*"    <= &2 last_date
*"    => &3 DAY_IN
*"    => &4 date
*"----------------------------------------------------------------------
DEFINE make_range.
  &1-SIGN   = 'I'.
  &1-OPTION = ld_rsdsexpr-option.
  &1-LOW    = ld_rsdsexpr-low.
  &1-HIGH   = ld_rsdsexpr-high.
  APPEND &1.
END-OF-DEFINITION."make_range

*&--------------------------------------------------------------------*
*&      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.

  REFRESH: it_dyn_texpr.
  REFRESH: r_racct_ru, r_rzzlokkt_ru,
           r_racct_ua, r_rzzlokkt_ua,
           r_racct_kz, r_rzzlokkt_kz,
           r_racct.

  g_repid = sy-repid.
* get report dynamic selections:
  call function 'RS_REFRESH_FROM_DYNAMICAL_SEL'
    exporting
      curr_report        = g_repid
      mode_write_or_move = 'M'
    importing
      p_trange           = rt_dyn_trange
    exceptions
      not_found          = 1
      wrong_type         = 2
      others             = 3.
  if sy-subrc ne 0.
    exit.
  endif.
* delete rt_dyn_trange where tablename ne 'BSIS'.                "740027
  call function 'FREE_SELECTIONS_RANGE_2_EX'
    exporting
      field_ranges = rt_dyn_trange
    importing
      expressions  = it_dyn_texpr[].

  loop at it_dyn_texpr into ld_rsds_expr.
    loop at ld_rsds_expr-expr_tab into ld_rsdsexpr.

      CASE ld_rsds_expr-tablename.
      WHEN 'ZSLI01T'.
        make_range r_racct.
      WHEN 'ZSLRU'.
        IF ld_rsdsexpr-fieldname EQ 'RACCT'.
          make_range r_racct_ru.
        ELSEIF ld_rsdsexpr-fieldname EQ 'RZZLOKKT'.
          make_range r_rzzlokkt_ru.
        ENDIF.
      ENDCASE.
    endloop.
  endloop.
endform.                    "GET_DYNAMIC_SELECTION

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Function Modules | Функциональные модули All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
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.