sapdev logo background
sapdev logo sapdev logo
Comments

SAP OO OBS LOOP DBTAB 1 documentation, setup help and example usage



Return to SAP documentation index


INCLUDE
ARTICLE

Cannot Use LOOP AT

You cannot use the LOOP AT statement to read data from database tables in ABAP Objects.

  • In ABAP Objects, the following statements cause an error message:


  • t100 = space.
    t100-sprsl = 'D'.
    t100-arbgb = 'BC'.
    t100-msgnr = '1'.

    LOOP AT t100.
    ...
    ENDLOOP.
  • Correct syntax:


  • DATA wa TYPE t100.

    SELECT * FROM t100 INTO wa WHERE sprsl = 'D' AND
    arbgb = 'BC' AND
    msgnr LIKE '1%'.
    ...
    ENDSELECT.
  • Cause:


  • The Open-SQL and SELECT statements have replaced LOOP AT . The latter only works with database tables, whose name corresponds to R/2-ATAB naming conventions (no more than five places, beginning with T) or with table work areas declared using theTABLES statement, which is not allowed in ABAP Objects. Access is by generic key values, which are taken from the filled part of the table work area from left to right. For this reason, you should declare keys explicitly in the WHERE clause of the SELECT statement instead.
    Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved




    OO_OBS_LOOP_1
    OO_OBS_MAJOR_MINOR_1




    comments powered by Disqus