Associate SAP Query to a Transaction Code

So many times I saw Transaction Code for SAP Query defined in a strange way; many ABAP developers uses to create a TCode for SAP Query as they do for common reports.

This is dangerous because the report is auto-generated and sometimes this report changes (especially after a system upgrade) or it does not contains new implementations (you have to force regeneration).

The right way to create a Transaction Code is to refers directly to the SAP Query (AQQU object type).

From transaction SE93 create a new Object as shown in the image below

Abap query

in the next screen complete the fields

Transaction START_REPORT

Skip initial screen X

Box “Classification” (as you want)

Box “Default value” add the following parameters:

D_SREPOVARI-REPORTTYPE AQ
D_SREPOVARI-EXTDREPORT <sap query name in SQ01>
D_SREPOVARI-REPORT <user groups belonging to the query>

If user group is in global area you ave to add “<space>G”.

For example if you want to use the query ZQUERY in global user group area ZUSERGR you have to set:

D_SREPOVARI-REPORTTYPE AQ
D_SREPOVARI-EXTDREPORT ZQUERY
D_SREPOVARI-REPORT ZUSERGR G

Further informations on SAP Query could be found on OSS note “393160 – SAP Query Using queries.pdf”.

8 Comments

  1. Valentin says:

    Hi,

    I have tried your solution but it doesn’t work. The problem is that D_SREPOVARI-REPORT should be: first 12 chars name of the user group and than the “G” flag; more exactly:
    “ZUSERGR G” -> total of 13 chars

    BR,

  2. Ivan Femia says:

    This is not a solution, it is the standard behavior. Btw I don’t understand your comment

    ZUSERGR -> 7 chars
    space -> 1 char
    G -> 1 char

    Total 9 chars

    Indeed in table SREPOVARI (ECC)
    Field Data element
    REPORT PROGNAME CHAR 40 0 ABAP Program Name

    Regards,
    Ivan

  3. j says:

    Hi,
    I’m trying associate a transaction to a view.
    I have build a view, ZMATPRICE, with se11, the view includes camps of MARA, MAKT and MBEW, and i want call him from a transaction.

    What transaction can i use?

  4. Ivan Femia says:

    Hi,

    you have to create your own Custom transaction code from SE93 calling a table maintenance.
    1 – Create a new Transaction with parameters
    2 – Associate transaction SM30 with skip initial screen
    3 – add the following parameters: VIEWNAME and SHOW ‘X’

    Regards
    Ivan

  5. j says:

    Hi,

    thanks.

    ,regards

    J

  6. Bharath says:

    Hi, good post, thank you

  7. Steve says:

    In our system I found that the username was 12 characters so the ‘G’ for global area had to be in position 14, that is, 12 + space + ‘G’.

    Hopefully this is useful to someone else who finds this post. Also there is a forth parameter “D_SREPOVARI-VARIANT” if yoiu want to pre-select a query variant.

    cheers
    S.

  8. Ohoboho says:

    If i understand correct there should be enough spaces after D_SREPOVARI-REPORT so G to be on 13 position ? Is this correct or this is system dependent behaviour

0 Trackbacks

Leave a Reply

%d bloggers like this: