FM - GUI_UPLOAD - Uploading Junk Data
Hi All,
I am using FM GUI_UPLOAD, and while upload its not recognising the character, Instead it shows some Junk values in the itab. Can anyone lemme know how can this be corrected.
Many Thanks,
Simin.
Hi Simin,
Which type of file u r uploading. It will work for text file.
If it is excel file then use below code to upload the data.
PARAMETERS: po_file TYPE rlgrap-filename DEFAULT 'E:test.xls'.
TYPES: BEGIN OF t_final,
empno(10) TYPE c,
name(30) TYPE c,
state(25) TYPE c,
END OF t_final.
DATA: i_tab TYPE STANDARD TABLE OF alsmex_tabline,
i_final TYPE STANDARD TABLE OF t_final,
wa_tab TYPE alsmex_tabline,
wa_final TYPE t_final.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR po_file.
PERFORM open_folder.
START-OF-SELECTION.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = po_file
i_begin_col = 1
i_begin_row = 1
i_end_col = 3
i_end_row = 65256
TABLES
intern = i_tab
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
CHECK NOT i_tab[] IS INITIAL.
LOOP AT i_tab INTO wa_tab.
CASE wa_tab-col.
WHEN 1.
wa_final-empno = wa_tab-value.
WHEN 2.
wa_final-name = wa_tab-value.
WHEN 3.
wa_final-state = wa_tab-value.
ENDCASE.
AT END OF row.
APPEND wa_final TO i_final.
CLEAR wa_final.
ENDAT.
ENDLOOP.
FORM open_folder .
DATA: li_file TYPE TABLE OF sdokpath,
lwa_file TYPE sdokpath.
CLEAR: po_file, lwa_file.
REFRESH li_file[].
CALL FUNCTION 'TMP_GUI_FILE_OPEN_DIALOG'
TABLES
file_table = li_file
EXCEPTIONS
cntl_error = 1
OTHERS = 2.
IF sy-subrc IS INITIAL.
READ TABLE li_file INTO lwa_file INDEX 1.
IF sy-subrc IS INITIAL.
po_file = lwa_file-pathname.
ENDIF.
ENDIF.
If it is text file let me know what data u r uploading. Paste the piece of file data.
Thanks,
Vinod.
Similar Messages
-
Upload excel data thru gui_upload in CRM
Hi,
Can anyone tell me how to upload excel data into internal table thru GUI_UPLOAD only in CRM without converting into text files. Please help me out.
Thanks in advance.
regards
sireeshahi,
Use the FM 'ALSM_EXCEL_TO_INTERNAL_TABLE'.
call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
exporting
filename = filename
i_begin_col = i_begin_col
i_begin_row = i_begin_row
i_end_col = i_end_col
i_end_row = i_end_row
tables
intern = intern
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3 .
if sy-subrc <> 0.
* error
endif.
Regards,
Richa -
" Can not interpret the data in file " error while uploading the data in DB
Dear All ,
After running the below report I am getting the " Can not interpret the data in file " error.
Need to upload the data in DB through excel or .txt file.
Kindly advise to resolve the issue.
REPORT ZTEST_4.
data : it like ZPRINT_LOC occurs 0 with header line,
FILETABLE type table of FILE_TABLE,
wa_filetable like line of filetable,
wa_filename type string,
rc type i.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
CHANGING
FILE_TABLE = filetable
RC = rc.
IF SY-SUBRC = 0.
read table filetable into wa_filetable index 1.
move wa_filetable-FILENAME to wa_filename.
Else.
Write: / 'HI'.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
start-of-selection.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = wa_filename
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
TABLES
DATA_TAB = it.
IF SY-SUBRC = 0.
Write: / 'HI'.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
insert ZPRINT_LOC from table it.
if sy-subrc = 0.
commit work.
else.
rollback work.
endif.
Regards
Machindra Patade
Edited by: Machindra Patade on Apr 9, 2010 1:34 PMDear dedeepya reddy,
Not able to upload the excel but have sucess to upload the .csv file to db through the below code. Thanks for your advise.
REPORT ZTEST_3.
internal table declaration
DATA: itab TYPE STANDARD TABLE OF ZPRINT_LOC,
wa LIKE LINE OF itab,
wa1 like line of itab.
variable declaration
DATA: v_excel_string(2000) TYPE c,
v_file LIKE v_excel_string VALUE 'C:\Documents and Settings\devadm\Desktop\test.csv', " name of the file
delimiter TYPE c VALUE ' '. " delimiter with default value space
read the file from the application server
OPEN DATASET v_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc NE 0.
write:/ 'error opening file'.
ELSE.
WHILE ( sy-subrc EQ 0 ).
READ DATASET v_file INTO wa.
IF NOT wa IS INITIAL.
append wa TO itab.
ENDIF.
CLEAR wa.
ENDWHILE.
ENDIF.
CLOSE DATASET v_file.
EXEC SQL.
TRUNCATE TABLE "ZPRINT_LOC"
ENDEXEC.
*------display the data from the internal table
LOOP AT itab into wa1.
WRITE:/ wa1-mandt,wa1-zloc_code,wa1-zloc_desc,wa1-zloc,wa1-zstate.
ENDLOOP.
insert ZPRINT_LOC from table itab. -
Problem to upload the data into internal table record length more than 6000
Hi all
I stuck with this problem from past 3 days. I have to upload the data from excel sheet. iam making it tab delimited and trying to upload from gui_upload. but in the structure of file, we have, one field of 4000 characters, and other fields of 255 characters.
how can i upload this into internal table . From excel sheet or from tab delimeted or any other format? or any special function module is there? while iam doing this its truncating the datat 255 characters and not uploading the other fields also...
can any one of you help me out. ASAP
thnks in advancefrom one of the forum iam just pasting code which it is used in lsmw, try the same logic in ur code hope it can work.
you have to create multiple lines with do...enddo loop., like this:
(assuming excel_long_text-text is 924 characters long, 7 lines X 132 char)
__GLOBAL_DATA__
data: offset type i,
text_132(132) type c.
__BEGIN_OF_RECORD__ Before Using Conversion Rules
Rule : Default Settings Modified
Code: /sapdmc/ltxtl = init_/sapdmc/ltxtl.
CLEAR offset.
DO 7 TIMES.
text_132 = excel_long_text-text+offset(132).
offset = offset + 132.
__END_OF_RECORD__ After Using Conversion Rules
Rule : Default Settings Modified
Code: transfer_record.
ENDDO.
also check this
COMMIT_TEXT
To load long text into SAP
READ_TEXT
To load long text into SAP -
Uploading the data from a flat file into ztable
Hi,
I have a requirement where I have to upload the data from 2 flat files into 2 z tables(ZRB_HDR,ZRB_ITM).From the 1st flat file only data for few fields have to be uploaded into ztable(ZRB_HRD) .Fromthe 2nd flat file data for all the fields have to me uploaded into ztable(ZRB_ITM). How can I do this?
Regards,
Hemahi,
declare two internal table with structur of your tables.
your flat files should be .txt files.
now make use of GUI_UPLOAD function module to upload your flatfile into internal tables.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'c:\file1.txt'
has_field_separator = 'X'
TABLES
data_tab = itab1
EXCEPTIONS
OTHERS = 1.
use this function twice for two tables.
then loop them individually and make use of insert command. -
Problem in the BDC program to upload the data from a flat file.
Hi,
I am required to write a BDC program to upload the data from a flat file. The conditions are as mentioned below:-
1) Selection Screen will be prompted to user and user needs to provide:- File Path on presentation server (with F4 help for this obligatory parameter) and File Separator e.g. @,#,$,%,... etc(fields in the file will be separated by using this special character) or fields may be separated by tab(tab delimited).
2) Finally after the data is uploaded, following messages need to be displayed:-
a) Total Number of records successfully uploaded.
b) Session Name
c) Number of Sessions created.
Problem is when each record is fetched from flat file, the record needs to be split into individual fields separated by delimiter or in case tab separated, then proceeding in usual manner.
It would be great if you provide me either the logic, pseudocode, or sample code for this BDC program.
Thanks,Here is an example program, if you require the delimitor to be a TAB, then enter TAB on the selection screen, if you require the delimitor to be a comma, slash, pipe, whatever, then simply enter that value. This example is simply the uploading of the file, not the BDC, I assume that you know what to do once you have the data into the internal table.
REPORT zrich_0001.
TYPES: BEGIN OF ttab,
rec TYPE string,
END OF ttab.
TYPES: BEGIN OF tdat,
fld1(10) TYPE c,
fld2(10) TYPE c,
fld3(10) TYPE c,
fld4(10) TYPE c,
END OF tdat.
DATA: itab TYPE TABLE OF ttab.
data: xtab like line of itab.
DATA: idat TYPE TABLE OF tdat.
data: xdat like line of idat.
DATA: file_str TYPE string.
DATA: delimitor TYPE string.
PARAMETERS: p_file TYPE localfile.
PARAMETERS: p_del(5) TYPE c.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
DATA: ifiletab TYPE filetable.
DATA: xfiletab LIKE LINE OF ifiletab.
DATA: rc TYPE i.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
CHANGING
file_table = ifiletab
rc = rc.
READ TABLE ifiletab INTO xfiletab INDEX 1.
IF sy-subrc = 0.
p_file = xfiletab-filename.
ENDIF.
START-OF-SELECTION.
TRANSLATE p_del TO UPPER CASE.
CASE p_del.
WHEN 'TAB'.
delimitor = cl_abap_char_utilities=>horizontal_tab.
WHEN others.
delimitor = p_del.
ENDCASE.
file_str = p_file.
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = file_str
CHANGING
data_tab = itab.
LOOP AT itab into xtab.
CLEAR xdat.
SPLIT xtab-rec AT delimitor INTO xdat-fld1
xdat-fld2
xdat-fld3
xdat-fld4.
APPEND xdat to idat.
ENDLOOP.
LOOP AT idat into xdat.
WRITE:/ xdat-fld1, xdat-fld2, xdat-fld3, xdat-fld4.
ENDLOOP.
Regards,
Rich Heilman -
GUI_UPLOAD to read data from an Excel File
Hi Folks,
I'm using FM GUI_UPLOAD to read data from an Excel File. But all I see in the table returned is 1 row with garbage values (special chacaters). Excel Workbook has proper data in the sheet, but its not getting uploaded properly. Sy-subrc is 0.
What could be the reason?
Thanksuse FM : ALSM_EXCEL_TO_INTERNAL_TABLE
See the example program to get from XLS file to Internal table
REPORT ZLWMI151_UPLOAD no standard page heading
line-size 100 line-count 60.
*tables : zbatch_cross_ref.
data : begin of t_text occurs 0,
werks(4) type c,
cmatnr(15) type c,
srlno(12) type n,
matnr(7) type n,
charg(10) type n,
end of t_text.
data: begin of t_zbatch occurs 0,
werks like zbatch_cross_ref-werks,
cmatnr like zbatch_cross_ref-cmatnr,
srlno like zbatch_cross_ref-srlno,
matnr like zbatch_cross_ref-matnr,
charg like zbatch_cross_ref-charg,
end of t_zbatch.
data : g_repid like sy-repid,
g_line like sy-index,
g_line1 like sy-index,
$v_start_col type i value '1',
$v_start_row type i value '2',
$v_end_col type i value '256',
$v_end_row type i value '65536',
gd_currentrow type i.
data: itab like alsmex_tabline occurs 0 with header line.
data : t_final like zbatch_cross_ref occurs 0 with header line.
selection-screen : begin of block blk with frame title text.
parameters : p_file like rlgrap-filename obligatory.
selection-screen : end of block blk.
initialization.
g_repid = sy-repid.
at selection-screen on value-request for p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = g_repid
IMPORTING
FILE_NAME = p_file.
start-of-selection.
Uploading the data into Internal Table
perform upload_data.
perform modify_table.
top-of-page.
CALL FUNCTION 'Z_HEADER'
EXPORTING
FLEX_TEXT1 =
FLEX_TEXT2 =
FLEX_TEXT3 =
*& Form upload_data
text
FORM upload_data.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = p_file
I_BEGIN_COL = $v_start_col
I_BEGIN_ROW = $v_start_row
I_END_COL = $v_end_col
I_END_ROW = $v_end_row
TABLES
INTERN = itab
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
write:/10 'File '.
ENDIF.
if sy-subrc eq 0.
read table itab index 1.
gd_currentrow = itab-row.
loop at itab.
if itab-row ne gd_currentrow.
append t_text.
clear t_text.
gd_currentrow = itab-row.
endif.
case itab-col.
when '0001'.
t_text-werks = itab-value.
when '0002'.
t_text-cmatnr = itab-value.
when '0003'.
t_text-srlno = itab-value.
when '0004'.
t_text-matnr = itab-value.
when '0005'.
t_text-charg = itab-value.
endcase.
endloop.
endif.
append t_text.
ENDFORM. " upload_data
*& Form modify_table
Modify the table ZBATCH_CROSS_REF
FORM modify_table.
loop at t_text.
t_final-werks = t_text-werks.
t_final-cmatnr = t_text-cmatnr.
t_final-srlno = t_text-srlno.
t_final-matnr = t_text-matnr.
t_final-charg = t_text-charg.
t_final-erdat = sy-datum.
t_final-erzet = sy-uzeit.
t_final-ernam = sy-uname.
t_final-rstat = 'U'.
append t_final.
clear t_final.
endloop.
delete t_final where werks = ''.
describe table t_final lines g_line.
sort t_final by werks cmatnr srlno.
Deleting the Duplicate Records
perform select_data.
describe table t_final lines g_line1.
modify zbatch_cross_ref from table t_final.
if sy-subrc ne 0.
write:/ 'Updation failed'.
else.
Skip 1.
Write:/12 'Updation has been Completed Sucessfully'.
skip 1.
Write:/12 'Records in file ',42 g_line .
write:/12 'Updated records in Table',42 g_line1.
endif.
delete from zbatch_cross_ref where werks = ''.
ENDFORM. " modify_table
*& Form select_data
Deleting the duplicate records
FORM select_data.
select werks
cmatnr
srlno from zbatch_cross_ref
into table t_zbatch for all entries in t_final
where werks = t_final-werks
and cmatnr = t_final-cmatnr
and srlno = t_final-srlno.
sort t_zbatch by werks cmatnr srlno.
loop at t_zbatch.
read table t_final with key werks = t_zbatch-werks
cmatnr = t_zbatch-cmatnr
srlno = t_zbatch-srlno.
if sy-subrc eq 0.
delete table t_final .
endif.
clear: t_zbatch,
t_final.
endloop.
ENDFORM. " select_data -
ERROR while uploading the data into ztable with background processing
Hi gurus,
i am trying to upload the data from excel file to internal table
its working fine ..
but........
if i try to upload the data with background processing , in sm37 it is saying "error during the upload of clipboard contents".
Regards,
SriHi,
FM GUI_UPLOAD doesnt work in background, use dataset to upload it from application server.
refer below code
*--Local Variables
DATA : l_file TYPE string,
l_line TYPE string,
l_index TYPE sy-tabix.
*--Clear
CLEAR : l_file.
l_file = p_ipfile.
*--Read the data from application server file.
OPEN DATASET l_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc NE 0.
*--Error in opening file
MESSAGE i368(00) WITH text-005.
ENDIF.
*--Get all the records from the specified location.
DO.
READ DATASET l_file INTO l_line.
IF sy-subrc NE 0.
EXIT.
ELSE.
SPLIT l_line AT cl_abap_char_utilities=>horizontal_tab
INTO st_ipfile-vbeln
st_ipfile-posnr
st_ipfile-edatu
st_ipfile-wmeng.
APPEND st_ipfile TO it_ipfile.
ENDIF.
ENDDO.
Regards,
Prashant -
Hi all,
I am new to ABAP Development. I need to upload a .DAT file (the file doesn#t have any proper structure-- Please find the .DAT file in the attachment). After uploading the DATA (.DAT) fiel I need to split in into different columns. Refering the attached .DAT fiel the fields in bracets like:
[Arbeitstag], [Pecunia], [Mita], [Kunde], [Auftrag] and [Position] are different fields that need to be arranged in columns in an internal table. this .DAT fiel which I want to upload and then SPLIT it into various fields will will treated as MASTER DATA table for further programming. The program that I had written is as below. Also please refer the attached .DAT table.
Please if any one could help me. i searched a lot in different forums but couldn't find me a solution. Also note that the attached fiel is in text (.txt) format here but in real situation the same fiel is in DATA (.DAT) format.
*& Report ZDEMO_ZEITERFASSUNG9
REPORT ZDEMO_ZEITERFASSUNG9.
Types: Begin of ttab,
Rec(1000) type c,
End of ttab.
DATA: itab type table of ttab.
DATA: wa_tab type ttab.
DATA: file_str type string.
Parameters: p_file type localfile.
At selection-screen on value-request for p_file.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
* PROGRAM_NAME = SYST-REPID
* DYNPRO_NUMBER = SYST-DYNNR
* FIELD_NAME = ' '
STATIC = 'X'
* MASK = ' '
CHANGING
file_name = p_file.
* EXCEPTIONS
* MASK_TOO_LONG = 1
* OTHERS = 2
Start-of-Selection.
file_str = P_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = '\\10.10.1.92\Volume_1\_projekte\Zeiterfassung-SAP\BUP_ZEIT.DAT' " This the file source address
FILETYPE = 'DAT'
HAS_FIELD_SEPARATOR = ';'
* 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 = 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
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.
LOOP at itab into wa_tab.
WRITE: / wa_tab.
ENDLOOP.
I will be grateful to all you experts for ur inputs
regards
Chandan SinghFor every Auftrag, there are multiple Position entries.
Rest of the blocks don't seems to have any relation.
So you can check this code to see how internal table lt_str is built whose first 3 fields have data contained in Auftrag, and next 3 fields have Position data. The structure is flat, assuming that every Position record is related to preceding Auftrag.
Try out this snippet.
DATA lt_data TYPE TABLE OF string.
DATA lv_data TYPE string.
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = 'C:\temp\test.txt'
CHANGING
data_tab = lt_data
EXCEPTIONS
OTHERS = 19.
CHECK sy-subrc EQ 0.
TYPES:
BEGIN OF ty_str,
a1 TYPE string,
a2 TYPE string,
a3 TYPE string,
p1 TYPE string,
p2 TYPE string,
p3 TYPE string,
END OF ty_str.
DATA: lt_str TYPE TABLE OF ty_str,
ls_str TYPE ty_str,
lv_block TYPE string,
lv_flag TYPE boolean.
LOOP AT lt_data INTO lv_data.
CASE lv_data.
WHEN '[Version]' OR '[StdSatz]' OR '[Arbeitstag]' OR '[Pecunia]'
OR '[Mita]' OR '[Kunde]' OR '[Auftrag]' OR '[Position]'.
lv_block = lv_data.
lv_flag = abap_false.
WHEN OTHERS.
lv_flag = abap_true.
ENDCASE.
CHECK lv_flag EQ abap_true.
CASE lv_block.
WHEN '[Auftrag]'.
SPLIT lv_data AT ';' INTO ls_str-a1 ls_str-a2 ls_str-a3.
WHEN '[Position]'.
SPLIT lv_data AT ';' INTO ls_str-p1 ls_str-p2 ls_str-p3.
APPEND ls_str TO lt_str.
ENDCASE.
ENDLOOP. -
hi hr gurus,
plz help
we have 3 shifts like 6-2,2-10,10-6.
while uploading time data to sap from third party system.
do we need to take care of the shifts times in BDC?
or do we need to manage it in configurations
if you have any code please send me
regardsHi,
As above said was the also procedure to do the BDC recording.Hope you understand the precedure in detail else have a look @ this.
1.Goto transaction shdb for recording.
2.There give the recording name starting with Z or Y letter.
3.Click "New Recording" button in the left extreme Application tool bar.
4.You will get a new pop up window Create Recording there give Recording Name"Z r Y" and give the transaction code that you going to record for e.g (PA30,XK01).
5.Leave the Mode as it is and click "Start Recording".
6.Here you will get the transaction code window for e.g if you are giving PA30 it will call the corresponding transaction.
7.Start recording by entering the values which you want to record.
8.After recording save the recording and give back.
9.There you find the list of process which is done.
10.Enter your recording name and press enter you will get the program name.
11.Select the program name and press "program" button in the application tool bar.It will ask abt the prgm name and give read from file.
12.You will get the coding in se38 for recording.
13.Edit your program for uploading the flat file from you legacy system to application server by using CALL FUNCTION "GUI_UPLOAD".
14.Get the flat file and fill it in internal table and pass the internal table values by giving "loop at internal table" after READ DATASET statement.
15.Select the call transaction for small no. of data for large no. of data we have to use session method.(Refer some links for difference between session and call transaction).
16.There by executing the program we will get the output which record are created.
Thanks,
Sakthi.C
*Rewards if usefull--* -
Upload excel data into Internal table
Hi,
I'm trying to upload excel data into internal table, well the excel file layout will be different on each run of the report.
Excel file will have 60 columns and 500 record limit. I can upload the excel data using 'ALSM_EXCEL_TO_INTERNAL_TABLE' and 'KCD_EXCEL_OLE_TO_INT_CONVERT' but the output table is generates 60 lines for each record i.e.., 60 * 500 = 30,000 which could cause performance.
I try with the FM 'TEXT_CONVERT_XLS_TO_SAP', but this will only work if the file structure is static. It didn't work for dynamic file layout. Even GUI_UPLOAD doesn't work to upload excel file, it will work if I convert the file to Tab delimited file.
Please advise if you know any alternate procedure to upload excel data into internal table.
Thanks,
Kumar.Moderator message - Cross post locked
Rob -
Download File from DMS into WD ABAP gives junk data
Hi Experts ,
I want to achieve following functionality in WD ABAP.
User should be able to upload and download any file ( in any fromat ) , to / form document management server.
Since user can upload / download any file so I am using a file download UI , which would open any file in a new window.
I have searched about this in SDN ([ link |https://wiki.sdn.sap.com/wiki/display/Snippets/WDA%20Retrieve%20Data%20from%20DMS%20server]) and I have created a FM which gives me Xstring corresponding to the file in the DMS system.
then I pass this Xstring data to my context 'DATACONTENT' which is bound to file download UI (data property). But When I execute this application I am getting junk data in the new window. Please correct me where I am making a mistake.
following is the code in FM which in turn passes v_xstring ( of type xstring ) to WD ABAP . Then I bind this value to context
'DATACONTENT'.
wd_context->set_attribute( name = 'DATACONTENT' value = V_XSTRING ).
FUNCTION ZTESTING_EP.
""Local Interface:
*" IMPORTING
*" VALUE(DOCUMENTTYPE) LIKE BAPI_DOC_AUX-DOCTYPE DEFAULT 'IVF'
*" VALUE(DOCUMENTNUMBER) LIKE BAPI_DOC_AUX-DOCNUMBER DEFAULT 1
*" VALUE(DOCUMENTPART) LIKE BAPI_DOC_AUX-DOCPART DEFAULT 000
*" VALUE(DOCUMENTVERSION) LIKE BAPI_DOC_AUX-DOCVERSION DEFAULT 00
*" EXPORTING
*" VALUE(C) LIKE BAPIEMPLB-RETURN
*" VALUE(V_XSTRING) TYPE XSTRING
*" VALUE(RETURN) TYPE BAPIRET2
data: ls_docfiles type bapi_doc_files2,
ls_dms type dms_doc_files,
lt_docfiles type standard table of bapi_doc_files2.
select single * from dms_doc_files
into ls_dms
where "Retrieve file
MOVE '0000000000000000000000001' to DOCUMENTNUMBER .
MOVE '000' to DOCUMENTPART .
MOVE '00' to DOCUMENTVERSION .
if sy-subrc = 0.
ls_docfiles-documenttype = DOCUMENTTYPE.
ls_docfiles-documentnumber = DOCUMENTNUMBER .
ls_docfiles-documentpart = DOCUMENTPART .
ls_docfiles-documentversion = DOCUMENTVERSION.
endif.
call function 'BAPI_DOCUMENT_CHECKOUTVIEW2'
exporting
documenttype = ls_docfiles-documenttype
documentnumber = ls_docfiles-documentnumber
documentpart = ls_docfiles-documentpart
documentversion = ls_docfiles-documentversion
documentfile = ls_docfiles
getstructure = '1'
getcomponents = 'X'
getheader = 'X'
pf_ftp_dest = 'SAPFTPA'
IMPORTING
return = return
tables
documentfiles = lt_docfiles.
MOVE return to return.
data: i_bin type standard table of sdokcntbin,
i_info type standard table of scms_acinf,
v_info type scms_acinf,
v_id type sdok_phid,
v_cat type sdok_stcat.
if sy-subrc = 0.
loop at lt_docfiles into ls_docfiles.
v_id = ls_docfiles-docfile.
v_cat = ls_docfiles-storagecategory.
call function 'SCMS_DOC_READ'
exporting
stor_cat = v_cat
doc_id = v_id
phio_id = ls_docfiles-file_id
tables
access_info = i_info
content_bin = i_bin
exceptions
bad_storage_type = 1
bad_request = 2
unauthorized = 3
comp_not_found = 4
not_found = 5
forbidden = 6
conflict = 7
internal_server_error = 8
error_http = 9
error_signature = 10
error_config = 11
error_format = 12
error_parameter = 13
error = 14
others = 15
endloop.
if sy-subrc <> 0.
else.
data: v_xstring type xstring.
read table i_info into v_info index 1.
call function 'SCMS_BINARY_TO_XSTRING'
exporting
input_length = v_info-comp_size
importing
buffer = v_xstring
tables
binary_tab = i_bin
exceptions
failed = 1
others = 2
if sy-subrc <> 0.
endif.
endif.
endif.
ENDFUNCTION.
Thanks in advance
AbhayHi Abhay,
I have used the belwo method to achive the same:
1) Call funtion 'CVAPI_DOC_GETDETAIL' to get the document details.This function module returns PT_FILES tables parameter
2) Loop at PT_FILES and call the 'CV120_GET_MIME_TYPE' funtion by passing DAPPL of PT_FILES to get the mime type.
3)call function 'CVAPI_DOC_CHECKOUTVIEW' by passing PT_FILES values form above retrived to the function module in this step
4)Loop at the content and convert to XSTRING using SCMS_XSTRING_TO_BINARY
After getting the XSTRING,MIMETYPE use ATTACH_FILE_FOR_RESPONSE method of CL_WD_RUNTIME_SERVICES to download the file
Sample Code:
CALL FUNCTION 'CVAPI_DOC_GETDETAIL'
EXPORTING
pf_dokar = ls_draw-dokar
pf_doknr = iv_documentnumber
pf_dokvr = ls_draw-dokvr
pf_doktl = ls_draw-doktl
pf_read_drat = abap_true
IMPORTING
psx_draw = ls_draw
TABLES
pt_drat = et_drat
pt_files = et_files
EXCEPTIONS
not_found = 1
no_auth = 2
error = 3
OTHERS = 4.
ENDIF.
IF et_files IS NOT INITIAL.
LOOP AT et_files INTO ls_files.
CALL FUNCTION 'CV120_GET_MIME_TYPE'
EXPORTING
pf_dappl = ls_files-dappl
* PF_FILE =
IMPORTING
pfx_mimetype = lv_mimetype.
CLEAR lt_files_checkout.
CLEAR lt_content.
ls_files_checkout-description = ls_files-description.
ls_files_checkout-lo_objid = ls_files-lo_objid.
ls_files_checkout-ph_objid = ls_files-ph_objid.
APPEND ls_files_checkout TO lt_files_checkout.
CALL FUNCTION 'CVAPI_DOC_CHECKOUTVIEW'
EXPORTING
pf_dokar = ls_draw-dokar
pf_doknr = iv_documentnumber
pf_dokvr = ls_draw-dokvr
pf_doktl = ls_draw-doktl
pf_content_provide = gc_content_provide
* PS_API_CONTROL =
* PF_STD_URL = 'X'
IMPORTING
psx_message = ls_message
psx_draw = ls_draw
TABLES
pt_files = lt_files_checkout
* PTX_COMPONENTS =
ptx_content = lt_content.
IF ls_message CA gc_error_a.
ev_fail = abap_true.
ELSE.
CLEAR lt_xdata.
CLEAR ls_bindata.
*Data into String
LOOP AT lt_content INTO ls_content.
lv_size = ls_content-orln.
ls_xdata-line = ls_content-orblk.
APPEND ls_xdata TO lt_xdata.
ENDLOOP.
* -- Convert XData to Xstring
CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
EXPORTING
input_length = lv_size
IMPORTING
buffer = ls_bindata
TABLES
binary_tab = lt_xdata
EXCEPTIONS
failed = 1
OTHERS = 2.
IF sy-subrc NE 0.
ev_fail = abap_true.
ELSE.
ls_file_list-filename = ls_files-description.
ls_file_list-mimetype = lv_mimetype.
ls_file_list-content = ls_bindata.
ls_file_list-application_id = ls_files-lo_objid.
ls_file_list-file_id = ls_files-ph_objid.
APPEND ls_file_list TO et_file_list.
ENDIF.
ENDIF.
ENDLOOP.
ENDIF.
Regards,
Madhu -
Problem in Uploading Excel Data ! - Urgent
Dear Experts,
I am uploading excel data using FM 'TEXT_CONVERT_XLS_TO_SAP' , its directly convert data and store in internal table same as in excel sheet(row , column wise).
But the problem is , one of the column having description more then 500 characters. so while uploding excel to itab its truncating the text and only uploding 255 characters.
Is there any other way , so that i can upload more then 500 characters long text. Also i have tried 'ALSM_EXCEL_TO_INTERNAL_TABLE' FM , it was also not working.
Please Help me , its Urgent.
Points will be rewared.
Thanks & Regards,Hi,
Please use FM 'GUI_UPLOAD'.
types: begin of ttab,
rec(1000) type c,
end of ttab.
types: begin of tdat,
fld1(10) type c,
fld2(10) type c,
fld3(10) type c,
end of tdat.
data: itab type table of ttab with header line.
data: idat type table of tdat with header line.
data: file_str type string.
parameters: p_file type localfile.
at selection-screen on value-request for p_file.
call function 'KD_GET_FILENAME_ON_F4'
exporting
static = 'X'
changing
file_name = p_file.
start-of-selection.
file_str = p_file.
call function 'GUI_UPLOAD'
exporting
filename = file_str
filetype = 'ASC'
tables
data_tab = 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
others = 17.
Best regards,
Prashant -
How to delete the Junk Data From Excel Sheet
Dear ABAPers,
I am uploading the Excel sheet from the Desktop to the SAP System. In the Internal table i am getting Unwanted Junk data's for Example '##########'.I am not getting this Junk data for all the times. i am getting it for Some times.How to ignore these junk data.
Thanks & Regards,
Ashok.Dear Friends,
I communicated wrongly.I am very sorry for that.The Problem is I am getting All the Data into the internal table in addition to that lines i am getting the Junk data in the internal table at the end of the internal table.
Excel Sheet
L-1 21.10.2008 1110 888555444676001
L-1 21.10.2008 1110 888555444676002
L-1 21.10.2008 1110 888555444676003
L-1 21.10.2008 1110 888555444676004
Internal table
L-1 21.10.2008 1110 888555444676001
L-1 21.10.2008 1110 888555444676002
L-1 21.10.2008 1110 888555444676003
L-1 21.10.2008 1110 888555444676004
Thanks & Regards,
Ashok. -
FM "GUI_UPLOAD " File type 'DAT' with UNICODE
Hi all,
Were using UNICODE and we have developed a FM which upload the data from application server as well as from presentation server. Its based on selection screen options. We are using GUI_UPLOAD FM in our function module. We have hardcode file type as DAT.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = Z_FILENAME
FILETYPE = 'DAT'
HAS_FIELD_SEPARATOR = 'X'
TABLES
DATA_TAB = T_INPUT
But when were uploading file from presentation server as CSV, Tab delimited or even XLS .its giving an error. Why is that? Is this any thing to do with UNICODE? What should be the type of file DAT?
Please give your suggestions/input.
Thanks
Bye"subrc = 5 "
INVALID_TYPE = 5
Why We cant user file type 'DAT' with GUI_UPLOAD ?
Im defining the structure as per file and rests of things are fine.
Thanks for the reply...!
<b>GUI_UPLOAD HELP !!!</b>
Value range
<b>'DAT'</b>
The components of the internal table are filled from the file. If the table contains several columns, the entries in the file must be separated by tabs. No conversion exits are carried out.
The following applies for the different data types:
I or N or P or F
The numbers must be formatted according to the decimal representation defined in the user settings.
D The date must be defined according to the date format defined in the user settings.
T The time must have the format hh:mm:ss.
Message was edited by: Suleman Javed
Maybe you are looking for
-
Gwtting error while activation of datasource
Hi i am using demo version . while activating my datasource ( flat file and , r/3 datasources) i am getting this error. please let me know this error will be system related or we can solve our self also function module SDF/AL_MAP_TRANSID_LOGH DOENT N
-
How do i send hyperlink to a text box within the same page
how do i send hyperlink to a text box within the same page on iweb
-
Entity Descriptions are not displayed correctly in Combo box dropdown list
In Web Analysis, Entity Descriptions are not displayed correctly in Combo box dropdown list when entity descriptions from HFM contains a dot(.) Example: 'Entity A. LTD' becomes 'LTD' 'Entity B Inc.' becomes blank It seems that everything before the d
-
Using Logical Directory property in Assign File Adapter BPEL
Hi, I wanted to use The Logical Directory which I created while making File Adapter in a BPEL process in 11g, in an assign activity. How it can be done? Thanks in advance Sharat
-
OPEN DATASET file FOR OUTPUT IN TEXT MODE ENCODING NON-UNICODE
Hi There, I also have the similar issue. I am able to write the data into appliaction server in Chinese Characters using :OPEN DATASET datei FOR OUTPUT IN TEXT MODE ENCODING DEFAULT or OPEN DATASET datei FOR OUTPUT IN TEXT MODE ENCODING UTF-8. But wh