我们经常会遇到如下的需求,在页面的几个输入框中输入参数,然后在根据输入条件显示结果集列表。这是最常见的report形式。可是问题是,在使用parameters作为参数的时候,某一项的值没有输入,sql执行后的结果与我们期望的不相符,根源在于某一字段为空,查询条件就会去搜索这一字段为空的值,结果往往是没有符合条件的结果。
对应这种情况,可以采取多种方法解决,如使用range,或者使用动态sql语句。但是也可以使用select options 来代替parameters进行输入参数定义。因为select options定义出来的实际上是一个内表,在查询的时候使用IN,即使没有输入,查询语句会忽略这一项的匹配,而不会取数据库里找寻没有值或为空的记录匹配。这样的查询结果才是我们所需要的。
然而,select options 默认会产生两个输入框,这与parameters有些不同,不过没有关系,在定义select options的时候只需要加上一些特殊操作即可以只显示第一个输入框,这样在外观上与parameters就很相似了。
如: SELECT-OPTIONS: so_gjahr FOR bsik-gjahr NO INTERVALS . 这样在查询的时候就不能按照 '=' 来设置查询条件了,而应该应 'IN' 来设置这个条件,即:…… where bsik-gjahr IN so_gjahr ……。这样,即使so_gjahr即使没有输入也不会影响到最终查询的结果。
abap 面试!
37. What are select options and how are they different from parameters?
select options provide
ranges where as parameters do not.
SELECT-OPTIONS declares an internal table which is automatically filled with values
or ranges
of values entered by the end user. For each SELECT-OPTIONS , the system creates a selection table.
SELECT-OPTIONS FOR .
A selection table is an internal table with fields SIGN, OPTION, LOW and
HIGH.
The type of LOW and HIGH is the same as that of .
The SIGN field can take the following values: I
Inclusive (should apply) E Exclusive (should not apply)
The OPTION field can take the following values: EQ Equal GT
Greater than NE Not equal BT Between LE Less
than or equal NB Not between LT Less than CP Contains pattern GE Greater
than or equal NP No pattern.
Select Options vs Parameters
PARAMETERS allow users to enter a single
value into an internal field within a report.
SELECT-OPTIONS allow users to fill an internal table with a range of
values.
For each PARAMETERS or SELECT-OPTIONS statement you should define text elements by choosing
Goto - Text
elements - Selection texts - Change.
Eg:- Parameters name(30).
when the user executes the ABAP/4 program,an
input field for 'name' will appear on the selection screen.You can change the comments on the left side of the input fields
by using text elements as described in Selection Texts.
分享到:
相关推荐
SAP-EWM-快速指南
COSHIP-SAP用户操作手册-MM-采购合同维护.doc COSHIP-SAP用户操作手册-MM不合格品处理.doc COSHIP-SAP用户操作手册-MM供应商主数据.doc COSHIP-SAP用户操作手册-MM信息记录维护.doc COSHIP-SAP用户操作手册-MM库存...
WDA中select option的用法
SAP-MM-UM-002 供应商主数据维护操作手册.doc SAP-MM-UM-003 供应商考核评估维护用户操作手册.doc SAP-MM-UM-004 信息记录维护操作手册 .doc SAP-MM-UM-005 货源清单维护用户操作手册.doc SAP-MM-UM-006 配额协议...
SAP BWBO 实战指南--像学习OFFICE一样学习BW,全篇。
SAP中文使用手册--FI总账相关方面的功能介绍
SAP ABAP 常用T-CODE SAP ABAP
SAP-FICO---快速指南
SAP 高级教程系列-QM模块
SAP-APO---快速指南.docx
SAP-CO-PC-Product-Costing-in-SAP-ERP6-0.pptx
SAP ME How to Guide - Message Board
云南鸿翔SAP培训------ABAP,abap的ppt,很好的资料哦
SAP-Fiori---快速指南
SAP-PP
SAP HANA HA360 - SAP HANA - Hands-on Lab(Col99).pdf
100小时学SAP之PP---生产篇DP版
Solution in Detail - SAP NetWeaver Single Sign-On
51SAP教育中心---SAP实施方法介绍TIM.pptx
sap中文使用手册--AP应付账款