2008 Aug 22 4:35 PM
Hi,
I am doing a BDC report in which i am dowloading data in local file using GUI_DOWNLOAD from one server and from another server uploading the data using GUI_UPLOAD into internal table having the same structure as that of one used in download but upload process is getting fail raising EXCEPTION(BAD_DATA_FORMAT), i have tried all file type( TXT, XLS, CSV ).
2008 Aug 22 4:39 PM
If the File is TAB delimited then don't mention any file type, simply specify the file path and HAS_FIELD_SEPARATOR = 'X' . This will work Check it once.
call function 'GUI_UPLOAD'
exporting
filename = filename
HAS_FIELD_SEPARATOR = ' X'
tables
data_tab = 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.
if sy-subrc ne 0.
endif.
If the File is TAB delimited then don't mention any file type, simply specify the file path and HAS_FIELD_SEPARATOR = 'X' . This will work Check it once.
call function 'GUI_UPLOAD'
exporting
filename = filename
HAS_FIELD_SEPARATOR = ' X'
tables
data_tab = 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.
if sy-subrc ne 0.
endif.
2008 Aug 22 4:39 PM
If the File is TAB delimited then don't mention any file type, simply specify the file path and HAS_FIELD_SEPARATOR = 'X' . This will work Check it once.
call function 'GUI_UPLOAD'
exporting
filename = filename
HAS_FIELD_SEPARATOR = ' X'
tables
data_tab = 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.
if sy-subrc ne 0.
endif.
2008 Aug 22 5:37 PM
ALSM_EXCEL_TO_INTERNAL_TABLE try with this function module to upload the data into SAP.
2008 Aug 25 9:42 AM
Hi Manish,
See my code and understand,
if you have doubts plse let me know
DATA : it_excel LIKE alsmex_tabline OCCURS 0 WITH HEADER LINE.
DATA: xcel TYPE TABLE OF alsmex_tabline WITH HEADER LINE.
DATA : gd_scol TYPE i VALUE '1',
gd_srow TYPE i VALUE '3',
v_partner LIKE kna1-kunnr,
gd_ecol TYPE i VALUE '256',
v_vbeln TYPE vbak-vbeln,
gd_erow TYPE i VALUE '65536'
DATA: BEGIN OF gt_out OCCURS 0,
soind(1) TYPE c, " Sales Order indicator (H) - Header
auart LIKE vbak-auart, " Order Type
kunnr LIKE kna1-kunnr, "Sold To Party
bstkd LIKE vbkd-bstkd, "PO Number
matnr LIKE vbap-matnr, "Article Number
req_qty LIKE vbap-kwmeng, "Quantity
werks LIKE vbap-werks, "Site
rsite LIKE vbap-werks,
END OF gt_out.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: p_file TYPE rlgrap-filename OBLIGATORY .
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
PARAMETERS: c1 AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN END OF BLOCK b2.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
PERFORM get_file.
*===========================================================
Start of selection
*===========================================================
START-OF-SELECTION.
PERFORM upload_excel_file TABLES gt_out
USING p_file
gd_scol
gd_srow
gd_ecol
gd_erow.
&----
*& Form get_file
&----
text
-
--> p1 text
<-- p2 text
-
FORM get_file .
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
program_name = syst-repid
dynpro_number = syst-dynnr
field_name = p_file
CHANGING
file_name = p_file.
IF sy-subrc 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " get_file
&----
*& Form upload_excel_file
&----
text
-
-->P_IT_DATATAB text
-->P_P_FILE text
-->P_GD_SCOL text
-->P_GD_SROW text
-->P_GD_ECOL text
-->P_GD_EROW text
-
FORM upload_excel_file TABLES gt_out
"Insert correct name for <...>
USING p_p_file
p_gd_scol
p_gd_srow
p_gd_ecol
p_gd_erow.
DATA : lt_intern TYPE kcde_cells OCCURS 0 WITH HEADER LINE.
DATA : ld_index TYPE i.
FIELD-SYMBOLS: <fs> TYPE ANY.
CALL FUNCTION 'KCD_EXCEL_OLE_TO_INT_CONVERT'
EXPORTING
filename = p_p_file
i_begin_col = p_gd_scol
i_begin_row = p_gd_srow
i_end_col = p_gd_ecol
i_end_row = p_gd_erow
TABLES
intern = lt_intern[].
IF sy-subrc 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'KCD_EXCEL_OLE_TO_INT_CONVERT'
EXPORTING
FILENAME = p_p_file
i_begin_col = p_gd_scol
i_begin_row = p_gd_srow
i_end_col = p_gd_ecol
i_end_row = p_gd_erow
TABLES
intern = lt_intern[]
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.
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 gt_out TO <fs>.
MOVE lt_intern-value TO <fs>.
AT END OF row.
APPEND gt_out.
CLEAR gt_out.
ENDAT.
ENDLOOP.
ENDIF.
ENDFORM. " upload_excel_file
Hope this code is helpful to you. Follow the steps as it is, change only your output internal tables. It will work.
Regards,
Santosh Kumar M.
2008 Aug 25 11:57 AM
Hi
If you want download and upload file through T.codes, Please try it.....
Upload file from presentation server use 'CG3Z' tcode.
download file from Appl server using 'CG3Y' T.code
Thanks & Regards
Sai
2008 Aug 25 9:53 PM
Hi,
Use Filetype = 'ASC' in exporting parameter of GUI_UPLOAD.
and it will be fine.
Thanks,
Kartavya
2008 Aug 26 5:31 AM
Hi Manish,
This error generally happens when you have header line.So please remove header line and tryit.Let me know still there s a problem
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |