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

converting excel data into sap data

Former Member
0 Likes
1,029

Hi All,

Help me on this , while while convert the data from excel to sap internal table, all the EXCEL data will come in one column in the inetrnal table .

i am using CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE' function for the converting.

This is the code.

DATA: it_main LIKE STANDARD TABLE OF alsmex_tabline WITH HEADER LINE.

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

EXPORTING

filename = 'C:\Documents and Settings\Naresh.Mekala\Desktop\ttd.xls'

i_begin_col = 1

i_begin_row = 1

i_end_col = 3

i_end_row = 3

TABLES

intern = it_main

  • EXCEPTIONS

  • INCONSISTENT_PARAMETERS = 1

  • UPLOAD_OLE = 2

  • OTHERS = 3

.

IF sy-subrc EQ 0.

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

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

ENDIF.

LOOP AT it_main.

*WRITE:/ IT_MAIN-ROW, ' ',

*IT_MAIN-COL, ' ',

WRITE: / it_main-value.

ENDLOOP.

9 REPLIES 9
Read only

RaymondGiuseppi
Active Contributor
0 Likes
979

You coding is correct (i copied it and its worked fine) so the problem is in your Excel ?

Regards,

Raymond

Read only

0 Likes
979

Hi friend,

i created excel sheet like three rows and three columns.

Regards,

Naresh

Read only

0 Likes
979

Hi..

You can use the function Module SAP_CONVERT_TO_XLS_FORMAT to update data from excel to sap.

Best Regards,

Vanessa Noronha.

Read only

0 Likes
979

Hello Naresh,

As per my understanding, you have a excel with say 3 rows and 3 columns and you uploaded the same and collected the data in an internal table. Now you are getting the data in the same column and this is your concern.

Id this is the concern, then see in the internal table you are getting the row numbeer, cloumn number and the value of the cell (row, column). So based on the row number and column number you have to process the data accordingly.

Hope this helps you.

Regards,

Sachinkumar Mehta.

Read only

Former Member
0 Likes
979

Hi friend,

i created excel sheet like three rows and three columns.

Regards,

Naresh

Read only

Former Member
0 Likes
979

DATA : it_raw TYPE truxs_t_text_data.

DATA: filename1(128) TYPE c.

MOVE: filename TO filename1.

CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'

EXPORTING

  • I_FIELD_SEPERATOR =

i_line_header = 'X'

i_tab_raw_data = it_raw " WORK TABLE

i_filename = filename1

TABLES

i_tab_converted_data = IT_DUMMY "ACTUAL 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.

Read only

Former Member
0 Likes
979

Have a look at program FILA_HELP_UPLOAD_EXCEL_01 for an example.

Rob

Read only

Former Member
0 Likes
979

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.

break developer.

LOOP AT intern.

intern1 = intern.

CLEAR intern1-row.

APPEND intern1.

ENDLOOP.

SORT intern1 BY col.

LOOP AT intern1.

AT NEW col.

t_col-col = intern1-col.

APPEND t_col.

ENDAT.

zwlen = strlen( intern1-value ).

READ TABLE t_col WITH KEY col = intern1-col.

IF sy-subrc EQ 0.

IF zwlen > t_col-size.

t_col-size = zwlen.

  • Internal Table, Current Row Index

MODIFY t_col INDEX sy-tabix.

ENDIF.

ENDIF.

ENDLOOP.

DESCRIBE TABLE t_col LINES zwlines.

SORT intern BY row col.

DO zwlines TIMES.

WRITE sy-index TO fieldnames-title.

APPEND fieldnames.

ENDDO.

SORT intern BY row col.

LOOP AT intern.

tind = intern-col.

CONCATENATE 'DATA_TAB-VALUE_' tind INTO zwfeld.

ASSIGN (zwfeld) TO <fs1>.

<fs1> = intern-value.

AT END OF row.

APPEND data_tab.

CLEAR data_tab.

ENDAT.

ENDLOOP.

Read only

Former Member
0 Likes
979

thanks for all