*&---------------------------------------------------------------------*
*& Report  zzzz
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT zzzz.

TYPES BEGIN OF ty_num.
TYPES  num TYPE i.
TYPES END OF ty_num.

DATA gt_num TYPE TABLE OF ty_num.
DATA gt_stack TYPE TABLE OF ty_num.


PERFORM frm_initialize.
PERFORM lookup USING 0.
*&---------------------------------------------------------------------*
*&      Form  frm_initialize
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM frm_initialize.
  DATA ls_num TYPE ty_num.

  DO 10 TIMES.
    ls_num-num = sy-index.
    APPEND ls_num TO gt_num.
  ENDDO.
ENDFORM.                    "frm_initialize
*&---------------------------------------------------------------------*
*&      Form  lookup
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->SY-TABIX   text
*----------------------------------------------------------------------*
FORM lookup USING pv_tabix.
  DATA ls_num TYPE ty_num.
  DATA lv_index TYPE i.
  DATA lv_tabix TYPE i.

  lv_index = pv_tabix + 1.

  DATA lv_lines TYPE i.

  DESCRIBE TABLE gt_num LINES lv_lines.

  LOOP AT gt_num INTO ls_num FROM lv_index.
    lv_tabix = sy-tabix.

    PERFORM push USING ls_num.

    PERFORM write.

    PERFORM lookup USING lv_tabix.

    PERFORM popup.
  ENDLOOP.
ENDFORM.                    "recurs

*&---------------------------------------------------------------------*
*&      Form  push
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->PS_NUM     text
*----------------------------------------------------------------------*
FORM push USING ps_num.
  APPEND ps_num TO gt_stack.
ENDFORM.                    "push
*&---------------------------------------------------------------------*
*&      Form  write
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM write.
  FIELD-SYMBOLS <ls_num> TYPE ty_num.

  LOOP AT gt_stack ASSIGNING <ls_num>.
    AT FIRST.
      WRITE: / <ls_num>-num.
      CONTINUE.
    ENDAT.

    WRITE <ls_num>-num.
  ENDLOOP.
ENDFORM.                    "write

*&---------------------------------------------------------------------*
*&      Form  popup
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM popup.
  DATA lv_lines TYPE i.

  DESCRIBE TABLE gt_stack LINES lv_lines.

  DELETE gt_stack INDEX lv_lines.
ENDFORM.                    "popup

posted on 2020-08-15 21:53  北上  阅读(368)  评论(0编辑  收藏  举报