根据选择屏幕创建12个月份

DATA: BEGIN OF wa_month,
  month(6) TYPE c,
  END OF wa_month.

PARAMETERS: p_pwerk LIKE afpo-pwerk OBLIGATORY,
            p_date LIKE sy-datum OBLIGATORY.

START-OF-SELECTION.
  PERFORM creat_allmonth.

*&---------------------------------------------------------------------*
*&      Form  CREAT_ALLMONTH
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM creat_allmonth .

  DATA: c1(6) TYPE c,
        y2(4) TYPE c,
        m3(2) TYPE c.

  MOVE p_date(6) TO c1.
  MOVE p_date(4) TO y2.
  MOVE p_date+4(2) TO m3.
  APPEND c1 TO it_month.
  DO 11 TIMES.
    m3 = m3 + 1.
    IF m3 < 10.
      CONCATENATE y2 '0' m3 INTO c1.
      APPEND c1 TO it_month.
    ELSEIF m3 > 9 AND m3 < 13.
      CONCATENATE y2  m3 INTO c1.
      APPEND c1 TO it_month.
    ELSEIF m3 > 12.
      m3 = 1.
      y2 = y2 + 1.
      CONCATENATE y2 '0' m3 INTO c1.
      APPEND c1 TO it_month.
    ENDIF.

  ENDDO.

ENDFORM.  
原文地址:https://www.cnblogs.com/huangjianisgood/p/2749730.html