Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Structure

Former Member
0 Kudos

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.

9 REPLIES 9

Former Member
0 Kudos

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

0 Kudos

mara? Is that a table in the database? My problem is that I want to take the information in my structure and put it into a workarea. How do I do that?

0 Kudos

Linn:

Loop at it_order into wa_order.
...
endloop.

Rob

Former Member
0 Kudos

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

Rob

Former Member
0 Kudos

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

Former Member
0 Kudos

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.

Former Member
0 Kudos

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,

Former Member
0 Kudos

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

Former Member
0 Kudos

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.