‎2010 Jan 20 5:22 AM
Hi,
I have a requirement where in i have to cut and paste the data from excel sheet to screen in SAP. I have developed modulepool screen for this. In the screen i have 5 differnt fields and i want to copy data from excel sheet for these 5 fields and paste in the screen. As the fields are different i am unable to paste the data. Pls let me know how to solve this.
Thanks,
Raju
‎2010 Jan 20 5:49 AM
Hi
I suggest you to download excel sheet values in different variables or inernal table and then pass these values to screen fields.
I think thiis will resolve your problem.
Thanks
Khushboo
‎2010 Jan 20 5:56 AM
and that your fields in excel are not same as in module pool table, process the data in internal tab after you have imported it from excel.
Sumit
‎2010 Jan 20 5:58 AM
Dear Raj,
as my understanding y copy and paste
just use to download the data from excel to internal table and than populate that that wer ervr u need in modulepool
Thanks
Surendra P
‎2010 Jan 20 6:02 AM
Hi,
You can upload the Excel file into an Internal table using ALSM_EXCEL_TO_INTERNAL_TABLE, this internal table can be same as the one you are using on Table control. or Transfer this data to the internal table which you are using in Table control.
SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: l_file TYPE rlgrap-filename OBLIGATORY .
SELECTION-SCREEN : END OF BLOCK b1.
data : ist_excel TYPE STANDARD TABLE OF alsmex_tabline,
AT SELECTION-SCREEN ON VALUE-REQUEST FOR l_file.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
file_name = l_file.
REFRESH:ist_excel[].
CLEAR :ist_excel[].
*********** Get data from Excel File to Internal Table **********
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = l_file
i_begin_col = 1
i_begin_row = 2
i_end_col = 8
i_end_row = 9999
TABLES
intern = ist_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.
ENDIF.
*********** Set the Records of Internal table in Tabular Format **********
trow = 1.
LOOP AT ist_excel INTO wa_excel WHERE value NE ' '.
IF trow NE wa_excel-row.
trow = trow + 1.
ENDIF.
ENDLOOP.
row = 1.
WHILE row <= trow.
LOOP AT ist_excel INTO wa_excel WHERE row = row.
CASE wa_excel-col.
WHEN '0001'.
wa_emp_details-empnumber = wa_excel-value.
WHEN '0002'.
wa_emp_details-empaddr = wa_excel-value.
WHEN '0003'.
wa_emp_details-empphone = wa_excel-value.
WHEN '0004'.
wa_emp_details-empcity = wa_excel-value.
WHEN '0005'.
wa_emp_details-empfax = wa_excel-value.
WHEN '0006'.
wa_emp_details-empregio = wa_excel-value.
WHEN '0007'.
wa_emp_details-emphouseno = wa_excel-value.
ENDCASE.
ENDLOOP.
APPEND wa_emp_details TO ist_emp_details.
" Now pass this data back to the Internal Table you are using in Table Control
CLEAR:wa_emp_details.
row = row + 1.
ENDWHILE.Cheerz
Ram
‎2010 Jan 20 6:03 AM
There is now way to copy fields at one go.You can either copy one by one or write a Program to upload from excel to module pool screens.
Regards
Gaurav
‎2010 Jan 20 6:10 AM
Hi
If the fields are not selection screen fields and you want to paste the whole excel data into the screen , try using table control in the screen having same field names as in excel file. Just a suggestion , if i got ur requirement correct.
Thanks
Subha
‎2010 Jan 20 6:27 AM
Hi All,
Thanks for your answers,
I dont want to download the data from excel into internal table and display.
I just want to copy data from excel and paste into those 5 fields.
Apart from fields i have table controls in the screen, for which i can directly copy the data from excel sheet and paste in screen, but for individual fields if i want to copy and paste data from excel sheet... how to proceed, is it possible or not.
Thanks,
Raju
‎2010 Feb 04 8:12 AM
‎2010 Mar 22 10:17 AM
try using clipboard feature and get the data into an internal table in PAI, thereafter add this data to the table and display.
see the sample code below. You need to write another code snippet to split the values for col 1 and col 2 etc. after you have copied the data into the file_tab
MODULE get_clipboard_data OUTPUT.
modification for clipboard paste
types: begin of ty_tab,
locnr type locnr,
end of ty_tab.
data: lwa_tab type ty_tab.
data: li_tab type standard table of ty_tab.
data: li_tab_clip type filetable.
data: lwa_tab_clip type file_table.
data:lwa_klastab type rmclk.
*data: begin of li_klastab occurs 0.
include structure rmclk.
*data: end of li_klastab.
field-symbols:
<lfs_klastab> type rmclk.
case sy-ucomm.
WHEN 'CLIP'.
refresh: li_tab, li_tab_clip. "li_klastab.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>CLIPBOARD_IMPORT
IMPORTING
DATA = li_tab_clip
LENGTH =
EXCEPTIONS
CNTL_ERROR = 1
ERROR_NO_GUI = 2
NOT_SUPPORTED_BY_GUI = 3
others = 4
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
li_tab[] = li_tab_clip[].
*li_klastab[] = klastab[].
loop at li_tab into lwa_tab.
loop at klastab assigning <lfs_klastab>.
if <lfs_klastab>-objek is initial.
<lfs_klastab>-objek = lwa_tab-locnr.
<lfs_klastab>-index_tab = '1'.
else.
lwa_klastab-objek = lwa_tab-locnr.
lwa_klastab-index_tab = '1'.
append lwa_klastab to klastab.
endif.
exit.
endloop.
endloop.
*klastab[] = li_klastab[].
endcase.
ENDMODULE. " get_clipboard_data OUTPUT