Header in GUI_UPLOAD
Hi everyone,
I am trying to read XML file with function module GUI_UPLOAD.
There are some Parameters about Header that I can't understand.
e.g.[IMPORTING] header_length TYPE I
[EXPORTING] header TYPE XSTRING
A XML file have element, node, attribute. How should I the Header understand.
thanks in advance.
HI Liang,
Instead of gui_upload fm use IMPORT_FROM_FILE method of CL_XML_DOCUMENT to upload XML document.
DATA: gcl_xml TYPE REF TO cl_xml_document.
DATA: gv_subrc TYPE sy-subrc.
START-OF-SELECTION.
CREATE OBJECT gcl_xml.
*Upload XML File
CALL METHOD gcl_xml->import_from_file
EXPORTING
filename = 'c:\test.xml'
RECEIVING
retcode = gv_subrc.
IF gv_subrc = 0.
*Display XML
CALL METHOD gcl_xml->display.
ENDIF.
Regards,
Vineesh B.
Similar Messages
-
How to ignore the column header in GUI_UPLOAD
Hi,
I am trying to use GUI_UPLOAD to upload data from text file into a table. However there is no parameter to ignore the column headers in this function. how can i set to ignore the column headers in this function?Check the function module documentation and also refer to the parameter: HEADER_LENGTH
Length of Header for Binary Data
Description
Specifies the length of the header information. You must only set this parameter if the file type is 'BIN'. The default value '00' means that there is no header in the file.
Default
'00' -
Flat file header diferent from remaining file (function module GUI_UPLOAD)
Hello gurus,
I need to upload a flat file but the header is the control record with the number of lines in the file, and has a diferent structure from remaining file records.
I'm using GUI_UPLOAD in ASCII mode for the flat file and my first line with the control record does not "fit" the structure of the remaining records.
Whats the best way I read diferent line structures in the flat file so I can have a counter from the first line and all other lines in an internal table?
Using GUI_UPLOAD twice with diferent internal tables will have performance degraded...
regards.
Sérgio.Hi,
Declare an itab as
ITAB TYPE STANDARD TABLE OF STRING
Variable for Tab limited
data :gc_con_tab TYPE c VALUE cl_abap_char_utilities=>horizontal_tab.
pass the control record to the internal table first then.
loop at it_final into wa_final.
concatenating gc_con_tab will add TABs in your output.
CONCATENATE wa_final-f1 wa_final-f2
into ITABl separated by gc_con_tab.
append ITAB.
endloop.
Then use GUI_DOWNLOAD to download ITAB.
Regards,
Shanmugavel chandrasekaran -
Header line in Gui_upload
Hello,
I wish to upload contents of an excel file to an internal table using GUI_UPLOAD.
This file has the first row as header for the rows below.
How do i ignore this row when uploading contents to internal table?
Thanks in advance.Welcome to SDN.
IF you want it to upload with GUI_UPLOAD then after uploading the records in table delete the row with index 1 from the intenal table.
otherwise you can always go for ALSM_EXCEL_TO_INTERNAL_TABLE, where you can give the sarting row and column to read the excel.
I will prefer the later one anytime over the former.
A sample code -
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.
clear intern.
LOOP AT intern.
at new col.
v_new = 1.
endat.
if v_new = 1.
clear v_new.
col = intern-col.
CASE col .
when '1'.
itab-ENO = intern-value.
when '2'.
itab-ENAME = intern-value.
endcase.
endif.
at end of row.
append itab. clear itab.
endat.
endloop.
Regards,
Amit
Reward all helpful replies. -
Handling header line in gui_upload
Hi friends,
I am trying to use gui_upload to read text file.
Input text file has header line in it.So file should be read from 2nd line as 1st line is header and data starts from 2nd line.
but it is returning error = 8.
Kindly help me friends
Thx in advance.Hi,
Keep header = 'X'.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = pfname1
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 = 'x'
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.
Rgds
siva -
How to put the header in excel file in GUI_DOWNLOAD
Hi,
I have a requirement , Which I m downloading the contents of internal table using the GUI_DOWNLOAD in excel format, I need to keep the first line of the excel sheet as a header, Can any one suggest how to go for this,Hello,
You can have the data in the data tab & field name in the field tab. And so you can download both the field name and the value for the same using the FM u2013 GUI_DOWNLOAD (File type should be u2018ASCu2019).
Hope, you need additional information to be added as the header.
One option: You can call the GUI_UPLOAD twice.
First one with the header in the data tab.
Second one with the option append = u2018Xu2019 with the actual data and header and pass the same above file name as input.
Also, there is a solved forum already exists but with a different solution. You can go through the below link also:
Re: GUI_DOWNLOAD with Header
Regards,
Selva K. -
"Cannot interpret data in file" error while using GUI_UPLOAD for .xls file
Hi,
I have made a program using FM GUI_UPLOAD to upload an .xls file to an internal table. But upon executing ,it gives error "Cannot Interpret data in file". I have seen in other posts people talking about GUI_UPLOAD FM to upload data from excel directly into internal table. Kindly help.
Here is my code. I had tried using different combination for HAS_FIELD_SEPARATOR but still its not working.
In my emp1.xls file , the data in each column is present in the same order as in the internal table. Although the first column in my internal table is NUMC. I dont know if that is causing the problem.
REPORT ZUPLOAD_1.
data: itab TYPE TABLE OF zempl_master WITH HEADER LINE.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = 'C:\empl1.xls'
FILETYPE = 'ASC'
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 = 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.
write:/ itab-emp_no,itab-name.
endloop.hi amber22 you need to use the below fm to upload an xls file
FORM EXCEL_UPLOAD .
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = FILENAM
I_BEGIN_COL = 1
I_BEGIN_ROW = 1
I_END_COL = 6
I_END_ROW = 100
TABLES
INTERN = xl_itab.
* EXCEPTIONS
* INCONSISTENT_PARAMETERS = 1
* UPLOAD_OLE = 2
* OTHERS = 3 .
IF SY-SUBRC = 0.
MESSAGE 'DATA UPLOADED SUCCESSFULLY' TYPE 'I'.
ENDIF.
ENDFORM. " EXCEL_UPLOAD -
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 using the function module GUI_UPLOAD
Hi,
My requirement is to upload the data from .txt file into internal table.
I have given my code like this
PARAMETERS: p_fname LIKE rlgrap-filename.
data: begin of gt_string occurs 0,
record type char255,
end of gt_string.
AT SELECTION-SCREEN ON VALUE-REQUEST for p_fname.
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_fname
EXCEPTIONS
MASK_TOO_LONG = 1
OTHERS = 2
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 'GUI_UPLOAD'
EXPORTING
filename = p_fname
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
CHECK_BOM = ' '
NO_AUTH_CHECK = ' '
IMPORTING
FILELENGTH =
HEADER =
tables
data_tab = gt_string
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.
Here I am getting dump error as 'Type conflict when calling a function module.
The function module interface allows you to specify only fields
of a particular type under "FILENAME". The field "P_FNAME" specified here has a different field type'.
What would be the reason for this error?
Can anyone help me?
Regards,
Hemasee this sample program for F4 help
*& Report ZSD_EXCEL_INT_APP
REPORT ZSD_EXCEL_INT_APP.
parameter: file_nm type localfile.
types : begin of it_tab1,
f1(20),
f2(40),
f3(20),
end of it_tab1.
data : it_tab type table of ALSMEX_TABLINE with header line,
file type rlgrap-filename.
data : it_tab2 type it_tab1 occurs 1,
wa_tab2 type it_tab1,
w_message(100) TYPE c.
at selection-screen on value-request for file_nm.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
PROGRAM_NAME = SYST-REPID
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = ' '
STATIC = 'X'
MASK = ' '
CHANGING
file_name = file_nm
EXCEPTIONS
MASK_TOO_LONG = 1
OTHERS = 2
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
start-of-selection.
refresh it_tab2[].clear wa_tab2.
file = file_nm.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = file
i_begin_col = '1'
i_begin_row = '1'
i_end_col = '10'
i_end_row = '35'
tables
intern = it_tab
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.
loop at it_tab.
case it_tab-col.
when '002'.
wa_tab2-f1 = it_tab-value.
when '004'.
wa_tab2-f2 = it_tab-value.
when '008'.
wa_tab2-f3 = it_tab-value.
endcase.
at end of row.
append wa_tab2 to it_tab2.
clear wa_tab2.
endat.
endloop.
data : p_file TYPE rlgrap-filename value 'TEST3.txt'.
OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
*--- Display error messages if any.
IF sy-subrc NE 0.
MESSAGE e001(zsd_mes).
EXIT.
ELSE.
*---Data is downloaded to the application server file path
LOOP AT it_tab2 INTO wa_tab2.
TRANSFER wa_tab2 TO p_file.
ENDLOOP.
ENDIF.
*--Close the Application server file (Mandatory).
CLOSE DATASET p_file.
loop at it_tab2 into wa_tab2.
write : / wa_tab2-f1,wa_tab2-f2,wa_tab2-f3.
endloop. -
Gui_upload for uploading binary file
Hello All,
I am trying to upload '.jpg' files using gui_upload function.
But something goes wrong and it dumps.
I am new to ABAP.
following is the code i used.
DATA: xline TYPE xstring.
DATA : t_file LIKE TABLE OF xline WITH HEADER LINE.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filetype = 'BIN'
filename = 'C:\Documents and Settings\I046674\Desktop\RawTest\images\Image_1000.jpg'
TABLES
data_tab = t_file.
It dumps in the 'GUI_UPLOAD' function itself.
Saying follownig,
==========================================
Error analysis
The error occurred at a statement in the form
ASSIGN f TO <fs> TYPE t
One of these two cases occurred:
1) Field f is a string, a data reference, an object reference, an
internal table or a structure that contains such a field. With the
TYPE addition, this is not possible.
2) Field f is of type x and field symbol <fs> has a character-type type.
When executing the statement, the length of f is not a multiple of
the length (in bytes) of a Unicode character.
===============================================
Can someone help me on this?
Thanks & Regards,
Abhijithi,
Master Data Documents Upload ABAP Program
Re: Upload Master Data documents
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'c:\temp\text.txt'
filetype = ' '
IMPORTING
filelength = fleng
TABLES
data_tab = text_tab
EXCEPTIONS
file_write_error = 1
invalid_type = 2
no_authority = 3
unknown_error = 4
OTHERS = 10.
thanks -
Problem with GUI_UPLOAD using excel sheet
Hi,
I am trying to upload excel sheet thru GUI_UPLOAD ... this excel sheet has a header line and 3 line of data. Even if I remove the header line then also the internal while debugging is showing 28 lines of entries with "#" "squares" in some columns ... while in others where data should be there shows all Zeros....
The excel sheet has the following info
Rate Type Valid From Date From Currency To Currency Indirect Quote Direct Quote
M 29.09.2006 SGD USD 1.6932
M 29.09.2006 USD SGD 1.6932
M 29.09.2006 SGD MYR 2.19653
KURST GDATU FCURR TCURR INUKURS DUKURS
###ࡱ |########|#####|### #| 0.00000 |0.00000 |
##29 |00000000| | | 0.00000 |0.00000 |
o#d# |00000000| | | 0.00000 |0.00000 |
The code that I am writing is as follows:-
*& INTERNAL TABLES
DATA : BEGIN OF T_INPUT occurs 0,
KURST LIKE TCURV-KURST, " Exchange rate type
GDATU LIKE SY-DATUM, " Date from which rate is effective
FCURR LIKE TCURC-WAERS, " From currency
TCURR LIKE TCURC-WAERS, " To currency
INUKURS LIKE TCURR-UKURS, " Indirect Quote
DUKURS LIKE TCURR-UKURS, " Direct Quote
END OF T_INPUT.
S T A R T - O F - S E L E C T I O N *
START-OF-SELECTION.
Perform to upload the excel file.
PERFORM UPLOAD_EXCEL_FILE.
FORM UPLOAD_EXCEL_FILE .
DATA: L_FILENM TYPE STRING.
L_FILENM = P_FILENM.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = L_FILENM
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_INPUT
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.Hi SB,
pls change the data type declared for 'valid from date'
from
DATA : BEGIN OF T_INPUT occurs 0,
KURST LIKE TCURV-KURST, " Exchange rate type
<b>GDATU LIKE SY-DATUM,</b> " Date from which rate is effective
FCURR LIKE TCURC-WAERS, " From currency
TCURR LIKE TCURC-WAERS, " To currency
INUKURS LIKE TCURR-UKURS, " Indirect Quote
DUKURS LIKE TCURR-UKURS, " Direct Quote
END OF T_INPUT.
to
DATA : BEGIN OF T_INPUT occurs 0,
KURST LIKE TCURV-KURST, " Exchange rate type
GDATU(10) type c, " Date from which rate is effective
FCURR LIKE TCURC-WAERS, " From currency
TCURR LIKE TCURC-WAERS, " To currency
INUKURS LIKE TCURR-UKURS, " Indirect Quote
DUKURS LIKE TCURR-UKURS, " Direct Quote
END OF T_INPUT.
Cheers,
Vikram
Please reward for helpful replies!! -
Issue with field separator in GUI_UPLOAD
Hello Gurus
I am facing issue with gui_upload. I have a text file in which the fields are eparated by single Pipe i.e |. Now when I try to read the data from file in internal table even with using field separator it does not insert data in proper fields.
DATA: BEGIN OF IT_TAB OCCURS 0,
OBJECT_ID type string,
VERSION_SERIES_ID TYPE string,
VERSION_NUMBER TYPE string,
REVISION TYPE string,
DOC_NUMBER TYPE string,
DOCTITLE TYPE string,
FILESIZE TYPE string,
MIME_TYPE TYPE string,
PLANTUNIT TYPE string,
END OF IT_TAB.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = w_mpath
FILETYPE = 'ASC'
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 = it_tab[]
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.
I want the data to get appended in internal table based on | separator.
Please help.
Regards,
Rajesh.Hi,
I believe the field separator parameter will work for Excel files..You have to get the internal table in a string format..and then use split statement..
check this example..
DATA: BEGIN OF it_tab OCCURS 0,
object_id TYPE string,
version_series_id TYPE string,
version_number TYPE string,
revision TYPE string,
doc_number TYPE string,
doctitle TYPE string,
filesize TYPE string,
mime_type TYPE string,
plantunit TYPE string,
END OF it_tab.
DATA: t_tab TYPE TABLE OF string,
v_string TYPE string.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'C:\TEST.TXT'
* has_field_separator = '|' "Actually not required.
TABLES
data_tab = t_tab
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.
ENDIF.
LOOP AT t_tab INTO v_string.
SPLIT v_string AT ','
INTO
it_tab-object_id
it_tab-version_series_id
it_tab-version_number
it_tab-revision
it_tab-doc_number
it_tab-doctitle
it_tab-filesize
it_tab-mime_type
it_tab-plantunit.
APPEND it_tab.
CLEAR: it_tab.
ENDLOOP.
Thanks
Naren
Edited by: Narendran Muthukumaran on Oct 15, 2008 4:58 PM -
Excel data transfer into SAP internal table with GUI_UPLOAD
hi all,
i m using SRM4 system and i wanted to develop one report which will upload data from excel and convert it into IT.
i know that many threads are posted on this topic.
but my requirement is slight different. in the system only one function module is available that is "GUI_UPLOAD" and we want that user shd not save file as tab delimited before calling this fm. instead, program shd take care of all these things...
please suggest something asap..
helpful ans will be rewarded..
thanks,
jigs.Dear Jigs,
Please go though the following lines of code:
D A T A D E C L A R A T I O N *
TABLES: ANEP,
BKPF.
TYPES: BEGIN OF TY_TABDATA,
MANDT LIKE SY-MANDT, " Client
ZSLNUM LIKE ZSHIFTDEPN-ZSLNUM, " Serial Number
ZASSET LIKE ZSHIFTDEPN-ZASSET, " Original asset that was transferred
ZYEAR LIKE ZSHIFTDEPN-ZYEAR, " Fiscal Year
ZPERIOD LIKE ZSHIFTDEPN-ZPERIOD, " Fiscal Period
ZSHIFT1 LIKE ZSHIFTDEPN-ZSHIFT1, " Shift No. 1
ZSHIFT2 LIKE ZSHIFTDEPN-ZSHIFT1, " Shift No. 2
ZSHIFT3 LIKE ZSHIFTDEPN-ZSHIFT1, " Shift No. 3
END OF TY_TABDATA.
Declaration of the Internal Table with Header Line comprising of the uploaded data.
DATA: BEGIN OF IT_FILE_UPLOAD OCCURS 0.
INCLUDE STRUCTURE ALSMEX_TABLINE. " Rows for Table with Excel Data
DATA: END OF IT_FILE_UPLOAD.
S E L E C T I O N - S C R E E N *
SELECTION-SCREEN: BEGIN OF BLOCK B1 WITH FRAME,
BEGIN OF BLOCK B2 WITH FRAME.
PARAMETERS: P_FNAME LIKE RLGRAP-FILENAME OBLIGATORY.
SELECTION-SCREEN: END OF BLOCK B2,
END OF BLOCK B1.
E V E N T : AT S E L E C T I O N - S C R E E N *
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FNAME.
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_FNAME
EXCEPTIONS
MASK_TOO_LONG = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
E V E N T : S T A R T - O F - S E L E C T I O N *
START-OF-SELECTION.
Upload Excel file into Internal Table.
PERFORM UPLOAD_EXCEL_FILE.
Organize the uploaded data into another Internal Table.
PERFORM ORGANIZE_UPLOADED_DATA.
E V E N T : E N D - O F - S E L E C T I O N *
END-OF-SELECTION.
*& Form UPLOAD_EXCEL_FILE
text
--> p1 text
<-- p2 text
FORM UPLOAD_EXCEL_FILE .
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = P_FNAME
I_BEGIN_COL = 1
I_BEGIN_ROW = 3
I_END_COL = 7
I_END_ROW = 32000
TABLES
INTERN = IT_FILE_UPLOAD
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.
ENDFORM. " UPLOAD_EXCEL_FILE
*& Form ORGANIZE_UPLOADED_DATA
text
--> p1 text
<-- p2 text
FORM ORGANIZE_UPLOADED_DATA .
SORT IT_FILE_UPLOAD BY ROW
COL.
LOOP AT IT_FILE_UPLOAD.
CASE IT_FILE_UPLOAD-COL.
WHEN 1.
WA_TABDATA-ZSLNUM = IT_FILE_UPLOAD-VALUE.
WHEN 2.
WA_TABDATA-ZASSET = IT_FILE_UPLOAD-VALUE.
WHEN 3.
WA_TABDATA-ZYEAR = IT_FILE_UPLOAD-VALUE.
WHEN 4.
WA_TABDATA-ZPERIOD = IT_FILE_UPLOAD-VALUE.
WHEN 5.
WA_TABDATA-ZSHIFT1 = IT_FILE_UPLOAD-VALUE.
WHEN 6.
WA_TABDATA-ZSHIFT2 = IT_FILE_UPLOAD-VALUE.
WHEN 7.
WA_TABDATA-ZSHIFT3 = IT_FILE_UPLOAD-VALUE.
ENDCASE.
AT END OF ROW.
WA_TABDATA-MANDT = SY-MANDT.
APPEND WA_TABDATA TO IT_TABDATA.
CLEAR: WA_TABDATA.
ENDAT.
ENDLOOP.
ENDFORM. " ORGANIZE_UPLOADED_DATA
In the subroutine --> ORGANIZE_UPLOADED_DATA, data are organized as per the structure declared above.
Regards,
Abir
Don't forget to award points * -
GUI_UPLOAD & GUI_DOWNLOAD
Hi Could anyone please explain me kind of inputs that I need to give to this Function Module. I want to import one excel file and need to do some processing on it and replace original excel file by new one.
Can i Use above mentioned Function Modules to satisfy my requirements?
Thanks & Regards
JigarHI,
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = 'C:/VEND.XLS'(file path)
FILETYPE = 'ASC'(file type)
TABLES
DATA_TAB = ITAB.(internal table.)
UR MODUFICATIONS IN THE DATA.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
FILENAME = 'C:/VEND.XLS'(file path)
FILETYPE = 'ASC'
APPEND = ' '
WRITE_FIELD_SEPARATOR = ' X'(IN CASE IF U WANT FIELD SEPERATOR)
HEADER = '00'
TRUNC_TRAILING_BLANKS = ' '
WRITE_LF = 'X'
COL_SELECT = ' '
COL_SELECT_MASK = ' '
DAT_MODE = ' '
CONFIRM_OVERWRITE = ' '
NO_AUTH_CHECK = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
WRITE_BOM = ' '
TRUNC_TRAILING_BLANKS_EOL = 'X'
WK1_N_FORMAT = ' '
WK1_N_SIZE = ' '
WK1_T_FORMAT = ' '
WK1_T_SIZE = ' '
WRITE_EOL = ABAP_TRUE
IMPORTING
FILELENGTH =
TABLES
DATA_TAB = ITAB(MODIFIED INTERNAL TABLE DATA).
REGARDS,
BHARAT. -
GUI_UPLOAD Function Module in 4.6C does not split into lines
Dear All,
I'm about to upload text file into SAP using the FM 'GUI_UPLOAD'.
Previously I've developed a test program to upload the same file in SAP v4.7
and it returns correctly into several lines as expected.
Snippet:
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = l_filename
filetype = 'ASC'
has_field_separator = ' '
header_length = 0
read_by_line = 'X'
TABLES
data_tab = gt_tabfile
As we can see, the 'read_by_line' parameter is already 'X'. gt_tabfile only consist of 1 string column.
But as I run the same code using the same parameter and file in SAP v4.6C
it returned only 1 line of very long string instead of the correct lines resulted in 4.7.
Is there anything to do with codepage (4.6 is English 1100, I forgot the codepage in 4.7 but i believe it's the same due to language selection is EN). Or anything to do with OSS Note?
Kindly help me to resolve the issue.
Appreciate it very muchThank you for trying to help.
Please be noted I've done all the possible value on these parameter
- filetype 'ASC' OR 'BIN'
- has_field_separator ' ' or 'X'
- header_length 0 or 1 which is dont make sense since my file dont have header so must be 0
- read_by_line ' ' of 'X' doesnt work my expectation.
Any other good questions please? How 4.6C and 4.7 above make a different result?
Maybe you are looking for
-
Is that a webkit rendering issue in Safari 5.1?
I add my voice to rendering issues encountered in Safari 5.1, here they are: 1) Fonts look pixelated on some websites. Here's an example drawn from weebly. The font used here is OFL Sorts Mill Goudy, so I guess there must be a font rendering engine i
-
I've got an iPod Touch 32Gb 3rd Gen, I tried updating it to iOS 4.3 (it was on 4.1) So everytime it gave me an error while Backing up my iPod (the step before extracting) So i thought, if i reset the iTouch from the Settings, it won't try to Backup.
-
Help! Iphoto will not display, only get a revolving beachball!
Need help very new to MAC and i'm one very frustrated dude at this point! I don't even know how to tell you what OS i'm using. Here's my issue was trying to import new photo to Iphoto from an SD card and all I can get is a revolving beachball and a
-
Separating albums that have the same name by the same artist?
I have two albums by the group The Small Faces and both are entitled "Small Faces." One came out in 1966 and the next in 1967. They are different albums, just on different labels which may be why they used the same name twice. Anyway, i can't figure
-
Another one of those battery problems...so scared
Hey all, I know that many people are posting battery problems and I think I have a similar one...I just don't know if apple will listen to me. My 15" mbp shuts down at around 45% charge for no reason. I applied the update that apple provided but to n