Upload Function module
Hi all,
I tried to upload the Data from flat file into internal table but it is displaying some thing wrong please go through the program, flatfile and output and please suggest me.
Program:
data : begin of itab occurs 0,
kunnr type kna1-kunnr,
Name1 type kna1-name1,
ort01 type kna1-ort01,
land1 type kna1-land1,
end of itab.
CALL FUNCTION 'UPLOAD'
EXPORTING
CODEPAGE = ' '
FILENAME = 'c:/test.txt'
FILETYPE = 'asc'
ITEM = ' '
FILEMASK_MASK = ' '
FILEMASK_TEXT = ' '
FILETYPE_NO_CHANGE = ' '
FILEMASK_ALL = ' '
FILETYPE_NO_SHOW = ' '
LINE_EXIT = ' '
USER_FORM = ' '
USER_PROG = ' '
SILENT = 'S'
IMPORTING
FILESIZE =
CANCEL =
ACT_FILENAME =
ACT_FILETYPE =
TABLES
data_tab = itab
EXCEPTIONS
CONVERSION_ERROR = 1
INVALID_TABLE_WIDTH = 2
INVALID_TYPE = 3
NO_BATCH = 4
UNKNOWN_ERROR = 5
GUI_REFUSE_FILETRANSFER = 6
OTHERS = 7
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
loop at itab.
write : / itab-kunnr, itab-name1, itab-ort01, itab-land1.
endloop.
test file have the following data sapetated by tab spaces:
0001 Ranjith nrml in
0002 mahesh nzb us
and the Output is some thing errotic as below
0001#Ranji th#nrml#in
0002#mahes h#nzb#us
Please suggest me
Thanks in advance.
flie save as tab deilmeter.
Download/Upload SAP Users Favorites
This program allows you to transfer the user Favorites from one PC to another.
Written by : SAP Basis, ABAP Programming and Other IMG Stuff
http://www.sap-img.com
REPORT ZFAVORITES.
DATA : G_FILE(128) TYPE C.
DATA : G_PATH(80) TYPE C.
DATA : G_END(8) TYPE C.
DATA : G_SUBRC LIKE SY-SUBRC.
PARAMETERS: P_UNAME LIKE SY-UNAME DEFAULT SY-UNAME.
PARAMETERS: P_LANGU LIKE SY-LANGU DEFAULT SY-LANGU.
SELECTION-SCREEN SKIP.
PARAMETERS: P_IMP RADIOBUTTON GROUP ACT .
PARAMETERS: P_EXP RADIOBUTTON GROUP ACT DEFAULT 'X'.
SELECTION-SCREEN ULINE.
SELECTION-SCREEN BEGIN OF BLOCK FIL.
PARAMETERS: P_TYPE LIKE RLGRAP-FILETYPE DEFAULT 'ASC'.
PARAMETERS: P_PATH LIKE G_PATH DEFAULT 'C:TEMPXXX.MEN'.
SELECTION-SCREEN END OF BLOCK FIL.
DATA: IT_USER_NODES TYPE TABLE OF BXMNODES1 WITH HEADER LINE.
DATA: IT_FAV_NODES TYPE TABLE OF BXMNODES WITH HEADER LINE.
DATA: BEGIN OF IT_PCF OCCURS 0,
LINE(4096) TYPE C.
DATA: END OF IT_PCF.
INITIALIZATION.
REPLACE 'XXX' WITH SY-UNAME INTO P_PATH.
CONDENSE P_PATH NO-GAPS.
SY-TITLE = 'UPLOAD/DOWNLOAD FAVORITE'.
START-OF-SELECTION.
CLEAR IT_USER_NODES[].
CLEAR IT_FAV_NODES[].
G_FILE = P_UNAME.
IF P_UNAME <> SY-UNAME.
MESSAGE W398(00) WITH 'CURRENT USER <> USER TO BE MODIFIED!'.
ENDIF.
IF P_IMP = 'X'.
PERFORM IMPORT_FAV TABLES IT_FAV_NODES.
PERFORM WRITE_FAV_DB TABLES IT_FAV_NODES.
ELSEIF P_EXP = 'X'.
PERFORM EXPORT_FAV TABLES IT_FAV_NODES.
ENDIF.
FORM DATA_EXPORT TABLES PIT_PCF
USING P_FILE.
CALL FUNCTION 'DOWNLOAD'
EXPORTING
FILENAME = P_FILE
FILETYPE = P_TYPE
TABLES
DATA_TAB = PIT_PCF
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_WRITE_ERROR = 2
INVALID_FILESIZE = 3
INVALID_TABLE_WIDTH = 4
INVALID_TYPE = 5
NO_BATCH = 6
UNKNOWN_ERROR = 7
GUI_REFUSE_FILETRANSFER = 8
OTHERS = 9.
IF SY-SUBRC NE 0.
WRITE: / 'FAILURE IN DOWNLOAD' , P_FILE.
ENDIF.
ENDFORM.
FORM DATA_IMPORT TABLES PIT_PCF
USING P_FILE P_SUBRC.
CALL FUNCTION 'UPLOAD'
EXPORTING
FILENAME = P_FILE
FILETYPE = P_TYPE
TABLES
DATA_TAB = PIT_PCF
EXCEPTIONS
CONVERSION_ERROR = 1
FILE_OPEN_ERROR = 2
FILE_READ_ERROR = 3
INVALID_TABLE_WIDTH = 4
INVALID_TYPE = 5
NO_BATCH = 6
UNKNOWN_ERROR = 7
GUI_REFUSE_FILETRANSFER = 8
OTHERS = 9.
IF SY-SUBRC NE 0.
WRITE: / 'UPLOAD FAILED' , P_FILE.
P_SUBRC = SY-SUBRC .
ENDIF.
ENDFORM.
FORM IMPORT_FAV TABLES PIT_FAV_NODES STRUCTURE IT_FAV_NODES.
G_FILE = P_PATH.
PERFORM DATA_IMPORT TABLES IT_FAV_NODES USING G_FILE G_SUBRC .
ENDFORM.
FORM EXPORT_FAV TABLES PIT_FAV_NODES STRUCTURE IT_FAV_NODES.
CALL FUNCTION 'BX_FAVOS_READ_ALL_NODES'
EXPORTING
USER_NAME = P_UNAME
LANGUAGE = P_LANGU
TABLES
OUTPUT_NODES_AND_TEXTS = IT_FAV_NODES.
G_FILE = P_PATH.
PERFORM DATA_EXPORT TABLES IT_FAV_NODES USING G_FILE .
ENDFORM.
FORM WRITE_FAV_DB TABLES PIT_FAV_NODES STRUCTURE IT_FAV_NODES.
CALL FUNCTION 'BX_FAVOS_WRITE_ALL_NODES'
EXPORTING
USER_NAME = P_UNAME
TARGET_CLIENT = SY-MANDT
TABLES
INPUT_NODES_AND_TEXTS = PIT_FAV_NODES.
ENDFORM.
Fast Links:
Sample Download Programs:
Download in Background in Excel Format
Download/Upload ABAP program from Local Harddisk
Get help for your ABAP problems
Do you have a ABAP Question?
SAP Books
SAP Certification, Functional, Basis Administration and ABAP Programming Reference Books
ABAP Programming Tips
ABAP Forum for Discussion and Samples Program Codes for Abapers
Best regards,
SAP Basis, ABAP Programming and Other IMG Stuff
http://www.sap-img.com
All the site contents are Copyright © www.sap-img.com and the content authors. All rights reserved.
All product names are trademarks of their respective companies. The site www.sap-img.com is in no way affiliated with SAP AG.
Every effort is made to ensure the content integrity. Information used on this site is at your own risk.
The content on this site may not be reproduced or redistributed without the express written permission of
www.sap-img.com or the content authors.
Similar Messages
-
GUI_DOWNLOAD and UPLOAD Function Modules?
Hi All,
What exactly done by GUI_DOWNLOAD and UPLOAD Function Modules?
Akshitha.What you exactly want know?
Here is the Sap documentation for both FM:
FU GUI_UPLOAD
Short Text
Upload for Data Provider
Functionality
The module loads a file from the PC to the server. Data can be transferred binarily or as text. Numbers and date fields can be interpreted according to the user settings.
Example
Binary upload: No conversion or interpretation
begin of itab,
raw(255) type x,
end of itab occurs 0.
CALL FUNCTION 'GUI_UPLOAD'
exporting
filetype = 'BIN'
filename = 'C:\DOWNLOAD.BIN'
tables
data_tab = itab.
Text upload
begin of itab,
text(255) type c,
end of itab occurs 0.
CALL FUNCTION 'GUI_UPLOAD'
exporting
filetype = 'ASC'
filename = 'C:\DOWNLOAD.TXT'
tables
data_tab = itab.
Parameters
FILENAME
FILETYPE
HAS_FIELD_SEPARATOR
HEADER_LENGTH
READ_BY_LINE
DAT_MODE
CODEPAGE
IGNORE_CERR
REPLACEMENT
CHECK_BOM
VIRUS_SCAN_PROFILE
NO_AUTH_CHECK
FILELENGTH
HEADER
DATA_TAB
Exceptions
FILE_OPEN_ERROR
FILE_READ_ERROR
NO_BATCH
GUI_REFUSE_FILETRANSFER
INVALID_TYPE
NO_AUTHORITY
UNKNOWN_ERROR
BAD_DATA_FORMAT
HEADER_NOT_ALLOWED
SEPARATOR_NOT_ALLOWED
HEADER_TOO_LONG
UNKNOWN_DP_ERROR
ACCESS_DENIED
DP_OUT_OF_MEMORY
DISK_FULL
DP_TIMEOUT
Function Group
SFES
FU GUI_DOWNLOAD
Short Text
Download an Internal Table to the PC
Functionality
Data transfer of an internal table form the server to a file on the PC. The Gui_Download module replaces the obsolete modules Ws_Download and Download. The file dialog of the download module is available in the class Cl_Gui_Frontend_Services.
Further information
TYPE-POOLS: ABAP.
Binary download table
DATA: BEGIN OF line_bin,
data(1024) TYPE X,
END OF line_bin.
DATA: data_tab_bin LIKE STANDARD TABLE OF line_bin.
Ascii download table
DATA: BEGIN OF line_asc,
text(1024) TYPE C,
END OF line_asc.
DATA: data_tab_asc LIKE STANDARD TABLE OF line_asc.
DAT download table
DATA: BEGIN OF line_dat,
Packed TYPE P,
Text(10) TYPE C,
Number TYPE I,
Date TYPE D,
Time TYPE T,
Float TYPE F,
Hex(3) TYPE X,
String TYPE String,
END OF line_dat.
DATA: data_tab_dat LIKE STANDARD TABLE OF line_dat.
Get filename
DATA: fullpath TYPE String,
filename TYPE String,
path TYPE String,
user_action TYPE I,
encoding TYPE ABAP_ENCODING.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_SAVE_DIALOG
EXPORTING
WINDOW_TITLE = 'Gui_Download Demo'
WITH_ENCODING = 'X'
INITIAL_DIRECTORY = 'C:\'
CHANGING
FILENAME = filename
PATH = path
FULLPATH = fullpath
USER_ACTION = user_action
FILE_ENCODING = encoding
EXCEPTIONS
CNTL_ERROR = 1
ERROR_NO_GUI = 2
NOT_SUPPORTED_BY_GUI = 3
others = 4.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
IF user_action <> CL_GUI_FRONTEND_SERVICES=>ACTION_OK.
EXIT.
ENDIF.
Download variables
DATA: length TYPE I.
Binary download
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = fullpath
FILETYPE = 'BIN'
IMPORTING
FILELENGTH = length
TABLES
DATA_TAB = data_tab_bin
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22.
Ascii download
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = fullpath
FILETYPE = 'ASC'
IMPORTING
FILELENGTH = length
TABLES
DATA_TAB = data_tab_asc
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22.
DAT download
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = fullpath
FILETYPE = 'DAT'
IMPORTING
FILELENGTH = length
TABLES
DATA_TAB = data_tab_dat
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22.
Parameters
BIN_FILESIZE
FILENAME
FILETYPE
APPEND
WRITE_FIELD_SEPARATOR
HEADER
TRUNC_TRAILING_BLANKS
WRITE_LF
COL_SELECT
COL_SELECT_MASK
DAT_MODE
CONFIRM_OVERWRITE
NO_AUTH_CHECK
CODEPAGE
IGNORE_CERR
REPLACEMENT
WRITE_BOM
TRUNC_TRAILING_BLANKS_EOL
WK1_N_FORMAT
WK1_N_SIZE
WK1_T_FORMAT
WK1_T_SIZE
WRITE_EOL
FILELENGTH
DATA_TAB
FIELDNAMES
Exceptions
FILE_WRITE_ERROR
NO_BATCH
GUI_REFUSE_FILETRANSFER
INVALID_TYPE
NO_AUTHORITY
UNKNOWN_ERROR
HEADER_NOT_ALLOWED
SEPARATOR_NOT_ALLOWED
FILESIZE_NOT_ALLOWED
HEADER_TOO_LONG
DP_ERROR_CREATE
DP_ERROR_SEND
DP_ERROR_WRITE
UNKNOWN_DP_ERROR
ACCESS_DENIED
DP_OUT_OF_MEMORY
DISK_FULL
DP_TIMEOUT
FILE_NOT_FOUND
DATAPROVIDER_EXCEPTION
CONTROL_FLUSH_ERROR
Function Group
SFES -
hi,
when i upload a file using gui upload Function module , the dot in the excel sheet gets converted into 'e' . is there any other Function module i can use to do that .
Thanks,
AmitHI,
You need to USe the FM <b>'ALSM_EXCEL_TO_INTERNAL_TABLE'</b>
*& Report UPLOAD_EXCEL *
*& Upload and excel file into an internal table using the following *
*& function module: ALSM_EXCEL_TO_INTERNAL_TABLE *
REPORT UPLOAD_EXCEL no standard page heading.
*Data Declaration
data: itab like alsmex_tabline occurs 0 with header line.
* Has the following format:
* Row number | Colum Number | Value
* i.e. 1 1 Name1
* 2 1 Joe
TYPES: Begin of t_record,
name1 like itab-value,
name2 like itab-value,
age like itab-value,
End of t_record.
DATA: it_record type standard table of t_record initial size 0,
wa_record type t_record.
DATA: gd_currentrow type i.
*Selection Screen Declaration
PARAMETER p_infile like rlgrap-filename.
*START OF SELECTION
call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
exporting
filename = p_infile
i_begin_col = '1'
i_begin_row = '2' "Do not require headings
i_end_col = '14'
i_end_row = '31'
tables
intern = itab
exceptions
inconsistent_parameters = 1
upload_ole = 2
others = 3.
if sy-subrc <> 0.
message e010(zz) with text-001. "Problem uploading Excel Spreadsheet
endif.
* Sort table by rows and colums
sort itab by row col.
* Get first row retrieved
read table itab index 1.
* Set first row retrieved to current row
gd_currentrow = itab-row.
loop at itab.
* Reset values for next row
if itab-row ne gd_currentrow.
append wa_record to it_record.
clear wa_record.
gd_currentrow = itab-row.
endif.
case itab-col.
when '0001'. "First name
wa_record-name1 = itab-value.
when '0002'. "Surname
wa_record-name2 = itab-value.
when '0003'. "Age
wa_record-age = itab-value.
endcase.
endloop.
append wa_record to it_record.
*!! Excel data is now contained within the internal table IT_RECORD
* Display report data for illustration purposes
loop at it_record into wa_record.
write:/ sy-vline,
(10) wa_record-name1, sy-vline,
(10) wa_record-name2, sy-vline,
(10) wa_record-age, sy-vline.
endloop.
See the Below wxamples to uploa the excel file
http://www.sapdevelopment.co.uk/file/file_upexcel.htm
http://www.sap-img.com/abap/upload-material-master-finish-goods.htm -
MySAP replacements for Excel upload function modules?
I am doing some development in SRM 4.0 (WAS 640) and I notice that a few of my favorite function modules are no longer available. Specifically, I'm missing these the most:
KCD_EXCEL_OLE_TO_INT_CONVERT
ALSM_EXCEL_TO_INTERNAL_TABLE
Are there new equivalents? I know how to access XLS files by writing my own OLE calls, but sometimes it's just easier to use the standard function modules instead.
Yes, I've done a function module search, but I've found nothing that looks to the the same as my old friends.Hi Chris,
I can't give you an alternative function module per say. Obviously, the downside of using SAP functions, that were probably never released for customer consumption anyway is that they can easily disappear. The suggestion I have is to use the features offered by DOI (desktop office integration). There in lies a set of classes and methods for generically accessing various documents (e.g. ms word, excel etc.) There is some examples in the re-use library (tcode se83). So here you don't need to be worried about the OLE either. Possibly in WAS there might also be some other classes that might access Excel sheets. Downside of finding a new function is that it might disappear in the next version you go to, whereas DOI is unlikey to disappear in a hurry. Best of luck.
p.s. there are a few other postings in the forum, maybe one will give you an answer, if you haven't search already.
Message was edited by: Michael Bennett -
Using Upload function module data is truncated to 255 characters
I am using FM UPLOAD. However, when I bring in the file, it is truncated to 255 characters.
Here is what I have:
DATA: BEGIN OF rec_input2 occurs 0,
line TYPE string,
END OF rec_input2.
CALL FUNCTION 'UPLOAD'
EXPORTING
FILENAME = 's:\ersd20100217'
FILETYPE = 'ASC'
TABLES
DATA_TAB = rec_input2
Please advise how I can upload this file without truncation.
Thanks.
MichaelModerator message - FAQ Please search before asking - post locked
Rob -
Change from UPLOAD to GUI_UPLOAD function module
pls let me know that wat are the changes that should be made if the report currently using UPLOAD function module and it should be replaced with GUI_UPLOAD function module ..
wat should be the TYPE of file name and File type ???????? with the respect to changes ....
thanks . in advance..Check out this thread to find the answer
UPLOAD and GUI_UPLOAD
Regards,
Santosh -
Problem in GUI_UPLOAD function module
Hi Folks,
I am in the BI system where I have limited scope of upload function module, So I used GUI_UPLOAD as a upload function module.
I am uploading CSV file and which have amount field (with comma ',' ) as one of the column , So it is truncating the other columns while retrieving data into internal table and giving wrong data in columns.
Any other Function module, or tricks to upload file which have ',' in one of the column.
Thanks
PPHi,
Well in this case you will have to change the file format i.e. Instead of CSV make it tab delimited etc.
Else change the amount value by replacing comma(which woud be a tedious task).
There is no other alternative.
Best regards,
Prashant -
Upload data from excel with vba by calling a function module
Hello all,
i have a problem with the function module "ALSM_EXCEL_TO_INTERNAL_TABLE". I will call this function module with vba to load data from excel to sap with a Buttonclick. I have copied this function module and set it remotable. But i can´t call it from excel.
Can you give me some tips how can i
upload data from excel with vba by click a button.
The problem seems the function: call method cl_gui_frontend_services=>clipboard_import in the function module, because when i comment this function call the vba-call is true but no results.
How can I call the function module correct with vba?
Thanks a lot for your tips!!!!
Chris
Message was edited by:
Christoph KirschnerHI
Uploading data directly from Excel file format
* Upload data direct from excel.xls file to SAP
REPORT ZEXCELUPLOAD.
PARAMETERS: filename LIKE rlgrap-filename MEMORY ID M01,
begcol TYPE i DEFAULT 1 NO-DISPLAY,
begrow TYPE i DEFAULT 1 NO-DISPLAY,
endcol TYPE i DEFAULT 100 NO-DISPLAY,
endrow TYPE i DEFAULT 32000 NO-DISPLAY.
* Tick don't append header
PARAMETERS: kzheader AS CHECKBOX.
DATA: BEGIN OF intern OCCURS 0.
INCLUDE STRUCTURE alsmex_tabline.
DATA: END OF intern.
DATA: BEGIN OF intern1 OCCURS 0.
INCLUDE STRUCTURE alsmex_tabline.
DATA: END OF intern1.
DATA: BEGIN OF t_col OCCURS 0,
col LIKE alsmex_tabline-col,
size TYPE i.
DATA: END OF t_col.
DATA: zwlen TYPE i,
zwlines TYPE i.
DATA: BEGIN OF fieldnames OCCURS 3,
title(60),
table(6),
field(10),
kz(1),
END OF fieldnames.
* No of columns
DATA: BEGIN OF data_tab OCCURS 0,
value_0001(50),
value_0002(50),
value_0003(50),
value_0004(50),
value_0005(50),
value_0006(50),
value_0007(50),
value_0008(50),
value_0009(50),
value_0010(50),
value_0011(50),
value_0012(50),
value_0013(50),
value_0014(50),
value_0015(50),
value_0016(50),
value_0017(50),
value_0018(50),
value_0019(50),
value_0020(50),
value_0021(50),
value_0022(50),
value_0023(50),
value_0024(50),
value_0025(50),
value_0026(50),
value_0027(50),
value_0028(50),
value_0029(50),
value_0030(50),
value_0031(50),
value_0032(50),
value_0033(50),
value_0034(50),
value_0035(50),
value_0036(50),
value_0037(50),
value_0038(50),
value_0039(50),
value_0040(50),
value_0041(50),
value_0042(50),
value_0043(50),
value_0044(50),
value_0045(50),
value_0046(50),
value_0047(50),
value_0048(50),
value_0049(50),
value_0050(50),
value_0051(50),
value_0052(50),
value_0053(50),
value_0054(50),
value_0055(50),
value_0056(50),
value_0057(50),
value_0058(50),
value_0059(50),
value_0060(50),
value_0061(50),
value_0062(50),
value_0063(50),
value_0064(50),
value_0065(50),
value_0066(50),
value_0067(50),
value_0068(50),
value_0069(50),
value_0070(50),
value_0071(50),
value_0072(50),
value_0073(50),
value_0074(50),
value_0075(50),
value_0076(50),
value_0077(50),
value_0078(50),
value_0079(50),
value_0080(50),
value_0081(50),
value_0082(50),
value_0083(50),
value_0084(50),
value_0085(50),
value_0086(50),
value_0087(50),
value_0088(50),
value_0089(50),
value_0090(50),
value_0091(50),
value_0092(50),
value_0093(50),
value_0094(50),
value_0095(50),
value_0096(50),
value_0097(50),
value_0098(50),
value_0099(50),
value_0100(50).
DATA: END OF data_tab.
DATA: tind(4) TYPE n.
DATA: zwfeld(19).
FIELD-SYMBOLS: <fs1>.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR filename.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
mask = '*.xls'
static = 'X'
CHANGING
file_name = filename.
START-OF-SELECTION.
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.
END-OF-SELECTION.
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.
IF kzheader = 'X'.
LOOP AT intern.
fieldnames-title = intern-value.
APPEND fieldnames.
AT END OF row.
EXIT.
ENDAT.
ENDLOOP.
ELSE.
DO zwlines TIMES.
WRITE sy-index TO fieldnames-title.
APPEND fieldnames.
ENDDO.
ENDIF.
SORT intern BY row col.
LOOP AT intern.
IF kzheader = 'X'
AND intern-row = 1.
CONTINUE.
ENDIF.
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.
CALL FUNCTION 'DISPLAY_BASIC_LIST'
EXPORTING
file_name = filename
TABLES
data_tab = data_tab
fieldname_tab = fieldnames.
*-- End of Program
<b>Excel Upload Alternative - KCD_EXCEL_OLE_TO_INT_CONVERT</b>
*Title : Excel Uploading
TYPES: BEGIN OF t_datatab,
col1(25) TYPE c,
col2(30) TYPE c,
col3(30) TYPE c,
col4(30) TYPE c,
col5(30) TYPE c,
col6(30) TYPE c,
col7(30) TYPE c,
col8(30) TYPE c,
col9(30) TYPE c,
col10(30) TYPE c,
col11(30) TYPE c,
END OF t_datatab.
DATA: it_datatab TYPE STANDARD TABLE OF t_datatab INITIAL SIZE 0,
wa_datatab TYPE t_datatab.
Data : p_table type t_datatab occurs 0 with header line.
DATA : gd_scol TYPE i VALUE '1',
gd_srow TYPE i VALUE '1',
gd_ecol TYPE i VALUE '256',
gd_erow TYPE i VALUE '65536'.
DATA: it_tab TYPE filetable,
gd_subrc TYPE i.
field-symbols : <fs>.
*Selection screen definition
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: p_file LIKE rlgrap-filename
DEFAULT 'c:test.xls' OBLIGATORY. " File Name
SELECTION-SCREEN END OF BLOCK b1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
REFRESH: it_tab.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
window_title = 'Select File'
default_filename = '*.xls'
multiselection = ' '
CHANGING
file_table = it_tab
rc = gd_subrc.
LOOP AT it_tab INTO p_file.
* so_fpath-sign = 'I'.
* so_fpath-option = 'EQ'.
* append so_fpath.
ENDLOOP.
START-OF-SELECTION.
PERFORM upload_excel_file TABLES it_datatab
USING p_file
gd_scol
gd_srow
gd_ecol
gd_erow.
* END-OF-SELECTION.
END-OF-SELECTION.
LOOP AT it_datatab INTO wa_datatab.
WRITE:/ wa_datatab-col1,
wa_datatab-col2,
wa_datatab-col3,
wa_datatab-col4,
wa_datatab-col5,
wa_datatab-col6,
wa_datatab-col7,
wa_datatab-col8,
wa_datatab-col9,
wa_datatab-col10,
wa_datatab-col11.
ENDLOOP.
*& Form UPLOAD_EXCEL_FILE
* upload excel spreadsheet into internal table
* -->P_TABLE Table to return excel data into
* -->P_FILE file name and path
* -->P_SCOL start column
* -->P_SROW start row
* -->P_ECOL end column
* -->P_EROW end row
FORM upload_excel_file TABLES p_table
USING p_file
p_scol
p_srow
p_ecol
p_erow.
DATA : lt_intern TYPE kcde_cells OCCURS 0 WITH HEADER LINE.
* Has the following format:
* Row number | Colum Number | Value
* i.e. 1 1 Name1
* 2 1 Joe
DATA : ld_index TYPE i.
* Note: Alternative function module - 'ALSM_EXCEL_TO_INTERNAL_TABLE'
CALL FUNCTION 'KCD_EXCEL_OLE_TO_INT_CONVERT'
EXPORTING
filename = p_file
i_begin_col = p_scol
i_begin_row = p_srow
i_end_col = p_ecol
i_end_row = p_erow
TABLES
intern = LT_INTERN
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
IF sy-subrc <> 0.
FORMAT COLOR COL_BACKGROUND INTENSIFIED.
WRITE:/ 'Error Uploading file'.
EXIT.
ENDIF.
IF lt_intern[] IS INITIAL.
FORMAT COLOR COL_BACKGROUND INTENSIFIED.
WRITE:/ 'No Data Uploaded'.
EXIT.
ELSE.
SORT lt_intern BY row col.
LOOP AT lt_intern.
MOVE lt_intern-col TO ld_index.
assign component ld_index of structure
p_table to <fs>.
move : lt_intern-value to <fs>.
* MOVE lt_intern-value TO p_table.
AT END OF row.
APPEND p_table.
CLEAR p_table.
ENDAT.
ENDLOOP.
ENDIF.
ENDFORM. "UPLOAD_EXCEL_FILE
Regards
Pavan -
How to upload Excel file in BI using function module in abap program
How to upload Excel file in BI using function module in abap program?
Hi Anuj,
To upload the file , you can try a standard program "RSEPSFTP" .
while you execute the program , a selection screen appears in which the inputs should be give as
RFC destination - The target server name
FTP command- PUT
local file - your file name
local directory - path of your local file
remote file - your target file name
remote directory - where it has to be stored
Hope this is useful for you
Thanks & regards
Anju -
Existing Function modules or Standard upload Programs
Hi,
Can any one tell, Are there any Function modules or Standard upload programs exists for following transactions:
Creating production version(C223)
Creating Master recipe(C201)
Creation Apportionment Structure(C202)
Creation BOM Allocation(CS08)
(This all tcodes comes under Production planning.)
Thanks in advance.Hi Vanitha,
Check this
for C223
CM_FV_PROD_VERS_MAINTAIN
CM_FV_PROD_VERS_SAVE
CM_FV_PROD_VERS_SAVE_ALL
CY01_ORDER_MODIFY_PROD_VERSION
For C201
C2_CU_RECIPE_EXCLUDE_CREATE
CONTROL_RECIPE_CREATE
For C202
APPOINTMENT_GRP_CREATE
APPOINTMENT_CREATE
APPOINTMENT_GENERATE
APPOINTMENT_GENERATE_2
For CS08
CSAP_MAT_BOM_ALLOC_CREATE
Hope it helps...
Lokesh
pls. reward appropriate points
Message was edited by: Lokesh Aggarwal -
Need Function module to upload an excel file to SAP
Need Function module to upload more than 100 characters of excel file data into SAP internal table.
Currently i have two function module
1. ALSM_EXCEL_TO_INTERNAL_TABLE --32 characters max
2. KCD_EXCEL_OLE_TO_INT_CONVERT --50 characters max
Please let me know some pointers.
Thanks in Advance,
A.Karthikeyan.hi,
use the FM GUI_UPLOAD
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = W_FILENAME
FILETYPE = W_FILETYPE
HAS_FIELD_SEPARATOR = 'X'
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = 'X'
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
CHECK_BOM = ' '
VIRUS_SCAN_PROFILE =
NO_AUTH_CHECK = ' '
IMPORTING
FILELENGTH =
HEADER =
TABLES
DATA_TAB = wp_it_upload
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17. -
Function module to choose the file for download and upload
what is the function module to choose the file for download and upload for presentation server.
give me with examplePlease search in SCN.
This has been discussed so many times. -
Function module "UPLOAD" failed for Unicode
Hi,
I have a program that uses the Function module UPLOAD. This function again uses the function ws_upload, which is obsolete. ws_upload and ws_download have been replaced by the new ones in CL_GUI_FRONTEND_SERVICES. But what function / method is replacing the UPLOAD function ?Hi!
I'm using the function module GUI_UPLOAD for unicode files also.
Regards
Tamá -
Function module to upload excel to internal table in SAP 7.0 version system
<<Question has been asked and answered many times - please search before asking for function modules for common tasks>>
currently i am using SAP Netweaver7.0 version, i need a Funtion Module to upload an Excel sheet data to an internal table.
please let me know this ASAP.
thanks,
Edited by: Matt on Aug 24, 2009 7:25 AMhi,
the FM you have suggested does not exist in the *version 7.0*
added the FM "ALSM_....",also does not exist
pls suggest a FM for SAP7.0 version -
Best practice to upload data for Appraisals: BDC, LSMW or functional module
Hi,
I have heard that BDC and LSMW do not work for data upload in appraisals. Is it true?
Can we use ECATT or SECATT to upload data in appraisals?
I somewhere got the information that functional modules
HRHAP_DOCUMENT_PREPARE
HRHAP_DOC_UPDATE_BODY_AND_SAVE
HRHAP_DOCUMENT_CREATE
are used to upload the data for appraisals?
Many of my earlier clients found it very hectic to create appraisal templates every year (PHAP_CREATE). They needed something automated for this. I managed to suggest them manual upload or SECATT, but I am not sure if BDC/LSMW work for this.
Can somebody throw some light on this?
Best regards,
Veera Sasidhar JangamHi,
You need to write a code for same and use function modules available as those does direct updates to database.
If client is not bothered about look and feel during dataload or do not care about display infotypes during data updates then use above method otherwise BDC needs to be written with screen control programming in it.
Thanks,
Ameet
Maybe you are looking for
-
How to enter many receiving lines for one PO Line
Hi, we are working in oracle applications 11i From Oracle Inventory Responsibility->Transactions->Receiving: Enter Purchase Order Number: Receipts Window: we have a line with item quantity of 100 (for example). I need to receive that item on many lin
-
GUI_DOWNLOAD is giving # for other than english content
Hi Guys, I am using GUI_DOWNLOAD FM for downloading internal table content. When my table has content other than english language, my downloaded file has only # symbols. I getting code page number for the language using FM NLS_GET_FRONTEND_CP and pa
-
My Iphone 5 was stolen a couples of months in Lousiana when I was on vacation. I reported stolen and bought a new I pnone 5S and I erase the numser from my Icloud accounr and today got a text today from a florida area code that said they bought an
-
My computer recently crashed, my music library is on my iPod. I want to upload my music on another computer without losing any songs. I did not back my music up. HELP! Message was edited by: yellobanana47
-
Two dual-channel scsi controllers on S10 8/07 x86?
I'm attempting an install of Solaris 10 8/07 x86 on a server with four channels of scsi devices. The problem is that the install procedure only recognises the controller on the motherboard, and not the additional controller on the pci bus with the bo