2006 Feb 23 3:56 PM
Hi All,
I have seen in a program the internal table like this:
<b> data: begin of i_table,
record(2) type c,
matnr like mara-matnr,
smatn like knodd-smatn,
laeda like mara-laeda,
......................
......................
end of i_table.</b>
and he's using that internal table later on in the program.
but when i tried to add some more fields to that internal table and use, it's giving syntax error saying that "OCCURS n" specification is missing.
How come he could used that internal table without "Occus n" specificaiton, and why it is giving error for me now.
plz clarify.
thnx a lot.
2006 Feb 23 3:57 PM
data: begin of i_table <b>occurs 0,</b>
record(2) type c,
matnr like mara-matnr,
smatn like knodd-smatn,
laeda like mara-laeda,
......................
......................
end of i_table.
occurs 0 is missing..
regards
vijay
2006 Feb 23 3:56 PM
he might have used it as <b>TYPES</b>, is the code posted by u the same as written by him
data: begin of i_table <b>occurs 5</b>,
record(2) type c,
matnr like mara-matnr,
smatn like knodd-smatn,
laeda like mara-laeda,
Message was edited by: Sekhar
2006 Feb 23 3:57 PM
data: begin of i_table <b>occurs 0,</b>
record(2) type c,
matnr like mara-matnr,
smatn like knodd-smatn,
laeda like mara-laeda,
......................
......................
end of i_table.
occurs 0 is missing..
regards
vijay
2006 Feb 23 4:00 PM
no, u got me wrong.
that program was working fine without "occurs n" specification earlier.
but when i tried to add some more fields to that, it is giving errors?
my question is: how come that program worked fine earlier without that "occurs n" specification?
hope it is clear now.
-
there is not such "TYPES" mentioning and no "WITH HEADER LINE" mentioning.
Message was edited by: venu gopal
2006 Feb 23 4:03 PM
Hi Venu gopal,
According to the definition,it is a structure.He must have defined a internal table with that structure.
But when you define a tbale without occurs n,it is a structure.
2006 Feb 23 4:04 PM
Hi Venu,
then they might have declared it some where like this
data: itab like i_table occurs 0 with header line.
so the error is coming because you might have used some where you are doing one of these..'
<b> loop at i_table. or read table i_table or select into i_table</b>
regards
vijay
2006 Feb 23 4:06 PM
2006 Feb 23 4:29 PM
When you added the extra fields, did you also add some coding like: append i_table or loop at i_table? That would explain why it worked before but not after your changes.
Rob
2006 Feb 23 4:47 PM
yes. you all r correct.
it was just a structure earlier.
now after adding the fileds, i'm trying to do the "append itab" and "loop at itab".
tht's why it is giving the error.
tht's cleared now.
could you please tell me how to overcome this?
now that i'm trying to add some more fields to that stucture and trying to do the "append" and loop at itab", how should i proceed for that changes to be done?
thnx a lot.
2006 Feb 23 4:51 PM
Hi Venu gopal,
Declare another internal with this structure.Or just add <b>OCCURS 0</b> to the existing definition of the internal table.
Also you can add your additional fields to this internal table definition.
Message was edited by: Phani Kiran Nudurupati
2006 Feb 23 4:51 PM
declare like this
add the fields u want to the structure and declare like this
data:it_table like i_table occurs 0 with header line.
Message was edited by: Sekhar
2006 Feb 23 4:56 PM
Just look for the
decalration of
<b>data: itab like i_table occurs 0 with header line.</b>
do operation on the table <b>itab</b>.
what ever you want to do , loop or what ever..
Regards
vijay
2006 Feb 23 5:00 PM
You're really changing the logic of the program. Without knowing the new requirements, it's hard to tell you how to proceed.
In particular, the old logic may not work if you simply change the structure to an internal table.
Rob
2006 Feb 23 5:47 PM
the existing structure is like this, right.
<b>data: begin of i_table,
record(2) type c,
matnr like mara-matnr,
smatn like knodd-smatn,
laeda like mara-laeda,
......................
......................
end of i_table.</b>
now i want to populate this stucture as an internal table , with adding my 3 more fields.
the extra 3 fields i should add are:
ex_f1 type c,
ex_f2 type c,
ex_f3 type c,
how can i do that?
thnx
Message was edited by: venu gopal
2006 Feb 23 5:52 PM
Hi,
what do you mean by this...
data: itab like i_table occurs 0 with header line.
extrafiled1 type c,
extrafield2 type c,
extrafield3 type c.
and add those fields to the structure, since it is a structure , you/some one might have delcared internal table based on it, and populate the fields to that itab,
...
regards
vijay
2006 Feb 23 6:05 PM
Hi venu
for the changed structure create a internal table
data: itab like i_struct occurs 0.
itab-<field> = ''.
itab-<field> = ''.
itab-<field> = ''.
itab-<field> = ''.
itab-<field> = ''.
append itab.
regards
kishore
2006 Feb 23 6:12 PM
try this without disturbing ur original structure
data : begin of it_new occurs 0,
begin of i_table,
record(2) type c,
matnr like mara-matnr,
smatn like knodd-smatn,
laeda like mara-laeda,
......................
......................
end of i_table,
ex_f1 type c,
ex_f2 type c,
ex_f3 type c,
end of it_new.
so while retreiving u can use it_new-i_table-matnr.
Message was edited by: Sekhar
2006 Feb 23 6:22 PM
thnx shekar,
i have tried the method:
i have added the 3 more new fields to the old existing sturcture.
and populated the internal table like this.
<b>data: it_new like i_table occurs 0 with header line.</b>
but it is giving an error saying that, " field i_table is uknown, it is not defined".
and there are 100 fields in the old existing stucture.
my question is: can't i include the stucture and the 3 new fileds in the newly populated internal table like:
<b>data: begin of it_new occurs 0,
include structure i_table,
ex_f1 type c,
ex_f2 type c,
ex_f3 type c,
end of it_new.</b>
plz let me know.
thnx much
2006 Feb 23 6:34 PM
use this..
Types: begin of tp_new.
include structure i_table.
types: ex_f1 type c,
ex_f2 type c,
ex_f3 type c,
end of tp_new.
data : it_new type table of tp_new with header line.
hope it helps.
Bikash
2006 Feb 23 6:35 PM
yes u can use like this
DATA : BEGIN OF I_NEW.
INCLUDE STRUCTURE I_TABLE.
DATA : ex_f1 type c,
ex_f2 type c,
ex_f3 type c.
DATA :END OF I_NEW.
2006 Feb 23 6:46 PM
whenever i'm doing that, it is giving error " field I_TABLE is unknown. it is not defined".
wht could be the reason for this error?
thnx
2006 Feb 23 6:55 PM
I am not getting any error
did u declare the same(syntax) as i had declared ,
2006 Feb 23 7:08 PM
shekar,
now that is not coming, but different error is coming.
later in the code, it is showing the error "<b>it_new</b> is not an internal table, <b>occurs n</b> specification is missing".
plz help me.
thnx.
2006 Feb 23 7:14 PM
now it_new acts as a structure , u have to declare another table
data : it_new1 like it_new occurs 0 with header line.
2006 Feb 23 7:25 PM
can't I avoid the structure and declare a new internal table with the old sturcture (i_table) itself.???
for eg: if i have select matnr from the old structure it is getting a complicated process...
plz let me know,
thnx
2006 Feb 23 7:30 PM
Hi Venu gopal,
You can directly declare the internal table instead of defining a structure & using it in declaring your internal table.
But you have to write all the fields again in your internal table.
2006 Feb 23 7:32 PM
1. u cannot declare like ur old structure as u want some more fields to be added to the existing structure.
u have to declare a new structure as per ur requirement.
2.I dont know why u feel complicated in selecting matnr
pls reward points for all the useful answers that u had got against each one and close it if solved
Message was edited by: Sekhar
2006 Feb 23 8:13 PM
thnx each and every one for the immense help, espicially Shekar.
venu
Message was edited by: venu gopal
Message was edited by: venu gopal
2006 Feb 23 3:59 PM
Hi Venugopal,
Check in the same program,he must have defined some other internal table & used this structure.
like..
DATA: I_TABLE1 LIKE I_TABLE OCCURS 0 WITH HEADER LINE.
2006 Feb 23 3:59 PM
Hi,
without the OCCURS you have define a structure not a table. So you can't append anything.
Maybe you will have later a command like :
data : it_table like table of i_table with header-line.
Rgd
Frédéric
2006 Feb 23 4:01 PM
Hi Venu
if you are trying to populate the internal table with the rows then you should specify the occurs n statement so that the system allocates the necessary memory for the internal table.
regards
kishore
2006 Feb 23 4:09 PM
If we use DATA without occurs it acts as a structure
u might have tried to Loop at that internal table , so it gave u the error
2006 Feb 23 4:10 PM
The program may be earlier populating only Header and not the Body. Just check whether earlier append statement was there before your more fields addition? If this was there earlier too then you would have encountered the same problem earlier too.