Skip to Content
author's profile photo Former Member
Former Member

Dynamic Where Clause in a Loop ??

I need a dynamich where-clause in a Loop-Statement, like this:

LOOP AT gt_outtab INTO gs_outtab

WHERE ( delta IS INITIAL AND <f_per> IS INITIAL ).

gs_outtab-delta = gs_outtab-per01.

MODIFY gt_outtab FROM gs_outtab.

ENDLOOP.

First I tried this:

LOOP AT gt_outtab INTO gs_outtab

WHERE ( delta IS INITIAL AND (ls_per) IS INITIAL ).

gs_outtab-delta = gs_outtab-per01.

MODIFY gt_outtab FROM gs_outtab.

ENDLOOP.

but with both I get a syntax error.

Do you have an idea, how can I use the component I need dynamically?

thanks.

Samir

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    Posted on Apr 13, 2006 at 08:56 AM

    Hello Samir,

    We can not specify the dynamic where clause in Loop.

    IF you want to achieve for you logic,

    LOOP AT gt_outtab INTO gs_outtab

    WHERE delta IS INITIAL.

    <b> assign f_per to <f_per>.

    if f_per is initial.</b>

    gs_outtab-delta = gs_outtab-per01.

    MODIFY gt_outtab FROM gs_outtab.

    <b>endif.</b>

    ENDLOOP.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 13, 2006 at 08:52 AM

    take refrence from given link...

    dynamic-where-clause

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 13, 2006 at 08:57 AM

    HI

    GOOD

    Dynamic Conditions

    To specify a condition dynamically, use:

    SELECT ... WHERE (<itab>) ...

    where <itab> is an internal table with line type C and maximum length 72 characters. All of the conditions listed above except for selection tables, can be written into the lines of <itab>. However, you may only use literals, and not the names of data objects. The internal table can also be left empty.

    If you only want to specify a part of the condition dynamically, use:

    SELECT ... WHERE <cond> AND (<itab>) ...

    You cannot link a static and a dynamic condition using OR.

    You may only use dynamic conditions in the WHERE clause of the SELECT statement.

    ===============================

    DATA: TAB_SPFLI TYPE TABLE OF SPFLI,

    TAB_SFLIGHT TYPE SORTED TABLE OF SFLIGHT

    WITH UNIQUE KEY TABLE LINE,

    WA LIKE LINE OF TAB_SFLIGHT.

    SELECT CARRID CONNID

    INTO CORRESPONDING FIELDS OF TABLE TAB_SPFLI

    FROM SPFLI

    WHERE CITYFROM = 'NEW YORK'.

    SELECT CARRID CONNID FLDATE

    INTO CORRESPONDING FIELDS OF TABLE TAB_SFLIGHT

    FROM SFLIGHT

    FOR ALL ENTRIES IN TAB_SPFLI

    WHERE CARRID = TAB_SPFLI-CARRID AND

    CONNID = TAB_SPFLI-CONNID.

    LOOP AT TAB_SFLIGHT INTO WA.

    AT NEW CONNID.

    WRITE: / WA-CARRID, WA-CONNID.

    ENDAT.

    WRITE: / WA-FLDATE.

    ENDLOOP.

    THANKS

    MRUTYUN

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 13, 2006 at 09:11 AM

    thanks for the answers yet.

    but I think only the answer of Naimesh Patel could be useful, i'm just checking, because there seems to be a difference between an dynamic where-clause in a select and a loop statement.

    Samir

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.