‎2007 Feb 23 5:19 PM
Hi Gurus....
Please explain me how to write dynamic Query,,, Pl. give me with example.
Also would like to know basics of Collect statement and it's use..
Thanks
Ritesh
‎2007 Feb 23 5:23 PM
Hi Ritesh,
COLLECT is used to create unique or compressed datsets. The key fields are the default key fields of the internal table itab . If all non-numeric fields are same in the internal table then it will add numeric fields and maintains a single entry
If you use only COLLECT to fill an internal table, COLLECT makes sure that the internal table does not contain two entries with the same default key fields.
Check this link to know about COLLECT statement
http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/collect.htm
Dynamic query can be built in SAP with the help of () values.
DATA:
V_TABNAME TYPE DDO2L-TABNAME,
V_CONDTION TYPE STRING.
V_TABNAME = 'MARA'.
V_CONDTION = 'MATNR LIKE 'S*'.
SELECT MATNR
FROM <b>(V_TABNAME)</b>
INTO TABLE ITAB
WHERE <b>(V_CONDTION)</b>.
Thanks,
Vinay
‎2007 Feb 23 6:27 PM
Collect statement sums up numerical value if non-numeric values are same.
For e.g.:
Header of internal table contains
-
abc sy 120
Body of an internal table
-
xyz st 110
abx pi 120
abc sy 140
collect itab.
-
xyz st 110
abx pi 120
abc sy 260
Thanks,
Santosh
‎2007 Feb 23 9:58 PM
you can always visit tcode ABAPDOCU to knw such things rapidly.
Thanks
Ashwani