Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

SQVI Query

Former Member
0 Kudos

Dear All, please help me about SQVI..

I have converted from the SQVI quickview to query in development client, then assigned the query (program name) to T-code using SE93. Then, i've downloaded the query from development client and uploaded it to quality client..

After uploaded to quality client, the program name for the query was changed. So, the T-code said that the program "AQxxxxxxxxxxxxxZxxxxx not found" because there is different names between development and quality client..

I have questions:

  1. Can i have the same names between both clients? If it can't, what must i do?
  2. Do i have to create the SQVI query direct in the quality clients or transport from development client like i've done?

Please give me advice through this problem..

Thanks before..

10 REPLIES 10

Matt_Fraser
Active Contributor
0 Kudos

Hi Sylviani,

I believe the reason you are getting different program names in DEV and QAS for your query is because of using the 'download' and 'upload' options to move the query. If you use 'export' instead, then the query (and possibly its infoset, depending on the option you choose) should be written to a standard transport, which can then be imported to QAS (and later PRD) via conventional transport means. This should keep your program name consistent across the systems, and thus your tcode assignment should work.

Regards,

Matt

0 Kudos

Hi Matt..

Thanks for your advice..

I did what you said, i exported and imported the infoset and query with RSAQR3TR.. But, when i checked the program name in quality client, still it's different from the development client..

I also tried transport with help from BASIS, but the query doesnt'exist in quality client..

Is there something wrong with the steps?

Thanks..

0 Kudos

Hi Sylviani

This most likely occurred as the query is created in the 'Standard Query Area' and the generated ABAP program linked to a transaction code. so when the query is exported to a pc/laptop and imported into a QA system the target system, so when running the transaction code, the system cannot find the program.

Basically, a query should not be accessed using the name of the report generated by it (for example, by 'submit') because the name may change (for example, when upgrading from Release 3.x to 4.x), and also because the code generated may not necessarily correspond to the current query definition (the code may not be available in the system at all, even though the definition of the query is available in the system).

Below is a comparison between a Development and Production system, for the SAP Query, the generated program names:

The program is broken down as follows:

  • 1st 2 characters indicate it is a query, i.e. ‘AQ’
  • 2nd 2 characters indicate a generated ID, i.e. ‘CS’ = DEV and ‘IC’ = PRD (note global queries use a different identifier)
  • 3rd group of characters indicates the User Group with ‘=’ included to pad the group, i.e. ‘ZSD=========’
  • 4th group of characters indicates the Query Name, i.e. ‘ZSDCONTLINKORD’

The solution is to apply the guideline as given in the SAP OSS Note 393160 - SAP Query: Using queries.

Basically it can be broken down into 4 steps:

1. Create a custom table

2. Create a custom program

*&---------------------------------------------------------------------*

*& Report  ZBW_GEN_CALL_QUERY

*&

*&---------------------------------------------------------------------*

*&

*& Version 2.0

*&---------------------------------------------------------------------*

REPORT  ZBW_GEN_CALL_QUERY.

INCLUDE RSAQCOMC.

INCLUDE RSAQCOM1.

* Reference to tables

TABLES: ZBW_GEN_QRY.

* Declaration of internal tables

DATA: BEGIN OF itab_QUERY OCCURS 0.

        INCLUDE STRUCTURE ZBW_GEN_QRY.

DATA: END OF itab_QUERY.

* Declaration of variables

DATA: p_wsid  TYPE C LENGTH 1,

      p_ugroup TYPE bgname,

      p_query TYPE quname,

      p_vari TYPE vari.

* call via IQAPI_QCALL (as of Release 6.10 )

DATA: qid TYPE AQLQID.

* Get the query linked to the transaction

SELECT *

  INTO CORRESPONDING FIELDS OF TABLE itab_QUERY

  FROM ZBW_GEN_QRY

  WHERE ZTCODE = SY-TCODE.

IF SY-SUBRC = 0.

  READ TABLE itab_QUERY

    WITH KEY ZTCODE = SY-TCODE.

  IF SY-SUBRC = 0.

    CASE itab_QUERY-ZWSID.

* Global Query Area

      WHEN 'X'.

        qid-workspace = ws_global.

        p_wsid = itab_QUERY-ZWSID.

        p_ugroup = itab_QUERY-ZUGROUP.

        p_query = itab_QUERY-ZQUERY.

        IF itab_QUERY-ZVARI = ''.

          p_vari = SPACE.

        ELSE.

          p_vari = itab_QUERY-ZVARI.

        ENDIF.

* Standard Query Area

      WHEN OTHERS.

        qid-workspace = ws_standard.

        p_wsid = SPACE.

        p_ugroup = itab_QUERY-ZUGROUP.

        p_query = itab_QUERY-ZQUERY.

        IF itab_QUERY-ZVARI = ''.

          p_vari = SPACE.

        ELSE.

          p_vari = itab_QUERY-ZVARI.

        ENDIF.

    ENDCASE.

  ENDIF.

ENDIF.

* User Group and Query to QID

qid-usergroup = p_ugroup.

qid-query = p_query.

* Call the Query

CALL FUNCTION 'IQAPI_QCALL'

  EXPORTING

    OLD_QID = qid

    VARIANT = p_vari

  EXCEPTIONS

    OTHERS  = 1.

IF SY-SUBRC <> 0.

  MESSAGE ID sy-msgid TYPE 'I' number sy-msgno

    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

CLEAR: itab_QUERY.

REFRESH: itab_QUERY.

FREE: itab_QUERY.

3. Create a custom transaction code

4. Link the custom transaction to the custom program

Then maintain the custom table

  • Insert with the transaction code that will call the SAP Query
  • Mark whether the query is from the Global or Standard Query Area
    • ‘X’ = Global
    • ‘ ‘ = Standard
  • Indicate which user group the query is in
  • Indicate the query name
  • Optionally if a variant is to be used this can be also maintained

