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: 
3 REPLIES 3
Read only

Former Member
0 Likes
421

hi,

http://www.susanto.id.au/papers/DynOpenSQL.asp

ex:

SELECT *

FROM (w_table)

INTO CORRESPONDING FIELDS OF wa_consolidate

WHERE kappl EQ wa_kona-kappl

AND kschl EQ wa_t6b2f-kschl

AND vkorg EQ wa_kona-vkorg

AND vtweg EQ wa_kona-vtweg

AND datbi GE p_datbi

AND knuma EQ wa_kona-knuma.

here table is select ed dynamically.

regards,

sandeep

Read only

Former Member
0 Likes
421

Hi

It means the table and where condition are managed dynamically in the program, so they aren't hardcoded.

DATA: tablename(30) TYPE c.

DATA: t_cond(1000) TYPE c OCCURS 0 WITH HEADER LINE.

DATA: wa TYPE REF TO data.
FIELD-SYMBOLS: <wa> TYPE ANY.

START-OF-SELECTION.

  tablename = 'BKPF'.

* Create a workarea
  CREATE DATA wa TYPE (tablename).
  ASSIGN wa->* TO <wa>.



  CONCATENATE 'BUKRS =' '''' '1000' '''' INTO t_cond.
  APPEND t_cond.


  CONCATENATE 'AND GJAHR = ' '''' '2008' '''' INTO t_cond.
  APPEND t_cond.

  SELECT * FROM (tablename) INTO <wa> WHERE (t_cond).
  ENDSELECT.

The query above it can write statically:

SELECT * FROM BKPF WHERE BUKRS = '1000'
                                         AND GJAHR = '2008'.
ENDSELECT.

The main difference is it can't use a SELECT-OPTIONS or RANGES in the dynamic sql, but the WHERE condition has to have constants value only.

The performance should be better for the static sql.

Max