How to attach an internal table as excel file in wf container.
Hi all, I have a task that is attaching an xml file in wf container, but I need to attach as excel file, how can I convert this xml to excel ?
my currento code is like this:
* Call Transformation to generate XSTRING of the generated data *
TRY .
CALL TRANSFORMATION ztr_wf_excel
SOURCE appl_stat = li_data2
RESULT XML pi_attach.
CATCH cx_st_error INTO lo_exception.
lv_text = lo_exception->get_text( ).
ENDTRY.
IF lv_text IS INITIAL.
pi_header-file_type = 'B'.
pi_header-file_name = 'Data'.
pi_header-file_extension = 'XLS'.
pi_header-language = 'E'.
CALL FUNCTION 'SAP_WAPI_ATTACHMENT_ADD'
EXPORTING
workitem_id = lw_worklist-wi_id
att_header = pi_header
att_bin = pi_attach
do_commit = 'X'
IMPORTING
att_id = lw_att_id.
this code is working fine, but I need to attach an excel file instead an xml file
How can I do that?
Regards
hi ,
Follow this approach :
You can use following funcntions. First one to create internal table to string and second FM SCMS_STRING_TO_XSTRING to convert String to XSTRING. Then this XSTRING value you can pass to CL_WD_RUNTIME_SERVICES=>ATTACH_FILE_TO_RESPONSE.
data: tab_str type string.
data: begin of it_tab1,
name(20),
age(10) ,
end of it_tab1.
data : lv_name type xstring.
data it_tab like STANDARD TABLE OF it_tab1.
data: wa like line of it_tab.
wa-name = 'naresh'.
wa-age = '30'.
append wa to it_tab.
wa-name = 'naresh1'.
wa-age = '31'.
append wa to it_tab.
CALL FUNCTION 'SOTR_SERV_TABLE_TO_STRING'
IMPORTING
TEXT = tab_str
TABLES
TEXT_TAB = it_tab
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
TEXT = tab_str
IMPORTING
BUFFER = lv_name
CALL METHOD CL_WD_RUNTIME_SERVICES=>ATTACH_FILE_TO_RESPONSE
EXPORTING
I_FILENAME = 'c:\test.txt'
I_CONTENT = lv_name
I_MIME_TYPE = 'TXT'
Refer below links. This has been discussed many times :
Re: download a file
Similar Messages
-
Send An Internal Table Via Excel File As An Attachment of E-mail
Hi,
I've sent my internal table via Excel file as an attachment of email but all records of internal table are in a row of sended excel file.
How can i send an internal table via excel file , records of internal table for each rows of excel file,as an attachment of email correctly?
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = w_doc_data
put_in_outbox = 'X'
sender_address = ld_sender_address
sender_address_type = ld_sender_address_type
commit_work = 'X'
IMPORTING
sent_to_all = w_sent_all
TABLES
packing_list = t_packing_list " t_packing_list-doc_type = 'XLS'.
contents_bin = pit_attach " this is a normal internal table.
contents_txt = pit_message
receivers = t_receivers
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.Hi,
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 T_FINAL INTO WA_T_FINAL.
CONCATENATE WA_T_FINAL-PERNR
WA_T_FINAL-NAME
WA_T_FINAL-LEVEL
WA_T_FINAL-POS
WA_T_FINAL-JOB
WA_T_FINAL-SECTION
WA_T_FINAL-DEPT
WA_T_FINAL-GROUP
WA_T_FINAL-EX_HEAD
WA_T_FINAL-SUPID
WA_T_FINAL-SUPNM
WA_T_FINAL-FHRNM
WA_T_FINAL-VACID
WA_T_FINAL-VAC_SECTION
WA_T_FINAL-VAC_DEPT
WA_T_FINAL-VAC_GROUP
WA_T_FINAL-VAC_EX_HEAD
WA_T_FINAL-VAC_FHRNM
INTO T_FINAL3 SEPARATED BY CON_TAB.
CONCATENATE CON_CRET T_FINAL3 INTO T_FINAL3.
APPEND T_FINAL3.
ENDLOOP.
*Fill the document data.
W_DOC_DATA-DOC_SIZE = 1.
*Populate the subject/generic message attributes
W_DOC_DATA-OBJ_LANGU = SY-LANGU.
W_DOC_DATA-OBJ_NAME = 'REPORT'.
W_DOC_DATA-OBJ_DESCR = LD_MTITLE . "mail description
W_DOC_DATA-SENSITIVTY = 'F'.
*Fill the document data and get size of attachment
CLEAR W_DOC_DATA.
READ TABLE T_FINAL1 INDEX W_CNT.
W_DOC_DATA-DOC_SIZE =
( W_CNT - 1 ) * 255 + STRLEN( T_FINAL1 ).
W_DOC_DATA-OBJ_LANGU = SY-LANGU.
W_DOC_DATA-OBJ_NAME = 'SAPRPT'.
W_DOC_DATA-OBJ_DESCR = LD_MTITLE.
W_DOC_DATA-SENSITIVTY = 'F'.
CLEAR T_ATTACHMENT.
REFRESH T_ATTACHMENT.
T_ATTACHMENT[] = PT_FINAL1[].
*Describe the body of the message
CLEAR T_PACKING_LIST.
REFRESH T_PACKING_LIST.
T_PACKING_LIST-TRANSF_BIN = SPACE.
T_PACKING_LIST-HEAD_START = 1.
T_PACKING_LIST-HEAD_NUM = 0.
T_PACKING_LIST-BODY_START = 1.
DESCRIBE TABLE IT_MESSAGE LINES T_PACKING_LIST-BODY_NUM.
T_PACKING_LIST-DOC_TYPE = 'RAW'.
APPEND T_PACKING_LIST.
*Create 1st attachment notification
T_PACKING_LIST-TRANSF_BIN = 'X'.
T_PACKING_LIST-HEAD_START = 1.
T_PACKING_LIST-HEAD_NUM = 1.
T_PACKING_LIST-BODY_START = 1.
DESCRIBE TABLE T_ATTACHMENT LINES T_PACKING_LIST-BODY_NUM.
T_PACKING_LIST-DOC_TYPE = LD_FORMAT.
T_PACKING_LIST-OBJ_DESCR = 'Application 1'.
T_PACKING_LIST-OBJ_NAME = 'Application 1'.
T_PACKING_LIST-DOC_SIZE = T_PACKING_LIST-BODY_NUM * 255.
APPEND T_PACKING_LIST.
CLEAR T_PACKING_LIST.
*Add the recipients email address
CLEAR T_RECEIVERS.
REFRESH T_RECEIVERS.
T_RECEIVERS-RECEIVER = LD_EMAIL.
T_RECEIVERS-REC_TYPE = 'U'.
T_RECEIVERS-COM_TYPE = 'INT'.
T_RECEIVERS-NOTIF_DEL = 'X'.
T_RECEIVERS-NOTIF_NDEL = 'X'.
APPEND T_RECEIVERS.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
DOCUMENT_DATA = W_DOC_DATA
PUT_IN_OUTBOX = 'X'
SENDER_ADDRESS = LD_SENDER_ADDRESS
SENDER_ADDRESS_TYPE = LD_SENDER_ADDRESS_TYPE
COMMIT_WORK = 'X'
IMPORTING
SENT_TO_ALL = W_SENT_ALL
TABLES
PACKING_LIST = T_PACKING_LIST
CONTENTS_BIN = T_ATTACHMENT
CONTENTS_TXT = IT_MESSAGE
RECEIVERS = T_RECEIVERS
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.
Edited by: Rahul Ghosh on Apr 6, 2009 6:42 AM -
Conversion of internal table into excel file format &put it on app server
Hi,
My requirement is to convert the internal table into excel file format and I have to store it on application server so that administrator can send the file thr e-mail attachment.
So, please let me know how to convert the records of internal table and store it on application server in Excel file format.
TIA,
NitinHi,
Use FM GUI_DOWNLOAD to download the data from inernal table to excel sheet.
Then Using tcode CG3Z u can transfer file to application server.
*& Form sub_download
text
--> p1 text
<-- p2 text
FORM sub_download.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
filename = p_path
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 = ' '
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 = ' '
IMPORTING
FILELENGTH =
TABLES
data_tab = it_final
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.
ENDFORM. " sub_download
Otherwise use OPEN DATASET and TRANSFER statement to download data from internal table to direct application server
Regards,
Prashant -
Function module to get data into internal table from Excel file sheets
Hi,
I have to upload customers from excel file.
we are donloading customer data excel file sheets.
Customer data in 1 sheet, tax data the other sheet of same excel file, Customer master-Credit data in other sheet of same excel file.
so i have 3-4 sheet in one excel file.
now my requirement is to get the data from excel file into internal table.
is there any function module.
Thanks & RegardsI am sending you the idea with an example how you can upload data from an EXCEL file into an internal table. I am not sure if you can take data from different sheet in the same EXCEL file. I think that this is not possible (try it )
Upload the data into an internal table, like the way that I am describing in the above:
DATA: L_MAX_COL_NB TYPE I.
DATA: l_file_name LIKE RLGRAP-FILENAME.
Just to be sure that is the correct type for the FM.
l_file_name = P_FILE_NAME.
L_MAX_COL_NB = 58. "Maximum nb of colums that the FM can read.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = l_file_name
I_BEGIN_COL = 1
I_BEGIN_ROW = 2
I_END_COL = L_MAX_COL_NB
I_END_ROW = 9999
TABLES
INTERN = PT_EXCEL
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
ENDIF.
Now you should upload the data into your own itab. The Function Module will return to you all the an itab
from all fields and columns. Define the structure of the uploading file into SE11 - Data Dictionary. Then read the fieldcatalog of this structure. In the code that I am sending to you, I am insearting an empty line into the internal table and then I am assigning this line into a corresponding field-symbol. Then I am able to change the working area - so and the line of the itab. Propably you could you the statement APPEND INITIAL LINE TO (your_table_name) ASSIGNING <your_field_symbol>, but the example was written in an old SAP version.
FIELD-SYMBOLS:
<F_REC> LIKE WA_UPLOAD_FILE, "working are of the uploading file
<F_FIELD> TYPE ANY.
DATA: COLUMN_INT TYPE I,
C_FIELDNAME(30) TYPE C.
PERFORM GET_FIELDCATOLG TABLES FIELDCAT
USING 'ZECO_CHARALAMBOUS_FILE'.
LOOP AT PT_EXCEL.
AT NEW ROW.
ASSIGN WA_UPLOAD_FILE TO <F_REC>.
ENDAT.
COLUMN_INT = PT_EXCEL-COL.
READ TABLE FIELDCAT INTO WA_FIELDCAT INDEX COLUMN_INT.
CONCATENATE '<F_REC>-' WA_FIELDCAT-FIELDNAME INTO C_FIELDNAME.
ASSIGN (C_FIELDNAME) TO <F_FIELD>.
<F_FIELD> = PT_EXCEL-VALUE.
AT END OF ROW.
APPEND WA_UPLOAD_FILE TO GT_UPLOAD_FILE.
CLEAR WA_UPLOAD_FILE.
ENDAT.
ENDLOOP.
With Regards
George
Edited by: giorgos michaelaris on Mar 4, 2010 3:44 PM -
Export internal table to Excel file pressing a new button created in ALV
Hello, I am trying to implement the functionality to export to excel file inside a button that i have created into my ALV. I don't want to use FileDownload UI.
The code I have set for event handler of this button is the following:
METHOD attach_files .
TYPES:
BEGIN OF tipo_alv_tab,
tipod TYPE objid,
descd TYPE p1000-stext,
begda TYPE begdatum,
endda TYPE enddatum,
pernr TYPE pernr_d,
nombre TYPE ad_namefir,
email TYPE ad_smtpadr,
posicion TYPE p1000-stext,
uodesc TYPE p1000-stext,
END OF tipo_alv_tab.
DATA:
i_alv_tab TYPE TABLE OF tipo_alv_tab,
conv_out TYPE REF TO cl_abap_conv_out_ce,
content TYPE xstring,
lv_filename TYPE string,
xml_out TYPE string.
Fill values from memory
IMPORT name1 TO i_alv_tab FROM MEMORY ID 'ZCA'.
Build XML file with internal table information
CALL TRANSFORMATION ('ID') SOURCE tab = i_alv_tab[] RESULT XML xml_out.
Build XSTRING with XML
CALL FUNCTION 'CRM_IC_XML_STRING2XSTRING'
EXPORTING
instring = xml_out
IMPORTING
outxstring = content.
Format XSTRING
conv_out = cl_abap_conv_out_ce=>create( encoding = 'UTF-8' ).
Convert data
conv_out->convert( EXPORTING data = xml_out IMPORTING buffer = content ).
Save file
CALL METHOD cl_wd_runtime_services=>attach_file_to_response
EXPORTING
i_filename = 'Excel File.xls'
i_content = content
i_mime_type = 'application/msexcel'
i_in_new_window = i_in_new_window
i_inplace = i_inplace.
ENDMETHOD.
When pressing the button, the file created is without extension, and with a rare name. When trying to open the file, it seems to be corrupted.
Does anyone know what am I doing wrong???
Please, help is really really appreciated!!!!Hi Jorge,
The export data to excel functionality is available inbuilt in ALV and you dont have to write any implementation. However, if you want to create your own button for it, you can do so as below.
data:
lr_button type ref to cl_salv_wd_fe_button,
lr_function type ref to cl_salv_wd_function.
CREATE OBJECT lr_button.
lr_button->set_text( 'Export to excel' ).
lr_button->set_tooltip( 'Export data to excel' ).
lr_function = l_alv_model->if_salv_wd_function_settings~create_function( id = 'EXCEL' ).
lr_function->set_function_std( IF_SALV_WD_C_STD_FUNCTIONS=>EXPORT_EXCEL ).
lr_function->set_editor( lr_button ).
Now, you have created your own button, created a user defined function for the ALV and set this button as editor for the function. And using the set_function_std method, we have just mapped the functionality of your new button to the existing export to excel functionality in ALV.
Hope this is what you are looking for.
Regards
Nithya -
Reg: Downloading the internal table into excel file.
Hi,
My requirement is i am collecting data in the internal table and i have to download the contents in an excel file and i have declared like this.
PARAMETERS : x_test TYPE string
DEFAULT 'C:\temp\file.txt'.
I have given the default file path like this and i am using the function module .
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
FILENAME = OUTPUT_PATH
FILETYPE = 'DAT'
IMPORTING
FILELENGTH =
TABLES
DATA_TAB = INT_INPUT
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.
My requirement is i dont want to change my extension as .txt from .exl to my parameter addition and in the function module the file type should be 'dat' only and in the runtime i want to change the file name which i have given in the .
PARAMETERS : x_test TYPE string
DEFAULT 'C:\temp\file.txt' this file.txt into datas.xls.
it would be grateful if some one share some valuable views to wards this query
Thanks and Regards,
KenyHi,
Use this code.
It will ask for the file name...there u can change.
data : l_filename type string,
l_filetype type char10,
l_path type string,
l_fullpath type string.
l_filetype = 'DAT'.
*Get the file name
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_SAVE_DIALOG
EXPORTING
FILE_FILTER = '*.DAT'
INITIAL_DIRECTORY = 'C:\'
CHANGING
FILENAME = l_filename
PATH = l_path
FULLPATH = l_fullpath
EXCEPTIONS
CNTL_ERROR = 1
ERROR_NO_GUI = 2
NOT_SUPPORTED_BY_GUI = 3
others = 4.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
check l_fullpath is not initial.
*Download file
CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD
EXPORTING
FILENAME = l_fullpath
FILETYPE = l_filetype
CHANGING
DATA_TAB = t_data_sum[]
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 NE 0.
MESSAGE e398(00) WITH sy-subrc ' Error downloading file' '' ''.
ENDIF.
Regards
Sandeep REddy -
How to Convert an internal table into Text File
Hello friends,
Can you help me to find out the way to convert an internal table data into a flat file.
the problem is that my internal table contains fields with data type INT also.please go through the code and the parameter passed to the finction module ... since you didn't show your coding i am giving you the sample code also ..
REPORT y_ss_test_ekko .
* To hold selection data
DATA: i_ekko TYPE STANDARD TABLE OF ekko.
* To hold converted text data
DATA: i_text(4096) TYPE c OCCURS 0.
* Selection Screen
PARAMETERS: p_ebeln LIKE ekko-ebeln.
* Select data into an ITAB based on the selection Criteria
SELECT * FROM ekko
INTO TABLE i_ekko
WHERE ebeln = p_ebeln.
* Process further only if found some data
IF NOT i_ekko[] IS INITIAL.
* Convert data in internal table to a delimited text data
CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'
EXPORTING
i_field_seperator = '|'
TABLES
i_tab_sap_data = i_ekko
CHANGING
i_tab_converted_data = i_text
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
WRITE: / 'Program failed to Convert data.'.
ELSE.
* Download convert data to Presentation Server
CALL FUNCTION 'DOWNLOAD'
TABLES
data_tab = i_text
EXCEPTIONS
OTHERS = 8.
IF sy-subrc <> 0.
WRITE: / 'Program failed to download data.'.
ENDIF.
ENDIF.
ENDIF.
reward points if it is usefull ....
Girish -
Downloading internal table in excel file on application server
Hi,
I am trying to download ITAB into excel file on my application server . I am using FM 'SAP_CONVERT_TO_XLS_FORMAT' for that .
When I run the report I can see file getting generated on APP server but no ITAB data is saved in that excel.
After debugging I found that error code 'SAVE_DOCUMENT_FAILED' is retuned in above FM.
Could any one please suggest how to go about this?
Regards,
GaneshHi ganesh,
Please have a look into the below link
[Link1|How to Upload Excel file to Application Server]
[Link2|Error in Downloading the Text file on Application Server]
Hope this will be Helpful
Thanks
Kalyan -
Download Internal table to Excel with different Tabs - ole2_object
Hi All,
I am using ole2_object to download the data from internal table to Excel file. As per different values in sorting key, data will be downloading in different tab in same Excel file.
In my internal table one field is of character type and some times contains number as value.
e.g. itab-code = 000002.
While downloading to Excel, Excel consider this value as numeric and remove the leading zero.
Any suggestions for how to set format property as Text for this cell, will highly appreciated.
Sample code -
data: gs_excel type ole2_object,
gs_wbooklist type ole2_object,
gs_application type ole2_object,
gs_wbook type ole2_object,
gs_activesheet type ole2_object,
gs_sheets type ole2_object,
gs_newsheet type ole2_object,
gs_cell type ole2_object.
create object gs_excel 'EXCEL.APPLICATION'.
get property of gs_excel 'workbooks' = gs_wbooklist.
get property of gs_wbooklist 'Application' = gs_application.
set property of gs_application 'SheetsInNewWorkbook' = 1.
call method of gs_wbooklist 'Add' = gs_wbook.
get property of gs_application 'ActiveSheet' = gs_activesheet.
set property of gs_activesheet 'Name' = datasheet_name.
call method of gs_excel 'Cells' = gs_cell exporting #1 = v_row
#2 = v_col.
set property of gs_cell 'value' = <f>.
GET PROPERTY OF gs_cell 'Font' = gs_Font.
SET PROPERTY OF gs_Font 'Bold' = 1 .
Thanks.
Regards,
Meenakshi.Hello,
Just concatenate ' infont of the fields, which you want to treat as a text.
Like,
itab-code = '00002'.
concatenate '''' itab-code into itab-code.
modify itab.
You can also set the text properties of the cell by,
SET PROPERTY OF gs_cell 'NumberFormat' = '@' .
but, it will remove the leading zeros and set the format as text.
Regards,
Naimesh -
Download Internal Table to Excel
Hi All,
I m new to Webdynpro for ABAP and i m trying to download the data as it is in the Internal Table to excel file using FM 'CRM_IC_XML_STRING2XSTRING' ( to convert string to xstring) and CLASS 'cl_wd_runtime_services=>attach_file_to_response' ( to attach the content in excel).
The export is working fine, but it also has some extra rows and columns with data "/asx:abap".
Also the header is appended with data like "/@version/#agg".
The columns were sorted by its name and gets interchanged and sometimes repeated too.
Is there a way to get the header formatted and trim the unwanted rows and columns appearing.
Thanks in advance,
Raju JHi Vankat,
In last thread i have posted that creating an XLST for the xml will solve the problem. But still it was working fine in MS Excel 2007 and not in the older versions in my case.
Again, i thought of following the method adviced by Radhika(in the previous post).
Loop your internal table and concatenate the content to a string variable SEPARATED BY cl_abap_char_utilities=>horizontal_tab.
Then convert the string to XSTRING using the below FM.
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = l_outstream "Concatenated string
IMPORTING
buffer = l_content. "Resulted xstring
Then call the cl_wd_runtime_services as mentioned below.
cl_wd_runtime_services=>attach_file_to_response(
i_filename = 'filename.xls'
i_content = l_content "Resulted xstring
i_mime_type = 'EXCEL'
i_in_new_window = abap_true ).
This is one way and the other is,
If you want to do it using
CALL TRANSFORMATION ZXSLT "While creating ZXSLT select the prog. type as XSLT program.
SOURCE tab = internal_table[]
RESULT XML l_outstream.
Then convert the l_outstream to xstring and attach to cl_wd_runtime_services.
ZXSLT will contain code like this,
<xsl:transform version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:asx="http://www.sap.com/abapxml"
xmlns:x="urn:schemas-microsoft-com:office:excel">
<xsl:strip-space elements="*"/>
<xsl:template match="asx:abap/asx:values/TAB">
<items>
<xsl:for-each select = "item">
<it>
<OBJECT_ID><xsl:value-of select="OBJECT_ID"/></OBJECT_ID>
<DESCRIPTION><xsl:value-of select="DESCRIPTION"/></DESCRIPTION>
</it>
</xsl:for-each>
</items>
</xsl:template>
</xsl:transform>
I think this will solve your problem.
Regards,
Raju J -
Function Module to Download Internal table in EXCEL
Hi All,
I need a Function Module to download the Internal table to Excel File.
I Have used SAP_CONVERT_TO_XLS_FORMAT,
but this function modules are using GUI_Download indirectly.
I dont want to use GUI_DOWNLOAD as i am going to call this Function Module in Portal.
So pls anybody has this type of function module.
Thanks & Regards,
Dhruv ShahHello Dhruv.
In Agreement with Deniz.
It is required to Export the query as an excel file.
[SAP HELP Library - Standard Reference - Exporting as a CSV File / MS Excel 2000 File|http://help.sap.com/saphelp_nw04/helpdata/en/d2/11a28fc26d4042a6d230a9783152f2/content.htm]
[SDN - Reference - Error in "Export to Microsoft Excel" from Portal|Error in "Export to Microsoft Excel" from Portal;
Hope this works out well.
Good Luck & Regards.
Harsh Dave -
Email internal table as zip file
Hello everyone
I spent several days to have a full example on how to convert an internal table has ZIP file than send it by email.
I found several example to upload file from the OS and than convert it to ZIP to save it after. But nothing from the current internal email.
So, for the benefit of everybody who that can interrest, here is the code I did. Feel free to optimize it and post the new version here.
===========================================
Moderator message - Please respect the 2,500 character maximum when posting. Post only the relevant portions of code
==========================================
Regards
dstj
Edited by: Rob Burbank on Feb 12, 2010 2:09 PMHello Daniel,
Thank you very much for this post, it is quite helpful. However, I have followed your template very closely and my file will not send. I am not an advaned ABAP programmer, but have a good knowledge of programming in general...here's a bit of my code related to this...
*-Create table body
LOOP AT (internal table) INTO (structure)
(Fill lv_line with one line of string based on structure)
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = lv_line
IMPORTING
buffer = lv_xline
CONCATENATE lv_xcontent lv_xline INTO lv_xcontent IN BYTE MODE.
ENDLOOP.
*-Create zip xstring
CREATE OBJECT lo_zipper.
CALL METHOD lo_zipper->add
EXPORTING
name = 'AHReport.zip'
content = lv_xcontent.
CALL METHOD lo_zipper->save
RECEIVING
zip = lv_xzipcontent.
*-Convert zip xstring to binary
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = lv_xzipcontent
TABLES
binary_tab = lt_data.
*- Add attachment
TRY.
CALL METHOD l_document->add_attachment
EXPORTING
i_attachment_type = 'ZIP'
i_attachment_subject = 'Report'
i_att_content_hex = lt_data.
CATCH cx_document_bcs.
ENDTRY.
Any help would be very much appreciated, ty. -
Downloading table to excel-file obeying special conditions
hi all.
i download the internal table to excel file. the excel file is not initial, it has a header line (names of fields). I need to add the data from the table to the file, overwriting the previous data(if it was), but saving the header line. one more requirement: i need to be able to set visible length of each field. is it possible to do using standard function 'GUI_DOWNLOAD'?
thanks all in advance.With GUI_DOWNLOAD, you could only append (and not an actual XLS file, but a DAT or TXT file)
You should try to use OLE instructions, look at <a href="http://www.sap-img.com/abap/download-to-excel-with-format-border-color-cell-etc.htm">Download a report to excel with format (border, color cell, etc)</a> for a sample program using OLE.
Regards -
How to download internal table to excel sheet
I have a requirement to download nearly 8 to 10 internal tables to excel sheets(for each internal table one excel sheet) without displaying the diolog box showing open and save buttons.
scenario :
I will enter the path name like this - C:\myfolder\Custom_programs.xls.
C:\myfolder\Custom_tables.xls.
(File name does not exit..it has to created inside the
specified folder)
in submit button I populate 2 internal tables say it1 and it2. then I need to move the tables contents to the path I have specified above.
attach_file_to_response method is not working for the above reqt since it is showing the dialog box.
Please provide a suitable solution...Please ignore all the responders that are stating that you can use GUI_DOWNLOAD from Web Dynpro ABAP. As you found out, this absolutely will not work, since this function module and other download logic like it depends upon a connection to the SAPGUI. People posting to use the GUI_DOWNLOAD from WDA need to learn a little more about the architecture of WDA before they go posting incorrect repsonses in the forum. I have little tollerance for people posting outright incorrect information in the WDA Forum.
What you want to do - download silent - is not easily done from WDA. There are rules about how web applications must behave in a browser. Normal HTML/JavaScript does not allow silent downloads for security reasons. Obviously there are many untrustworthy websites on the internet that you wouldn't want to allow to directly access your local machine. WDA must live within these same browser limitations.
SAP has done some work using a Java Applet to get around some of these security issues. This funcitonality comes in NetWeaver 7.01. It is the AcfUpDownload UI element:
http://help.sap.com/saphelp_nw70ehp1/helpdata/en/47/b9157c878a2d67e10000000a42189c/frameset.htm
However it is designer for usage with the Content or KPro server - so even it might not meet your needs. -
Download internal table to Excel sheet
Hi,
I am trying a sampole program to download an internal table to excel and am
uisng the Fm GUI_DOWNLOAD for the same. But how do I ensure that each column
of internal will be aligned as columns in the excel sheet to. I a trying to do
that with a separator but I am not able to figure out.
Below is my code.
REPORT z_excel_download.
DATA : it_mara TYPE STANDARD TABLE OF mara WITH HEADER LINE.
DATA : BEGIN OF it_file OCCURS 0,
data(2000),
END OF it_file.
SELECT * FROM mara INTO TABLE it_mara UP TO 100 ROWS.
LOOP AT it_mara.
CONCATENATE it_mara-matnr
it_mara-ersda
it_mara-ernam
it_mara-pstat
it_mara-mtart
it_mara-mbrsh INTO it_file-data SEPARATED BY '/t'.
APPEND it_file.
ENDLOOP.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
filename = 'C:\Documents and Settings\XXXXXX\Desktop\test.xls'
TABLES
data_tab = it_file
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Thanks.Hi Varun,
On SDN are plenty of post where you can find the answer to your problem.
Please try the following code that I found here several years ago to resolve your problem.
Regards,
Eric
REPORT Excel.
TABLES:
sflight.
* header data................................
DATA :
header1 LIKE gxxlt_p-text VALUE 'Suresh',
header2 LIKE gxxlt_p-text VALUE 'Excel sheet'.
* Internal table for holding the SFLIGHT data
DATA BEGIN OF t_sflight OCCURS 0.
INCLUDE STRUCTURE sflight.
DATA END OF t_sflight.
* Internal table for holding the horizontal key.
DATA BEGIN OF t_hkey OCCURS 0.
INCLUDE STRUCTURE gxxlt_h.
DATA END OF t_hkey .
* Internal table for holding the vertical key.
DATA BEGIN OF t_vkey OCCURS 0.
INCLUDE STRUCTURE gxxlt_v.
DATA END OF t_vkey .
* Internal table for holding the online text....
DATA BEGIN OF t_online OCCURS 0.
INCLUDE STRUCTURE gxxlt_o.
DATA END OF t_online.
* Internal table to hold print text.............
DATA BEGIN OF t_print OCCURS 0.
INCLUDE STRUCTURE gxxlt_p.
DATA END OF t_print.
* Internal table to hold SEMA data..............
DATA BEGIN OF t_sema OCCURS 0.
INCLUDE STRUCTURE gxxlt_s.
DATA END OF t_sema.
* Retreiving data from sflight.
SELECT * FROM sflight
INTO TABLE t_sflight.
* Text which will be displayed online is declared here....
t_online-line_no = '1'.
t_online-info_name = 'Created by'.
t_online-info_value = 'SURESH KUMAR PARVATHANENI'.
APPEND t_online.
* Text which will be printed out..........................
t_print-hf = 'H'.
t_print-lcr = 'L'.
t_print-line_no = '1'.
t_print-text = 'This is the header'.
APPEND t_print.
t_print-hf = 'F'.
t_print-lcr = 'C'.
t_print-line_no = '1'.
t_print-text = 'This is the footer'.
APPEND t_print.
* Defining the vertical key columns.......
t_vkey-col_no = '1'.
t_vkey-col_name = 'MANDT'.
APPEND t_vkey.
t_vkey-col_no = '2'.
t_vkey-col_name = 'CARRID'.
APPEND t_vkey.
t_vkey-col_no = '3'.
t_vkey-col_name = 'CONNID'.
APPEND t_vkey.
t_vkey-col_no = '4'.
t_vkey-col_name = 'FLDATE'.
APPEND t_vkey.
* Header text for the data columns................
t_hkey-row_no = '1'.
t_hkey-col_no = 1.
t_hkey-col_name = 'PRICE'.
APPEND t_hkey.
t_hkey-col_no = 2.
t_hkey-col_name = 'CURRENCY'.
APPEND t_hkey.
t_hkey-col_no = 3.
t_hkey-col_name = 'PLANETYPE'.
APPEND t_hkey.
t_hkey-col_no = 4.
t_hkey-col_name = 'SEATSMAX'.
APPEND t_hkey.
t_hkey-col_no = 5.
t_hkey-col_name = 'SEATSOCC'.
APPEND t_hkey.
t_hkey-col_no = 6.
t_hkey-col_name = 'PAYMENTSUM'.
APPEND t_hkey.
* populating the SEMA data..........................
t_sema-col_no = 1.
t_sema-col_typ = 'STR'.
t_sema-col_ops = 'DFT'.
APPEND t_sema.
t_sema-col_no = 2.
APPEND t_sema.
t_sema-col_no = 3.
APPEND t_sema.
t_sema-col_no = 4.
APPEND t_sema.
t_sema-col_no = 5.
APPEND t_sema.
t_sema-col_no = 6.
APPEND t_sema.
t_sema-col_no = 7.
APPEND t_sema.
t_sema-col_no = 8.
APPEND t_sema.
t_sema-col_no = 9.
APPEND t_sema.
t_sema-col_no = 10.
t_sema-col_typ = 'NUM'.
t_sema-col_ops = 'ADD'.
APPEND t_sema.
CALL FUNCTION 'XXL_FULL_API'
EXPORTING
* DATA_ENDING_AT = 54
* DATA_STARTING_AT = 5
filename = 'TESTFILE'
header_1 = header1
header_2 = header2
no_dialog = 'X'
no_start = ' '
n_att_cols = 6
n_hrz_keys = 1
n_vrt_keys = 4
sema_type = 'X'
* SO_TITLE = ' '
TABLES
data = t_sflight
hkey = t_hkey
online_text = t_online
print_text = t_print
sema = t_sema
vkey = t_vkey
EXCEPTIONS
cancelled_by_user = 1
data_too_big = 2
dim_mismatch_data = 3
dim_mismatch_sema = 4
dim_mismatch_vkey = 5
error_in_hkey = 6
error_in_sema = 7
file_open_error = 8
file_write_error = 9
inv_data_range = 10
inv_winsys = 11
inv_xxl = 12
OTHERS = 13
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Maybe you are looking for
-
I have been unable to find out how to select the storyline where I want a clip inserted. Every time I try to insert a clip at the beginning of my project, it goes into the Title Storyline, not my primary one.
-
Convert quicktime file to wmv file
Does anyone happen to know how to do this please...? Thanks very much in advance. R GT
-
Uploading of attachment during supplier self registration
Dear all, Please suggest me what is the configuration to provide a browse option in SAP SRM portal user registration.. Thanks, Sumit
-
I need to reinstall iTunes 9 after uninstalling it on a power book g4 with os 10.4.11
I need to reinstall iTunes 9 after uninstalling it on a power book g4 with os 10.4.11
-
ExternalID of navigation model
Hi, I have default navigation model with various nodes. I am able to navigate to a specific node i.e. node with externalId 'test' by using $wcUrl('test') in a html page using content presenter. I want to access the same node with externalId 'test' in