前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >ABAP随笔-新语法 Fliiter

ABAP随笔-新语法 Fliiter

作者头像
Tab Zhu
发布2022-06-23 15:18:14
3410
发布2022-06-23 15:18:14
举报
文章被收录于专栏:TAB的coding生活

内表的过滤条件为(物料群组=01,工厂=1000) 或 (物料群组=01,工厂=3000)

代码语言:javascript
复制
*… FILTER type( itab [EXCEPT] [IN ftab] [USING KEY keyname]
*           WHERE c1 op f1 [AND c2 op f2 […]] )

TYPES:BEGIN OF ty_filter,
        matkl TYPE ekpo-matkl,
        werks TYPE ekpo-werks,
      END OF ty_filter,
      ty_filter_tab TYPE SORTED TABLE OF ty_filter
                      WITH UNIQUE KEY matkl werks.

DATA lt_ekpo TYPE STANDARD TABLE OF ekpo.
SELECT * FROM ekpo INTO TABLE lt_ekpo.

DATA lt_ekpo_sorted TYPE SORTED TABLE OF ekpo WITH UNIQUE KEY ebeln ebelp.
SELECT * FROM ekpo INTO TABLE lt_ekpo_sorted ORDER BY ebeln ebelp.

"1.直接用where条件去过滤
DATA(lt_ekpo_filter_01) = FILTER #( lt_ekpo_sorted WHERE ebeln = '4500000048' ).
"Output filtered records
cl_demo_output=>display( lt_ekpo_filter_01 ).

"制作过滤条件table,过滤条件一定要有key值
DATA(lt_filter) = VALUE ty_filter_tab(
( matkl = '01' werks = '1000' )
( matkl = '01' werks = '3000' )
).

"2.按照过滤条件table过滤数据,
DATA(lt_ekpo_filter_02) = FILTER #( lt_ekpo IN lt_filter
                                 WHERE matkl = matkl
                                   AND werks = werks ).
"Output filtered records
cl_demo_output=>display( lt_ekpo_filter_02 ).

"3.排除过滤
DATA(lt_ekpo_filter_03) = FILTER #( lt_ekpo EXCEPT IN lt_filter
                                 WHERE matkl = matkl
                                   AND werks = werks ).
"Output filtered records
cl_demo_output=>display( lt_ekpo_filter_03 ).
  1. 过滤出4500000048的订单

2.过滤出(物料群组=01,工厂=1000) 或 (物料群组=01,工厂=3000)的数据

3.过滤排除掉(物料群组=01,工厂=1000) 或 (物料群组=01,工厂=3000)的数据

END

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2019-12-31,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 SAP TAB 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档