Application Development 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: 

Dynamic Open SQL Under 46C

Former Member
0 Kudos

Hello Experts,

I'm now working on a dynamic open sql generator under version: 46C. The code which is proved correct under 610 turns out to run into some error under 46C. Here attaches my code:

SELECT SINGLE (p_sel_cls)

FROM (p_tabname) INTO li_fldresult

WHERE (p_where_cls).

p_sel_cls, p_tabname and p_where_cls are all dynamically constructed.

The compiling error is:

p_sel_cls is not an internal table.

Could anyone help me out? Thanks a lot.

Best regards,

James

1 ACCEPTED SOLUTION

former_member784222
Active Participant
0 Kudos

Hi,

In 46C p_tabname can be a variable

p_sel_cls, p_where_cls should be an internal table.

Declare p_sel_cls and p_where_cls as internal tables.

Append you dynamic clause in these internal tables and check.

Thanks and regards,

S. Chandra Mouli.

6 REPLIES 6

former_member784222
Active Participant
0 Kudos

Hi,

In 46C p_tabname can be a variable

p_sel_cls, p_where_cls should be an internal table.

Declare p_sel_cls and p_where_cls as internal tables.

Append you dynamic clause in these internal tables and check.

Thanks and regards,

S. Chandra Mouli.

0 Kudos

The original error disappears and now the error is:

li_fldresult cannot be a table, a reference, a string or contain any of these objects.

Could you let me know how I can hold the result? Thanks a lot.

Regards,

James Xie

0 Kudos

Hi,

How is 'li_fldresult' declared ?

0 Kudos

Hi,

It's simply declared as a string or int.

Regards,

James Xie

0 Kudos

Hi Experts,

Can anyone help me with this? The datatype of the database field is: CHAR with length 30 and I use a ABAP type: char with length 100 to hold this, the error says data read during the select access couldn't be inserted into the target field.

So how can I define a ABAP variable to receive db selection field.

Thanks a lot.

Regards,

James Xie

0 Kudos

Hi James,

Try the following code:

[code]

DATA: tabname LIKE dd03l-tabname VALUE 'T001'.

DATA: BEGIN OF fieldtab OCCURS 0,

text(100),

END OF fieldtab.

DATA: BEGIN OF destab OCCURS 0,

text(100),

END OF destab.

DATA dref TYPE REF TO data.

FIELD-SYMBOLS: <fs> TYPE ANY.

  • creates dynamic data

CREATE DATA dref TYPE (tabname).

ASSIGN dref->* TO <fs>.

*

fieldtab-text = 'BUKRS'.

APPEND fieldtab.

fieldtab-text = 'BUTXT'.

APPEND fieldtab.

SELECT SINGLE (fieldtab) INTO <fs> FROM (tabname).

/code]

Thanks and regards,

S. Chandra Mouli.