Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Uploading multiple excel sheets

Dear All,

We are having 4 different excel sheets where data is stored regarding the quantity of laptops, desktops, printers & xerox machines. This data is to be loaded into the SAP tables with Co Code & BA Code as primary key which is there available in excel sheets.

Plz help me in code to upload all the 4 files in SAP tables based on a combination of CO Code & BA Code.

The selection screen will have 4 fields to specify the path of all the 4 excel sheets & all the fields are obligatory.

Thanks & Reg,

Nishant

Tags:
replied

Hi Nishu,

Call this FORM as many times with the filenames and the start and end columns and rows..

form table_excel using filename(30)
                       startcol type i
                       endcol type i
                       startrow type i
                       endrow type i
                                              
           
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = filename
i_begin_col = startcol
i_begin_row = startrow
i_end_col = endcol
i_end_row = endrow
i_end_row = 4000
TABLES
intern = t_excel
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.
MESSAGE i010(zn) WITH 'Error in upload Please check the upload file'.
ENDIF.

DESCRIBE TABLE T_EXCEL LINES L_ENDROW1.

L_ENDROW1 = L_ENDROW1 / 2.


LOOP AT t_excel WHERE row = q_count.
IF t_excel-col = 1.
t_type2-gsber = t_excel-value.
ELSEIF t_excel-col = 2.
t_type2-bukrs = t_excel-value.
ENDIF.
ENDLOOP.
l_charlen1 = strlen( t_type2-bukrs ).
l_charlen2 = strlen( t_type2-gsber ).
if ( t_type2-bukrs <> ' ' and t_type2-gsber <> ' ' ).

if ( l_charlen1 = 4 and l_charlen2 = 4 ).

APPEND t_type2. 
CLEAR t_type2.

endif.

endif.
q_count = q_count + 1.
IF q_count > l_endrow1.
EXIT.
ENDIF.
ENDDO.


data : it_zfi_is_qty like table of zfi_is_qty with header line.

loop at t_type2.
 move-corresponding t_type2 to it_zfi_is_qty.
 append it_zfi_is_qty.
endloop.


insert zfi_is_qty from TABLE it_zfi_is_qty .
endform.

hope it works..

regards

satesh

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question