Downloading two internal tables in same text file
I have one internal table as like below.
Data:begin of itab1 occurs 0,
rec(5),
end of itab1.
Itab1 is getting updated from input text file(Continuous text).
Here Itab1 contains one record with Indicator '01 and n number of records with indicator '02'.
This needs to be seperated in to two internal tables.
data:Begin of Itab_Head occurs 0,
Rec_ind(2) type C,
Name(3) type C,
end of itab_Head.
data:Begin of Itab_Item occurs 0,
Rec_ind(2) type C,
Id(3) type C,
Status(10,
end of itab_Item.
loop at itab1.
If itab1-Rec+0(2) = '01'.
Itab_Head-Rec_Ind = itab1-rec+0(2).
Itab_Head-Name = itab1-rec+2(3).
Append Itab_Head.
elseif itab1-rec+0(2) = '02'.
Itab_Item-Rec_Ind = itab1-rec+0(2).
Itab_Item-Id = itab1-rec+2(3).
Append Itab_Item.
endif.
endloop.
After moving to the internal tables I am doing some processing and updating the status of Itab_item.
After all these again I have to download the internal table as a text file.Now my question is.
I have values in 2 diff internal tables.How to download the two in same file.
See this sample code.
data: itab1 type string occurs 0 with header line,
itab2 type string occurs 0 with header line.
itab1 = 'itab1_text'.
append itab1.
itab2 = 'itab2_text'.
append itab2.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD
exporting
FILENAME = 'C:\ftext.txt'
APPEND = 'X'
changing
DATA_TAB = itab1[].
CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD
exporting
FILENAME = 'C:\ftext.txt'
APPEND = 'X'
changing
DATA_TAB = itab2[].
Svetlin
Similar Messages
-
Download Internal Table into a Text File in BSP?
I have an internal table which i need to download into my local pc. I know i can not use FM gui_download. Could some one please post code on how to download the internal table into a text file in BSP. Also i am not sure if i can use save dialog FM. Also need suggestion on which FM to use for save dialog which tells where to save the file.
Any help will be appreciated.
Thanks
NahmanThis might be a good starting point.
<a href="/people/thomas.jung3/blog/2004/09/02/creating-a-bsp-extension-for-downloading-a-table">/people/thomas.jung3/blog/2004/09/02/creating-a-bsp-extension-for-downloading-a-table</a> -
Internal table to a text file in Unix
Hi ,
I was trying to download data from Internal table to a text file in Unix.
How do I do this?
One more thing is the fields on each record of the file should be delimited by the! (pipe) character.
Any one please me with the code.
Thankscheck these links...
ASCII value
ASCII value
Creating a Unix File
or do you mean application server?
then use open dataset. transfer and close dataset.
example:
DATA: e_file like rlgrap-filename value '/usr/sap/tmp/file.txt'.
open dataset e_file for output in text mode.
lOOP AT it_datatab......
transfer it_datatab to e_file.
ENDLOOP.
close dataset e_file.
regds,
kiran -
Get the Common from Two Internal Tables with same structure
Hi ,
I need to get the Common data from Two Internal Tables with same structure with using the looping method.
For e.g.
I have two internal table say ITAB1 and ITAB2.
ITAB1 has values A,B,C,D,E,F
ITAB2 has values A,H,B,Y,O
Output at runtime should be : A,BHi mohit,
1. If u want to compare all fields,
for matching purpose,
then we can do like this.
2.
report abc.
data : a like t001 occurs 0 with header line.
data : b like t001 occurs 0 with header line.
loop at a.
LOOP AT B.
IF A = B.
WRITE :/ 'SAME'.
ENDIF.
endloop.
ENDLOOP.
regards,
amit m. -
Wirte the content of an internal table into a text file
Hello Experts,
how can I wirte the content of an internal table into a text file and putit on my local
desktop ?
Regards
ertasHi,
You can use the FM GUI_DOWNLOAD for this purpose.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
FILENAME = 'c:\testmmv.txt'
FILETYPE = 'ASC'
APPEND = ' '
WRITE_FIELD_SEPARATOR = ' '
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_LF_AFTER_LAST_LINE = ABAP_TRUE
SHOW_TRANSFER_STATUS = ABAP_TRUE
IMPORTING
FILELENGTH =
TABLES
DATA_TAB = LT_STR
FIELDNAMES =
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.
Implement suitable error handling here
ENDIF.
With regards,
Vamsi -
Download chinese text from internal table to PC text file
Hi Experts,
Iam downloading internal table (which is having records in chinese text) on to PC file. But the iam not getting correct text in the pc file. Iam getting some garbage values text.
Iam using GUI_download FM to donwload the text.
Iam using internal table
Begin of itab occurs 0,
text type string,
end of itab.
and passing paramters.
Filename
codepage
table.
Can you please tell me how can I achive this and what are the parameter need to pass for this.
Thank In Advance.Hi,
You can use follwoing funtion modules instead of GUI_DOWNLOAD. It will be more easier.
SAP_CONVERT_TO_CSV_FORMAT
SAP_CONVERT_TO_TEX_FORMAT
SAP_CONVERT_TO_TXT_FORMAT
SAP_CONVERT_TO_XLS_FORMAT
SAP_CONVERT_TO_XML_FORMAT.
I hope this will help you out.
Help children of U.N World Food Program by rewarding points and encourage others to answer your queries. -
How to download an Internal Table to a flat file
Hi All,
I have an Internal Table with 7 columns.I am using FM 'Gui_download'.The flat file is generating correctly.But I need to display the 7 fields vertically one after other instead of displaying horizontally.The internal table consists of only one record.
Very Urgent
ThanksHi,
do you know the ABAP Development? I think you should post your question there. Also have you tried the SDN Search?
Regards
Gregor -
How to download data from an internal table to a text
Hi All,
I want to download data from an internal table to a text file.
The fields should be pipe(|) separated. I have tried GUI_DOWNLOAD but it is not taking the field separator.
The sample of the desired data that i require should be this way:-
13456TR|M|COUP|MATERIAL|KGS
Thanks in advance.
Regards
Satish.Hi,
Try this..
REPORT zc1download message-id zc1dwnmsg.
*& Declaration Section for the Tables *
TABLES: makt.
*& Declaration Section for the Internal Tables
DATA: intab TYPE TABLE OF makt,
wa_intab LIKE LINE OF intab,
no_of_rec TYPE i,
count TYPE i.
DATA: BEGIN OF f_intab,
str(255) TYPE c,
END OF f_intab.
DATA: t_intab LIKE TABLE OF f_intab,
w_intab LIKE LINE OF t_intab,
temp(255) TYPE c.
FIELD-SYMBOLS: <f> TYPE ANY.
*& Selection ScreenSection for the file download
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: file TYPE rlgrap-filename MEMORY ID file,
tab RADIOBUTTON GROUP rad1 DEFAULT 'X',
others RADIOBUTTON GROUP rad1,
delimit TYPE c.
SELECTION-SCREEN END OF BLOCK b1.
START-OF-SELECTION.
IF file IS INITIAL. " check to ensure file.
MESSAGE i001.
EXIT.
ENDIF.
IF others = 'X'. " check to ensure delimiter.
IF delimit = ' '.
MESSAGE i002.
EXIT.
ENDIF.
ENDIF.
SELECT * FROM makt INTO TABLE intab.
IF tab = 'X'. " default delimiter tab is used
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
filename = file
filetype = 'DAT'
mode = 'A'
TABLES
data_tab = intab
EXCEPTIONS
file_open_error = 1
file_write_error = 2
invalid_filesize = 3
invalid_type = 4
no_batch = 5
unknown_error = 6
invalid_table_width = 7
gui_refuse_filetransfer = 8
customer_error = 9
no_authority = 10
OTHERS = 11.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ELSE. " If user defind delimiter is to be used
Counts the number of fields *
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE wa_intab TO <f>.
IF sy-subrc <> 0.
EXIT.
ELSE.
count = count + 1.
ENDIF.
ENDDO.
LOOP AT intab INTO wa_intab.
DO count TIMES. " Adding the delimiter in required places
ASSIGN COMPONENT sy-index OF STRUCTURE wa_intab TO <f>.
CONCATENATE temp delimit <f> INTO temp.
ENDDO.
SHIFT temp.
APPEND temp TO t_intab.
CLEAR temp.
ENDLOOP.
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
filename = file
filetype = 'ASC'
mode = 'A'
TABLES
data_tab = t_intab
EXCEPTIONS
file_open_error = 1
file_write_error = 2
invalid_filesize = 3
invalid_type = 4
no_batch = 5
unknown_error = 6
invalid_table_width = 7
gui_refuse_filetransfer = 8
customer_error = 9
no_authority = 10
OTHERS = 11.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
WRITE:/ 'The Data has been tranfered to :', file.
Cheers
Kathir!~ -
I am using GUI_DOWNLOAD FM to download my internal table entries into .xls
Hi
I am using GUI_DOWNLOAD FM to download my internal table entries into .xls file. but it's not download total records in final table.
in debugging it showing total records.
exporting:
filename
filetype
field-suprater
header
tables
data_tab
fieldnames
plz help me.
thanks
SankarHi
Use as below:
CALL FUNCTION 'MS_EXCEL_OLE_STANDARD_DAT'
EXPORTING
file_name = p_file " path offile where u need to download
CREATE_PIVOT = 0
DATA_SHEET_NAME = ' '
PIVOT_SHEET_NAME = ' '
PASSWORD = ' '
PASSWORD_OPTION = 0
TABLES
PIVOT_FIELD_TAB =
data_tab = int_data "internal table with data
fieldnames = int_head "internal table with header
EXCEPTIONS
file_not_exist = 1
filename_expected = 2
communication_error = 3
ole_object_method_error = 4
ole_object_property_error = 5
invalid_filename = 6
invalid_pivot_fields = 7
download_problem = 8
OTHERS = 9
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,
Sreeram -
Function module for comparing contents of two internal tables
Hi All,
Is there any function module to compare contents of two internal tables of same structure?
If yes please let me know.
Thanks in advance.
AmolHi
call SE16 with table TFTIT in order to get a full list (it will be long...)
A list of FMs with parameters can be found in table FUNCT.
Finally go to sm37rsdf4
that will give you all the function modules with description
Here is the list:
http://www.erpgenie.com/abap/functions.htm
hope this helps...
Regards
CSM Reddy -
Downloading an internal table to presentation server from WebUI
Hi All,
We have a requirement to download an internal table as a CSV file from CRM 7.0 WebUI to the presentation server. The file path is fixed, so the user need not choose the download location. The data to be downloaded is not part of any view on the WebUI and is being collected through code from several context nodes.
We have looked at CL_BSP_UTILITY, which is not solving our purpose, as the prepared data stream gets over written by CRM 7.0 framework during execution.
Any suggestions on how we can achieve the functionality?
Regards,
MugdhaHi,
If you need to provide download window via the browser, check out this wiki - [http://wiki.sdn.sap.com/wiki/pages/pointstab/viewpageversion.action?pageId=187336093&version=6] . If you want to directly write to the presentation server, you have th efollowing ways. If you submit a report in background, you have the option of using CL_GUI_FRONTEND_SERVICES. Otherwise you can check out using a combination of javascript and activex objects ( [http://www.codingforums.com/showthread.php?t=136906] ).
Regards,
Arun Prakash -
Hi Guys,
I have two internal tables with same structure, ITAB1 is having 100 records and ITAB2 is having 150 records, i need to club two internal tables into ITAB3.
I hope, we can loop one internal table append record by record.
Is any other way, can we club two internal tables.
Thanks,
Gourisankar.Hi,
You can use INSERT LNES OF ITAB1 INTO ITAB3 and afterwards do the same with ITAB2.
Regards, Gerd Rother -
Find if there is any common record in two internal tables
hi,
I have two internal tables of same structure... say A and B.
I need to know if there are any common lines in them.
one way is to loop in any one of them and keep executing a read on the other.
can anyone suggest a better way.
thanks,
Arindam.Hi Arindam,
To find common records in two internal tables, they can be compared
If INT_DATA1 EQ INT_DATA2.
endif.
The first criterion for comparing internal tables is the number of lines they contain. If two internal tables contain the same number of lines, they are compared line by line, component by component.
If the internal tables contain the same number of records and are sorted on the same key, the comparison stops at the line where the records are not common. For example, if the number of common records is 4, the comparison stops at the 5th line and sy-tabix becomes 5.
Hope it helps.
Regards,
Nupur -
Multiple tables in GUI_DOWNLOAD in same text file
Hi,
Can anybody tell me how to pass multiple internal tables for download in same text file. And also each table output should start with NEW LINE. Please help me in executing this functionality.
Thanks,
AmolI'm not sure that I understand correctly but :
- if you mean that the first line before your table should be NEW LINE, then before Appending your new internal table (itab2) into the consolidated one (itab), you could just do something like :
itab-text = 'NEW LINE'.
append itab.
And then
append itab2 into itab.
- if you mean that the first line of your new table should begin you NEW LINE then it could be something like that :
read table itab2 index 1.
concatenate 'NEW LINE' itab2-text into itab2-text.
modify itab2 transporting text index 1.
append itab2 into itab.
Hope it helps,
Regards,
Sylvie -
How to download internal table data to .xlsx file ?
Hello All,
I am using SAP ECC 6.0. I need to download internal table data to .xlsx file.
I tried GUI_DOWNLOAD, all the data are getting transferred to the .xlsx file, but while opening I am getting the below error.
Excel cannot open the file "download.xlsx" because file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file.
Though Microsoft office 2007 is installed in my system.
Please help <removed by moderator>.
Edited by: Thomas Zloch on Oct 24, 2011 10:55 AMHi,
Please find the below code to download data into excel file.
DATA: ld_filename TYPE string,
ld_path TYPE string,
ld_fullpath TYPE string,
ld_result TYPE i.
Display save dialog window
CALL METHOD cl_gui_frontend_services=>file_save_dialog
EXPORTING
window_title = ' '
DEFAULT_EXTENSION = 'XLS'
default_file_name = 'accountsdata'
INITIAL_DIRECTORY = 'c:\temp\'
CHANGING
filename = ld_filename
path = ld_path
fullpath = ld_fullpath
user_action = ld_result.
Check user did not cancel request
CHECK ld_result EQ '0'.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = ld_fullpath
filetype = 'ASC'
APPEND = 'X'
write_field_separator = 'X'
CONFIRM_OVERWRITE = 'X'
TABLES
data_tab = it_datatab[] "need to declare and populate
EXCEPTIONS
file_open_error = 1
file_write_error = 2
OTHERS = 3.
Thanks and Regards
Chitra
Maybe you are looking for
-
I have been having issues with my battery capacity. The battery will drain within half an hour with it being fully charged when the battery normally lasts me all day. I haven't had the phone that long so it most definitely shouldn't be happening. I w
-
N:1 Multi mapping Not working !!
Hi Guys, I have input xml message structure as follows: <ROOT> <OUTPUT> ----------------------0..n <XQ_Segment> ---------------- 0..1 XQ_DATA -----------------0..1 XQ_Value -----------------0..1
-
ALV Display for Item & Sub-Item Level
Hi Experts, i am developing one report and i want the display it in ALV as shown below. Item Level: Tax Jurisdiction state current balance prior balance 3900000 LA 10000 15000 Sub-Item Level: Ju
-
Extract Tables/views into ECC 5.0 SAP system from Non-SAP system
Hi, I am looking for some inputs on how to set up the following scenario of extracting data stored in tables/views in a non-sap external system into my SAP ECC 5.0 SAP database. Currently we are using a middleware between SAP and the external system
-
[SOLVED]compile error w3m 0.5.3 with mouse support
Hi Friends. i'm Trying to compile w3m test based browser with mouse support. I donwloaded the latest source available from sourceforge website.The ./configure runs correctly and produces no errors. but when I run make, it gives me the following error