Skip to Content
author's profile photo
Former Member

Structure

The SELECT-statement does not work - why? Is it not possible to use the structure st_order, which I have created?

PARAMETERS pa_order TYPE vbeln.

TYPES: BEGIN OF st_order,

vbeln TYPE vbeln_va,

audat TYPE audat,

matnr TYPE matnr,

rfsta TYPE rfsta,

rfstk TYPE rfstk,

END OF st_order.

DATA: it_order TYPE STANDARD TABLE OF st_order,

wa_order LIKE LINE OF it_order.

SELECT: * FROM st_order INTO wa_order WHERE VBELN = pa_order.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

7 Answers

  • author's profile photo
    Former Member
    Sep 29, 2005 at 02:20 PM

    Hi Linn

    You have only defined a type and not a variable, you can use the type only to define another variable.

    TYPES: BEGIN OF st_order,

    vbeln TYPE vbeln_va,

    audat TYPE audat,

    matnr TYPE matnr,

    rfsta TYPE rfsta,

    rfstk TYPE rfstk,

    END OF st_order.

    You can use it to define something as a table (as you've done):

    DATA: it_order TYPE STANDARD TABLE OF st_order,

    But you can't use it in a select, here you can only use a database table.

    So if you want read sale order table:

    SELECT * FROM VBAK INTO wa_order

    WHERE VBELN = pa_order.

    If you use *, it means you want to extract whole record of VBAK, but you work area is smaller than VBAK, so yuo have to write

    SELECT vbeln audat matnr rfsta rfstk

    FROM VBAK INTO CORRESPONDING FIELDS OF

    wa_order WHERE VBELN = pa_order.

    It's only an example, I don't know which table you want to read, many fields are in your structure aren't in VBAK.

    Max

    Message was edited by: max bianchi

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Sep 29, 2005 at 02:03 PM

    hi,

    how can u read from st_order from <database table name >

    try with this

    SELECT * FROM mara INTO corresponding fields of wa_order WHERE VBELN = pa_order

    and why you are using :

    cheers,

    sasi

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Sep 29, 2005 at 02:05 PM

    ST_ORDER is just a structure, not a database table. You can only select from actual tables or views (into your structure).

    Rob

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Sep 29, 2005 at 04:17 PM

    Hi,

    You can select from the structure untill you should have a database table. In your program u didnot mention any of the database table.

    Sriram.

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Sep 29, 2005 at 04:40 PM

    Lynn,

    You have created a structure st_order using TYPES.

    Created an internal table it_order of type st_order

    Created an work area wa_area like it_order.

    They are all correct. What is wrong is doing a select from an internal table.

    In ABAP you use select statement for retrieving data from database tables but not internal tables.

    Instead use READ statement with an internal table if you want to read records in to an work area.

    Do F1 on READ.

    What is required is what data base tables should you use in order to populate your internal table it_order of type structure st_order.

    Do select on those database tables in to your internal table (do F1 on SELECT also) and loop thru that internal table into a work area.

    Thanks,

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Sep 29, 2005 at 05:01 PM

    Hi,

    The basic mistake you are doing is using a <b>SELECT</b> statement to read data from an <b>internal table</b>!!!!!.

    Use should use READ instead of a SELECT statement.

    Use it as

    <b>READ table it_order into wa_order where VBELN = pa)order.</b>

    This should work for your case.

    Please reward points if this explanation useful.

    Regards,

    Siva

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 30, 2005 at 03:41 AM
    PARAMETERS pa_order TYPE vbeln.
    
    TYPES: BEGIN OF st_order,
    vbeln TYPE vbeln_va, 
    audat TYPE audat, 
    matnr TYPE matnr, 
    rfsta TYPE rfsta, 
    rfstk TYPE rfstk, 
    END OF st_order.
    
    DATA: it_order TYPE STANDARD TABLE OF st_order,
    <b>   wa_order TYPE it_order.</b>
    
    SELECT * FROM st_order INTO it_order WHERE VBELN = pa_order. 
    
    Then use 
    READ TABLE it_order into wa_order <b>with key</b> vbeln = pa_order. 
    Or 
    Loop at it_order into wa_order where vbeln = pa_order.
    
    If sy-subrc = 0.
    
    endif.
    
    OR if u want only one row to be selected then u 
    can restrict in the select statement as
    
    SELECT SINGLE * FROM st_order INTO wa_order 
     WHERE VBELN = pa_order . 
    
    

    Hope this helps.

    Kindly reward points and close the thread.

    Add comment
    10|10000 characters needed characters exceeded