Skip to Content
0

take value from string for where condition

Oct 19, 2016 at 08:56 AM

91

avatar image

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).
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Best Answer
luca bigoni Oct 19, 2016 at 11:28 AM
0

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).
Share
10 |10000 characters needed characters left characters exceeded
luca bigoni Oct 19, 2016 at 09:04 AM
0

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.

Share
10 |10000 characters needed characters left characters exceeded
Rajasekhar Dinavahi Oct 19, 2016 at 09:41 AM
0

Hi

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

Regards

Raj

Show 1 Share
10 |10000 characters needed characters left characters exceeded

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"

0
Rajasekhar Dinavahi Oct 19, 2016 at 10:32 AM
0

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>.

Share
10 |10000 characters needed characters left characters exceeded