QUERY
[Link]
SQ03 SAP Query: Maintain user groups BC-SRV-QUE
SQ00 SAP Query: Start queries BC-SRV-QUE
SQ11 SAP Query: Web reporting (Admin) BC-SRV-QUE
SQ09 SAP Query: Maintain additional func. BC-SRV-QUE
SQ10 SAP Query: Role Administration BC-SRV-QUE
SQ01 SAP Query: Maintain queries BC-SRV-QUE
SQ02 SAP Query: Maintain InfoSet BC-SRV-QUE
SQVI QuickViewer BC-SRV-QUE
SQ07 SAP Query: Language comparison BC-SRV-QUE
I/ Introduction
1. InfoSet
Infoset is a special kind of Infoprovider which does not store data physically.
In other words, Infoset are InfoProviders that logically join data and provide this data for BI queries. Infoset collects
data from the tables of InfoProviders used to build it.
(InfoSet là một dạng join data từ các table, hoàn toàn là data động => thay đổi và update data từ sự thay đổi của
data trên các table là nó join), bên cạnh việc sử dụng InfoSet trong các báo cáo Query, thì còn sử dụng trong BI,
BW
Infoset describes data sources that are defined as a rule of join on Datastore objects, Info-objects or standard
InfoCubes.
Việc tạo Infoset là join các table, dựa trên các key fields, hoặc mình có thể tự join các field với nhau, tạo fields mới,
gán giá trị mới cho field với các logics do mình code
When to Use Infosets?
To join required data from basic InfoProviders
To allow BEx Reporting on a DataStore object without turning the BEx Reporting indicator on
To evaluate time dependencies
To create self joins and left outer joins
What are InfoSet Joins ?
DSO ( Data Store Objects) and/or InfoObjects (characteristics with master data) are connected in the InfoSet using
join conditions. The joined data from the InfoSets are available for access from Business Explorer Queries.
InfoSets allows you to report on several Info-Providers (Infocubes, Data Store objects, master data InfoObjects), but
they contain no data. With activated Infosets , you can define queries in the BI suite.
Joins are classified into four categories:
1. Inner Join
2. Left Outer Join
3. Temporal Join
4. Self Join
(Check lại loại Join 3 và 4)
2. Query
SAP Query is used to create reports for users who have little knowledge about SAP Table data storage structure.
SAP Query allows evaluating data in the SAP system.
SAP Query offers users a broad range of ways to define reporting programs and create different types of reports
such as basic lists, statistics, and ranked lists.
SAP Query – Features:
Following are the major components which are associated with SAP Query:
Info Sets – Are base for the Query and it contains one or more database table details
Queries – For the User to create and generate the Query
User Group – To restrict set of Users for a specific Query plus for Authorizations
Quick Viewer – A simple tool for quick report generation
SAP Query – Creation:
Step 1: Creation of User Group – SQ03
Step 2: Creation of Infoset – SQ02
Step 3: Creation of Query – SQ01
The Terminologies:
SAP Query – Area:
SAP Query Area is a set of objects having queries, InfoSets and User Groups which are consistent.
Following Query Areas:
Standard Area – They are Client Specific Queries and do not create an Work Bench Request
Global Area – Queries in the Global Area are Client Independent
Tạo user group => Infoset => Query
II/ PROCESS
1. Create user group SQ03
To restrict set of Users for a specific Query plus for Authorizations
User group sau đó sẽ được sử dụng để nhóm các InfoSet
2. Create InfoSet SQ02
Query Area: Standard (thực hiện Export và Import qua các môi trường) và Golbal (sẽ sinh TR)
Nếu dùng Standard thì có thể tạo Query trực tiếp trên PRD, nhưng Tcode thì vẫn tạo trên Dev =>
sau đó transport
- Data Fields: các field tương ứng trong các table được join. Các field mà tạo thêm
sẽ nằm trong phần Additonal fields
- Field group/data fields: đây là phần chứa các field mà sẽ được sử dụng (tại
SQ01 để chọn lấy lên, hoặc sử dụng để code thêm tại SQ02). Nếu field nào ko
được add vào một trong các group ở đây thì ko thể xử lý được
Join table
- Chọn Edit/Insert table nếu muốn join thêm table
- Join giữa các field của các table: có 2 loại join:
+ Inner join: đây là mapping 1-1, nếu A và B cùng có data thì mới lấy lên
+ Left outer join: mapping lấy tất cả, TH A có mà B ko có thì lấy A lên, giá trị
của B bỏ trống
Có thể kéo thả chuột để kéo đường link giữa các field của các table
- Cần chọn các field muốn xử lý, hiển thị sang phần Field group/Data field
Kéo thả sang bên Group chọn, hoặc đặt chuột phải như hình => field sau khi được chọn
sẽ có màu xanh
Trường hợp muốn tạo mới Field group, chọn
Trường hợp muốn tạo mới Field
Chọn Extras – Create – Addition field (TH muốn tạo mới table thì chọn Additional table)
- Điền tên technical field
- Điền các thông tin chi tiết của field
Có 2 cách điền:
+ theo LIKE Reference: chọn table và field muốn tạo các thông số giống
+ điền mannual: type, length (độ dài thực tế), output lengh (độ dài hiển thì trên field),
decimal (phần thập phân)
Nếu muốn hệ thống tự lấy text / description của field đó, tích như sau
=> tự lấy được text của field đó như sau
-Có thể code thêm vào các field tạo mới, hoặc field có sẵn
Chọn Code Selection: 5 Record Processing
Cách code như hình: kết thúc 1 line là dấu chấm …
Sau đó chọn để kiểm tra và sửa lỗi nếu có
Sau khi chỉnh sửa và xong hết các thông tin, chọn để tạo Infoset, và Save
Trường hợp muốn lấy dữ liệu từ nhiều field (table khác nhau), VD condition type tùy
combination mà lưu data ở các table khác nhau => code sử dụng lệnh concatenate … into
Loại bỏ giá trị rỗng
Trường hợp muốn loại bỏ các giá trị bằng 0 của các field đi, làm như sau:
VD:
Code như sau:
Code >< nghĩa là loại bỏ các giá trị
Concatenate ngày tháng năm
Định dạng ngày tháng năm không thể sử dụng hàm concatenate như bình thường, code như sau:
Hàm Conversion
Trường hợp muốn convert đơn vị (vd từ order unit => base unit) để lấy được tỉ lệ quy đổi, sẽ sử
dụng hàm conversion: MD_CONVERT_MATERIAL_UNIT
Muốn test hoạt động của Function module, sử dụng tcode SE30 như sau:
To test the performance of a function module:
1. Choose Function Modules → Runtime analysis (transaction SE30). The system executes the function
module and records the performance function in a performance data file.
2. To display the results of the analysis, choose Eval. rtime analysis.
Chọn Pattern => điền Function
Always have Selection fields from InfoSet (Tip4)
Create Radio button (Tip 8)
Display message in Status bar
SELECTION SCREEN
ALV OUTPUT
Interested? Then Do these small things in your Infosets.
1. In the Extras push button space of Infoset, you have a Code Tab-page. Here you select
‘AT SELECTION-SCREEN OUTPUT’ from the drop down list and give code like shown in
the picture, by customising as per your need. Save the code.
This results in displaying the message within quotes, in the status bar of the selection-screen as
soon as you run the query (through a Tcode or through SQ01)
(Like shown in the picture1 of this document)
1. Now, again in the Extras push button space, in the Code Tab-page. select
‘END-OF-SELECTION (after list)’ option from the drop down list and give code like shown in
the picture, by customising as per your need.
This results in the display of the message in the Status bar of the ALV output.
(Like shown in the picture2 of this document)
Note: In the code Type ‘S’ syntax makes this message appear in Status bar. If it is Type ‘I’ it
would be appearing as a pop-up.
Just to remind
After changes and Generation of Infoset, we should not forget that the changes will be seen
in the Infoset Query, only after Executing SQ01 once.
Export và Import Query to other Client
Tcode: SQ02, bởi vì sử dụng Query Area là Standard => nên muốn chuyển giữa các client cần
thực hiện Export và Import tương ứng (nếu là Global area sẽ sinh TR)
1. Export
2. Import
Nếu query or InfoSet đã có thì chọn Overwriting allowed
3. Create Query SQ01
- Data field: các group, field được add vào phần Group tại SQ02
+ Field display in list: hiển thị lên report
+ Selection sreen: là selection sreen
Nếu muốn sort các cột thì kéo chọn Field đó vào phần Sort field, chọn biểu tường Sort để xếp
tăng dần or giảm dần. Muốn bỏ Sort field thì kéo chọn vào Trash can
Sau khi define xong, chọn để chạy thử report.
Calling reports from InfoSet Query reports (tip2)
Sort fields
Make report colorful (tip3)
4. Quick Viewer SQVI
join table và lấy data trực tiếp => quick viewer
5. Create Tcode for Query SE93