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: 

INTERNAL TABLE

Former Member
0 Kudos
397

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.

1 ACCEPTED SOLUTION

former_member188685
Active Contributor
0 Kudos
347

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

32 REPLIES 32

Former Member
0 Kudos
347

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

former_member188685
Active Contributor
0 Kudos
348

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

0 Kudos
347

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

0 Kudos
347

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.

0 Kudos
347

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

0 Kudos
347

Hi

See where that strcuture is used and give us the code

Max

0 Kudos
347

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

0 Kudos
347

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.

0 Kudos
347

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

0 Kudos
347

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

0 Kudos
347

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

0 Kudos
347

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

0 Kudos
347

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

0 Kudos
347

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

0 Kudos
347

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

0 Kudos
347
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

0 Kudos
347

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

0 Kudos
347

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

0 Kudos
347
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.

0 Kudos
347

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

0 Kudos
347

I am not getting any error

did u declare the same(syntax) as i had declared ,

0 Kudos
347

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.

0 Kudos
347

now it_new acts as a structure , u have to declare another table

data : it_new1 like it_new occurs 0 with header line.

0 Kudos
347

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

0 Kudos
347

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.

0 Kudos
347

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

0 Kudos
347

thnx each and every one for the immense help, espicially Shekar.

venu

Message was edited by: venu gopal

Message was edited by: venu gopal

Former Member
0 Kudos
347

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.

FredericGirod
Active Contributor
0 Kudos
347

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

Former Member
0 Kudos
347

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

Former Member
0 Kudos
347

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

Former Member
0 Kudos
347

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.