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: 

Retrieving data from Excel format to internal table(deep structure)

Former Member
0 Kudos

hi all,

can anybody help me how to Retrieving data from Excel format to internal table(deep structure)

and if u have any sample code for that please send it.

my internal table is like this

DATA: BEGIN OF ty_text,

vbeln TYPE vbeln,

posnr TYPE posnr,

seqno TYPE seqno,

textid TYPE tdid,

tdline TYPE tdline,

END OF ty_text.

DATA: BEGIN OF ty_item,

vbeln TYPE vbeln,

posnr TYPE posnr,

dispct1(16),

dispct2(16),

dispct3(16),

text LIKE table of ty_text,

END OF ty_item.

3 REPLIES 3

Former Member
0 Kudos

Hi,

Use the below function module

CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'
EXPORTING
* I_FIELD_SEPERATOR =
* I_LINE_HEADER =
i_filename = p_fname "'D:file1.xls'
* I_APPL_KEEP = ' '
tables
i_tab_sap_data = input_rec "your internal table
* CHANGING
* I_TAB_CONVERTED_DATA =
* EXCEPTIONS
* CONVERSION_FAILED = 1
* OTHERS = 2
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

Check this out

http://www.sapdevelopment.co.uk/file/file_updownpop.htm

http://www.sapdevelopment.co.uk/programs/custom/zdownempdata.htm

heck this code also,

CALL FUNCTION 'WS_EXCEL'

EXPORTING

FILENAME = 'C:\Documents and Settings\sample.xls '

  • SYNCHRON = ' '

TABLES

DATA = itab

  • EXCEPTIONS

  • UNKNOWN_ERROR = 1

  • OTHERS = 2

.

IF SY-SUBRC <> 0.

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

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

ENDIF.

Thanks.

Former Member
0 Kudos

hi,

check this code

TABLES:zmatnr.

TYPE-POOLS truxs.

DATA : itab LIKE alsmex_tabline OCCURS 0 WITH HEADER LINE.

DATA row LIKE alsmex_tabline-row.

data : gi_final like zmatnr occurs 0 with header line.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

PARAMETER : pfname LIKE rlgrap-filename OBLIGATORY.

SELECTION-SCREEN END OF BLOCK b1.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR pfname.

PERFORM search.

START-OF-SELECTION.

perform process.

form process.

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

EXPORTING

filename = pfname

i_begin_col = 1

i_begin_row = 2

i_end_col = 12

i_end_row = 65000

TABLES

intern = itab

EXCEPTIONS

inconsistent_parameters = 1

upload_ole = 2

OTHERS = 3.

IF sy-subrc <> 0.

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

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

ENDIF.

describe table itab lines itab_count.

row = 1.

loop at itab.

if itab-row <> row.

append gi_final.

clear gi_final.

endif.

case itab-col.

when '1'.

gi_final-MATNR = itab-value.

when '2'.

gi_final-Maktx = itab-value.

endcase.

row = itab-row.

endloop.

append gi_final.

clear gi_final.

endform.

FORM search .

CALL FUNCTION 'KD_GET_FILENAME_ON_F4'

EXPORTING

static = 'X'

CHANGING

file_name = pfname.

ENDFORM.

regards

siva

Former Member
0 Kudos

hi

good

USE FM gui_download.

Check this,

/people/harry.dietz/blog/2005/11/11/yet-another-from-database-or-internal-table-to-excel

Tou can use this FM also,

CALL FUNCTION 'WS_EXCEL'

EXPORTING

FILENAME = 'C:/RAMU.XLS'

  • SYNCHRON = ' '

TABLES

DATA = LT_EXCEL " internal table u want to download to excel

  • EXCEPTIONS

  • UNKNOWN_ERROR = 1

  • OTHERS = 2

UPLOAD / Download Programs to PC

http://abap4.tripod.com/Upload_and_Download_ABAP_Source_Code.html

http://www.sapgenie.com/abap/code/abap13.htm

http://sap.ittoolbox.com/code/archives.asp?d=3333&a=s&i=10

http://www.sap-img.com/abap/download-and-upload-your-abap-program.htm

http://www.geocities.com/rmtiwari/Resources/Utilities/WebViewer.html

reward point if helpful,.

thanks

mrutyun^