Skip to content

Report Assignment In Sap Query Table

I’m sure that some of you have used the functionality called report assignment when creating queries.  For those that have not, this is a function that allows you to assign additional reports that you can jump to within the query’s results.  As an example, you have a query of material master data.  You can assign a jump to the material master itself.  I found some issues with making this work properly, so I found a trick to make it do what I wanted.  Let me explain:

This report assignment function allows you to assign a transaction or another query (among other things) so that the transaction or query is called within the results.  I’ll show you where and how below.

My complaint about using a transaction is I often found that the field value that I expected to see populated was not.  This is particularly true with the material master.  I found using a query produces better results.  The key is the InfoSet.  I have to admit that I’m not 100% confident in my explanation of the code below, but I think I’m close.

Let’s use the example of the material master.  Create a simple InfoSet with a direct read of the table MARA and include only the key fields in the field group defaults.  I named my InfoSet “REPORT_ASSIGNMENT_MM03” because I’ll use it to execute the transaction MM03.  Name yours as you see fit.  You should have an InfoSet that looks like so:

Click on the “Extras” button and pick the “Code” tab and the “DATA” code section.  You could also go directly there by choosing the menu path Goto | Code | DATA.

Enter the following code:

Here is the code snippet:

PARAMETERS: matnr LIKE rmmg1-matnr. SET PARAMETER ID 'MAT' FIELD matnr. CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN. EXIT.

The PARAMETERS command defines a variable for the selection screen.  To define the variable, I used a structure variable that is linked with that screen field (RMMG1-MATNR).  You can find it by looking at the technical information in the help for that field.

I found that using the exact screen field is crucial when you want the query to populate the value into the screen.

Next, the SET PARAMETER command pushes the value from the query results into the parameter ID ‘MAT’ using the screen field variable defined above.

Looking again at the technical information, you can see the parameter ID for the field Material shown here.  You may note that this is the same ID that you would use in your user profile.

Next, you have the CALL TRANSACTION statement with the modifier SKIP FIRST SCREEN.  I think the effect here is pretty clear – run MM03 and skip the selection screen where you see the field for material.

Finally, you have an EXIT command to end the processing in the InfoSet after the user finishes with the MM03 transaction.  It effectively pushes the user back to the original results.

Save and generate the InfoSet.  Don’t forget to assign to the proper user group and provide any authorizations that you might use in your environment.  Now you’ll need to create a very basic query that incorporates the newly created InfoSet.

This query should be very basic – much like the InfoSet.  Give it a title and assign the one field to the basic list.

After saving, you’re ready to use this query in another query’s report assignment.  Go to your original query’s Title, Format screen and select the menu path Goto | Report Assignment.

This brings up the list of all reports that are assigned to this query.  Obviously, you can add more than one.  For example, you can add one entry for changing a material and another for displaying a material.

Click on the button indicated (label “Insert Row”).  Enter the user group and query name created previously.

Now the new “report” query is assigned.

If only one report is defined, the result of a double click within the results of the original query will take you straight into the material master skipping the initial screen.  Depending on your settings, you may be required to select the views and organizational levels.  If, as in my example above, you assign two queries, then you’ll see a popup window asking you to choose which option you want.

Although I haven’t tried it, you could conceivably build in a check for authority in the code of the new InfoSet.  If you have authority to change, the CALL TRANSACTION would take you to MM02, otherwise to MM03.

I have also created the similar InfoSet & query combinations for purchase orders and sales orders.

The screenshot above is for display of purchase orders.  In this case, the PARAMETERS definition follows the same approach that I used for the material master where the field you see when the transaction starts is not linked with the underlying table EKKO, but with a structure called RM06E.

The screenshot above is for display of sales orders.  In this case, the PARAMETERS definition is slightly different.  It does not reference the screen field.

For the transaction VA03, you can see that the screen field is linked with the transparent table VBAK and not a structure like RMMG1.  In this case, I used the Data Element, but could easily have used LIKE vbak-vbeln.

If you are familiar with SAP Query already, you know that you can generate some very robust results with a little extra effort in the InfoSet and query.  This trick is particularly helpful, in my opinion, because it turns a simple set of records into a interactive report.  I’d like to hear your comments on how you are using it!

Like this:

LikeLoading...

Related

Frequent Asked Questions on SAP Query SQ01

ERP SAP Modules ==> ABAP

What is the useful of SQ01? How it works?

SQ01 : is used to create Query form infoset you have created here you can select fields for selection screen and for list generation using check boxes.

You can generated different types of report using basic list, ranked list, statistics to output in graphical form.

SQ02 : is used to create infoset you need to tell the data source for your infoset like table join, direct read or data reterival using program, you can also put extras fields, structures and tables using extras button. and can code your own select query for that field or structure.

After generating the infoset you have to assign this to your usergroup you already created.

SQ03 : is used to create user groups for queries because every user have to be in at least one user group for creating infoset and queries. you have to create a user group and assign your user to that usergroup.

Our company just upgrade from 4.6C to ECC6. In the query environment (SQ01), everytime we want to enter sq01 we must change the query area (Environment --> Query Areas) to 'standard area'. How to set as default to 'standard area' . Currently it's default to 'GLobal area'. 

Insert parameter AQW as 'blank' in your user paramters. 

Insert a default query group via paramater AQB (check the user group name in SQ01).
 

How to put a transaction code in SQ01?  
For example:
I created a report with a query SQ01 to have a ALV grid.
I've the sales order number and others data.
I want to go directly to the sales order when I click onto the line of this ALV grid.

While editing your query in SQ01, use the menu path Goto -> Report Assignment. Press F6 or click the insert row button. On the popup that follows, click the "Other report type" button. Choose 'TR' type and then enter your transaction code. Save the settings on the "Assign Reports" popup and you are good to go.
 

What are the steps to transfer to production client?

Use transaction SE01 / SE09. Here choose "modifiable" and click "Display".

Now you get a list of all requests which can be released. 

Identify your request number. Release the sub-request first and then the main request by selecting and using the "transport" icon.
 

How can you use where conditions in sq01? Where do you write the sql statements?

You can write sql statements under the event" RECORD PROCESSING".

You can write sql statement under the event START-OF-SELECTION.

Whatever you are selecting the tables for query those will joined internally as inner join under the record processing event as loop. 

One by one record will get process under "RECORD PROCESSING"

So if you want to check or validate any field you can write here.  Here all the output data will be taken care by system itself in ALV GRID.

START-OF-SELECTION.

Here you can write all the code as in ABAP Editor.

ABAP Query Part 1

Get help for your ABAP problems
Do you have a ABAP Question?

ABAP Books
ABAP Certification, BAPI, Java, Web Programming, Smart Forms, Sapscripts Reference Books

More ABAP Tips

Best regards,
SAP Basis, ABAP Programming and Other IMG Stuff
http://www.erpgreat.com

All the site contents are Copyright © www.erpgreat.com and the content authors. All rights reserved.
All product names are trademarks of their respective companies.  The site www.erpgreat.com is in no way affiliated with SAP AG. 
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk. 
 The content on this site may not be reproduced or redistributed without the express written permission of 
www.erpgreat.com or the content authors.