Gui upload Function module
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,
Amit
HI,
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
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 -
Batch Input Recording - GUI Upload Function
Hello,
i want to record a batch input.
Within the recording a Gui Upload Function is called, so that the user have to select a file from the local disk, which should be uploaded into the system. That step wasn't recorded by the bach input recording.
Is there any soluion for that?
Regards,
TomSdAs Suhas said, these kind of UI dialogs cannot be handled by batch input technology.
Sometimes transactions allow the batch input by displaying another kind of UI dialog that is allowed. Try to record using "simulate background mode", maybe the program will display another UI dialog. Make sure also to untick the "no BI mode" checkbox.
But maybe this transaction isn't planned to be used in batch input at all (which transaction do you need to record?). In that case, the only solution is maybe eCATT (with external tool connected as I am aware). -
Problem while uploading data with GUI UPLOAD Function
Hi,
I am facing problem while uploading data with FM GUI UPLOAD in out text file there are 7 row but after the FM GUI UPLOAD there are 14 entries are coming in Internal table and each alternate row is coming as blank with 0000 in some column in internal table first row is proper and second line is blank so on.
what can be the problem .
The program in which we are using this we are using it from last 2 year but we are facing problem today only.
regards,
zafarHi,
The file formate is same as it is from last two years it is automatically generated by one another bar code server and there is no change in the file formate.
So waht can be the problem to check any inconsistancy in system i have develop a samll program fro uploading a text file with same function module , but it is working fine.
regards,
zafar -
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 -
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. -
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 -
Hi all
I need to upload a Function module from SAP 4.6C to ECC 6.4 version. Can anyone help me on this ? A PROMPT reply will be highly appreciated as I need this urgently..2)now uplaos from c driv to diffrent server.
*& Report Z_CREATE_FM *
REPORT z_create_fm .
* Tables
* TYPES - Structures
* Structure for Function Module Attributes
TYPES: BEGIN OF s_fm_attributes ,
global_flag LIKE rs38l-global ,
remote_call LIKE rs38l-remote ,
update_task LIKE rs38l-utask ,
short_text LIKE tftit-stext ,
function_pool LIKE rs38l-area ,
END OF s_fm_attributes .
* Structure for Import Paramters
TYPES: BEGIN OF s_import_parameter .
INCLUDE STRUCTURE rsimp .
TYPES: END OF s_import_parameter .
* Structure for Changing Paramters
TYPES: BEGIN OF s_changing_parameter .
INCLUDE STRUCTURE rscha .
TYPES: END OF s_changing_parameter .
* Structure for Export Paramters
TYPES: BEGIN OF s_export_parameter .
INCLUDE STRUCTURE rsexp .
TYPES: END OF s_export_parameter .
* Structure for Table Paramters
TYPES: BEGIN OF s_tables_parameter .
INCLUDE STRUCTURE rstbl .
TYPES: END OF s_tables_parameter .
* Structure for Exception list
TYPES: BEGIN OF s_exception_list .
INCLUDE STRUCTURE rsexc.
TYPES: END OF s_exception_list .
* Structure for Documentation
TYPES: BEGIN OF s_documentation .
INCLUDE STRUCTURE rsfdo.
TYPES: END OF s_documentation .
* Structure for Exception list
TYPES: BEGIN OF s_source .
INCLUDE STRUCTURE rssource .
TYPES: END OF s_source .
* Internal Tables
DATA: t_fm_attributes TYPE s_fm_attributes OCCURS 0
WITH HEADER LINE ,
t_import_parameter TYPE s_import_parameter OCCURS 0
WITH HEADER LINE ,
t_changing_parameter TYPE s_changing_parameter OCCURS 0
WITH HEADER LINE ,
t_export_parameter TYPE s_export_parameter OCCURS 0
WITH HEADER LINE ,
t_tables_parameter TYPE s_tables_parameter OCCURS 0
WITH HEADER LINE ,
t_exception_list TYPE s_exception_list OCCURS 0
WITH HEADER LINE ,
t_documentation TYPE s_documentation OCCURS 0
WITH HEADER LINE ,
t_source TYPE s_source OCCURS 0
WITH HEADER LINE .
* Constants
CONSTANTS: c_dir(6) TYPE c VALUE 'C:FM' ,
c_bslash(1) TYPE c VALUE '' ,
c_file_attrib TYPE string " FM Attributes file
VALUE 'FM_ATTRIBUTES.XLS' ,
c_file_ip TYPE string " Import parameters File
VALUE 'IMPORT_PARAMTER.XLS' ,
c_file_cp TYPE string " Changing parameters File
VALUE 'CHANGING_PARAMTER.XLS' ,
c_file_ep TYPE string " Export parameters File
VALUE 'EXPORT_PARAMTER.XLS' ,
c_file_tp TYPE string " Tables parameters File
VALUE 'TABLES_PARAMTER.XLS' ,
c_file_el TYPE string " Exception list File
VALUE 'EXCEPTION_LIST.XLS' ,
c_file_docu TYPE string " Documentation File
VALUE 'DOCUMENTATION.XLS' ,
c_file_source TYPE string " Code Source File
VALUE 'SOURCE.XLS' .
* Work-fields
DATA: w_functionname LIKE rs38l-name , " FM Name
w_file TYPE string , " File name
w_global_flag LIKE rs38l-global , " Global flag for FM
w_remote_call LIKE rs38l-remote , " RFC flag
w_update_task LIKE rs38l-utask , " Update task flag
w_short_text LIKE tftit-stext , " Short text
w_function_pool LIKE rs38l-area , " Function Group
w_function_include LIKE rs38l-include , " FM Include file
w_corrnum_e LIKE e071-trkorr .
* Selection-Screen
SELECT-OPTIONS: s_fm FOR w_functionname OBLIGATORY NO INTERVALS.
* At selection-screen
* Start-of-selection
START-OF-SELECTION.
* Upload Function Modules.
PERFORM sub_upload_fm_data.
* End-of-selection
END-OF-SELECTION.
* Subroutines
*& Form sub_upload_fm_data
* Create Function Module by uploading their data from local file
FORM sub_upload_fm_data .
LOOP AT s_fm.
REFRESH: t_fm_attributes ,
t_import_parameter ,
t_changing_parameter ,
t_export_parameter ,
t_tables_parameter ,
t_exception_list ,
t_documentation ,
t_source .
CLEAR: w_functionname ,
w_global_flag ,
w_remote_call ,
w_update_task ,
w_short_text ,
w_function_pool .
MOVE s_fm-low TO w_functionname.
* Upload FUNCTION MODULE Attributes
CLEAR w_file.
CONCATENATE c_dir
w_functionname
c_bslash
c_file_attrib
INTO w_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = w_file
filetype = 'ASC'
has_field_separator = 'X'
* HEADER_LENGTH = 0
* READ_BY_LINE = 'X'
* DAT_MODE = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* CHECK_BOM = ' '
* IMPORTING
* FILELENGTH =
* HEADER =
TABLES
data_tab = t_fm_attributes
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 .
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
READ TABLE t_fm_attributes INDEX 1.
MOVE: t_fm_attributes-global_flag TO w_global_flag ,
t_fm_attributes-remote_call TO w_remote_call ,
t_fm_attributes-update_task TO w_update_task ,
t_fm_attributes-short_text TO w_short_text ,
t_fm_attributes-function_pool TO w_function_pool .
* Upload IMPORT Parameters
CLEAR w_file.
CONCATENATE c_dir
w_functionname
c_bslash
c_file_ip
INTO w_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = w_file
filetype = 'ASC'
has_field_separator = 'X'
* HEADER_LENGTH = 0
* READ_BY_LINE = 'X'
* DAT_MODE = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* CHECK_BOM = ' '
* IMPORTING
* FILELENGTH =
* HEADER =
TABLES
data_tab = t_import_parameter
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 .
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* Upload CHANGING Parameters
CLEAR w_file.
CONCATENATE c_dir
w_functionname
c_bslash
c_file_cp
INTO w_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = w_file
filetype = 'ASC'
has_field_separator = 'X'
* HEADER_LENGTH = 0
* READ_BY_LINE = 'X'
* DAT_MODE = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* CHECK_BOM = ' '
* IMPORTING
* FILELENGTH =
* HEADER =
TABLES
data_tab = t_changing_parameter
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 .
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* Upload EXPORT Parameters
CLEAR w_file.
CONCATENATE c_dir
w_functionname
c_bslash
c_file_ep
INTO w_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = w_file
filetype = 'ASC'
has_field_separator = 'X'
* HEADER_LENGTH = 0
* READ_BY_LINE = 'X'
* DAT_MODE = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* CHECK_BOM = ' '
* IMPORTING
* FILELENGTH =
* HEADER =
TABLES
data_tab = t_export_parameter
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 .
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* Upload TABLES Parameters
CLEAR w_file.
CONCATENATE c_dir
w_functionname
c_bslash
c_file_tp
INTO w_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = w_file
filetype = 'ASC'
has_field_separator = 'X'
* HEADER_LENGTH = 0
* READ_BY_LINE = 'X'
* DAT_MODE = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* CHECK_BOM = ' '
* IMPORTING
* FILELENGTH =
* HEADER =
TABLES
data_tab = t_tables_parameter
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 .
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* Upload EXCEPTIONS List
CLEAR w_file.
CONCATENATE c_dir
w_functionname
c_bslash
c_file_el
INTO w_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = w_file
filetype = 'ASC'
has_field_separator = 'X'
* HEADER_LENGTH = 0
* READ_BY_LINE = 'X'
* DAT_MODE = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* CHECK_BOM = ' '
* IMPORTING
* FILELENGTH =
* HEADER =
TABLES
data_tab = t_exception_list
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 .
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* Upload DOCUMENTATION
CLEAR w_file.
CONCATENATE c_dir
w_functionname
c_bslash
c_file_docu
INTO w_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = w_file
filetype = 'ASC'
has_field_separator = 'X'
* HEADER_LENGTH = 0
* READ_BY_LINE = 'X'
* DAT_MODE = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* CHECK_BOM = ' '
* IMPORTING
* FILELENGTH =
* HEADER =
TABLES
data_tab = t_documentation
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 .
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* Upload SOURCE Code
CLEAR w_file.
CONCATENATE c_dir
w_functionname
c_bslash
c_file_source
INTO w_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = w_file
filetype = 'ASC'
has_field_separator = 'X'
* HEADER_LENGTH = 0
* READ_BY_LINE = 'X'
* DAT_MODE = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* CHECK_BOM = ' '
* IMPORTING
* FILELENGTH =
* HEADER =
TABLES
data_tab = t_source
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 .
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* Create Function Module
CALL FUNCTION 'RS_FUNCTIONMODULE_INSERT'
EXPORTING
funcname = w_functionname
function_pool = w_function_pool
interface_global = w_global_flag
remote_call = w_remote_call
short_text = w_short_text
* SUPPRESS_CORR_CHECK = 'X'
update_task = w_update_task
* CORRNUM = ' '
* NAMESPACE = ' '
* SUPPRESS_LANGUAGE_CHECK = 'X'
* AUTHORITY_CHECK = 'X'
* SAVE_ACTIVE = 'X'
* NEW_SOURCE =
* EXCEPTION_CLASS = ' '
* SUPPRESS_UPGRADE_CHECK = ' '
IMPORTING
function_include = w_function_include
corrnum_e = w_corrnum_e
TABLES
import_parameter = t_import_parameter
export_parameter = t_export_parameter
tables_parameter = t_tables_parameter
changing_parameter = t_changing_parameter
exception_list = t_exception_list
parameter_docu = t_documentation
SOURCE = t_source
EXCEPTIONS
double_task = 1
error_message = 2
function_already_exists = 3
invalid_function_pool = 4
invalid_name = 5
too_many_functions = 6
no_modify_permission = 7
no_show_permission = 8
enqueue_system_failure = 9
canceled_in_corr = 10
OTHERS = 11 .
IF sy-subrc NE 0.
WRITE: / 'Error occured while creating FM: ' ,
w_functionname .
ELSE.
WRITE: / 'FM Created: ' ,
w_functionname .
* CALL FUNCTION 'RS_FUNCTION_ACTIVATE'
* EXPORTING
** ACTION = ' '
** CORR_INSERT = ' '
* funcname = w_functionname
** WITH_POPUP = 'X'
** SUPPRESS_WORKING_AREA = ' '
** OBJECT_SAVED =
* EXCEPTIONS
* CANCELLED = 1
* CANCELED_IN_CORR = 2
* EDITOR_NAVIGATION_FLAG = 3
* MESSAGE_SEND = 4
* NOT_FOUND = 5
* NO_ACTION = 6
* PERMISSION_FAILURE = 7
* OTHERS = 8 .
* IF sy-subrc NE 0.
* WRITE: / 'Error occured while activating FM: ' ,
* w_functionname .
* ELSE.
* WRITE: / 'Activated FM: ' ,
* w_functionname .
* ENDIF. " IF sy-subrc NE 0.(RS_FUNCTION_ACTIVATE)
ENDIF. " IF sy-subrc NE 0.
ENDLOOP. " LOOP AT s_fm.
ENDFORM. " sub_upload_fm_data -
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 -
HI ,
I am using GUI upload function and i get the data into table and i want to move this data to field type string how can i do that ?
Regards
Joy
DATA: gt_itab TYPE STANDARD TABLE OF char2048.
START-OF-SELECTION.
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = gs_file
CHANGING
data_tab = gt_itab
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
not_supported_by_gui = 17
error_no_gui = 18
OTHERS = 19.Hi,
Refer following code
types : BEGIN OF ty_s_download,
data TYPE string, "Tax Data
END OF ty_s_download.
G L O B A L D A T A D E C L A R A T I O N S
*Global Internal tables
DATA : gt_download TYPE STANDARD TABLE OF ty_s_download. "Download data
LOOP AT gt_tax_data INTO ls_tax_data.
Pass All the tax data to screen output table
ls_output-bukrs = ls_tax_data-bukrs.
ls_output-state = ls_tax_data-state.
ls_output-store = ls_tax_data-store.
ls_output-tax_type = ls_tax_data-tax_type.
ls_output-tax_rate = ls_tax_data-tax_rate.
ls_output-discount_amount = ls_tax_data-discount_amount.
lv_discount = ls_tax_data-discount_amount.
lv_tax_rate = ls_output-tax_rate.
Calculate Gross tax due
ls_output-gross_due = ls_tax_data-report_amount.
lv_gross_due = ls_output-gross_due.
IF NOT ls_tax_data-tax_rate IS INITIAL.
Calculate Taxable Purchase
ls_output-purchase = ls_output-gross_due / ls_tax_data-tax_rate.
ELSE.
ls_output-purchase = 0. "Default it to zero if the tax_rate is zero.
ENDIF.
lv_purchase = ls_output-purchase.
Calculate Net Tax Due
ls_output-net_due = ls_output-gross_due - ls_tax_data-discount_amount.
lv_net_due = ls_output-net_due.
Concatenate all field values
CONCATENATE ls_output-bukrs
ls_output-state
ls_output-store
ls_output-tax_type
lv_purchase
lv_tax_rate
lv_gross_due
lv_discount
lv_net_due
INTO ls_download-data
SEPARATED BY lc_tab.
Append all the downloaded tax data
APPEND ls_download TO gt_download.
Clear work areas
CLEAR : ls_output,
ls_tax_data,
ls_download,
lv_purchase,
lv_discount,
lv_tax_rate,
lv_net_due,
lv_gross_due.
ENDLOOP.
Regards,
Prashant -
BDC : Function Module to Upload Unicode text file
Hi Friends,
Can anyone tell me how to upload data to internal table by taking it from unicode text file ?
at present i'm using FM - GUI_UPLOAD which do not support Unicode text file.
SonalHi,
U Have to use CodePage Parameter to upload the data.
Check the Description
Character Representation for Output
Description
Use parameter CODEPAGE to specify the desired source codepage. If this parameter is not set, the codepage of the SAP GUI is used as the source codepage.
Value range
4-digit number of the SAP codepage. The function module SCP_CODEPAGE_BY_EXTERNAL_NAME provides the SAP codepage number for an external character set name, for example, "iso-8859-1". The function module NLS_GET_FRONTEND_CP provides the respective non-Unicode frontend codepage for a language.
The desired codepage can be determined interactively, if the parameter with_encoding of method file_open_dialog is set by cl_gui_frontend_services.
If the specified codepage is not suited for the Byte Order Mark of the file, an exception is triggered.
SPACE: Codepage of the frontend operating system
Default
SPACE -
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
Maybe you are looking for
-
The display of the microsoft owa web page does not display correctly. Does not appear to be in HTML - almost looks like plain text.
-
Data not showing correctly in essbase
Hi There, I just generate my monthly load table, for example, GL of month, I run the query, and the total number is matched with accounting generated report, then I load it to the essbase using the month data text file, as well as data load rule file
-
I have two related questions. How can I get a list of all the files that are currently open on a particular machine? I'm using Windows, so I don't know of anything like Runtime.exec("lsof");. More specifically, I need to see if a particular (given) f
-
Best solution to the flash border in IE
Hi, I've scoured the net looking for the solution and there seems to be quiite a few ways to get round the flash border problem in IE. Just like to ask, whats the best solution; easiest and quickest? I know this topic has been done to death but I'm n
-
Matrix with CFL and RecordSet with DoQuery
Hello Experts, How to use Matrix with CFL and RecordSet with DoQuery