‎2009 May 06 12:55 PM
Hi All i am using GUI_UPLOAD FM to upload some data fromm excel file.
cade is as folloes :
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = p_v_file
filetype = 'DAT'
has_field_separator = 'X'
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
CHECK_BOM = ' '
VIRUS_SCAN_PROFILE =
NO_AUTH_CHECK = ' '
IMPORTING
FILELENGTH =
HEADER =
TABLES
data_tab = it_data[]
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 <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
but data is not upladed and gives me the exception 8 : bad_data_format = 8
PLS HELP....
THANKS..
‎2009 May 06 1:02 PM
Hi,
Use this FM 'TEXT_CONVERT_XLS_TO_SAP'
Function module to upload the excel file from presentation server
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
i_field_seperator = 'X'
i_line_header = 'X'
i_tab_raw_data = wa_tab_raw_data
i_filename = p_inp
TABLES
i_tab_converted_data = t_input
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
Regards
Krishna
‎2009 May 06 12:57 PM
hi,
try to use ..
FM..ALSM_EXCEL_TO_INTERNAL_TABLE
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = infile "Input file name
i_begin_col = 1 "begin Column which data need to read from
i_end_col = 8 "End Column which data need to read upto
i_begin_row = 3 "skip first 2 rows because it contains header and sit data from row 3
i_end_row = 9999 "maximum row 99999
TABLES
intern = itab "interna; table where excel data will sit
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
IF sy-subrc NE 0.
write: / 'ERROR - unable to read/upload file'.
ENDIF.
Regards,
Prabhudas
‎2009 May 06 12:58 PM
‎2009 May 06 12:59 PM
MY FILE IS excel file .XLS and i cant use ALSM_ECEL*** fm SINCE LOTS OF DATA RECORDS.. CANT BIFORCATE THEM ALL..... IF I USE alsm*** need to use GUI_UPLOAD only...
‎2009 May 06 1:00 PM
‎2009 May 06 1:00 PM
Try to upload in BIN.
You can use too the CL_GUI_FRONTEND_SERVICES class to upload files.
Regards.
‎2009 May 06 1:02 PM
Hi,
Use this FM 'TEXT_CONVERT_XLS_TO_SAP'
Function module to upload the excel file from presentation server
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
i_field_seperator = 'X'
i_line_header = 'X'
i_tab_raw_data = wa_tab_raw_data
i_filename = p_inp
TABLES
i_tab_converted_data = t_input
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
Regards
Krishna
‎2009 May 06 1:03 PM
Hi ,
use the GUI_UPLOAD as below example..
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = FILENAME "input file
HAS_FIELD_SEPARATOR = '#' "Use this seperator for excel upload
DAT_MODE = 'X' "dat mode
TABLES
DATA_TAB = P_TABLE "Internal table which stores data
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 <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
regards,
Prabhudas
‎2009 May 06 1:04 PM
Yoy can use this FM
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
* I_FIELD_SEPERATOR =
* I_LINE_HEADER =
i_tab_raw_data = gv_raw
i_filename = p_file
TABLES
i_tab_converted_data = gt_upload
EXCEPTIONS
CONVERSION_FAILED = 1
OTHERS = 2
.
‎2014 Jun 23 2:09 PM
I have a problem close to this .
I want to upload a file in SAP, I am using a recorded Script but I want to give the File and path directly in the script file. Is there anyone who can help me to change this line :
session.findById("wnd[0]/usr/tabsTAB_MAIN/tabpTSMAIN/ssubSCR_MAIN:SAPLCV110:0102/btnPB_FILE_BROWSER").press
Here is the complete recorded code for CV01N:
If Not IsObject(application) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set application = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(connection) Then
Set connection = application.Children(0)
End If
If Not IsObject(session) Then
Set session = connection.Children(0)
End If
If IsObject(WScript) Then
WScript.ConnectObject session, "on"
WScript.ConnectObject application, "on"
End If
session.findById("wnd[0]").resizeWorkingPane 92,24,false
session.findById("wnd[0]/tbar[0]/okcd").text = "cv01n"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtDRAW-DOKNR").text = "filename foe SAP-test1"
session.findById("wnd[0]/usr/ctxtDRAW-DOKAR").text = "mtx"
session.findById("wnd[0]/usr/ctxtDRAW-DOKAR").setFocus
session.findById("wnd[0]/usr/ctxtDRAW-DOKAR").caretPosition = 3
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[1]").sendVKey 0
session.findById("wnd[0]/usr/tabsTAB_MAIN/tabpTSMAIN/ssubSCR_MAIN:SAPLCV110:0102/txtDRAT-DKTXT").text = "Description for file upload in SAP"
session.findById("wnd[0]/usr/tabsTAB_MAIN/tabpTSMAIN/ssubSCR_MAIN:SAPLCV110:0102/txtDRAT-DKTXT").caretPosition = 34
session.findById("wnd[0]/usr/tabsTAB_MAIN/tabpTSMAIN/ssubSCR_MAIN:SAPLCV110:0102/btnPB_FILE_BROWSER").press
session.findById("wnd[0]/tbar[0]/btn[11]").press
session.findById("wnd[0]/tbar[0]/btn[15]").press