Downloading data from internal table to xls file leading zeros are not disp
Hai abap gurus,
when i am downloading data from internal table to excle file. some field values in a column are with leading zeros and some others dont have leading zeros.but in the output it is showing without leading zeros. then how to get with exact values.
Ex:
<b>ECC Code.</b>
045234
88567
098456
but output is giving like this:
45234
88567
98456
how to get the actual values.....
plz help me in this matter.
Dear Kiran,
Those field in the internal table having Leading Zeroes, make those fields' datatype as character.
Then use the function module to download the content of the internal table to the excel file.
Regards,
Abir
Don't forget to Reward Points *
Similar Messages
-
Download data from internal table to flat file.
I need to download the data from Internal table to Flat file. can any one suggest how to do it? i suppose WS_Download OR GUI_DOWNLOAD.
but if it is please guide me how to use this.
is thre any other F.M. please provide the information.
Thanks in advanceHi,
Try this,
* File download, uses older techniques but achieves a perfectly
* acceptable solution which also allows the user to append data to
* an existing file.
PARAMETERS: p_file like rlgrap-filename.
* Internal table to store export data
DATA: begin of it_excelfile occurs 0,
row(500) type c,
end of it_excelfile.
DATA: rc TYPE sy-ucomm,
ld_answer TYPE c.
CALL FUNCTION 'WS_QUERY'
EXPORTING
query = 'FE' "File Exist?
filename = p_file
IMPORTING
return = rc.
IF rc NE 0. "If File alread exists
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
* TITLEBAR = ' '
* DIAGNOSE_OBJECT = ' '
text_question = 'File Already exists!!'
text_button_1 = 'Replace'
* ICON_BUTTON_1 = ' '
text_button_2 = 'New name'
* ICON_BUTTON_2 = ' '
* DEFAULT_BUTTON = '1'
* DISPLAY_CANCEL_BUTTON = 'X'
* USERDEFINED_F1_HELP = ' '
* START_COLUMN = 25
* START_ROW = 6
* POPUP_TYPE =
IMPORTING
answer = ld_answer
* TABLES
* PARAMETER =
EXCEPTIONS
text_not_found = 1
OTHERS = 2.
* Option 1: Overwrite
IF ld_answer EQ '1'.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
* BIN_FILESIZE =
filename = p_file "File Name
filetype = 'ASC'
* IMPORTING
* FILELENGTH =
TABLES
data_tab = it_excelfile "Data table
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE i003(zp) WITH
'There was an error during Excel file creation'(200).
exit. "Causes short dump if removed and excel document was open
ENDIF.
* Option 2: New name.
ELSEIF ld_answer EQ '2'.
CALL FUNCTION 'DOWNLOAD'
EXPORTING
filename = p_file "File name
filetype = 'ASC' "File type
* col_select = 'X' "COL_SELECT
* col_selectmask = 'XXXXXXXXXXXXXXXXXXXXXXXXXX'
* "COL_SELECTMASK
filetype_no_show = 'X' "Show file type selection?
* IMPORTING
* act_filename = filename_dat
TABLES
data_tab = it_excelfile "Data table
* fieldnames =
EXCEPTIONS
file_open_error = 01
file_write_error = 02
invalid_filesize = 03
invalid_table_width = 04
invalid_type = 05
no_batch = 06
unknown_error = 07.
ENDIF.
ELSE. "File does not alread exist.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
* BIN_FILESIZE =
filename = p_file "File name
filetype = 'ASC' "File type
* IMPORTING
* FILELENGTH =
TABLES
data_tab = it_excelfile "Data table
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE i003(zp) WITH
'There was an error during Excel file creation'(200).
exit. "Causes short dump if removed and excel document was open
ENDIF.
ENDIF.
Regards,
Raghav -
Error while downloading data from internal table into XML file
hi all,
i developed a program to download data from into internal table to xml file like this.
tables: mara.
parameters: p_matnr like mara-matnr.
data: begin of itab_mara occurs 0,
matnr like mara-matnr,
ernam like mara-ernam,
aenam like mara-aenam,
vpsta like mara-vpsta,
end of itab_mara.
data: lv_field_seperator type c, " value 'X',
lv_xml_doc_name(30) type c, " string value my xml file,
lv_result type i.
lv_field_seperator = 'x'.
lv_xml_doc_name = 'my xml file'.
types: begin of truxs_xml_line,
data(256) type x,
end of truxs_xml_line.
types:truxs_xml_table type table of truxs_xml_line.
data:lv_tab_converted_data type truxs_xml_line,
lt_tab_converted_data type truxs_xml_table.
data: lv_xml_file type rlgrap-filename value 'c:\simp.xml'.
select matnr ernam aenam vpsta from mara into table itab_mara up to 5
rows where matnr = p_matnr.
CALL FUNCTION 'SAP_CONVERT_TO_XML_FORMAT'
EXPORTING
I_FIELD_SEPERATOR = lv_field_seperator
I_LINE_HEADER =
I_FILENAME =
I_APPL_KEEP = ' '
I_XML_DOC_NAME = lv_xml_doc_name
IMPORTING
PE_BIN_FILESIZE = lv_result
TABLES
I_TAB_SAP_DATA = itab_mara
CHANGING
I_TAB_CONVERTED_DATA = lt_tab_converted_data
EXCEPTIONS
CONVERSION_FAILED = 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.
open dataset lv_xml_file for output in binary mode.
loop at lt_tab_converted_data into lv_tab_converted_data.
transfer lv_tab_converted_data to lv_xml_file.
endloop.
close dataset lv_xml_file.
this program is syntactically correct and getting executed, but when i open the target xml file it is showing the following error.
The XML page cannot be displayed
Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later.
XML document must have a top level element. Error processing resource 'file:///C:/simp.xml'.
will anyone show me the possible solution to rectify this error
thanks and regards,
anil.Hi,
Here is a small sample program to convert data in an internal table into XML format and display it.
DATA: itab TYPE TABLE OF spfli,
l_xml TYPE REF TO cl_xml_document.
* Read data into a ITAB
SELECT * FROM spfli INTO TABLE itab.
* Create the XML Object
CREATE OBJECT l_xml.
* Convert data in ITAB to XML
CALL METHOD l_xml->create_with_data( name = 'Test1'
dataobject = t_goal[] ).
* Display XML Document
CALL METHOD l_xml->display.
Here are some other sample SAP programs to handle XML in ABAP:
BCCIIXMLT1, BCCIIXMLT2, and BCCIIXMLT3.
Hope this helps,
Sumant. -
Upload data from Internal table to text file with '~' separator
can anyone help me to download data from internal table to flat file with '' separator. GUI_DOWNLOAD is not working in my case ....like for '' separator
Here it is
REPORT zkb_test1.
TYPE-POOLS: truxs.
DATA: i_scarr TYPE TABLE OF scarr,
i_conv_data TYPE truxs_t_text_data.
SELECT * FROM scarr INTO TABLE i_scarr.
CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'
EXPORTING
i_field_seperator = '~'
TABLES
i_tab_sap_data = i_scarr
CHANGING
i_tab_converted_data = i_conv_data
EXCEPTIONS
conversion_failed = 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 METHOD cl_gui_frontend_services=>gui_download
EXPORTING
filename = 'C:\Test1.txt'
filetype = 'ASC'
CHANGING
data_tab = i_conv_data
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
not_supported_by_gui = 22
error_no_gui = 23
OTHERS = 24.
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
Kathirvel -
Convert data from internal table to XML file.
Hi All,
I am selecting data from database into one internal table.
Now I want to convert data from internal table to xml file format and save in to my desktop. Please suggest me how I can achieve my requirement.
Kindly reply me ASAP.Use this FM. SAP_CONVERT_TO_XML_FORMAT
Check this link too -
Re: Data Export in XML format
XML files from ABAP programs -
Download data from internal table to excel sheet from the background
Hello Experts,
I have written a code where the data is stored in the internal table . Now when i run this code in the background i want this internal table data to get downloaded in the excel sheet. The function module GUI_DOWNLAOD is not supported in the background. So is there any other function module that can be used or is there any other way to do this
Thanks in advanceHi Aditya,
I would provide you 2 advice:
1. save the file on the application server as text file and the fileds in it separated by TAB,you can download the file whenever you want and open it with excel.
2.generate excel files and send it to the email address whatever you specify in the selection-screen.
Thanks,
Sam -
Create root node and child nodes while downloading data from internal table
Hi all,
i have to down load the details of three materials present in the internal table into
a XML file, the material number must be the root node, ERNAM,AENAM,VPSTA
fields must be its child nodes. in this way i have to display details of three
materials like material1,material2,material3.
how can i do that in 4.6c version.
Thanks,
satish.Hi Satish,
Please look into the following programs. These are sample SAP programs to deal with XML in 46c.
BCCIIXMLT1
BCCIIXMLT2
BCCIIXMLT3
Hope these will helps,
Sumant. -
Using abap code data from internal table to XML file create
Hi ALL,
i am using methods
L_VALUE = GS_DOCUMENT-U_MITARBEITER.
L_RC = L_ELEMENT_FLIGHTS->SET_ATTRIBUTE( NAME = 'U_Mitarbeiter' VALUE = L_VALUE ).
CLEAR: L_VALUE,
L_RC.
L_VALUE = GS_DOCUMENT-VORNAME .
L_RC = L_ELEMENT_FLIGHTS->SET_ATTRIBUTE( NAME = 'Vorname' VALUE = L_VALUE ).
ENDLOOP.
LOOP AT GS_DOCUMENT-GI_TIMETABLE INTO GS_TIMETABLE.
L_ELEMENT_AIRLINE = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(
NAME = 'Timetable'
PARENT = L_ELEMENT_FLIGHTS ).
Create attribute 'code' of node 'airline'
L_VALUE = GS_TIMETABLE-BEGINNUHRZEIT.
L_RC = L_ELEMENT_AIRLINE->SET_ATTRIBUTE( NAME = 'Beginnuhrzeit' VALUE = L_VALUE ).
L_VALUE = GS_TIMETABLE-BEMERKUNGEN.
L_RC = L_ELEMENT_AIRLINE->SET_ATTRIBUTE( NAME = 'Bemerkungen' VALUE = L_VALUE ).
L_VALUE = GS_TIMETABLE-ENDEUHRZEIT .
L_RC = L_ELEMENT_AIRLINE->SET_ATTRIBUTE( NAME = 'Endeuhrzeit' VALUE = L_VALUE ).
L_VALUE = GS_TIMETABLE-BUCHUNGSDATUM.
L_RC = L_ELEMENT_AIRLINE->SET_ATTRIBUTE( NAME = 'Buchungsdatum' VALUE = L_VALUE ).
ENDLOOP.
Creating a stream factory
L_STREAMFACTORY = L_IXML->CREATE_STREAM_FACTORY( ).
Connect internal XML table to stream factory
L_OSTREAM = L_STREAMFACTORY->CREATE_OSTREAM_ITABLE( TABLE = L_XML_TABLE ).
Rendering the document
L_RENDERER = L_IXML->CREATE_RENDERER( OSTREAM = L_OSTREAM
DOCUMENT = L_DOCUMENT ).
L_RC = L_RENDERER->RENDER( ).
Saving the XML document
L_XML_SIZE = L_OSTREAM->GET_NUM_WRITTEN_RAW( ).
i am geting the output,
line1
<?xml version="1.0"?><Head Document="002_TMA1_KW1_SAP.XML" Innenauftragsnummer="008004000800" Kalenderwoche="17" MonatJahr="04/2008" Name="" Personalnummer="91003139" Projektnummer="1400000700" Regionalstelle="B" U_Entleiher="1" U_Mitarbeiter="1" Vorname=
line 2
Ricky"><Timetable Beginnuhrzeit="08:00" Bemerkungen="" Endeuhrzeit="16:30" Buchungsdatum="21.04.2008"/><Timetable Beginnuhrzeit="08:00" Bemerkungen="" Endeuhrzeit="16:30" Buchungsdatum="22.04.2008"/><Timetable Beginnuhrzeit="08:00" Bemerkungen="" Endeuhrz
line 3
it="16:30" Buchungsdatum="23.04.2008"/><Timetable Beginnuhrzeit="08:00" Bemerkungen="" Endeuhrzeit="16:30" Buchungsdatum="24.04.2008"/><Timetable Beginnuhrzeit="08:00" Bemerkungen="" Endeuhrzeit="16:30" Buchungsdatum="25.04.2008"/></Head>
but i want this type line by line
<?xml version="1.0" encoding="ISO-8859-1"?>
<Document Dokumentnummer="001_TMA7_KW2_MAN" Dokumenttyp="TN_HE" Innenauftragsnummer="8004750104" Kalenderwoche="15" MonatJahr="04/2008" Name="Banana" Personalnummer="166326" Projektnummer="1400000203" Regionalstelle="RV1" U_Entleiher="1" U_Mitarbeiter="1" Vorname="Sepp">
<TimeTable Beginnuhrzeit="08:00" Bemerkungen="" Buchungsdatum="07.04.2008" Endeuhrzeit="16:00"/>
<TimeTable Beginnuhrzeit="08:00" Bemerkungen="" Buchungsdatum="08.04.2008" Endeuhrzeit="16:00"/>
<TimeTable Beginnuhrzeit="08:00" Bemerkungen="" Buchungsdatum="09.04.2008" Endeuhrzeit="16:30"/>
<TimeTable Beginnuhrzeit="08:00" Bemerkungen="" Buchungsdatum="10.04.2008" Endeuhrzeit="16:30"/>
<TimeTable Beginnuhrzeit="08:00" Bemerkungen="" Buchungsdatum="11.04.2008" Endeuhrzeit=""/>
</Document>
for line breaking, please give me solution
Regards,
SanthaHi,
Please give me more inforamtion, how to use this
CLASS cl_abap_char_utilities DEFINITION LOAD.
cl_abap_char_utilities=>newline
Regards,
Santha -
How to download leading zeros from internal table to XL file
Hi,
i am dowanloading data from interna table to XL file using GUI_DOWNLOAD FM. i want download the leading zeros also into xl file
EX: 012345
at present only "12345" is down loading into XL file. But i want "012345" into XL file.
Please help me.Hi,
Can you try with DBF format(Pass FILETYPE = 'DBF'? I remember that in this format data will be downloaded in database storage format. Just check and update if it works!!!
This is what FM documentation says.
'DBF' :
The data is downloaded in dBase format. With this format, the data types are stored as well, For this reason, import problems can be avoided - for example, problems with Microsoft Excel. In particular, you can avoid problems with the interpretation of numeric values.
Thanks,
Vinod. -
How to send data from internal table to the shared folder in ABAP
Hi experts,
My requirement is to transfer data from a file to shared folder. i just did reading data from a file to a internal table. Now i want to send this internal table data into a shared folder which is "
xxx\y\z....".
I do not have any idea on how to send data from internal table to the shared folder path.
can anybody please help me out how to do this?
Thanks & Regards
Sireesha.Where that folder is located, its on presentation server i.e. desktop or application server.
If its on presentation server, use FM GUI_UPLOAD.
If its on application server, then use DATASET functions. Have a look at below link.
[File Handling in ABAP|http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3ca6358411d1829f0000e829fbfe/frameset.htm]
I hope it helps.
Thanks,
Vibha
Please mark all the useful answers -
Gui_download for transferring the data from internal table to excel sheet.
hi all,
i am using gui_download for transferring the data from internal table to excel sheet.
I have a internal table with 3 columns col1,col2,col3 and I am getting the file at the specified path,but my problem is that,in the excel sheet(path specified) all the 3 columns values are printed in one column.Please help me.
Thanks in advance.Hi Venkata,
plz use FM 'SAP_CONVERT_TO_XLS_FORMAT' :
call function 'SAP_CONVERT_TO_XLS_FORMAT'
exporting
* I_FIELD_SEPERATOR =
* I_LINE_HEADER =
i_filename = p_file
* I_APPL_KEEP = ' '
tables
i_tab_sap_data = t_mbew
* CHANGING
* I_TAB_CONVERTED_DATA =
* EXCEPTIONS
* CONVERSION_FAILED = 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.
Hope this helps,
Erwan -
In PL-SQL archive data from a table to a file
I am currently developing a vb app where I need to archive data from a table to a file. I was hoping to do this with a stored procedure. I will also need to be able to retrieve the data from the file for future use if necessary. What file types are available? Thanks in advance for any suggestions.
What about exporting in an oracle binary format? The export files cannot be modifiable. Is there a way to use the export and import utility in PL/SQL?
null -
Reading Data from Internal Table
Hi,
Can anyone please tell me how to read data from Internal Tables in the Event Handler without using the Select statement OnInitialization?
Thanks,
GauravHi Siddhartha,
Can you tell me the problem in my code. I tried to work on the way you suggested. Though I have not finished with the coding, I just wanted to know whether I am going in the direction or not.
I have declared the the structure in Type Defination as
TYPES: BEGIN OF TEST_STRUC,
BEGDA TYPE BEGDA,
ENDDA TYPE ENDDA,
END OF TEST_STRUC.
TYPES: TEST_TAB_TYPE TYPE TABLE OF TEST_STRUC.
In the Event Handler, I have added the following code on OnInputProcessing:
event handler for checking and processing user input and
for defining navigation
DATA TEST_INFO LIKE LINE OF TEST_TAB.
DATA: MYTAB6 TYPE TABLE OF PA0006,
MYTAB6_WA LIKE LINE OF MYTAB6.
REFRESH TEST_TAB.
CLEAR TEST_INFO.
MYTAB6_WA-BEGDA = REQUEST->GET_FORM_FIELD( STARTDATE ).
MYTAB6_WA-ENDDA = REQUEST->GET_FORM_FIELD( ENDDATE ).
IF EVENT->NAME EQ 'button'
AND EVENT->SERVER_EVENT EQ 'click'.
LOOP AT MYTAB6 INTO MYTAB6_WA.
TEST_INFO-BEGDA = MYTAB6_WA-BEGDA.
TEST_INFO-ENDDA = MYTAB6_WA-ENDDA.
ENDLOOP.
APPEND TEST_INFO TO TEST_TAB.
CLEAR TEST_INFO.
NAVIGATION->SET_PARAMETER( NAME = 'test_tab'
VALUE = 'begda' ).
NAVIGATION->SET_PARAMETER( NAME = 'test_tab'
VALUE = 'endda' ).
NAVIGATION->GOTO_PAGE( 'MyBSP2.htm').
ENDIF.
P.S. MyBSP2.htm is my next page.
Thanks,
Gaurav -
Pass Date from Internal table to Date field of Deadline(in expression tab)
Hello,
I need to set deadline in workflow according to dates in Internal table. So please guide how to achieve this.Thanks Rick for taking interest in my issue.
Business scenario:-
--> when PO is created delivery date is given in PO.
--> Now all materials in PO can be delivered on same date or on different dates.
-->Their can be same delivery date or different delivery dates.
--> So for example:- For a PO their are 4 materials-
MATERIAL NAME DELIVERY DATE
Material1 10.11.2011
Material2 20.11.2011
Material3 20.11.2011
Material4 10.11.2011
Now Material2 and Material3 will be delivered on 20.11.2011 and Material1 and Material4 will be delivered on 10.11.2011.
Now a reminder mail should go to Vendor of that PO before 2 days of delivery date mean on 08.11.2011 and 18.11.2011.
So to store 2 dates I require internal table.
Now I am able to trigger reminder mail for 2 dates by using multiline element in miscellaneous tab of activity.
But as I discussed in previous post that if I add multiline element in Date field of Requested start deadline then it gives error(plz check prev. post to see exact error). So I tried to used internal table(container in workflow) in deadline which is filled from a task in activity, but it is also not working means mail is triggered as soon as worflow is executed.
So the main problem is deadline is not created based on dates in internal table and other all the things are working perfectly.
As I am very new to workflow area, I might be going wrong somewhere.
So please guide how to set deadline for multiple dates(according to my scenario).
Thanks in advance.
Regards,
Mihir -
How can i extract data from oracle table to flat file or excel spread shee
Hello,
DB Version is 10.1.0.3.0
How can i extract data from oracle table to flat file or excel spread sheet by using sub programs?
Regards,
DHere what I did
SET NEWPAGE 0
SET SPACE 0
SET LINESIZE 80
SET PAGESIZE 0
SET ECHO OFF
SET FEEDBACK OFF
SET VERIFY OFF
SET HEADING OFF
SET MARKUP HTML OFF SPOOL OFF
Sql> SPOOL bing
select * from -------;
SPOOL OFF;
I do not see file.
I also tried
Sql> SPOOL /tmp/bing
select * from -------;
SPOOL OFF;
But still not seeing the fie,
Maybe you are looking for
-
I can no longer import pictures to my ibook (OSX version 10.6.8) using iphoto 09 version 8.1.2 and now get message that file is in an unrecognizable format. What is wrong? Same camera as before.
-
Can somebody give me some suggestions? My problem is with homesharing on the ipad mini. This mini pretty new. It has done this since I purchased it. I turn on homesharing on the mini and only a few select artists show up. All of them won't show u
-
Problem in Org. Assignment
Hi Guys, I am facing problem in Organization Structure(Txn PPOM). I have created Org. Unit & Position with starting and end date as given below. 1) The problem is when I assign Position in org. assignment infotype in PA30 it maintains data with currr
-
Using Captivate 5, I need to create a project that captures Full Screen. Everything on the monitor needs to be part of the capture. My monitor is set to display at 1024 x 768. Captivate is set to 1024 x 768 Full Screen. When capturing the slides, I a
-
Where is the dry brush in the illustrator brush?
Hi! I am a beginner of Illustrator. I am using Illustrator CS5. Thank you.