‎2020 Aug 11 8:46 AM
Hello Gurus,
I'm trying to fetch data from sap query in SQ00. and used submit to send the parameters. I'm not sure how the data will fetch in it_ascii table, also i am writing the code in dev and my query is in qa, so needs to be a bit more sure before moving the changes.
*structure declaration
TYPES: BEGIN OF it_query,
grpdesc TYPE zmodel1,
matnr(18),
query_date TYPE sy-datum,
END OF it_query.
DATA: it_query TYPE STANDARD TABLE OF it_query,
wa_query TYPE it_query.
*range table creation
* DATA: r_variant TYPE RANGE OF zprodgrp_prddes-variant, "range table
* wa_variant LIKE LINE OF r_variant. "work area for range table
CLEAR: wa_variant,
wa_query.
REFRESH: it_listobj,
it_ascii,
r_variant,
it_query.
DATA: sel_date TYPE budat,
back_date TYPE budat.
DATA: r_date TYPE RANGE OF budat,
wa_date LIKE LINE OF r_date.
sel_date = p_date.
back_date = sel_date - 180.
wa_date-sign = 'I'.
wa_date-option = 'BT'.
wa_date-low = back_date.
wa_date-high = sel_date.
APPEND wa_date TO r_date.
LOOP AT it_prddes INTO wa_prddes.
wa_variant-sign = 'I'.
wa_variant-option = 'EQ'.
wa_variant-low = wa_prddes-variant.
APPEND wa_variant TO r_variant.
CLEAR : wa_prddes,
wa_variant.
ENDLOOP.
* Call the report
SUBMIT !QOVSDREPNEW====STO_FAST_DISP=
WITH VSTEL = p_plant
WITH LEDAT in r_date
WITH matnr IN r_variant
EXPORTING LIST TO MEMORY AND RETURN.
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = it_listobj.
CALL FUNCTION 'LIST_TO_ASCI'
TABLES
listasci = it_ascii
listobject = it_listobj
EXCEPTIONS
empty_list = 1
list_index_invalid = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE: 'Error converting to ASCII'(027) TYPE 'S' DISPLAY LIKE 'E'.
ENDIF.
* confused in this part how to loop to fill the data
LOOP AT it_ascii.
IF sy-tabix GT 1.
wa_query-matnr = it_ascii-line+6(18).
wa_query- = it_ascii-line+166(8).
APPEND wa_query TO it_query.
CLEAR: wa_query.
ENDIF.
ENDLOOP.
<br>
‎2020 Aug 11 10:39 AM
‎2020 Aug 11 11:06 AM
You may run the query in ALV grid mode and intercept the ALV data via CL_SALV_BS_RUNTIME_INFO for instance. Search the Web for more information.
‎2020 Aug 11 2:49 PM
By the way, don't call the SAP query like this:
SUBMIT !QOVSDREPNEW====STO_FAST_DISP=
(the !Q in front of the name means a temporary version of AQ...)
but instead call it via RSAQ_QUERY_CALL with the query name and user group.
‎2020 Aug 11 2:50 PM
Instead of using CL_SALV_BS_RUNTIME_INFO as I initially proposed, you may use the following parameters of RSAQ_QUERY_CALL to receive the data: DATA_TO_MEMORY = 'X' and REF_TO_LDATA will return the data via a data reference.
‎2020 Aug 12 8:59 AM
Hi Sandra,
Thanks for your response, the changes were moved in quality before you posted your comment. Now I'm getting this error, we can also call the program using submit, but it's showing program name not found. Kindly help this is a bit urgent.
‎2020 Aug 12 10:42 AM
You say "we can also call the program using submit", but you shouldn't. Isn't the function module RSAQ_QUERY_CALL sufficient?
‎2020 Aug 12 8:00 PM
I had gone through this program SAP_QUERY_DEMO_TRANSFER_1, could you help me how the data is fetched and how to loop throught the internal table by providing an example as other examples over the internet were not clear to me, also i am not that experienced. My query resides in QA, so I am also not able to figure out the structure of the internal table(how the data id fetched from this fm)
‎2020 Aug 13 8:09 PM
‎2020 Aug 14 8:47 AM
If you want to target someone, if this person has posted an Answer, use the button COMMENT, if this person is the Original Poster of the question he/she will be automatically informed, otherwise copy/paste their hyperlinked name so that the person receives a warning (NB: @ doesn't work/but typing this character will suggest hyperlinked names).
(i.e. I just see your message now because I look sometimes at all messages posted)
‎2020 Aug 14 8:52 AM
How do you want to test your program then? Ask the administrators to transport the query to the Development environment.
Or create a simple dummy query in the Development environment so that to test your program.
I just searched and found examples easily, for instance these ones: https://stackoverflow.com/questions/39331010/how-to-loop-at-table-only-having-ref-to-data, https://answers.sap.com/questions/8813080/where-can-i-get-the-itab-of-generated-sap-query.html.