-2

I would create in Abap a dynamic progressive select in a db table.
Es:
(1) my table has 4 key field;
(2) the first select is with all 4 key;
(3) if i don't find a record -> second select with first 3 key fields;
(4) if i don't find a record -> third select with first 2 key fields;
(5) if i don't find a record -> fourth select with only first key field;
(6) if i don't find a record -> raise error.

I must use field symbols, but how? Can you help me about implementation of selects?
Thanks

85ac
  • 1
  • "I must use field symbols" sounds like this is some kind of homework or exam question. If it is, then please be honest about it and review http://meta.stackexchange.com/questions/10811/how-to-ask-and-answer-homework-questions – vwegert Sep 04 '12 at 18:23

1 Answers1

1

Pseudocode of a naive approach:

SELECT INTO TABLE with all four fields.
IF sy-dbcnt = 0.
    SELECT INTO TABLE with three fields.
    IF sy-dbcnt = 0.
        SELECT INTO TABLE with two fields.
        IF sy-dbcnt = 0.
            SELECT INTO TABLE with one field.
            IF sy-dbcnt = 0.
                MESSAGE TYPE 'E'.
            ENDIF.
        ENDIF.
    ENDIF.
ENDIF.
LOOP AT table ASSIGNING <field_symbol>.
     "do something with the table line in the field symbol
ENDLOOP.
Philipp
  • 67,764
  • 9
  • 118
  • 153