Thursday 23 October 2014

Code Snippet for Table Control Page Up, Page Down, Last Page and First Page


Step1. program with the source code.























TYPES : BEGIN OF ty_val,
               val1 TYPE i,
              val11 TYPE i,
              END OF ty_val.

DATA : lt_val TYPE TABLE OF ty_val,
              ls_val TYPE ty_val,
              tl_line TYPE i,
             sl_line TYPE i,
             rm_line TYPE i.
CONTROLS : tc TYPE TABLEVIEW USING SCREEN 2000.

MODULE status_2000 OUTPUT.
 SET PF-STATUS 'STA-2000'.
 DESCRIBE TABLE lt_val LINES tl_line.
 IF tl_line IS INITIAL.
   DO 35 TIMES.
     ls_val-val1 = sy-index.
     ls_val-val11 = SY-INDEX * sy-index.
     INSERT ls_val INTO lt_val INDEX sy-index.
   ENDDO.
 ENDIF.
ENDMODULE.                 " status_2000  OUTPUT

MODULE tab_line OUTPUT.
 sl_line = sy-loopc. " Sy-loopc = number of visible lines in the table control
ENDMODULE.                 " tab_line  OUTPUT

MODULE scrool_table INPUT.
CASE sy-ucomm.
  WHEN 'TOP'.
    tc-top_line = 1.                      " when first page, make top line as 1.
  WHEN 'BOTTOM'.
    tc-top_line = tc-lines - sl_line + 1. " when last page display last set of records
  WHEN 'UP'.
    IF tc-top_line GT sl_line. " When previous page requested, if top line is grater than  visible line, 
      tc-top_line = tc-top_line - sl_line. " make top line as top line minus visible line else make top line                                                               "as 1.
    ELSE.
      tc-top_line = 1.
    ENDIF.
  WHEN 'DOWN'.
    rm_line = tc-lines - sl_line. " when next page, remaining line = total lines - visible lines in the 
    IF tc-top_line LT rm_line. " table control  if current line less than the remaining line , then shift the         tc-top_line = tc-top_line + sl_line. " table control lineto the next set of visible line
    ENDIF.

ENDCASE.
ENDMODULE.
--------------------------------------------------------------------------------------------------------------------------
Step2. Here if the pf status.











Step3. Flow logic of the screen.













Step4. Screen design of the table control.

























Step5. Output variations on user actions.

















--------------------------------------------------------------------------------------------------------------------------

No comments:

Comments system

Disqus Shortname