2018 Jul 09 9:19 AM
Hi ,
I have been trying to substitute this following obsolete code :
TABLES:ICON.
.....
.....
START-OF-SELECTION.
SELECT * FROM ICON ORDER BY NAME.
with the following code , but it's not working -
DATA: ICON_STRU TYPE ICON,
ICON_TAB TYPE TABLE OF ICON_STRU .
.....
.....
START-OF-SELECTION.
SELECT * FROM ICON_TAB ORDER BY NAME.
& when doing syntax check , it is giving following error:
The type "ICON_STRU" is unknown.
Since "Tables : ICON." is actually trying to create a structure with all the fields present in the DDIC table ICON , hence I substituted the code with :
DATA: ICON_STRU TYPE ICON,
which is doing the same thing i.e. creating a local structure with all the fields from ICON table
& then I am creating an Internal Table with this following code -
ICON_TAB TYPE TABLE ICON_STRU .
So , can anyone please tell me , what I am doing wrong in this coding?
Thanks & Regards,
Namrata
2018 Jul 10 5:00 AM
Sorry, if you need icon for display why dont just declare: TYPE-POOLS icon?
Otherwise, since ICON_STRU is variable ( under DATA statement) you can change ICON_TAB LIKE TABLE OF ICON_STRU. You should read about TYPE and DATA statement in F1 help.
2018 Jul 09 9:59 AM
hi,
this is extremely basic stuff, I suggest you do the following:
Go to se38, then CTL+F8, then type in Select into. This should explain what you're trying to achieve.
Kind regards, Rob Dielemans
2018 Jul 09 10:37 AM
Hi Rob,
You mean there is nothing wrong in declaring using this following code?
Data: ICON_STRU TYPE ICON,
ICON_TAB TYPE TABLE ICON_STRU .
But then in SE38 , why I'm getting this error - 'The type "ICON_STRU" is unknown.'
Also, I didn't get you what you wrote in the following - "Go to se38, then CTL+F8, then type in Select into." Can you please tell in more details?
2018 Jul 09 10:38 AM
I'm already using SE38 for coding! I didn't understand what you are pointing to...
2018 Jul 09 11:01 AM
He means that if you look at the syntax of SELECT you'll see why
SELECT * FROM ICON_TAB ORDER BY NAME.
is nonsense, and if you read a little about DATA and TYPES keyword in the documentation, you'll probably be able to work out why the below doesn't work (especially - and this is a hint - if you read the documentation for LIKE as well).
DATA: ICON_STRU TYPE ICON,
ICON_TAB TYPE TABLE OF ICON_STRU .
For syntax errors, always carefully read the syntax in the documentation.
2018 Jul 09 10:58 AM
Perform some search on DATA and TYPE(S) in Abap online documentation, and guess yourself 😉
2018 Jul 09 11:12 AM
2018 Jul 09 11:47 AM
How about:
SELECT [fieldlist] FROM icon INTO TABLE @DATA(lt_icon_data). (No * because it might be you don't need all the columns?)
And when LOOP-ing (or READ TABLE-ing):
LOOP AT lt_icon_data into data(ls_icon_data).
..
ENDLOOP.
2018 Jul 09 4:15 PM
Hi
What is "@DATA"? I didnt read this syntax in any book or abap documentation.
I mean the statement can be like this -
SELECT * FROM ICON ORDER BY NAME.
Then what is wrong in that? Not giving any error in SE38 and much simpler than all those jargons all of you used here just to confuse me more!!
2018 Jul 09 10:54 PM
It's new ABAP 7.4+ syntax. Won't work in an earlier release. We don't know what release you're working with, so people are trying to be helpful and suggesting new syntax, assuming it's applicable in your case.
2018 Jul 11 7:40 AM
Try reading the documentation for select. https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abapselect.htm
2018 Jul 11 7:49 AM
namrata.chaki, the @data is for inline declaration. It basically declares the internal table based on the fieldlist in your SQL. In short, you would not need to declare the internal table separately up front (see https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-US/abendata_inline.htm for more details).
And, no intention whatsoever to confuse you in any way. Just trying to help.
jelena.perfiljeva thanks! 😛
2018 Jul 09 11:12 PM
In this case the message means exactly what it says. ICON_STRU is not a type. It's a structure.
This code passes syntax check, for example:
DATA: icon_stru TYPE icon,
icon_tab TYPE TABLE OF icon.
START-OF-SELECTION.
SELECT * FROM icon
INTO TABLE icon_tab
ORDER BY name.
Type is either a dictionary type or what we define in the program using TYPES command. What is defined using DATA is a variable (of certain type).
Actually I ran into this a few times and got confused for a moment too. It kind of makes you think ICON_STRU doesn't exist at all but it is right there. 🙂 Have to really read this message carefully.
I agree with others that using SELECT * is not a good practice, unless you actually need all the data. I find that in the old programs SELECT * frequently comes hand in hand with TABLES. Lazy programming. 😞
2018 Jul 11 6:49 PM
2018 Jul 10 5:00 AM
Sorry, if you need icon for display why dont just declare: TYPE-POOLS icon?
Otherwise, since ICON_STRU is variable ( under DATA statement) you can change ICON_TAB LIKE TABLE OF ICON_STRU. You should read about TYPE and DATA statement in F1 help.
2018 Jul 10 10:39 PM
I feel that if another person suggests OP reads Help they'll completely lose it. 🙂