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 SQL for selection-option???

Former Member
0 Likes
409

Hi,

I am trying to select a table from the parameters (range ) , but every time i run it give me a dump witn error in where ...(itab)

First i declare :

data : cond(72) TYPE C,

itab LIKE TABLE OF cond .

select-options: p_auart FOR vbak-auart ,

p_vkorg FOR vbak-vkorg.

--->

If not p_auart is initial.

cond = 'auart IN p_auart' .

APPEND cond To itab.

endif.

the i do select:

Select * from vbak where (itab).

---> I give a dum in where clause....

So could you please help me out of this

Thanks

2 REPLIES 2
Read only

Former Member
0 Likes
368

Hi Friend,

Make the following corrections.Your code will work fine.

By the statement- 'itab LIKE TABLE OF cond .' you meant to create a table of the type 'COND' which should be a structure.

So, here lies the problem.In your case COND is a char type variable and you are trying to mimic the table 'itab' from it.

As a rule of thumb,a table should mimic a std., table or a structure.

So remove the following lines:

data : cond(72) TYPE C,

itab LIKE TABLE OF cond .

Include the following lines:

type: begin og itab_record,

cond(72) TYPE C,

end of itab_record."Declaration of structure itab_record.

data: itab type standard table of itab_record initial size 0 with header line."Declaration of the table itab which mimics the structure itab_record.

Modify these two statements,

cond = 'auart IN p_auart' .

APPEND cond To itab.

to

itab_record-cond = 'auart IN p_auart' .

append itab_record.

Other lines are exact,make these changes,execute it and seek my assistance if necessary.

Regards,

Lakshmanan

Read only

Former Member
0 Likes
368

The best way is to check the contents of ITAB in debug mode.

As per what i see you havent handled the case whereby no input is given to select-option.

Moreover P_AUART is select-option, so your condition should be:


If not p_auart[] is initial.  " Note the brackets '[]' as p_auart should be treated as internal table, p_auart without brackets is considered as the WA and it will be empty 

Regards

Eswar