2008 Aug 12 7:05 AM
hi
i use GUI_DOWNLOAD function download inter table data generated xls format.
in inter table data have ID FIeld which consist of numeric!
example:
35000078297773587
when download the field will change:3.50001E+16
i want to avoid it!
in sap stardand provide a mothod:
run REUSE_ALV_GRID_DISPLAY function to display
data.
in REUSE_ALV_GRID_DISPLAY screen:
go to list>export>sprresheet
choice excel(in MHTML format) will download data what i want!
who know which function is executed in REUSE_ALV_GRID_DISPLAY .
or exist other method to solve this issue!
help!
thank you advance!
2008 Aug 12 7:21 AM
hi,
before passing the internal table to FM, store it in a separate internal table in the form of a character string.
for eg:
CLASS cl_abap_char_utilities DEFINITION LOAD.
CONSTANTS: con_tab TYPE c VALUE cl_abap_char_utilities=>horizontal_tab,
con_cret TYPE c VALUE cl_abap_char_utilities=>cr_lf.
loop at itab.
concatenate var1 var2 var3 into itab_new-line separated by con_tab
concatenate con_cret itab_new-line into itab_new-line.
APPEND itab_new-line.
endloop.
now, pass this new internal table itab_new to the FM.
Edited by: vikram shah on Aug 12, 2008 11:51 AM
2008 Aug 12 7:31 AM
Hi,
Declare the internal table of type STRING.
Declare two variable of type Cl_ABAP_CHAR_UTILTIES->HORIZONTAL TAB and Cl_ABAP_CHAR_UTILTIES->VERTICAL TAB. Use them for column separation and row separation.
pass the final table to GT_FINAL(of type STRING) to function module.
'SCMS_STRING_TO_FTEXT'.
and then pass it to GUI_DOWNLOAD.
regards,
Vamsi
2008 Aug 12 7:48 AM
you can use the following:
data: lt_lines type table of string.
data: ls_lines type string.
data: lv_string type string.
data: lt_content type table of <x>.
data: ls_content type <x>.
loop at lt_content into ls_content.
lv_string = ls_content-<filed1>.
concatenate ls_lines lv_string into ls_lines separated by ';'.
.
.
.
lv_string = ls_content-<filedn>.
concatenate ls_lines lv_string into ls_lines separated by ';'.
append ls_lines to lt_lines.
endloop.
OPEN DATASET is_dstfmt-fnamappl FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
LOOP AT lt_lines into ls_lines.
TRANSFER ls_lines TO is_dstfmt-fnamappl.
ENDLOOP.
CLOSE DATASET is_dstfmt-fnamappl.
You must fill the structure is_dstfmt.
The extension of the file must be ".csv". You can open it with excel!
2008 Aug 12 8:04 AM
hi vikram
thank you very help!
i have do it!
but the result have the same!
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = FILENAME
FILETYPE = 'DAT'
CODEPAGE = '4110'
TABLES
DATA_TAB = IT_S.
DATA_TAB = <F_FS>.
2008 Aug 12 10:12 AM
hi,
try the following code. it is working here.
DATA: BEGIN OF itab OCCURS 0,
var1 TYPE f,
var2 TYPE c,
var3 TYPE c,
END OF itab.
DATA: BEGIN OF itab_new OCCURS 0,
line TYPE string,
END OF itab_new.
DATA: str_var1 TYPE string,
p10_4(10) TYPE p DECIMALS 4.
CLASS cl_abap_char_utilities DEFINITION LOAD.
CONSTANTS: con_tab TYPE c VALUE cl_abap_char_utilities=>horizontal_tab,
con_cret TYPE c VALUE cl_abap_char_utilities=>cr_lf.
itab-var1 = 5.
itab-var2 = 'A'.
itab-var3 = 'D'.
APPEND itab.
itab-var1 = 1500000.
itab-var2 = 'A'.
itab-var3 = 'D'.
APPEND itab.
LOOP AT itab.
CALL FUNCTION 'CEVA_CONVERT_FLOAT_TO_CHAR'
EXPORTING
float_imp = itab-var1
format_imp = p10_4
IMPORTING
char_exp = str_var1.
CONCATENATE str_var1 itab-var2 itab-var3 INTO itab_new-line SEPARATED BY con_tab.
* concatenate con_cret itab_new-line INTO itab_new-line.
APPEND itab_new.
CLEAR itab_new-line.
ENDLOOP.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = '..\DESKTOP\DICT.XLS' "ur path
filetype = 'ASC'
write_field_separator = con_tab
TABLES
data_tab = itab_new
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.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
2008 Aug 12 8:12 AM
hi vamsi
my trying code!
DATA:PLINE TYPE I,CLINE TYPE I.
REFRESH IT_S.
REFRESH itab.
CALL FUNCTION 'NAMETAB_GET'
EXPORTING
langu = sy-langu
tabname = itoper-tabname
TABLES
nametab = itab
EXCEPTIONS
no_texts_found = 1.
IF sy-subrc = 1.
MESSAGE 'STOP,CREATE TABLE ERROR' TYPE 'E'.
ENDIF.
DESCRIBE TABLE itab LINES pline.
LOOP AT <F_FS> ASSIGNING <F_FS5>.
CLEAR CLINE.
LOOP AT itab.
CLINE = sy-tabix.
ASSIGN COMPONENT itab-fieldname OF STRUCTURE <F_FS5> TO <F_FS6>.
IF SY-SUBRC = 0.
IF CLINE = 1.
WA_S = <F_FS6>.
ELSE.
CONCATENATE WA_S <F_FS6> INTO WA_S separated by con_tab.
IF CLINE = pline.
concatenate WA_S con_cret into WA_S.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
APPEND WA_S TO IT_S.
ENDLOOP.
IF <F_FS5> IS ASSIGNED.
UNASSIGN <F_FS5>.
ENDIF.
IF <F_FS6> IS ASSIGNED.
UNASSIGN <F_FS6>.
ENDIF.
now how to use the function:
CALL FUNCTION 'SCMS_STRING_TO_FTEXT'
EXPORTING
TEXT =
IMPORTING
LENGTH =
TABLES
FTEXT_TAB =
.
thank you very much!
2008 Aug 12 8:23 AM
HI
DATA:PLINE TYPE I,CLINE TYPE I.
REFRESH IT_S.
REFRESH: itab,GT_S.
CALL FUNCTION 'NAMETAB_GET'
EXPORTING
langu = sy-langu
tabname = itoper-tabname
TABLES
nametab = itab
EXCEPTIONS
no_texts_found = 1.
IF sy-subrc = 1.
MESSAGE 'STOP,CREATE TABLE ERROR' TYPE 'E'.
ENDIF.
DESCRIBE TABLE itab LINES pline.
LOOP AT <F_FS> ASSIGNING <F_FS5>.
CLEAR CLINE.
LOOP AT itab.
CLINE = sy-tabix.
ASSIGN COMPONENT itab-fieldname OF STRUCTURE <F_FS5> TO <F_FS6>.
IF SY-SUBRC = 0.
IF CLINE = 1.
WA_S = <F_FS6>.
ELSE.
CONCATENATE WA_S <F_FS6> INTO WA_S separated by con_tab.
IF CLINE = pline.
concatenate WA_S con_cret into WA_S.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
REFRESH IT_S.
CALL FUNCTION 'SCMS_STRING_TO_FTEXT'
EXPORTING
TEXT = WA_S
IMPORTING
LENGTH =
TABLES
FTEXT_TAB = IT_S
.
APPEND LINES OF IT_S TO GT_S.
APPEND WA_S TO IT_S.
ENDLOOP.
IF <F_FS5> IS ASSIGNED.
UNASSIGN <F_FS5>.
ENDIF.
IF <F_FS6> IS ASSIGNED.
UNASSIGN <F_FS6>.
ENDIF.
WHEN RUN:
CALL FUNCTION 'SCMS_STRING_TO_FTEXT'
EXPORTING
TEXT = WA_S
IMPORTING
LENGTH =
TABLES
FTEXT_TAB = IT_S
Will dump out!
TYPES:S_STRING TYPE STRING.
DATA:WA_S TYPE S_STRING,
IT_S TYPE TABLE OF S_STRING WITH HEADER LINE,
GT_S TYPE TABLE OF S_STRING WITH HEADER LINE.
2008 Aug 12 10:23 AM
hi vikram
thank you your hard work for this case!
but the result no change !
2008 Aug 12 10:30 AM
hi, can u explain ur problem again? is the number field that u r using of "float" type or of some other type?
according to my understanding the prob is that the number field when transferred to excel is displayed as 1.50000000E+03 instead of 1500000.
is that correct?
i executed my code here n after using the FM CEVA_CONVERT_FLOAT_TO_CHAR it is giving correct result. i.e., the number in the excel sheet is displayed as 1500000.
2008 Nov 13 5:04 AM