Friday, October 28, 2016

Selection Screen with Maximum Selection (UP TO ... ROWS) MXSEL


constants gc_max_rows type tbmaxsel value '100000'
constants gc_default_rows type tbmaxsel value '200'

parameter p_mxsel type tbmaxsel obligatory default gc_default_rows.

initialization.
  select single tbmaxsel from rseumod into p_mxsel 

    where uname sy-uname.
  perform trim_mxsel.

at selection-screen on p_mxsel.
  perform trim_mxsel.

start-of-selection.
  p_mxsel p_mxsel + 1.
  select from ...
    into corresponding fields of table gt_my
    up to p_mxsel rows
    where
       ...
  if gt_my is initial.
    message s429(mo).     " no data found
    return.
  endif.
  if linesgt_my p_mxsel.
    
    delete gt_my index p_mxsel.
    message s016(eswith p_mxsel" result cut off
  endif.
  p_mxsel p_mxsel 1.


form trim_mxsel.
  if p_mxsel > gc_max_rowsp_mxsel gc_max_rowsendif.
  if p_mxsel < 1p_mxsel gc_default_rowsendif.
endform.

No comments:

Post a Comment

SAP ABAP: Determine Timezone for Plant

    DATA:       lt_tzone TYPE STANDARD TABLE OF tznzone WITH DEFAULT KEY,       l_tzone  TYPE tznzone.     " get time zone for plant   ...