Skip to Content
author's profile photo
Former Member

Urgent dynamic select condition.

Hi SDN,

I am using a dynamic where clause in my select condition i.e.

Select * from (Table ) into table it_table

where ( dyn_tab ).

but some times it works well & some times it gives dump..

Can u please tell me why it's giving dump.

Regards,

Rahul

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Best Answer
    author's profile photo
    Former Member
    Posted on Aug 23, 2007 at 07:26 AM

    hI,

    DATA:

    gd_where_conditions TYPE string.

    SELECT * FROM ...

    WHERE ( gd_where_conditions ).

    However, if you are working on 6.20 (or less) than you could use the following function module to create your dynamic WHERE condition(s): RH_DYNAMIC_WHERE_BUILD

    The function module returns the WHERE conditions in CONDTAB. Thus, you could code:

    TYPES: BEGIN OF ty_s_clause.

    TYPES: line(72) TYPE c.

    TYPES: END OF ty_s_clause.

    DATA:

    gt_where_clauses TYPE STANDARD TABLE OF ty_s_clause

    WITH DEFAULT KEY.

    DATA:

    gt_condtab TYPE STANDARD TABLE OF hrcond.

    • Fill gt_condtab with the required conditions

    CALL FUNCTION 'RH_DYNAMIC_WHERE_BUILD'

    EXPORTING

    dbtable = space " can be empty

    TABLES

    condtab = gt_condtab

    where_clause = gt_where_clauses

    EXCEPTIONS

    empty_condtab = 01

    no_db_field = 02

    unknown_db = 03

    wrong_condition = 04.

    • Select your data

    SELECT * FROM ...

    WHERE (gt_where_clauses).

    hope this helps.

    plz reward if helpful

    rEGARDS,

    sANKAR

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Aug 23, 2007 at 07:25 AM

    well this is quite hard without any error message.

    sure i could start to estimate now and yeah prolly its a conversion error, but still this is way to less information to give any analysis on your problem.

    Add comment
    10|10000 characters needed characters exceeded