cancel
Showing results for 
Search instead for 
Did you mean: 

take value from string for where condition

Former Member
0 Kudos

Hello,

I have two dropdown by index in my webdynpro where I can get two string values. The first is a string that i would like to use as column name in a 'where condition' of a delete statement, the second is the value to which the field should be equal. How can I use the value of this strings in a where condition?

I tried to use brackets but it doesn't work.

my code is:


  data: lv_attr type string,

        lv_field type string.

*        lv_condition type string,

*        tmp type string,

*        lt_temptab TYPE TABLE OF ZTEST_SFLIGHT,

*        ls_temptab LIKE LINE OF lt_temptab,

*        dref type ref to data.



  WD_CONTEXT->GET_CHILD_NODE( name = 'NODE_DELETEFORM' )->GET_ATTRIBUTE( EXPORTING NAME = 'VALUE' IMPORTING VALUE = lv_attr ).

  WD_CONTEXT->GET_CHILD_NODE( name = 'NODE_TABFIELDS' )->GET_ATTRIBUTE( EXPORTING NAME = 'FIELDS' IMPORTING VALUE = lv_field ).



  delete from ztest_sflight where (lv_field) eq (lv_attr).

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

this worked for me!!!


  data: lv_attr type string,

        lv_field type string,

        s type string.



  WD_CONTEXT->GET_CHILD_NODE( name = 'NODE_DELETEFORM' )->GET_ATTRIBUTE( EXPORTING NAME = 'VALUE' IMPORTING VALUE = lv_attr ).

  WD_CONTEXT->GET_CHILD_NODE( name = 'NODE_TABFIELDS' )->GET_ATTRIBUTE( EXPORTING NAME = 'FIELDS' IMPORTING VALUE = lv_field ).



  concatenate lv_field '=' 'lv_attr' into s SEPARATED BY space.



  delete from ztest_sflight where (s).

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi

Build your whole where condition into field symbol.

For E.g:

concatenate <fs_attr> = <lv_field> and move it to <fs>

DELETE FROM ZTEST_SFLIGHT WHERE <fs>.

Former Member
0 Kudos

Hi

Try using field symbols instead of strings(assign the value of strings to the field symbols).

Regards

Raj

Former Member
0 Kudos

FIELD-SYMBOLS: <fs> TYPE string.
ASSIGN lv_field TO <fs>.

WD_CONTEXT->GET_CHILD_NODE( name = 'NODE_DELETEFORM' )->GET_ATTRIBUTE( EXPORTING NAME = 'VALUE' IMPORTING VALUE = lv_attr ).
WD_CONTEXT->GET_CHILD_NODE( name = 'NODE_TABFIELDS' )->GET_ATTRIBUTE( EXPORTING NAME = 'FIELDS' IMPORTING VALUE = lv_field ).

delete from ztest_sflight where <fs> eq lv_attr.

if I write this way and try to activate , an error message says "field <fs> unknown"

Former Member
0 Kudos

actually the problem is only with lv_field, because if I write "where carrid = lv_attr" it works. But I would like to take the value of the field from dropdown by index.