使用外部程序为Query提供数据
2011-06-20 10:38
453 查看
Query 很强大,通过下面的Help说明,可以实现使用ABAP程序来为InfoSet提供数据源,然后再作进一步的处理。
Retrieving Data with Programs
If you want to make evaluations for datasets, but SAP Query automatic data retrieval is not sufficient for the task, create an InfoSet by selecting the field Data Retrieval with Program in the Title and Database screen, then specify a program name and the name of a structure. This structure must reflect the record structure of the dataset you want to evaluate.
If you use the component Maintain Queries to create a query for this InfoSet, SAP Query uses the report as a model when generating the query report; the model report itself thus remains unchanged.
Before generating the InfoSet for the first time, you must create the model report yourself in the ABAP editor. The model report has to be syntactically correct and have the same definition for fixed point arithmetic as the InfoSet. It is not, however, intended that the model report itself be executed.
The structure of this model report and the sequence of its parts are regular. The main structure of a model report is given below.
Note : If the model report components are in the wrong sequence, SAP Query may generate meaningless reports. The character strings of the two comment lines *<QUERY_HEAD> and *<QUERY_BODY> are fixed to start immediately after the character “<”, but the system does not distinguish between upper and lower case.
Continue:
Generating the InfoSet is possible only if the model report exists, conforms to the above conventions, is free of syntax errors and has the correct fixed point arithmetic setting.
When you generate query reports which use a model report, the generated reports inherit the attributes of the model report. In the end, this allows you to retrieve data by using a logical database. However, you should onl
b80e
y make use of this option in special cases, since if you are using a logical database, it is better to set up the InfoSet this way also.
Below is a model report which uses the SELECT statement:
*————————————————————————–
* data retrieval program for functional area FLDP
*————————————————————————–
REPORT AQ00FLDP.
TABLES SAPLANE.
SELECT-OPTIONS TYPE FOR SAPLANE-PLANETYPE.
*<Query_head>
select * from saplane where planetype in type.
*<Query_body>
endselect.
Below is a model report which uses the LOOP statement:
*————————————————————————–
* data retrieval program for functional area FLDX
*————————————————————————–
REPORT AQ00FLDX.
TABLES: SAPLANE, INDX.
DATA: PLANEDATA LIKE SAPLANE OCCURS 100 WITH HEADER LINE.
SELECT-OPTIONS TYPE FOR PLANEDATA-PLANETYPE.
*<Query_head>
IMPORT PLANEDATA FROM DATABASE INDX(PL) ID ‘PLANEDAT’.
LOOP AT PLANEDATA WHERE PLANETYPE IN TYPE.
MOVE-CORRESPONDING PLANEDATA TO SAPLANE.
*<Query_body>
ENDLOOP.
The data is retrieved and placed in an internal table which is filled by an import from the INDX. In the LOOP structure, each line must be read from PLANEDATA into SAPLANE because the InfoSet was created via the structure SAPLANE and the query expects the data in a field string called SAPLANE.
You can see all the options available for you to use with InfoSets using logical databases in the screen for InfoSet maintenance, for example connecting additional tables and the definition of additional fields, and so on. Make a special note of the special features called Sequential Datasets at the end of the section.
InfoSets which retrieve data using a program, offer you a wide range of options. In a model report, there are no restrictions on how you should organize the retrieval of your data. Therefore you can use very complex algorithms. SELECT statements that read on a cross-client basis can also be used (option CLIENT SPECIFIED).
Retrieving Data with Programs
If you want to make evaluations for datasets, but SAP Query automatic data retrieval is not sufficient for the task, create an InfoSet by selecting the field Data Retrieval with Program in the Title and Database screen, then specify a program name and the name of a structure. This structure must reflect the record structure of the dataset you want to evaluate.
If you use the component Maintain Queries to create a query for this InfoSet, SAP Query uses the report as a model when generating the query report; the model report itself thus remains unchanged.
Before generating the InfoSet for the first time, you must create the model report yourself in the ABAP editor. The model report has to be syntactically correct and have the same definition for fixed point arithmetic as the InfoSet. It is not, however, intended that the model report itself be executed.
The structure of this model report and the sequence of its parts are regular. The main structure of a model report is given below.
Report xxxxxxxx . | |
Tables tab . | Definition of Dictionary structure used to set up the InfoSet. This structure must contain the records you want to evaluate. |
Parameters . | Definition of parameters, selection criteria, and fields. |
Select-Options:… | |
DATA :… | |
DATA: BEGIN OF itab OCCURS xxx. INCLUDE STRUCTURE tab. DATA: END of itab. | Definition of an internal table <itab> with structure <tab> which provides the records you want to evaluate. |
* <Query_head> | This comment must always appear after your data declarations. |
* Code to define the table itab, if such a table is used. * Beginning of a loop to retrieve each record and place it in the structure tab (SELECT, DO, LOOP, …) * Code for formatting data (if necessary) | |
* <Query_body> | This comment must always be the last ’statement’ in the loop. The data must be available in structure tab. |
* End of data retrieval loop for individual records (ENDSELECT, ENDDO, ENDLOOP;…) | |
Note : If the model report components are in the wrong sequence, SAP Query may generate meaningless reports. The character strings of the two comment lines *<QUERY_HEAD> and *<QUERY_BODY> are fixed to start immediately after the character “<”, but the system does not distinguish between upper and lower case.
Continue:
Generating the InfoSet is possible only if the model report exists, conforms to the above conventions, is free of syntax errors and has the correct fixed point arithmetic setting.
When you generate query reports which use a model report, the generated reports inherit the attributes of the model report. In the end, this allows you to retrieve data by using a logical database. However, you should onl
b80e
y make use of this option in special cases, since if you are using a logical database, it is better to set up the InfoSet this way also.
Below is a model report which uses the SELECT statement:
*————————————————————————–
* data retrieval program for functional area FLDP
*————————————————————————–
REPORT AQ00FLDP.
TABLES SAPLANE.
SELECT-OPTIONS TYPE FOR SAPLANE-PLANETYPE.
*<Query_head>
select * from saplane where planetype in type.
*<Query_body>
endselect.
Below is a model report which uses the LOOP statement:
*————————————————————————–
* data retrieval program for functional area FLDX
*————————————————————————–
REPORT AQ00FLDX.
TABLES: SAPLANE, INDX.
DATA: PLANEDATA LIKE SAPLANE OCCURS 100 WITH HEADER LINE.
SELECT-OPTIONS TYPE FOR PLANEDATA-PLANETYPE.
*<Query_head>
IMPORT PLANEDATA FROM DATABASE INDX(PL) ID ‘PLANEDAT’.
LOOP AT PLANEDATA WHERE PLANETYPE IN TYPE.
MOVE-CORRESPONDING PLANEDATA TO SAPLANE.
*<Query_body>
ENDLOOP.
The data is retrieved and placed in an internal table which is filled by an import from the INDX. In the LOOP structure, each line must be read from PLANEDATA into SAPLANE because the InfoSet was created via the structure SAPLANE and the query expects the data in a field string called SAPLANE.
You can see all the options available for you to use with InfoSets using logical databases in the screen for InfoSet maintenance, for example connecting additional tables and the definition of additional fields, and so on. Make a special note of the special features called Sequential Datasets at the end of the section.
InfoSets which retrieve data using a program, offer you a wide range of options. In a model report, there are no restrictions on how you should organize the retrieval of your data. Therefore you can use very complex algorithms. SELECT statements that read on a cross-client basis can also be used (option CLIENT SPECIFIED).
相关文章推荐
- 九宫格 Swift提供经典的数组和字典两种集合类型来存储集合数据,使用数组实现一个九宫格程序,
- 数据提供程序中Command组件使用
- (WebSite----Asp.Net Configuration----->无法连接到SQL Server数据库------>选择数据存储区---->应用程序当前被配置为使用提供程序:AspNetSqlProvider)解决方案
- Flex 3: 构建高级用户界面 使用数据提供程序1
- 使用SQL数据提供程序访问MSSQL数据库
- Flex 3:构建高级用户界面 使用数据提供程序2
- 使用OLEDB访问数据时未在本地计算机上注册“OraOLEDB.Oracle”提供程序解决方案
- (WebSite----Asp.Net Configuration----->无法连接到SQL Server数据库------>选择数据存储区---->应用程序当前被配置为使用提供程序:AspNetSqlProvider)解决方案
- 将表拖到O/R设计器提示:所选对象使用不支持的数据提供程序
- 如何:使用反射提供程序创建数据服务(WCF 数据服务)
- 微信小程序 异步请求拿数据+使用外部js库
- Net Core 使用外部登陆提供程序登陆的流程,以及身份认证的流程
- 合理使用.NET数据提供程序DataReader还是DataSet?
- 介绍如何使用 Jet OLE DB 提供程序 4.0 连接到不同的外部数据库
- 编写提供程序数据外部接口的程序
- webservice实际应用之调用外部系统提供的服务端地址,写java的webservice客户端程序并通过接口给外部系统传数据
- 使用反射提供程序创建数据服务(WCF 数据服务)
- Flex 3:构建高级用户界面 使用数据提供程序3
- 使用OLE DB数据提供程序访问MSSQL数据库
- Android之 内容提供器(1)——使用内容提供器访问其它程序共享的数据