Application Development and Automation 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: 
Read only

Regarding select statement on structure

Former Member
0 Likes
8,099

hi,

can we write select on structure?.........i hav to get condition record from konv(which is a structure) based on ekpo-ebeln.

for this i hav written code like this

IF NOT it_ekpo IS INITIAL.

SELECT knumv

kposn

kschl

kbetr

waers

KWERT

FROM konv

INTO TABLE it_konv

FOR ALL ENTRIES IN it_ekpo

WHERE knumv = it_ekpo-ebeln

  • and kposn = it_ekpo-ebelp

AND ( kschl EQ 'ZPF3' OR kschl EQ 'ZVAT'

OR kschl EQ 'ZCSR' OR kschl EQ 'ZFR3' ).

IF sy-subrc EQ 0.

SORT it_konv BY knumv kposn.

ENDIF.

ENDIF.

19 REPLIES 19
Read only

sreeramkumar_madisetty
Active Contributor
0 Likes
3,620

Hi

U can't write a select statement on structures/internal tables it's valid only for database tables/views.

Regards,

Sreeram

Read only

Former Member
0 Likes
3,620

Hi

You cannot write the Select statement on Structures but yo have a table for that structure where you will get the same data.

You can use komv & konp table instead of structure .

IF NOT IT_EKPO IS INITIAL.

SELECT KNUMV

KPOSN

KSCHL

KBETR

WAERS

KWERT

FROM KONV

INTO TABLE IT_KONP

FOR ALL ENTRIES IN IT_EKPO

WHERE KNUMV = IT_EKPO-EBELN

AND ( KSCHL EQ 'ZPF3' OR KSCHL EQ 'ZVAT'

OR KSCHL EQ 'ZCSR' OR KSCHL EQ 'ZFR3' ).

ENDIF.

Thanks & regards,,

Dileep .C

Read only

Former Member
0 Likes
3,620

Structures contain data only at run time .

Select statement is not meant for structures.

Read only

0 Likes
3,620

Select statement that you have mentioned is correct and is using database table.

Read only

0 Likes
3,620

but i m not getting data into it_konv

Read only

0 Likes
3,620

In ur where condition of select query U r comparing KNUMV = it_ekpo-ebeln which is wrong

it SHOULD BE:-

KNUMV = IT_EKKO_KNUMV.(in ur where condition of select query). KNUMV field is in EKKO the header table for PO not EKPO.

Edited by: vijetasap on Apr 22, 2009 9:53 AM

Read only

0 Likes
3,620

but i m not getting into variables.

LOOP AT it_konv INTO wa_konv.

IF wa_konv-kschl = 'ZPF3'.

v_pacnfwd = wa_konv-kWERT.

ELSEIF wa_konv-kschl = 'ZVAR'.

v_tax = wa_konv-kWERT.

ELSEIF wa_konv-kschl = 'ZCSR'.

v_cst = wa_konv-kWERT.

ELSEIF wa_konv-kschl = 'ZFR3'.

v_freight = wa_konv-kWERT.

ENDIF.

ENDLOOP.

Read only

0 Likes
3,620

have u changed ur code from EKPO table to EKKO table

IF NOT it_ekko IS INITIAL.

SELECT knumv

kposn

kschl

kbetr

waers

KWERT

FROM konv

INTO TABLE it_konv

FOR ALL ENTRIES IN it_ekpo

WHERE knumv = it_ekko-knumv

AND ( kschl EQ 'ZPF3' OR kschl EQ 'ZVAT'

OR kschl EQ 'ZCSR' OR kschl EQ 'ZFR3' ).

IF sy-subrc EQ 0.

SORT it_konv BY knumv kposn.

ENDIF.

ENDIF.

Read only

0 Likes
3,620

yeah i have changed

Read only

Former Member
0 Likes
3,620

Structure contains data at runtime only.

Select statement won't work for Structures.

Regards,

Joan

Read only

0 Likes
3,620

but i m getting data in it_komv now............

Read only

0 Likes
3,620

u r getting the data bcoz KONV is a table as well. Now what is ur problem plz explain....

Thanks

Vijeta

Read only

0 Likes
3,620

while looping over it_konv........the data is not getting and filled in work areas

Read only

0 Likes
3,620

please debug at loop atatement and see whether work area is populated or not and see whether ur table itab is table with header line or without header line.

Read only

0 Likes
3,620

work area data is not populating and internal table is without header line............

Read only

0 Likes
3,620

ok tell me how many rows r there in it_tab....

Read only

0 Likes
3,620

4 rows

Read only

Former Member
0 Likes
3,620

Hi,

select statement cannot be used on structures as they are meant to point the table rows and hold data only at runtime. Even if you want to fetch data from the structure, do it using table which the structure represents...

Mac.

Read only

Former Member
0 Likes
3,620

Hi,

You cannot put select query on any

structure, you have to find out the

table name from the database that

have all your required fields then put

select query on that.

Hope it helps

Regards

Mansi