Example:

and then execute the custom transaction code.

So far we have been using this solution for the last 5 years.

Regards

Derek

0 Kudos

Hi Derek, thank you for the solution..

But, the problem is i can't do ABAP so i can't make a custom table. That's why i used SQVI instead of custom program.

Is there any other options to make it works?

Thanks..

0 Kudos

Hi Sylviani

Unfortunately there is no other 'nice' solution available, only this one which is recommended by SAP.

You still use SQVI to create the queries anyway

If you cannot create the ABAP table and ABAP program yourself, can you get your BASIS team/ABAP Developers to create the table and program for you?.

Each time you create a new query you add it to the table and create a new transaction and link it to the custom ABAP program. The custom ABAP program works which transaction code is calling it and then selects the relevant entry from the table and executes the query.

Regards

Derek

Former Member
0 Kudos

Hi Sylviani,

You cannot use the AQXXX program directly to create the transaction.
Please refer to note 393160 about query transaction defination.
You can then use a template report to define the
report transaction:
as of Release 6.10, SAP delivers a template with Report
SAP_QUERY_CALL for this purpose. The template delivered has a
selection screen with parameters for query workspace, query user
group and query name, as well as for query variants, which you
should use to start the query. When you enter the values, a module
is called to execute the query.

For better explanation we can assume that you start query A of
usergroup U in standard area with variant V.

1.) Create a report transaction (Z1) for the
template report: SAP_QUERY_CALL
2)create a transaction Z2 with 'Transaction with parameters (paramter
transaction)'.There you enter Z1 in transaction field,
check the box for 'Skip initial screen' and at the end of this screen in
'default values' insert

P_UGROUP  U
P_VARI    V
P_QUERY   A
P_WSID    blank  (G for global area)

After saving the query A should be started with transaction Z2.

Hope it can help you.

Best regards
Ruby.

Matt_Fraser
Active Contributor
0 Kudos

Sylviani,

It's not necessary to know ABAP nor use the ABAP Workbench to create a query that can be called from a transaction code. You can't do it with SQVI, but you can do it with SQ01/SQ02, etc. However, there is a bit of a workaround way to do it, with the help of your Basis team, or someone with access to PFCG.

First, you must convert your query from a Quick Viewer query (SQVI) to a standard SAP Query (one that would be created from SQ01, for instance). You can do this in SQ01, via Query... Convert Quickview. Second, you will want to ensure that you create your query in the Standard Area, not the Global Area. The easiest way to do this is to use Environment... Query Areas and choose the Standard Area in SQ01 before you convert your Quickview. Likewise, choose an appropriate User Group to assign the query to, or create one.

Converting your quickview will create both a query and an infoset, probably. Note that you must do this all in your DEV system in order to create a transport.

Next, you must create a standard variant for your query, and call the variant CUS&STANDARD. The CUS& is very important. If you don't include that at the beginning of the variant name, it won't be transportable.

Next, you will want to go into PFCG, which is normally only accessible to user and authorizations administrators. You might need someone to assist you here if this isn't your role. This isn't mandatory, but it makes it much easier.

In PFCG, in the Menu page, click the button for Add Report. This function actually creates a transaction code and assigns it to a report. It has a radio button for selection SAP Query. Choose that, then put in your User Group, Query, and Variant. Check the box for Skip selection screen, and check the boxes as appropriate for GUI Support (SAPGUI for Windows at a minimum, but no harm in choosing all three). Save it, and give your transaction code a Z name and a description or title, and choose a Z package to save it in.

Later, from SE93, you can call up your transaction code and you will see it as a Parameter Transaction.

You can create the transaction directly in SE93, as follows. For Start object choose "Transaction with parameters (parameter transaction)." In the Transaction field put "START_REPORT". Check the box for Skip initial screen. Put "0" for Screen. Add your GUI Support options. Then the important part is the Default Values. You must fill in the following:

D_SREPOVARI-REPORTTYPE = AQ

D_SREPOVARI-REPORT = <Query User Group><5 blank spaces>S (i.e., if your query group is ZUSERS, put "ZUSERS     S"

D_SREPOVARI-EXTDREPORT = <Query Name, i.e. "ZQUERY">

D_SREPOVARI-VARIANT = CUS&<variant> (i.e. "CUS&STANDARD")

D_SREPOVARI-NOSELSCRN = <blank>

This should create a tcode that works with your query. The next part is transporting it. With queries, this gets a bit more complex. Generally, it will be easier if you can get your query, user group, and infoset all set up in the Standard Area, then you can use the Environment... Transports option from either SQ02 or SQ03 to write all three into a transport request. Later, when you import the transport request into the target system, you then must go into this same Environment... Transports tool to use the Import option, first for the user group, then for the infoset and query. In this case, list the transport request number as the Dataset with imports. After all this is done, you can create a second transport with your transaction code, so you probably need to get the query transport created first, then the transaction code transport.

Regards,

Matt

Former Member
0 Kudos

Hi Sylviani,

I think you have regenerate the program in Q. That should work.

Former Member
0 Kudos

Hi Sylviani,

May be below steps helps,

In SE93, Create a Paramter Transaction

-> Transaction = Start_report

-> In default values, give the below details:

     D_SREPOVARI-REPORTTYPE = AQ

     D_SREPOVARI-EXTDREPORT = Name of the Query

     D_SREPOVARI-REPORT = User Group

You can use below FM to find out Name of the query and user Group by passing program name.

FM - RSAQ_DECODE_REPORT_NAME

Regards,

Sid

0 Kudos

Just to stay on subject,

the blog Upgrade – Easy migration of AQ* Report transactions might help in case of mass conversion.

Best,

Andrea