Internal Table attached as Excel file to an eMail - BCS_EXAMPLE_7 for UC
Hi forums,
SAP provided an example report to send out internal tables attached as an Excel file to a recipients eMail address. I attached the coding of the BCS_EXAMPLE_7 programm to this thread.
report bcs_example_7.
This report provides an example for sending an Excel
attachment in Unicode Systems
constants:
gc_tab type c value cl_bcs_convert=>gc_tab,
gc_crlf type c value cl_bcs_convert=>gc_crlf.
parameters:
mailto type ad_smtpadr
default 'john.doe(a)crazy-company.com'. "#EC *
data send_request type ref to cl_bcs.
data document type ref to cl_document_bcs.
data recipient type ref to if_recipient_bcs.
data bcs_exception type ref to cx_bcs.
data main_text type bcsy_text.
data binary_content type solix_tab.
data size type so_obj_len.
data sent_to_all type os_boolean.
start-of-selection.
perform create_content.
perform send.
*& Form send
form send.
try.
-------- create persistent send request ------------------------
send_request = cl_bcs=>create_persistent( ).
-------- create and set document with attachment ---------------
create document object from internal table with text
append 'Hello world!' to main_text. "#EC NOTEXT
document = cl_document_bcs=>create_document(
i_type = 'RAW'
i_text = main_text
i_subject = 'Test Created By BCS_EXAMPLE_7' ). "#EC NOTEXT
add the spread sheet as attachment to document object
document->add_attachment(
i_attachment_type = 'xls' "#EC NOTEXT
i_attachment_subject = 'ExampleSpreadSheet' "#EC NOTEXT
i_attachment_size = size
i_att_content_hex = binary_content ).
add document object to send request
send_request->set_document( document ).
--------- add recipient (e-mail address) -----------------------
create recipient object
recipient = cl_cam_address_bcs=>create_internet_address( mailto ).
add recipient object to send request
send_request->add_recipient( recipient ).
---------- send document ---------------------------------------
sent_to_all = send_request->send( i_with_error_screen = 'X' ).
commit work.
if sent_to_all is initial.
message i500(sbcoms) with mailto.
else.
message s022(so).
endif.
------------ exception handling ----------------------------------
replace this rudimentary exception handling with your own one !!!
catch cx_bcs into bcs_exception.
message i865(so) with bcs_exception->error_type.
endtry.
endform. "send
*& Form create_content
Create Example Content
1) Write example text into a string
2) convert this string to solix_tab
form create_content.
data lv_string type string.
data ls_t100 type t100.
as example content we use some system messages out of t100
get them for all installed languages from db
and write one line for each language into the spread sheet
columns are separated by TAB and each line ends with CRLF
concatenate 'This Is Just Example Text!' "#EC NOTEXT
gc_crlf gc_crlf
into lv_string.
header line
concatenate lv_string
'MSGID' gc_tab
'MSGNO' gc_tab
'Language' gc_tab "#EC NOTEXT
'Text' gc_crlf "#EC NOTEXT
into lv_string.
data lines
select * from t100 into ls_t100
where arbgb = 'SO' and msgnr = '182'.
concatenate lv_string
ls_t100-arbgb gc_tab
ls_t100-msgnr gc_tab
ls_t100-sprsl gc_tab
ls_t100-text gc_crlf
into lv_string.
endselect.
select * from t100 into ls_t100
where arbgb = 'SO' and msgnr = '316'.
concatenate lv_string
ls_t100-arbgb gc_tab
ls_t100-msgnr gc_tab
ls_t100-sprsl gc_tab
ls_t100-text gc_crlf
into lv_string.
endselect.
convert the text string into UTF-16LE binary data including
byte-order-mark. Mircosoft Excel prefers these settings
all this is done by new class cl_bcs_convert (see note 1151257)
try.
cl_bcs_convert=>string_to_solix(
exporting
iv_string = lv_string
iv_codepage = '4103' "suitable for MS Excel, leave empty
iv_add_bom = 'X' "for other doc types
importing
et_solix = binary_content
ev_size = size ).
catch cx_bcs.
message e445(so).
endtry.
endform. "create_content
NOTES:
UTF-16LE including the BOM (Byte order mark)
is preferred by Microsoft Excel. If you want to create
other binary content you may choose another codepage (e.g.
'4110' (UTF-8) which is standard for e-mails).
Find SAP codepage names in the drop down list
for the codepage setting of node SMTP in transaction SCOT.
Or: leave iv_codepage and iv_add_bom empty. Then the target
codepage is set according to SAPconnect settings
Important:
SAP neither guarantees that the attachment created
by this report can be opened by all Excel Versions nor
that it can be opened by any 3rd party software at all
Best regards to you
Thorsten Hüser
SAP CRM Senior consultant
arvato / Bertelsmann
Hi forums,
SAP provided an example report to send out internal tables attached as an Excel file to a recipients eMail address. I attached the coding of the BCS_EXAMPLE_7 programm to this thread.
report bcs_example_7.
This report provides an example for sending an Excel
attachment in Unicode Systems
constants:
gc_tab type c value cl_bcs_convert=>gc_tab,
gc_crlf type c value cl_bcs_convert=>gc_crlf.
parameters:
mailto type ad_smtpadr
default 'john.doe(a)crazy-company.com'. "#EC *
data send_request type ref to cl_bcs.
data document type ref to cl_document_bcs.
data recipient type ref to if_recipient_bcs.
data bcs_exception type ref to cx_bcs.
data main_text type bcsy_text.
data binary_content type solix_tab.
data size type so_obj_len.
data sent_to_all type os_boolean.
start-of-selection.
perform create_content.
perform send.
*& Form send
form send.
try.
-------- create persistent send request ------------------------
send_request = cl_bcs=>create_persistent( ).
-------- create and set document with attachment ---------------
create document object from internal table with text
append 'Hello world!' to main_text. "#EC NOTEXT
document = cl_document_bcs=>create_document(
i_type = 'RAW'
i_text = main_text
i_subject = 'Test Created By BCS_EXAMPLE_7' ). "#EC NOTEXT
add the spread sheet as attachment to document object
document->add_attachment(
i_attachment_type = 'xls' "#EC NOTEXT
i_attachment_subject = 'ExampleSpreadSheet' "#EC NOTEXT
i_attachment_size = size
i_att_content_hex = binary_content ).
add document object to send request
send_request->set_document( document ).
--------- add recipient (e-mail address) -----------------------
create recipient object
recipient = cl_cam_address_bcs=>create_internet_address( mailto ).
add recipient object to send request
send_request->add_recipient( recipient ).
---------- send document ---------------------------------------
sent_to_all = send_request->send( i_with_error_screen = 'X' ).
commit work.
if sent_to_all is initial.
message i500(sbcoms) with mailto.
else.
message s022(so).
endif.
------------ exception handling ----------------------------------
replace this rudimentary exception handling with your own one !!!
catch cx_bcs into bcs_exception.
message i865(so) with bcs_exception->error_type.
endtry.
endform. "send
*& Form create_content
Create Example Content
1) Write example text into a string
2) convert this string to solix_tab
form create_content.
data lv_string type string.
data ls_t100 type t100.
as example content we use some system messages out of t100
get them for all installed languages from db
and write one line for each language into the spread sheet
columns are separated by TAB and each line ends with CRLF
concatenate 'This Is Just Example Text!' "#EC NOTEXT
gc_crlf gc_crlf
into lv_string.
header line
concatenate lv_string
'MSGID' gc_tab
'MSGNO' gc_tab
'Language' gc_tab "#EC NOTEXT
'Text' gc_crlf "#EC NOTEXT
into lv_string.
data lines
select * from t100 into ls_t100
where arbgb = 'SO' and msgnr = '182'.
concatenate lv_string
ls_t100-arbgb gc_tab
ls_t100-msgnr gc_tab
ls_t100-sprsl gc_tab
ls_t100-text gc_crlf
into lv_string.
endselect.
select * from t100 into ls_t100
where arbgb = 'SO' and msgnr = '316'.
concatenate lv_string
ls_t100-arbgb gc_tab
ls_t100-msgnr gc_tab
ls_t100-sprsl gc_tab
ls_t100-text gc_crlf
into lv_string.
endselect.
convert the text string into UTF-16LE binary data including
byte-order-mark. Mircosoft Excel prefers these settings
all this is done by new class cl_bcs_convert (see note 1151257)
try.
cl_bcs_convert=>string_to_solix(
exporting
iv_string = lv_string
iv_codepage = '4103' "suitable for MS Excel, leave empty
iv_add_bom = 'X' "for other doc types
importing
et_solix = binary_content
ev_size = size ).
catch cx_bcs.
message e445(so).
endtry.
endform. "create_content
NOTES:
UTF-16LE including the BOM (Byte order mark)
is preferred by Microsoft Excel. If you want to create
other binary content you may choose another codepage (e.g.
'4110' (UTF-8) which is standard for e-mails).
Find SAP codepage names in the drop down list
for the codepage setting of node SMTP in transaction SCOT.
Or: leave iv_codepage and iv_add_bom empty. Then the target
codepage is set according to SAPconnect settings
Important:
SAP neither guarantees that the attachment created
by this report can be opened by all Excel Versions nor
that it can be opened by any 3rd party software at all
Best regards to you
Thorsten Hüser
SAP CRM Senior consultant
arvato / Bertelsmann
Similar Messages
-
How to download values in an internal table into an excel file
is there any fn module to download the values in an internal table into an excel file..
hi
the function module "GUI_DOWNLOAD" downloads the data from
an internal table into a file (can be xl, dat ,doc etc) .
Plz follow the usage below ;
Parameters : pa_pfile LIKE rlgrap-filename OBLIGATORY.
Data : lv_filename TYPE STRING.
lv_filename = pa_pfile.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
FILENAME = lv_filename
FILETYPE = 'ASC'
APPEND = ' '
WRITE_FIELD_SEPARATOR = 'X'
HEADER = '00'
TRUNC_TRAILING_BLANKS = ' '
WRITE_LF = 'X'
COL_SELECT = ' '
COL_SELECT_MASK = ' '
DAT_MODE = ' '
CONFIRM_OVERWRITE = ' '
NO_AUTH_CHECK = ' '
IMPORTING
FILELENGTH =
TABLES
DATA_TAB = tb_download " table data to b downlaoded
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.
Regards
Pankaj -
How to convert Internal table values to excel file
Hi Experts!!!
I have requirement to generate a Excel(.xls) file for a requirement. For this the final internal table values has to be moved to excel file. I have used function module "SAP_CONVERT_TO_XLS_FORMAT" to generate it to my local machine. But when i tried to generate the file in "AL11" folder its giving a dump. Ex(/sapia/iface/out/comm/saphr/test.xls). Can anyone please tell me is there anyother function modules or program to generate in sapia folder.
Thanks.
Ganesh R Ktry to save as a tab delimited.
-
How to move large number of internal table data to excel by program
Hi,
Iam working on a classical report wherein my requirement is:
Have around 25 internal tables which I am displaying using a selection screen.I need to transfer this all internal tables data to Excel file by executing.
Now, let me know how can I transfer all those to excel by execution.
P.S.: GUI_DOWNLOAD or any other excel download related FMs are used to transfer for single/fewer internal tables.
But here I need to download 25 internal tables data through program.
How can I meet the requirement..?
Kindly advice.
Thanks,
Shiv.Hi,
Refer to the following code:
*& Report ZDOWNLOAD_PROGRAM
report zdownload_program.
parameter : p_path type rlgrap-filename default 'C:\Pdata.xls'.
data : gt_output type standard table of trdirt,
wa_output type trdirt,
p_filen type string.
at selection-screen on value-request for p_path.
clear p_path.
call function 'F4_FILENAME'
importing
file_name = p_path.
start-of-selection.
select * from trdirt
into table gt_output
where name like 'Z%'
or name like 'Y%'.
end-of-selection.
move : p_path to p_filen.
call function 'GUI_DOWNLOAD'
exporting
BIN_FILESIZE =
filename = p_filen
filetype = 'ASC'
APPEND = ' '
write_field_separator =
cl_abap_char_utilities=>horizontal_tab
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
IMPORTING
FILELENGTH =
tables
data_tab = gt_output
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.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
Regards
Rajesh Kumar -
Attaching generated excel file in cfmail
Hi,
I've attached the code in which I've generated an excel file
from my data, which the user can then open/save on their PC. I now
want to attach this excel file to an email (using cfmail) and send
it (the task will then become scheduled).
How do I save rather than output the excel file?
KatieHi,
Have a look at the following tags:
1)
<cfsavecontent> to generate a variable from your
tab-delimited content
<cffile action = "write"> to generate a temp file with
your content
<cfmail> and attach that file to your email
or
2)
<cfsavecontent>
<cfmail>,<cfmailpart> to attach the variable
directly to the email without creating a temp file first (have not
tried that myself)
cheers,
fober -
I am trying to attach two excel files to an email, and each time it goes as follows:
1. push the attach file button
2. chose my files
3. push the attach files button
4. the blue "progress" stripe begins to fill the address bar
5. Then it stops about an eighth of the way toward the end, and doesnt go any further...
I tried letting it go for a while, and giving it time, but it doesnt work. The file size is 34.4 (which I know is huge), but there is only about 20 lines of the Excel being used, but the program is trying to attach 64,599 lines of unused space, and that is why it isnt attaching im sure, but i dont know how to fix it, or if it is even possible.
Please help!
g5 Mac OS X (10.4.2)what email provider do you use?
i'd be surprised anyway if it will allow an attachment of that size. the limit is usuall between 1 and 5 MB, some going to 10 or 15 like gmail.
34MB? not unless you have an expensive or corporate email provider.
you can:
1: do like daddypaycheck said and reduce the file size by deleting unnecessary rows or collumns,
2: download OpenOffice.org, or NeoOffice, see if you like that and save it in the native format, usuall smaller file (beware compatibility)
3: use dropstuff or the like to break the file apart into multiple smaller compressed chunks, and send them in multiple emails (the size of the chunks each should match the attachment size limit for your email provider, see their website)
4:this is my favorite - put the file in your Sites folder, in your user's Home folder. open system prefs-> sharing. check the box to enable personal web sharing. go to www.whatismyip.org and copy the string of numbers that appear (that's your external ip). now you can host the file from your computer, and only email people a link to it! the link should be like this:
http://yourip/~your_short_username/name_of_exceldocument.xls
for example, here is my resume in .pdf, hosted from my computer (let me know if it works for you!)
http://67.40.250.86/~Willeyeam/images/WBLResume.pdf
Bam! I'd go with number 4, and test the url in your browser to make sure it works. once you get the page, you can "save as" and download the file. that way people can receive an email with only text, including the url (link) to the hosted file on your computer. then they can "save as" and download the file.
another, more sophisticated way to do this is to write a small .html page that has a link to that file (in your sites folder). name the .html file "index.html" and replace the file by that name which is by default placed in your Sites folder. that will then be your home page at:
http://yourip/~your_shortusername/
Rock on! -
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 -
Writing internal table contents to excel
hi,
i need to write data in my internal table to an excel spread sheet which should be similar to my internal table structure.
can someone help me out.
thanks,
ravi.Hi,
Try this one
FORM f9008_f4_hlp_for_pc_file.
DATA: li_filetable TYPE STANDARD TABLE OF file_table,
lv_return TYPE i,
lw_filetable TYPE file_table.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
window_title = 'Select file for download'
default_extension = '.txt'
initial_directory = 'C:'
CHANGING
file_table = li_filetable
rc = lv_return
EXCEPTIONS
file_open_dialog_failed = 1
cntl_error = 2
error_no_gui = 3
OTHERS = 4
IF sy-subrc <> 0.
MESSAGE e006 WITH text-077.
ELSE.
READ TABLE li_filetable INTO lw_filetable INDEX 1.
v_fnam = lw_filetable-filename.
ENDIF.
FORM f9007_download_file TABLES p_output.
DATA: lv_size TYPE i.
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
filename = v_fnam
filetype = 'DAT'
IMPORTING
filelength = lv_size
TABLES
data_tab = p_output
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
OTHERS = 10.
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. " f9007_download_file
<b>While downloading file, u wont get the header part, u have to append the header part</b>. Then u pass the final output table with header to the function module.
So that it will read the first line that will be header and then remaning data.
<i>Sample code:</i>U can create an internal table.
TYPES: begin of ty_itab ,
name(4) TYPE c,
***(3) Type c,
end of ty_itab.
DATA: i_itab type standard table of ty_itab,
w_itab type ty_itab.
Then do as below.
w_itab-name = 'NAME'.
w_itab-*** = '***'.
APPEND w_itab to i_output_final.
i_output[] = i_output_final.
APPEND i_output_final.
Now pass this final table to the functionmodule, so it is now with header.
Try this out.
Get back to me if u want any clarification. -
Download internal table data in excel format
Hi ,
i have a requirement where i need to download the internal table data in excel format .. I tried using the FM SAP_CONVERT_TO_XLS_FORMAT but this downloads to excel sheet same as .txt file foemat without columns ... i need to have the data in excel sheet with column heading and separated by each coulmn which should be similar as a general sheet with column names and the respective data in the columns . Appreciate any inputs .
Thanks,
Latha.Hi,
you can this in Debugging mode,
say,once you got entire data into ITAB
salect the TABLE option and provide the table name
now on the top most you can see excel icon,you click
on that,now system will prompts you for to the file to be saved.
Regards,
Vijaya. -
How to convert internal table data into excel format?
Hi all,
I want to convert internal table data in excel format and then
send it as email attachment in workflow.
Please tell me how do i perform this.
Regards,
Arpita.Hi Arpita,
Try this sample code::
Send mail
maildata-obj_name = 'TEST'.
maildata-obj_descr = 'Test Subject'.
loop at htmllines.
mailtxt = htmllines.
append mailtxt.
endloop.
mailrec-receiver = 'your receiver mail id'.
mailrec-rec_type = 'U'.
append mailrec.
call function 'SO_NEW_DOCUMENT_SEND_API1'
exporting
document_data = maildata
document_type = 'EXL'
put_in_outbox = 'X'
tables
object_header = mailtxt
object_content = mailtxt
receivers = mailrec
exceptions
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
others = 8.
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 it will help you.
Regards,
NIkita -
Internal table data to XML file.
Hi All,
May I know how can we convert the internal table data to xml file?
Regards
Ramesh.Re: Convert XML to internal Table
Go through the link..u should be able to solve the problem.. -
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> -
Download internal table data to Excel in background
Hi all ,
Can anyone tell that how i can download internal table data
into Excel sheet in Backgroud Mode .
I used both fun mod ws and gui download but these are not working in background mod .
Please help issue is urgent .
Answer is rewarded by point .
With Regards ,
Nilesh Jainhi,
you have to use function module 'SAP_CONVERT_TO_XLS_FORMAT'.
DATA:
ITAB1 TYPE TRUXS_T_TEXT_DATA.
CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'
EXPORTING
I_FIELD_SEPERATOR = ';'
I_LINE_HEADER =
i_filename = filename
I_APPL_KEEP = ' '
tables
i_tab_sap_data = itab
CHANGING
I_TAB_CONVERTED_DATA = itab1
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.
try this one.
reward points if useful,
thanks & regards,
rajee. -
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 -
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
Maybe you are looking for
-
I have a 2012 Macbook Air and an iPhone 5, both with up-to-date software. When I set up Text Message Forwarding, everything went according to plan, until I sent a relatively wordy text to a friend (from my Macbook) to a friend on an Android phone. It
-
Automatically capturing text from service entry sheet at MIRO
Dear all, I am working on a scenario where invoice posting(MIRO) is to be done against service entry sheet. I want to insert a text at the time of creating service entry sheet and to capture the same automatically in MIRO. Can you pl advise me how ca
-
I have drop the SD card to DVD rom .How to get back it?
when SD card drop to DVD rom inside. How to get back it?
-
Loading the cube from 3 datasources and getting 3 records for each keyfield
Hi All, I am loading an InfoCube from 3 separated datasources. These 3 datasources are UD Datasources and their unique source system is UD Connect. Each of the datasource contains a unique key field 'Incident Number' (same as we use have in Datasourc
-
LR4 - what happened to the mask tool?
In LR 3, when I clicked on the mask tool I could see little circles marking my previous adjustments and I could then click on one of the circles to eliminate it or adjust it. I don't see that anymore. Is there a preference I cannot find that I need