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 tables

Former Member
0 Kudos
101

I am having a flat file which contains a field named matnr.

i nedd to declare a internal table with field matnr1 and matnr 2.

my problem is in my flat file they may be 10 material numbers or 100.

so looking how to declare an internal table dynamically so that my internal table should contain 10 material matnr1....matnr10 if it contains 100 internal table should contain matnr1..............matnr100.

if not able to understand please do reply

6 REPLIES 6

Former Member
0 Kudos
75

Hi,

No need to bother about how an internal Table takes how many records.(10 or 100)

At run time they increase automatically depending on the requirement.

Just declare Itab as OCCURS 0.

Regards,

Anji

Former Member
0 Kudos
75

Hi bala,

1. From Vertical----


> To Horizontal

2. Its very difficult to do this way, dynamically.

3. Its best to declare pre-defined fixed fields with name such as

MATNR001, MATNR002 .. and so on.

regards,

amit m.

Former Member
0 Kudos
75

please be more clear

Former Member
0 Kudos
75

Hi,

Declare liek this,

DATA: ITAB LIKE STANDARD TABLE OF <Flatfile Structure> WITH HEADER LINE.

It should work.

Thanks,

Prashanth

Former Member
0 Kudos
75

data : begin of itab occurs 0,

matnr(200),

end of itab.

data : title(200),

vtext(18).

:

data : len type i.

using gui_upload fn module just fill int table itab1.

sort itab1 by matnr.

delete adjacent duplicates from itab1 comparing matnr.

describe table itab1 lines len.

do len times.

concatenate 'Matnr' sy-index into v_text.

conactenate title v_text into title separated by space..

enddo.

write : / title.

IT WILL SHOW THE HEADING

loop at itab1.

concatenate itab-matnr itab1-matnr into itab-matnr.

endloop.

append itab-matnr.

loop at itab.

write : / itab-matnr.

endloop.

it will show the matrial no.

regards

shiba dutta

0 Kudos
75

if your is regarding n number of materials i.e different records then declaring the itab with occurs 0 would serve your purpose as size of the itab would increase dyanmically. But if your case is regarding having n number of material fields its not possible to declare new fields for an itab dynamically. If you are not sure on how many fields are there, then you are gonna face a problem in uploading the flat file to the itab

My suggestion is you reanalyse the requirement and change your logic accordingly