新语法
SELECT 'I' AS sign, 'EQ' AS option, substring( kunnr,1,4 ) AS low, CAST( @space AS CHAR( 4 ) ) AS high FROM @mt_table AS m INTO TABLE @DATA(rt_werks)."直营店
*SELECT SINGLE zwlsx INTO l_labor FROM zsdt_i011 WHERE zdhmb = 'DX01' AND matnr = l_matnr. *l_labor = l_labor + 1. *l_labor = |{ l_labor ALPHA = IN }|. *WRITE l_labor. DATA:p_kunnr TYPE kunnr. p_kunnr = 'D001'. *&*********取数 TYPES: BEGIN OF ty_man, name TYPE char10, " 姓名 sex TYPE char1, " 性别 age TYPE p DECIMALS 2, " 年龄 school TYPE char20, " 学校 END OF ty_man. DATA: gt_man TYPE TABLE OF ty_man. gt_man = VALUE #( ( name = 'Anna' sex = 'G' age = 17 ) ( name = 'Ann' sex = 'G' age = 16 ) ). cl_demo_output=>write( gt_man ). "内表基础上附加额外数据 gt_man = VALUE #( BASE gt_man ( name = 'Xiaohong' sex = 'G' age = 20 school = 'C SCHOOL' ) ( name = 'Xiaoming' sex = 'B' age = 21 school = 'D SCHOOL' ) ). cl_demo_output=>write( gt_man ). SELECT parvw AS partn_role FROM tpar INTO TABLE @DATA(lt_tpar) WHERE parvw IN ( 'AG','RE','RG','WE' ). *lt_partner = VALUE #( FOR ls_tpar IN lt_tpar * ( VALUE #( BASE CORRESPONDING #( ls_tpar ) partn_numb = p_kunnr ) ) ). *LOOP AT lt_partner ASSIGNING FIELD-SYMBOL(<fs1>). * *ENDLOOP. * *TYPES: ty_menge TYPE rlfmg . *DATA:s_mon TYPE RANGE OF rpsxxxxx-smon. *e_msg = |物料凭证{ goodsmvt_headret-mat_doc }创建成功;|. * ** dmbtr,"订货金额 ** CAST( 0 AS CURR( 15,2 ) ) AS credit_limit, ** zdlvr_date,"配送日期 ** date_arr,"到货日期 ** zrev_flag, ** CASE zrev_flag ** WHEN 'X' THEN '已评审' ** WHEN 'N' THEN '未评审' ** WHEN 'R' THEN '已拒绝' ** END AS zrev_ftxt, ** zsend_flag,"发送状态 * *"配送中心名称确定 *DATA : lt_t001w TYPE HASHED TABLE OF typ_t001w WITH UNIQUE KEY zdis_ctr, *gt_head TYPE STANDARD TABLE OF typ_head. *gt_head = CORRESPONDING #( gt_head FROM lt_t001w USING zdis_ctr = zdis_ctr ). "内表行数 DATA(lv_lines) = lines( gt_man ). "内表中符合条件的数据有几条 DATA(lv_lines_g) = REDUCE i( INIT x = 0 FOR ls_man IN gt_man WHERE ( sex = 'G' ) NEXT x = x + 1 ). cl_demo_output=>write( lv_lines ). cl_demo_output=>write( lv_lines_g ). "累计内表中符合条件的年龄之和 TYPES: ty_age TYPE p DECIMALS 2. DATA(lv_sum_age) = REDUCE ty_age( INIT dage = VALUE ty_age( ) FOR wa IN gt_man WHERE ( sex = 'G' ) NEXT dage = dage + wa-age ). cl_demo_output=>write( lv_sum_age ). "综合例子 TYPES:BEGIN OF ty_result, sum TYPE p DECIMALS 2, "总和 max TYPE p DECIMALS 2, "最大值 avg TYPE p DECIMALS 2, "平均 cunt TYPE i, "记录数 END OF ty_result. DATA(ls_result) = REDUCE ty_result( INIT res = VALUE ty_result( ) "可以默认值:ty_result( min = 0 max = 0 ) FOR <fs_man> IN gt_man WHERE ( sex = 'G' ) "性别为G NEXT res-sum = res-sum + <fs_man>-age "年龄总和 res-max = nmax( val1 = res-max val2 = <fs_man>-age )"最大年龄 res-cunt = res-cunt + 1 "满足条件的条目数 ). ls_result-avg = ls_result-sum / ls_result-cunt. "平均值 cl_demo_output=>write( ls_result ). cl_demo_output=>display( ). * ---退货 *TYPES: ty_menge TYPE rlfmg . *DATA(m_back_day) = REDUCE ty_menge( INIT menge = VALUE ty_menge( ) * FOR wa_back IN gt_zsdi25_back WHERE ( zdbrq = it_date * AND matnr = ls_ctpd-matnr * AND kunnr = ls_ctpd-kunnr ) * NEXT menge = menge + wa_back-menge ).