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

not getting actual value in loop on select statement

Former Member
0 Likes
539

Hi

I have written following code to get professor number on each loop and display it on the report but I get 9 rows of 00000000 instead of actual professor number. Can anyone help me please?

tables: ukurs.

data: itab like ukurs occurs 0 with header line.

select prfnr from ukurs into table itab

where prfnr in (00000002, 00000003,00000006).

loop at itab.

write:/ itab-prfnr.

endloop.

Thanks,

Khalid Atiq

1 ACCEPTED SOLUTION
Read only

Sandra_Rossi
Active Contributor
0 Likes
495

Hi Khalidatiq,

when you use SELECT <list of table columns> FROM <table> INTO \[TABLE\] <data object>, the data object must fit exactly the list of fields, in the same sequence and with exactly the same data types.

In your case, table column is PRFNR, and data object is (an internal table) with row type UKURS. So you must declare your data object like this :

data: itab like ukurs-prfnr occurs 0 with header line.

Note that your writing is obsolete, you'd better use, for example :

data itab type standard table of ukurs-prfnr.

Best regards,

Sandra

Hi

I have written following code to get professor number on each loop and display it on the report but I get 9 rows of 00000000 instead of actual professor number. Can anyone help me please?

tables: ukurs.

data: itab like ukurs occurs 0 with header line.

select prfnr from ukurs into table itab

where prfnr in (00000002, 00000003,00000006).

loop at itab.

write:/ itab-prfnr.

endloop.

Thanks,

Khalid Atiq

2 REPLIES 2
Read only

chaouki_akir
Contributor
0 Likes
495

Bonjour,

There is a problem in your SELECT statement: replace "INTO TABLE" with "INTO CORRESPONDING FIELDS OF TABLE"

tables: ukurs.

data: itab like ukurs occurs 0 with header line.

SELECT prfnr FROM ukurs INTO   CORRESPONDING FIELDS OF TABLE itab
where prfnr in (00000002, 00000003,00000006).
loop at itab.
write:/ itab-prfnr.
endloop.

Cordialement,

Chaouki

Read only

Sandra_Rossi
Active Contributor
0 Likes
496

Hi Khalidatiq,

when you use SELECT <list of table columns> FROM <table> INTO \[TABLE\] <data object>, the data object must fit exactly the list of fields, in the same sequence and with exactly the same data types.

In your case, table column is PRFNR, and data object is (an internal table) with row type UKURS. So you must declare your data object like this :

data: itab like ukurs-prfnr occurs 0 with header line.

Note that your writing is obsolete, you'd better use, for example :

data itab type standard table of ukurs-prfnr.

Best regards,

Sandra