Professional Documents
Culture Documents
This blog will focus on the capabilities of SAP Query (a.k.a. Adhoc Query) and Creating Custom
fields in infosets, with emphasis on HR Module.
Most of the reporting needs of an organization can be addressed through Adhoc Queries. For
some specific requirements we will need custom ABAP reports, and to create custom fields
ABAP knowledge is required.
First let’s refresh some concepts, processes and transactions involved in the process.
Logical database will always use inner join and will skip the rows that will not match in
corresponding infotypes. For example: You are trying to create a query with Pernr and name
from infotype 2 and Work Address from infotype 6. Then the report will not include the persons
that do not have a work address. Only employees shown on the report will be those that have a
work address subtype of infotype 6 populated. This constraint is usually overlooked and it results
in wrong reports.
1. Go to Transaction SQ02.
2. Give Infoset a description, give source of data for infoset i.e. Logical Database or Tables etc.
3. If you have used logical database e.g. PNPCE then a screen will pop-up to select the infotypes.
a. Select the infotypes and continue.
b. If you later want to add more infotypes then click on menu item ‘Edit’ -> ‘Change Info-Type Selection’
and add or remove the infotypes.
4. If you have used tables then only give one table name and you will be brought to the screen where you can
add more tables and specify joins between tables.
a. To add more tables, click on ‘Join Tables’ and click on ‘Insert Tables’.
b. You can drag and drop the matching field from one table to another to specify joins, you can also
change the join type from inner join to outer join.
5. There is an area ‘Field Group’ in infoset screen, only the fields that appear here will be available while creating
queries. All fields from infotypes may not be available in field groups, so you will have to manually drag and
drop them in appropriate field groups.
6. On the left hand side, under each node of infotype/table you will see some fields in blank or blue text color.
Blue fields are those that are included in the infoset and hence available for reporting in SQ01.
7. Save and generate your infoset. This is mandatory, as when you generate the infoset, a program is generated
with the code reflecting your changes in infoset.
1. Give name of the query you want to create and hit create button.
2. You will be asked the name of the infoset that you want to use.
NOTE: You cannot change the infoset later, so be sure which infoset you want to
choose, otherwise you will have to create a new query to choose a different infoset.
1. There will be various options on next screen regarding output format, title etc. which are pretty self
explanatory and we will not go into details of them.
2. A faster way will be to click on ‘Basic List’ button.
3. Expand the infotype in which you are interested.
4. You will see two check boxes in front of each field.
a. First box is to display the field on the report.
b. Second box is to display the field on the selection screen to restrict the records based on some criteria.
5. Fields will by default have same order in which you select them. It can be changed visa dragging and dropping
on appropriate location in right hand pane.
6. Each infotype will have ‘Additional Fields’ node which contains the texts for codes like for Position, it will
contain a field text:position which will display the STEXT for that position.
7. Save and Run your report.
We can create fields that will fetch data according to out own logic, fields that are not provided
by SAP. For that, you will need ABAP access to the system, so if you are working in Production
or Quality system then most probably you will not have authorization for that. If you need
custom development then best place is the Development environment. We can then either
transport the infoset from Development to next systems or we can download and upload it in
production (which will again need production system to be opened for some time).
Tips:
1. If you are working on custom fields in infoset and have opened a query in another session then the changes in
custom fields will not be seen in that query. You need to generate the query again, go to tcode SQ01, select
the query, go to menu option ‘Query -> More Functions -> Generate Program’, then go out of SQ01 transaction
and then come back to SQ01 and select your query
2. If you have changed the data types of custom field in infoset then you need to ‘Adjust’ the query, it is easy,
again come out of SQ01 and then go back, it will automatically ask for updating the new changes. Click on
‘Automatically Adjust’ check box next to each field and update the query. Otherwise you can go to menu option
‘Query -> More Functions -> Adjust’.
Local Fields:
Local Fields are used in queries, if you already have your infoset developed and want to include
some simple logic then Local Fields can be useful. They are usually a calculation on another
field, like for example if you want to add a field for membership status depending on field Age
(Assuming you already have a field Age in your infoset, or Age is another calculated local field).
You will find rest of the items on the above screen pretty self explanatory, click on ‘Complex
Calculation’ (there is nothing complex here, do not worry).
Report Assignment:
A very very interesting area that is mostly ignored and has a great potential for interactive
reporting. To use this feature, go to menu item ‘Goto -> Report Assignment’.
Lets say we are developing a simple report in HR, that displays Personnal Number, First Name
and Last Name. Your report lists a lot of record and you want the user to have power to double
click on any employee row and then open up the details in PA20. Isn’t that fascinating?
Another example would be that when a user double click a query row, the data of that employee
is passed to an ABAP Program and that triggers some interface or whatever is coded in that
program.
Report Assignment is in fact making the reports interactive. SAP provides various options for
that. It will take many pages to go through all of them, for the sake of understanding we will go
through the simplest of them.
Click on ‘Other report type’ and you will see the available options. Here are the actions that can
be done when user double clicks the row:
Select ‘Transaction’, on next screen you will be asked to enter the TCODE.
Save the program, and run the report. And, double click on any person’s record and you will be
brought to transaction PA20 with that person’s data populated on the screen. You can also
choose to go to PA30 so that user can change the data quickly.