‎2006 Dec 03 11:23 PM
Hello folks
I have an ABAP query. It gets the data I need, but because of the way the tables have to be joined, I get multiple records . If I write a SAP ABAP report, it would be straight forward to get exactly the records I am interested in, however I am stuck with having to use SAP query and enhance the results using ABAP code.
I have pasted the code (SAP generated based on the infoset defined in SQ02)below for your reference. The internal table <b>%dtab</b> has the data I am interested in, however when I try to refer to this internal table I get an error. I do not remember what the error was but it failed a syntax check. I am sure that somebody who has done this before knows what I am talking about. Here is the code from the SAP query.
To retrace the steps I have done, in SQ02, I clicked "EXTRAS --> Code Tab". Here I tried adding the following line of code in the "End-of-selection (before list)" coding section. I was trying to put this declaration .
w_dtab like line of %dtab.
I tried this in the start-of-selection block as well, but ended with the same syntax check.
Does this have to do with how this table is defined else can anybody advice how I can manipulate the data that is present in the internal table "%dtab" ?
Thanks
Hari
********
report AQ10AFI=========INV_SHIP_CA===.
include /1BCDWB/IQ000000000073DAT.
data %dtab type standard table of /1BCDWB/IQ000000000073 with header line.
data %subrc type sy-subrc.
include /1BCDWB/IQ000000000073SSCR.
include /1BCDWB/IQ000000000073SSCRAT.
start-of-selection.
if %runmode-extr_on <> space.
call function '/1BCDWB/IQ000000000073EXTR'
tables %selopt = %seloptions
%dtab = %dtab
changing %rtmode = %runmode
exceptions no_data = 1
others = 2.
%subrc = sy-subrc.
call function 'RSAQRT_CHECK_EXTR'
exporting extr_subrc = %subrc
tables dtab = %dtab
changing rtmode = %runmode.
endif.
end-of-selection.
if %runmode-show_on <> space.
call function '/1BCDWB/IQ000000000073SHOW'
tables %dtab = %dtab
changing %rtmode = %runmode.
endif.
*----
special code for old API and BW extractor calls
*----
form %set_data changing p_lines type i.
import ldata to %dtab from memory id 'AQLISTDATA'.
describe table %dtab lines p_lines.
free memory id 'AQLISTDATA'.
endform.
form %get_data tables p_dtab structure %dtab
using p_first type i
p_last type i.
append lines of %dtab from p_first to p_last to p_dtab.
endform.
form %get_ref_to_table using p_lid type aql_lid
p_ref type ref to data
p_subrc type i.
if p_lid = %iqid-lid.
create data p_ref like %dtab[].
p_subrc = 0.
else.
p_subrc = 4.
endif.
endform.
‎2006 Dec 04 4:49 AM
Hi Hari,
First thing is this is not the way to convert the SAP Query to Report.
First check that how many table in your query they have used.To check this if you go in SQ02 press display button left side you can see the tables.To check the fields selecting from tables check in field groups.
In record processing check are there any conditions are there.
Now wrire a select statement by joing all tables which you found above and in this select statement extract all fields which you found in field group into one internal table .Here you give the selection screen fields as condition fields in select statement.If you found any conditions in record processing event ,Loop that internal table and check the conditions or modifications.
If you need more help let me know.
Pls. reward points for helpful answers
‎2006 Dec 04 6:51 PM
I am not sure I understand your comment "First thing is this is not the way to convert the SAP Query to Report."
However the intention is to further filter the records that the query is currently retrieving. However your approach seems to be going down the line of having additional SELECT statements, and processing the internal table populated by the select statement.
How is that going to integrate with the internal %dtab which is what is eventually displayed ?