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: 

Header line in Gui_upload

Former Member
0 Kudos

Hello,

I wish to upload contents of an excel file to an internal table using GUI_UPLOAD.

This file has the first row as header for the rows below.

How do i ignore this row when uploading contents to internal table?

Thanks in advance.

1 ACCEPTED SOLUTION

amit_khare
Active Contributor
0 Kudos

Welcome to SDN.

IF you want it to upload with GUI_UPLOAD then after uploading the records in table delete the row with index 1 from the intenal table.

otherwise you can always go for ALSM_EXCEL_TO_INTERNAL_TABLE, where you can give the sarting row and column to read the excel.

I will prefer the later one anytime over the former.

A sample code -

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

EXPORTING

filename = filename

i_begin_col = begcol

i_begin_row = begrow

i_end_col = endcol

i_end_row = endrow

TABLES

intern = intern

EXCEPTIONS

inconsistent_parameters = 1

upload_ole = 2

OTHERS = 3.

IF sy-subrc <> 0.

WRITE:/ 'Upload Error ', SY-SUBRC.

ENDIF.

clear intern.

LOOP AT intern.

at new col.

v_new = 1.

endat.

if v_new = 1.

clear v_new.

col = intern-col.

CASE col .

when '1'.

itab-ENO = intern-value.

when '2'.

itab-ENAME = intern-value.

endcase.

endif.

at end of row.

append itab. clear itab.

endat.

endloop.

Regards,

Amit

Reward all helpful replies.

10 REPLIES 10

amit_khare
Active Contributor
0 Kudos

Welcome to SDN.

IF you want it to upload with GUI_UPLOAD then after uploading the records in table delete the row with index 1 from the intenal table.

otherwise you can always go for ALSM_EXCEL_TO_INTERNAL_TABLE, where you can give the sarting row and column to read the excel.

I will prefer the later one anytime over the former.

A sample code -

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

EXPORTING

filename = filename

i_begin_col = begcol

i_begin_row = begrow

i_end_col = endcol

i_end_row = endrow

TABLES

intern = intern

EXCEPTIONS

inconsistent_parameters = 1

upload_ole = 2

OTHERS = 3.

IF sy-subrc <> 0.

WRITE:/ 'Upload Error ', SY-SUBRC.

ENDIF.

clear intern.

LOOP AT intern.

at new col.

v_new = 1.

endat.

if v_new = 1.

clear v_new.

col = intern-col.

CASE col .

when '1'.

itab-ENO = intern-value.

when '2'.

itab-ENAME = intern-value.

endcase.

endif.

at end of row.

append itab. clear itab.

endat.

endloop.

Regards,

Amit

Reward all helpful replies.

0 Kudos

Thanks for the reply, Amit. But the FM 'ASLM_EXCEL_TO_INTERNAL' does not work on the server I'm working on.

Also, getting all the data into an internal table and then deleting the 1st row is also not happening as it is not able to interpret the file data because of type mismatch in internal table structure and excel file data(the header)...

0 Kudos

Define one more internal table(itab2) with the structure same as your current internal table(itab1) but with all <b>character fields</b>. Keep all the names same, just change the type.

Use itab2 for GUI_UPLOAD.

After GUI_UPLOAD, Delete first record in itab2. And then,

LOOP AT ITAB2.

CLEAR ITAB1.

MOVE-CORRESPONDING ITAB2 TO ITAB1.

APPEND ITAB1.

ENDLOOP.

Message was edited by:

Darshil Shah

0 Kudos

Are you in SRM or CRM.....

If not this FM is there in all version of R/3.

'ALSM_EXCEL_TO_INTERNAL_TABLE'

Regards,

Amit

0 Kudos

I'm not in R/3..

0 Kudos

If you are not on R/3 or ECC system then check these links -

Regards,

Amit

0 Kudos

Hi RN

I am facing exactly the same problem.

Have you found a solution yet?

If so, would appreciate if you could share some tips.

Thanks.

0 Kudos

The solution which Darshil Shah has provided solved my problem.You could check that out. In case of any problem let me know.

0 Kudos

Thanks a million! It works.

0 Kudos

Did you convert u're excell to .txt

when i use the GUI_upload it after every space it put # how do u do that . though a split?