Application Development and Automation 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: 
Read only

Dynamic Query and Collect Statement.

Former Member
0 Likes
552

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

3 REPLIES 3
Read only

Former Member
0 Likes
474

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

Read only

Former Member
0 Likes
474

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

Read only

Former Member
0 Likes
474

you can always visit tcode ABAPDOCU to knw such things rapidly.

Thanks

Ashwani