2007 Oct 25 7:32 AM
hi,
how to upload data from excel sheet to sap using call tranaction or session input or lsmw ?
2007 Oct 25 7:34 AM
convert the xls to a tab delimetd file by saving it as a tab delimted in windows.
now when u run lsmw , uae this file and use file type as tabular
hi,
how to upload data from excel sheet to sap using call tranaction or session input or lsmw ?
2007 Oct 25 7:34 AM
convert the xls to a tab delimetd file by saving it as a tab delimted in windows.
now when u run lsmw , uae this file and use file type as tabular
2007 Oct 25 7:35 AM
Use this FM ALSM_EXCEL_TO_INTERNAL_TABLE to upload excel into an internal table in call tranaction or session input.
For LSMW.. that will automatically reads Excel depending on the field mapping you have done.
2007 Oct 25 10:06 AM
Use FMs
GUI_DOWNLOAD
ALSM_EXCEL_TO_INTERNAL_TABLE
Hope this helps
Reward if it does
2007 Oct 25 10:21 AM
Hi ,
In LSMW it is not possible to upload the data in Excel format, you need to save the excel sheet data as a tab delimeted file and then upload the data using LSMW.
For BDC or Call transaction you can upload the Excel file by using the function module ''ALSM_EXCEL_TO_INTERNAL_TABLE''.
See the foloowing sample code:
UPLOAD OF EXCEL FILE:
REPORT ZRAJESH..
TYPE-POOLS : slis.
DATA : BEGIN OF it_fin OCCURS 1,
f1(20),
f2(30),
f3(20),
f4 TYPE i,
END OF it_fin.
DATA : intern1 TYPE TABLE OF alsmex_tabline WITH HEADER LINE.
REFRESH it_fin[].CLEAR it_fin.
CLEAR intern1.
PARAMETERS fl_name TYPE rlgrap-filename.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR fl_name.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
PROGRAM_NAME = SYST-REPID
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = ' '
static = 'X'
MASK = ' '
CHANGING
file_name = fl_name
EXCEPTIONS
MASK_TOO_LONG = 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.
START-OF-SELECTION.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = fl_name
i_begin_col = '1'
i_begin_row = '1'
i_end_col = '4'
i_end_row = '35'
TABLES
intern = intern1
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.
CLEAR fl_name.
FIELD-SYMBOLS : <fs1> TYPE ANY,
<fs2> TYPE ANY.
data: v_col(3) type n ,
v_col2(3) type n value '003'.
LOOP AT intern1.
v_col = intern1-col.
ASSIGN component v_col2 of structure intern1 TO <fs1>.
ASSIGN component v_col of structure it_fin TO <fs2>.
<fs2> = <fs1>.
CASE INTERN1-COL.
*
WHEN '001'.
*
IT_FIN-F1 = INTERN1-VALUE.
*
WHEN '002'.
*
IT_FIN-F2 = INTERN1-VALUE.
*
WHEN '003'.
*
IT_FIN-F3 = INTERN1-VALUE.
*
WHEN '004'.
*
IT_FIN-F4 = INTERN1-VALUE.
*
*
*
ENDCASE.
*
AT END OF row.
APPEND it_fin.
CLEAR: it_fin,v_col.
ENDAT.
ENDLOOP.
DATA : v_prgname TYPE sy-repid VALUE sy-repid,
it_fldcat TYPE slis_fieldcat_alv OCCURS 1,
wa_fldcat TYPE slis_fieldcat_alv,
it_sort TYPE slis_sortinfo_alv OCCURS 1,
wa_sort TYPE slis_sortinfo_alv.
wa_fldcat-fieldname = 'F1'.
wa_fldcat-col_pos = 1.
wa_fldcat-tabname = 'IT_FIN'.
wa_fldcat-seltext_m = 'VENDOR NO'.
APPEND wa_fldcat TO it_fldcat.
CLEAR wa_fldcat.
wa_fldcat-fieldname = 'F2'.
wa_fldcat-col_pos = 2.
wa_fldcat-tabname = 'IT_FIN'.
wa_fldcat-seltext_m = 'VENDOR NAME'.
APPEND wa_fldcat TO it_fldcat.
CLEAR wa_fldcat.
wa_fldcat-fieldname = 'F3'.
wa_fldcat-col_pos = 3.
wa_fldcat-tabname = 'IT_FIN'.
wa_fldcat-seltext_m = 'VENDOR CITY'.
APPEND wa_fldcat TO it_fldcat.
CLEAR wa_fldcat.
wa_fldcat-fieldname = 'F4'.
wa_fldcat-col_pos = 4.
wa_fldcat-tabname = 'IT_FIN'.
wa_fldcat-seltext_m = 'AMOUNT'.
*wa_fldcat-do_sum = 'X'.
APPEND wa_fldcat TO it_fldcat.
CLEAR wa_fldcat.
*
*wa_sort-fieldname = 'F3'.
*wa_sort-tabname = 'IT_FIN'.
*wa_sort-up = 'X'.
*wa_sort-subtot = 'X'.
*append wa_sort to it_sort.
*clear wa_sort.
*
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
i_callback_program = v_prgname
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE =
I_GRID_SETTINGS =
IS_LAYOUT =
it_fieldcat = it_fldcat[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
it_sort = it_sort[]
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS =
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
I_HTML_HEIGHT_TOP = 0
I_HTML_HEIGHT_END = 0
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO =
IR_SALV_FULLSCREEN_ADAPTER =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = it_fin
EXCEPTIONS
program_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.
2007 Oct 25 10:34 AM
Hi,
File manuplations...............................
1. At the presentation level:
->GUI_UPLOAD
->GUI_DOWNLOAD
->CL_GUI_FRONTEND
2. At the application server level:
->OPEN DATASET : open a file in the application server for reading or writing.
->READ DATASET : used to read from a file on the application server that has been opened for reading
-> TRANSFER DATASET : writing data to a file.
-> CLOSE DATASET : closes the file
-> DELETE DATASET : delete file
************************************************************************************************
If file is on the local PC,use the function module GUI_UPLOAD to upload it into an internal table by passing the given parameters......
call function 'GUI_UPLOAD'
exporting
filename = p_file
filetype = 'ASC'
has_field_separator = '#'
tables
data_tab = t_data
******************************************************************************
p_file : excel file path.
t_data : internal table
*******************************************************************************
<b>reward points if useful.</b>
regards,
Vinod Samuel.
<b></b><b></b>
2007 Oct 25 12:41 PM
we cant upload xls file using lsmw in this method we have to .txt/.csv
thanks