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!
You have a PO report and wants to drill in to each PO in enjoy transaction code ME23N. This is usually not possible, and most of you will just use ME23 to display.
I will explain how to do this with ME23N.
Step 1: SQ02
a) Create a infoset e.g. MM_DISPLAY_PO, and name your infoset.
b) You select Direct Read of table EKPO.
c) You should have PO and Item in your field group.
d) Under “Extras” tab, create a code.
e) Put in below codes:
SET PARAMETER ID ‘BSP’ FIELD EKPO–ebelp.
SET PARAMETER ID ‘BES’ FIELD EKPO–ebeln.
CALL FUNCTION ‘ME_DISPLAY_PURCHASE_DOCUMENT’
i_ebeln = EKPO–ebeln
i_ebelp = EKPO–ebelp
i_enjoy = ‘X’
OTHERS = 1.
f) Save code, infoset and generate.
e) Assign this infoset to a dummy user group. E.g. IT_DUMMY
Step 2: SQ01
a) Go to your dummy group.
b) Create a query e.g. MM_DISPLAY_PO and reference to your new infoset above.
c) Have the 2 available fields Purchase Order and Item in your selection screen and list field under Basic list.
d) Save your query and try it out with some PO number in your selection screen. You should be able to go to the respective PO.
a) For your PO report in your main query group, do a report assignment to the dummy query group and query you have created above. This is found in change mode –> menu –> Goto –> Report assignment. Fill in the dummy group and query you have from above and save in the pop up box.
b) Save your main PO report query.
c) Run your main report and execute it. when you double click on the respective PO line, you should now be able to see ME23N with the respective PO!!!