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

Alter an internal table

Former Member
0 Likes
1,590

Hi,

I am declaring an internal table using INCLUDE structure say MARA.On inclusion the internal table structure will include 'MANDT' field also.

Now I need to remove this MANDT column from internal table in the program.

Can we alter the structure of this internal table by removing any column at run time.!!

Please suggest.

Thanks,

Vipin

9 REPLIES 9
Read only

Former Member
0 Likes
1,107

Hi.....

Just see this link...

it helps you a lot......

http://www.saptechnical.com/Tutorials/ABAP/DynamicInternaltable/DynamicInternalTable.htm

Reward points if useful......

Suresh.....

Read only

Former Member
0 Likes
1,107

hi Vipin,

as per my understanding, it is not possible to delete it at runtime.

just try not to use that field at all while u r using that table for output.

i think it won't effect your output.

Please let me know the exact prob. ur getting while populating that internal table.

Regards

Praveen

Read only

0 Likes
1,107

Hi Praveen,

Actually after declaration I am uploading an excel file which doesn't contain this MANDT but contain all other fields . Now If i upload data will come into internal table in wrong sequence.

Therefore I need to exclude this MANDT field at runtime.Also It will help to write

a fine pretty good readable program.

Hope you got the problem.

Regards

Vipin

Read only

0 Likes
1,107

hi Vipin,

i feel u shud proceed like this:

just upload the file and after uploading it into file_tab, just populate it by truncating MANDT field.

t_file-field1 = file_tab-field1+0(3).

t_file-field2 = file_tab-field1+x(y)..

Try this way and let me know..

Read only

0 Likes
1,107

Hi,

I am using WS_UPLOAD function to upload file contents to internal table.

Thanks

Vipin

Read only

0 Likes
1,107

Hi,

Try this:

1. Do not use Include structure to delcare structure of itab use field list instead.

OR

2. if u dont want as above then , In excel add first column as MANDT, Upload excel, run following loop.

loop at itab.

itab-mandt =sy-mandt.

modify itab.

endloop.

Hope these are two best options for you.

Reward if helpful.

Jogdand M B

Read only

0 Likes
1,107

data: begin of file_tab.

include structure mara.

data: end of file_tab.

CALL FUNCTION 'WS_UPLOAD'

  • EXPORTING

  • CODEPAGE = ' '

  • FILENAME = ' '

  • FILETYPE = 'ASC'

  • HEADLEN = ' '

  • LINE_EXIT = ' '

  • TRUNCLEN = ' '

  • USER_FORM = ' '

  • USER_PROG = ' '

  • DAT_D_FORMAT = ' '

  • IMPORTING

  • FILELENGTH =

TABLES

data_tab = file_tab.

  • EXCEPTIONS

  • CONVERSION_ERROR = 1

  • FILE_OPEN_ERROR = 2

  • FILE_READ_ERROR = 3

  • INVALID_TYPE = 4

  • NO_BATCH = 5

  • UNKNOWN_ERROR = 6

  • INVALID_TABLE_WIDTH = 7

  • GUI_REFUSE_FILETRANSFER = 8

  • CUSTOMER_ERROR = 9

  • OTHERS = 10

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

now populate your desired table this way:

outtab-field1 = file-tab+3(x)....

try this way....

Read only

Former Member
0 Likes
1,107

Hi,

That's why there are different means of declaring an internal Table;

So if you don't want MANDT field then deon't declare using Include structure,

We use this type of declation generally when we try to modify the table from an internal table.

Declare the internal table other way.

and why do you need all the table fields first up all?

So depending on our requirement we should use correct type of declaration of internal tables.

reward if useful

regards,

ANJI

Read only

Former Member
0 Likes
1,107

Hi,

for that u have to create internal table with out using include structure.or enter 3 spaces in the flat file.

to create a structure follow these steps.go to se38.

press pattern->structured data object(radio button)->with fields from structure(radio button)->enter database table and press enter

select all check boxes except MANDT.AND PRESS COPY.it will ask u for structured data object.give the name with which u want to crete an internal table and press enter.

rgds,

bharat.