Skip to Content
0
Former Member
Dec 03, 2006 at 11:23 PM

Enhance SAP Query (susing ABAP code) - ECC6.0

1320 Views

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.