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: 

How to call SAP query in a program

vijy_mukunthan
Active Contributor
0 Kudos

Hi experts

I have created a query in SQVI its gives a result. Now i want this query to be used in my program. Is there any FM which gets the quary name and populates the result in iternal table. So that i can use that result.

I know without query you can write using the tables you can fetch the records but i just want to explore a new way to do things. If any body done such type let me know and also give some sample code or process how to achieve it.

Regards

Vijay

8 REPLIES 8

anup_deshmukh4
Active Contributor
0 Kudos

you can do this in the following way,

1. you go to selection screen of sqvi report copy the program name and call it in your program

2. you can go to the program there would be certain includes and function modules that were generated during the sqvi process you will get the ACTUAL QUERY generated by the system in the SQVI joins or tables ...( This one is the better option...)

0 Kudos

Hi Anup Deshmukh

Can you explain with an example with a sample code. Give the FM details so that it would be very helpful.

Regards

Vijay

0 Kudos

Hi All

My excat requirement is by SAP query a program is designed with 7 tables and giving the one sales document no has input, it takes more than half an hour to show the result. This is the performance issue. So we have decided to copy the program and find where the select statment is used and need to change the where condition. But when i look through the code, there is no select statment and i don't understant code itself. How to find that or how to proceed the other way to solve this issue.

Regards

Vijay

0 Kudos

Hi Vijay,

As the code for the Query is generated dynamically, there will be a performance problem init. The best way to address this is to create a program instead of changing the existing code in the query program.

Hope this helps.

Regards,

Siva Prakash

vijy_mukunthan
Active Contributor
0 Kudos

Hi

Can any one done this way?

Regards

Vijay

karthik_vardhan
Explorer
0 Kudos

Hi,

First Generate program from SQVI for your Query .

then use Submit statement at any Point to get result for ur input from that Query .

0 Kudos

Hi Siva

My final option is that only. That you can do any how. But my intension is to learn something new way. How to do copy the query and where to inject the code is there any example in wiki or artical for that. I want to something new. Old way of creating a report program is possible i want to do this way. If some body could help me out.

@ karthik

I have generated the SAP query and i got the program but when i view the code i dont find any select statment or where storing my input data. How to identity that i did in debug mode but am not sure where it pulls the data and where it put in internal table. Can you throw some light with example code or an article.

Regards

Vijay

0 Kudos

See In Case of Submit there is no need for u from where data is getting fetched .

U can Just Submit that report with Input parameters (Selection parameters) from another Customized (Z or y) report

before that Report displaying the Values Import thoose Values into your program & Stop Processing That Program .

Using Leave Program Stmt .

Now EXample :A11111111 is Proram Generated from SQVI .

Ur Prog is ZABC .

Report ZABC .

Submit Report A11111111 ........ .

Then get those Values .

Do What Ever Processing U Want on that Data & Display .

Otherwise Display Directly .