user1953051
user1953051

Reputation: 611

Show table data on screen

I have a database table named zrswheel .I entered 3 datas and want to show them on screen.Here s my code

 REPORT  ZRS_WHEEL.

    TYPES:
      BEGIN OF ty_zrswheel,
          lv_brand TYPE c,
          lv_dimension TYPE i,
          lv_pressure TYPE i,
        END OF ty_zrswheel.
    DATA:
      wa_zrswheel TYPE ty_zrswheel,
      it_zrswheel TYPE TABLE of ty_zrswheel.

    SELECT dimension pressure brand 
        FROM zrswheel 
        INTO TABLE it_zrswheel.

    *WHERE ID=''.

    IF sy-subrc NE 0.
      write: 'There is an Error in retrieving data.'.
    ELSE.
      LOOP AT it_zrswheel INTO wa_zrswheel.
        WRITE: wa_zrswheel-lv_dimension,wa_zrswheel-lv_brand,wa_zrswheel-lv_pressure.
        NEW-LINE.
      ENDLOOP.
    ENDIF.

When I execute I get this error:

Runtime Errors : DBIF_RSQL_INVALID_RSQL
Except. CX_SY_OPEN_SQL_DB

Upvotes: 0

Views: 5463

Answers (2)

knut
knut

Reputation: 27855

What is the structure of your zrswheel? Does it fit to your internal structure ty_zrswheel?

Without knowing the structure of zrswheel, nobody can help you. The following is just a guess from my side.

It is very unusual to call fields in a structure like lv_. So I think your zrswheel is defined as:

dimension type c,
brand     type i
pressure  type i

I think your report should look like:

  REPORT  ZRS_WHEEL.

    DATA:
      wa_zrswheel TYPE zrswheel,
      it_zrswheel TYPE TABLE of zrswheel.

    SELECT * FROM zrswheel INTO TABLE it_zrswheel.
    LOOP AT it_zrswheel INTO wa_zrswheel.
      WRITE: / wa_zrswheel-dimension,wa_zrswheel-brand,wa_zrswheel-pressure.
    ENDLOOP.
    IF sy-subrc NE 0.
      write: 'Nothing found'.
    ENDIF.

If you want only select an extract of zrswheel, then try:

  REPORT  ZRS_WHEEL.

    TYPES:
      BEGIN OF ty_zrswheel,
          brand     LIKE zrswheel-brand,     "or lv_brand?
          dimension LIKE zrswheel-dimension, "or lv_dimension?,
          pressure  LIKE zrswheel-pressure,  "or lv_pressure?,
        END OF ty_zrswheel.
    DATA:
      wa_zrswheel TYPE ty_zrswheel,
      it_zrswheel TYPE TABLE of ty_zrswheel.

    SELECT *FROM zrswheel 
        INTO corresponding fields of TABLE it_zrswheel.

    LOOP AT it_zrswheel INTO wa_zrswheel.
      WRITE: / wa_zrswheel-dimension,wa_zrswheel-brand,wa_zrswheel-pressure.
    ENDLOOP.
    IF sy-subrc NE 0.
      write: 'There is an Error in retrieving data.'.
    ENDIF.

Remark: I'm not sure about the correct syntax of INTO CORRESPONDING FIELDS - please check the online help or wait for my update when I have a SAP-system to check the syntax)

Upvotes: 1

TheG
TheG

Reputation: 155

Check your order of fields in the structure and in the select statement. Ensure the data types and length match for the fields .

Upvotes: 0

Related Questions