Infoset Query: User Defined Fields _______________________________________________________________________
Author: Jogeswara Rao Kavala
We know that Infoset Query is a report development tool given to Functional people by SAP. Using this, a Functional person can be independent of ABAP to a large extent in the area of Report programs. Infoset query is cross-functional application. Though this document demos in Plant Maintenance environment, it is believed to be useful for other Functional people also.
This document is based on the assumption that the readers have basic working knowledge in the area of Infoset Queries which involve Tcodes SQ03, SQ02 and SQ01. Points discussed here, take an Infoset query closer to an ABAP report program.
2. Customer defined fields
Most of us, especially beginners, usually work on standard fields available in the tables we work on, in the Infoset (SQ02). But, sooner almost everyone gets the desire to have his/her own defined fields in the report as a function of standard fields. Such fields are also referred to as Derived fields, Local fields or Additional fields.
About the task chosen to Demo this
A client has a requirement to compute the duration of fields Required Start Date & Time and Required End Date & Time in a Notification (VIQMEL table). The same is taken for demo here. Hereon we will be referring to this field as ' mnthr ' .
(The above is an example of how requirements arise for derived fields. In IW28 standard report, we have computed duration for Malfunction Dates, but not for the fields referred above.)
Two ways to do this:
1.To define and compute this 'mnthr' field in the Infoset (SQ02)
SQ02 --> Click on Extras button
Click on Create icon in the Extras Tab.
In the pop-up, select Additional Field option and give the Additional field name as say MNTHR.
Continue and define the details and Continue .
After this step we see a node created for Additional fields in the left side.
Also in Extras tab on the right.
Now, place the cursor on the field name and click on ' CodingForAddition' icon.
You are now taken to the Code tab.
Here, give the code to calculate the Duration (mnthr)
We have used a function module to easily calculate the duration between two Dates and Times.
This might look complex initially for beginners, but if you try it is simple application to understand.
One data type ‘duration’ (type i) declared here for temporary use in this code, because we import the duration from FM in this form (seconds).
So, we got the value here for the additional field, we defined (in the form of seconds). To convert the same into Hrs the last line of coding used.
(In other situations, the additional-field value calculation might be much simpler like some arithmetic expression of few standard fields. The coding will be done accordingly)
All done. Now, you can drag this mnthr into desired Field Group on the right, to have this field in SQ01 for reports.
2.Now let’s see how we do this in Infoset Query way (SQ01)
Reach the following field selection screen in SQ01.
We see this (Short Name, Local field indicator columns appear)
Now go to the fields which are the components of the formula to calculate your duration (mnthr)
We know they are Required Start Date & Time and Required End Date & Time.
(I need not mention that these fields have come from the VIQMEL table fields selected in Infoset, SQ02)
And identify them with some Short names like shown below.
Now let us create our Local field (Additional field) mnthr, as under.
Now define the parameters of the field as under.
Now we need to give our code in the Calculation formula seen at the bottom.
If our code is simple we can give it in this screen itself. If it contains more if s then we need to click on Complex Calculation button and to give the full code. (Our present case needs to go here)
So now, are giving the following code in the complex calculation screen.
(Note that what we mention against ‘Condition’ fields here, are nothing but ‘IF’ in ABAP coding.)
You may try to understand the logic (Condition vs Formula) given above, so that the formula giving would be easier for your other requirements.
Select this field by ticking the Check-box in the Field selection screen to have it in the Basic List Fields.
(Also we need to select this field in Basic List screen too as we always do.)
Now this field will appear in the Local Fields node of the Basic list screen of SQ01.
- In an Infoset query, we can have user fields derived from both SQ02 and SQ01.
- A user field created in SQ02 would appear in ‘Additional Fields’ node and a user field created in SQ01 would appear in ‘Local Fields’ node in the Basic List screen (SQ01).
- The above narration mainly illustrates the procedure to have user defined fields. A little complex example has been demonstrated here, so that simple requirements can be easily met.
- The author wishes to compile some more useful points in the area of Infoset queries, into another document.
Jogeswara Rao K