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

excel upload

Former Member
0 Likes
1,152

Hi all,

I need to upload excel data to z tables.

here i created table maintance generator for those tables.

how to upload the data from excel sheet to these tables.

Through BDC R is there any other way??

Please suggest.

Thanks,

CS.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,017

use WS_upload / GUI_upload fn module to upload data from EXcel to ztables,

Rgds,

Jothi.P

9 REPLIES 9
Read only

Former Member
0 Likes
1,018

use WS_upload / GUI_upload fn module to upload data from EXcel to ztables,

Rgds,

Jothi.P

Read only

Former Member
0 Likes
1,017

first use FM ALSM_EXCEL_TO_INTERNAL_TABLE and then move the date to internal table and

use

INSERT ZTABLE FROM TABLE ITAB.

Read only

Former Member
0 Likes
1,017

hi..

you can use either <b>BDC or LSMW</b> to upload datas from excel sheet to z tables..

first u have to convert the excel sheet into text format.

also u can use FM <b>GUI_UPLOAD</b>

below is the sample code, prepare the excel file data , as declared in the strucutre..once u have data in the internal table use INSERT command to put the records from the internal table to ZTABLE.

do like this :;

DATA : BEGIN OF TYP_INPUT ,

MATNR LIKE MARA-MATNR,

WERKS LIKE MARC-WERKS,

LGORT LIKE MARD-LGORT,

LGNUM LIKE MLGN-LGNUM,

LGTYP LIKE MLGT-LGTYP,

LTKZA LIKE MLGN-LTKZA,

LTKZE LIKE MLGN-LTKZE,

LGBKZ LIKE MLGN-LGBKZ,

LGPLA LIKE MLGT-LGPLA,

END OF TYP_INPUT.

*Input File Data

DATA : IT_FILE LIKE TYP_INPUT OCCURS 0 WITH HEADER LINE.

*"INTERNAL TAB TO TAKE EXCEL SHEET.

DATA : IT_EXCEL LIKE ALSMEX_TABLINE OCCURS 0 WITH HEADER LINE.

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

EXPORTING

FILENAME = P_PFILE

I_BEGIN_COL = 1

I_BEGIN_ROW = 2

I_END_COL = 9

I_END_ROW = 6000

TABLES

INTERN = IT_EXCEL

EXCEPTIONS

INCONSISTENT_PARAMETERS = 1

UPLOAD_OLE = 2

OTHERS = 3.

  • If Error Opening File

IF SY-SUBRC NE 0.

  • Message : Unable to Open File

MESSAGE I102.

STOP.

ENDIF.

****************************************************************

  • IT_EXCEL CONTAINS DATA IN THE FORM OF ROW, COL, VALUE *

  • CONVERTING THAT INTERNAL TABLE TO FORMAT THAT OF EXCEL SHEET *

****************************************************************

IF NOT IT_EXCEL[] IS INITIAL.

SORT IT_EXCEL BY ROW COL.

LOOP AT IT_EXCEL.

CASE IT_EXCEL-COL.

WHEN 1.

IT_FILE-MATNR = IT_EXCEL-VALUE.

WHEN 2.

IT_FILE-WERKS = IT_EXCEL-VALUE.

WHEN 3.

IT_FILE-LGORT = IT_EXCEL-VALUE.

WHEN 4.

IT_FILE-LGNUM = IT_EXCEL-VALUE.

WHEN 5.

IT_FILE-LGTYP = IT_EXCEL-VALUE.

WHEN 6.

IT_FILE-LTKZA = IT_EXCEL-VALUE.

WHEN 7.

IT_FILE-LTKZE = IT_EXCEL-VALUE.

WHEN 8.

IT_FILE-LGBKZ = IT_EXCEL-VALUE.

WHEN 9.

IT_FILE-LGPLA = IT_EXCEL-VALUE.

ENDCASE.

AT END OF ROW.

APPEND IT_FILE.

CLEAR IT_FILE.

ENDAT.

ENDLOOP.

ELSE.

MESSAGE I000 WITH 'The input file is empty'.

STOP.

ENDIF.

<b>Reward points if useful</b>

Regards

Ashu

Read only

Former Member
0 Likes
1,017

Hi CS,

First get the data into internal table using ALSM_EXCEL_TO_INTERNAL_TABLE and then upload it to DB table.

regards,

Atish

Read only

Former Member
0 Likes
1,017

Hi,

Create a report program with following steps :

Use FM GUI_UPLOAD to upload the excel file.

You will get the data into internal table.

Use statement INSERT ZTABLE using itab.

COMMIT WORK.

Best regards,

Prashant

Read only

Former Member
0 Likes
1,017

Hi,

U can upload the data through Table maintenance generator and thru BDC.

Read only

Former Member
0 Likes
1,017

Hi,

First upload the data to internal table, from there move into Ztable.

There are two function modules you can use: (1) 'ALSM_EXCEL_TO_INTERNAL_TABLE' or

(2) 'KCD_EXCEL_OLE_TO_INT'. Very similar but the first function module (ASLM) used in for foreground processing.

For sample code,Refer the foll, link

http://diocio.wordpress.com/2007/02/12/sap-upload-excel-document-into-internal-table-2/

Regards,

sathiya Ramasmay

Read only

jaideeps
Product and Topic Expert
Product and Topic Expert
0 Likes
1,017

hi,

chk this

TYPE-POOLS: truxs.

PARAMETERS: p_file TYPE rlgrap-filename.

TYPES: BEGIN OF t_datatab,

col1(30) TYPE c,

col2(30) TYPE c,

col3(30) TYPE c,

END OF t_datatab.

DATA: it_datatab type standard table of t_datatab,

wa_datatab type t_datatab.

DATA: it_raw TYPE truxs_t_text_data.

  • At selection screen

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

CALL FUNCTION 'F4_FILENAME'

EXPORTING

field_name = 'P_FILE'

IMPORTING

file_name = p_file.

***********************************************************************

*START-OF-SELECTION.

START-OF-SELECTION.

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 = p_file

TABLES

i_tab_converted_data = it_datatab[] "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.

***********************************************************************

  • END-OF-SELECTION.

END-OF-SELECTION.

LOOP AT it_datatab INTO wa_datatab.

WRITE:/ wa_datatab-col1,

wa_datatab-col2,

wa_datatab-col3.

ENDLOOP.

thanks

jaideep

*reward points if useful...

Read only

Former Member
0 Likes
1,017

This message was moderated.