欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

【SAP】ABAP——RANGE用法

程序员文章站 2022-05-18 07:54:01
...
DATA ra_bwart TYPE RANGE OF mseg-bwart."移动类型
DATA ls_bwart LIKE LINE OF ra_bwart.

DATA ra_date TYPE RANGE OF sy-datum."日期期间
DATA ls_date LIKE LINE OF ra_date.

  ls_bwart-low = '201'.
  ls_bwart-sign = 'I'.
  ls_bwart-option = 'EQ'.
  APPEND ls_bwart TO ra_bwart.

  ls_bwart-low = '202'.
  ls_bwart-sign = 'I'.
  ls_bwart-option = 'EQ'.
  APPEND ls_bwart TO ra_bwart.

CONCATENATE p_lfgja p_lfmon '01' INTO ls_date-low."该月第一天
  CALL FUNCTION 'BKK_GET_MONTH_LASTDAY'
    EXPORTING
      i_date = ls_date-low
    IMPORTING
      e_date = ls_date-high."该月最后一天
  ls_date-sign = 'I'.
  ls_date-option = 'BT'.
  APPEND ls_date TO ra_date."ra_date为当月期间

SELECT SUM( a~erfmg ) AS erfmg SUM( a~dmbtr ) AS dmbtr
      INTO CORRESPONDING FIELDS OF wa_data
      FROM mseg AS a
      INNER JOIN mkpf AS b
              ON a~mblnr = b~mblnr
             AND a~mjahr = b~mjahr
      WHERE a~matnr = wa_data-matnr
        AND a~werks = wa_data-werks
        AND a~bwart IN ra_bwart
        AND a~sobkz IN ra_sobkz
        AND b~budat IN ra_date.