Application Development and Automation 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: 
Read only

How to read SQ01 Query in ABAP Program.

Former Member
0 Kudos
2,766

I have a SAP Query written in SQ01. However I want to use this Query in ABAP Program.

I have written the code

SUBMIT aqzzzhtr_persadme_y=========== via SELECTION-SCREEN

EXPORTING LIST TO MEMORY AND RETURN.

aqzzzhtr_persadme_y=========== - Is the Program Generated for my SQ01 Report Query.

Going to System --> Status --> aqzzzhtr_persadme_y===========

CALL FUNCTION 'LIST_FROM_MEMORY'

TABLES

listobject = itab_list

EXCEPTIONS

not_found = 4

OTHERS = 8.

But the List is not showing the correct value, in turn showing some Junk Value which is not the actual output of the report.

I have also used Write_List, Display_List but none fo them is working correctly.

aqzzzhtr_persadme_y=========== - Is the Program Generated for my SQ01 Report Query.

Kindly suggest and guide me throught right steps.

7 REPLIES 7
Read only

Former Member
0 Kudos
1,499

in the output format of the query (inSQ01) check if its set to SAP List viewer. set it if not set. then this below query works. .change your query name..

submit aqzzzdmscm======zdm_po======== using selection-set 'V1' EXPORTING LIST TO MEMORY
              AND RETURN.

DATA list_tab TYPE TABLE OF abaplist.

CALL FUNCTION 'LIST_FROM_MEMORY'
  TABLES
    listobject = list_tab
  EXCEPTIONS
    not_found  = 1
    OTHERS     = 2.

IF sy-subrc = 0.
  CALL FUNCTION 'WRITE_LIST'
    TABLES
      listobject = list_tab.
ENDIF.

Read only

Former Member
0 Kudos
1,499

Hi Ritesh,

If your are using LIST_FROM_MEMORY and if your output is in junk value,

Use FUNCTION MODULE 'LIST_TO_TXT' , surely you will get your actual output.

Regards,

Saravana.S

Read only

0 Kudos
1,499

No This is not working...

Suppose there are 2 Programs A and B.

In A i have written Submit B Exporting to memory list and return

I want the data of B Report that is run.

Please suggest.

Read only

0 Kudos
1,499

You can use this blog to learn how to get output of a submitted report :

Some example usage:

DATA:lf_ref TYPE REF TO data,
       lf_ref1 type ref to data.


  cl_salv_bs_runtime_info=>set(
  EXPORTING display  = abap_false
    metadata = abap_true
    data     = abap_true ).
  Submit (program)  USING SELECTION-SET variant EXPORTING LIST TO MEMORY
            AND RETURN.
  TRY.
      cl_salv_bs_runtime_info=>get_data_ref(
  IMPORTING r_data = lf_ref ).
      ASSIGN lf_ref->* TO <lt_data>.
    CATCH cx_salv_bs_sc_runtime_info.
      MESSAGE `Programdan veri çekilemedi` TYPE 'E'.
  ENDTRY.
  cl_salv_bs_runtime_info=>clear_all( ).
  CREATE DATA lf_ref1 LIKE LINE OF <lt_data>.
  ASSIGN lf_ref1->* TO <lt_line>.

Edited by: kerimmkilic on Jan 24, 2012 4:31 PM

Read only

0 Kudos
1,499

what error are you facing when you tried the code which I suggested along with the option of SAP list viewer?

Read only

JurijsP
Explorer
0 Kudos
1,499

Hi Ritesh,

Have you solved the issue? Can you please share if yes.

I have same problem (can't get results when submitting to query generated report)

Thank you!

Read only

0 Kudos
740

Use de FM RSAQ_REMOTE_QUERY_CALL