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
Similar Messages
-
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 -
Hi all,
i am trying to download ALV to excel file.
but as the alv contains many fields,
the row in the excel is automatically wrapped to the
next row ..
what i want is the row in excel should come as it is
in the ALV (whole thing in one line) and should not wrap to next row
Regards,
TarangHi Shah,
<b>
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'</b>
EXPORTING
I_CALLBACK_PROGRAM = V_REPID
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IS_LAYOUT = WA_LAYOUT
I_SAVE = 'A'
IT_FIELDCAT = I_FLDCAT_HEAD
IT_SORT = IT_SORT
IT_EVENTS = I_EVENTS
TABLES
T_OUTTAB = IT_FINAL
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC = 0.
<b> CALL FUNCTION 'GUI_DOWNLOAD'</b>
EXPORTING
BIN_FILESIZE =
FILENAME = 'C:\Documents and Settings\vikranthk\Desktop\vikranth.xls'
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 = ' '
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
Thanks
Vikranth Khimavath
Message was edited by: Khimavath Vikranth -
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 -
How to export data from a Dynpro table to Excel file?
Hi
Here I go again. I read the post <b>Looking for example to export data from a DynPro table to Excel file</b> and put the code lines into a Web Dynpro Project where we need to export a dynpro table to Excel file but exactly at line 23 it doesn't recognize <b>workBook = new HSSFWorkbook();</b>
1 //Declare this in the end between the Begin others block.
2
3 private FileOutputStream out = null;
4 private HSSFWorkbook workBook = null;
5 private HSSFSheet hsSheet = null;
6 private HSSFRow row = null;
7 private HSSFCell cell = null;
8 private HSSFCellStyle cs = null;
9 private HSSFCellStyle cs1 = null;
10 private HSSFCellStyle cs2 = null;
11 private HSSFDataFormat dataFormat = null;
12 private HSSFFont f = null;
13 private HSSFFont f1 = null;
14
15 //Code to create the Excel.
16
17 public void onActionExportToExcel(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
18 {
19 //@@begin onActionExportToExcel(ServerEvent)
20 try
21 {
22 out = new FileOutputStream("C:/mydirectory/myfiles/testexcel.xls");
23 workBook = new HSSFWorkbook();
24 hsSheet = workBook.createSheet("My Sheet");
25 cs = workBook.createCellStyle();
26 cs1 = workBook.createCellStyle();
27 cs2 = workBook.createCellStyle();
28 dataFormat = workBook.createDataFormat();
29 f = workBook.createFont();
30 f1 = workBook.createFont();
31 f.setFontHeightInPoints((short) 12);
32 // make it blue
33 f.setColor( (short)HSSFFont.COLOR_NORMAL );
34 // make it bold
35 // arial is the default font
36 f.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
37
38 // set font 2 to 10 point type
39 f1.setFontHeightInPoints((short) 10);
40 // make it red
41 f1.setColor( (short)HSSFFont.COLOR_RED );
42 // make it bold
43 f1.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
44 f1.setStrikeout(true);
45 cs.setFont(f);
46 cs.setDataFormat(dataFormat.getFormat("#,##0.0"));
47
48 // set a thick border
49 cs2.setBorderBottom(cs2.BORDER_THICK);
50
51 // fill w fg fill color
52 cs2.setFillPattern((short) HSSFCellStyle.SOLID_FOREGROUND);
53 cs2.setFillBackgroundColor((short)HSSFCellStyle.SOLID_FOREGROUND);
54 // set the cell format to text see HSSFDataFormat for a full list
55 cs2.setDataFormat(HSSFDataFormat.getBuiltinFormat("text"));
56 cs2.setFont(f1);
57 cs2.setLocked(true);
58 cs2.setWrapText(true);
59 row = hsSheet.createRow(0);
60 hsSheet.createFreezePane(0,1,1,1);
61 for(int i=1; i<10;i++)
62 {
63 cell = row.createCell((short)i);
64 cell.setCellValue("Excel Column "+i);
65 cell.setCellStyle(cs2);
66 }
67 workBook.write(out);
68 out.close();
69
70 //Read the file that was created.
71
72 FileInputStream fin = new FileInputStream("C:/mydirectory/myfiles/testexcel.xls");
73 byte b[] = new byte[fin.available()];
74 fin.read(b,0,b.length);
75 fin.close();
76
77 wdContext.currentContextElement().setDataContent(b);
78 }
79 catch(Exception e)
80 {
81 wdComponentAPI.getComponent().getMessageManager().reportException("Exception while reading file "+e,true);
82 }
83 //@@end
84 }
I don't know why this happen? Any information I will appreciate it.
Thanks in advance!!!
Tokio Franco ChangAfter test the code lines appears this error stacktrace:
[code]
java.lang.NoClassDefFoundError: org/apache/poi/hssf/usermodel/HSSFWorkbook
at com.sap.tc.webdynpro.progmodel.api.iwdcustomevent.ExportToExcel.onActionAct1(ExportToExcel.java:232)
at com.sap.tc.webdynpro.progmodel.api.iwdcustomevent.wdp.InternalExportToExcel.wdInvokeEventHandler(InternalExportToExcel.java:147)
at com.sap.tc.webdynpro.progmodel.generation.DelegatingView.invokeEventHandler(DelegatingView.java:87)
at com.sap.tc.webdynpro.progmodel.controller.Action.fire(Action.java:67)
at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.handleAction(WebDynproMainTask.java:101)
at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.handleActionEvent(WebDynproMainTask.java:304)
at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.execute(WebDynproMainTask.java:649)
at com.sap.tc.webdynpro.clientserver.cal.AbstractClient.executeTasks(AbstractClient.java:59)
at com.sap.tc.webdynpro.clientserver.cal.ClientManager.doProcessing(ClientManager.java:252)
at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doWebDynproProcessing(DispatcherServlet.java:154)
at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doContent(DispatcherServlet.java:116)
at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doPost(DispatcherServlet.java:55)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:392)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:266)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:345)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:323)
at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:865)
at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:240)
at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:148)
at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:37)
at com.sap.engine.core.cluster.impl6.session.UnorderedChannel$MessageRunner.run(UnorderedChannel.java:71)
at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
at java.security.AccessController.doPrivileged(Native Method)
at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:95)
at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:159)
Thanks in advance!!!
Tokio Franco Chang
[/code] -
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 -
Downloading report in excel file
When I download reoprt in excel file then if material no is 0002134 then in the excel file this becomes 2134,
I am saving file from the Menu System->Save-> Local fiie and then selecting spreadsheet.
When I save as text file then it is not removing leading zeros, only in excel file it is removing leading zeros.
I wanted to know that how to download in excel file so that my material no should download as it is .
Thanks
APrasadMenu System->Save-> Local fiie and then selecting spreadsheet.
Spreadsheet is not EXCEL. It is a an internal format.
if you enter xls as extension, then you just tell Microsoft to open this file with excel.
Excel then automatically coverts it to its own rules.
When download with Menu System->Save-> Local fiie and then selecting spreadsheet enter the file extension txt
Then open Excel, use file > open
find your file and open it, Excel will come up with an import assistant.
there you can define if the column is to be loaded as numbers or text. -
Hi experts,
I used subtotals in ALV.first three columns I claculated based on the addition of individual column.In fourth column i calculated the value based on three calculated values ...It is not problem.
when i download this into excel file the original value is only coming .the calculated value i.e) calculated based on three values didnt get displayed in excel file..Help me please...
Thank u,
Manjula Devi.DHi.
I find that
List > Export > Spreadsheet
gives no subtotals, but
List > Export > Local File and then Spreadsheet
does give subtotals.
I find that
Views > Microsoft Excel
followed by
Save As
does give subtotals.
John -
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 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?
Regardshi ,
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 -
Looking for example to export data from a DynPro table to Excel file
Hello,
I have a certain content in a table.
I would like to export this content to Excel file and let the user save it on his PC. I tried to use the Office Controller but with no success.
Have someone already made something like this and can show me an example?Hi
I already explained this in another post. Anyway i will cut and paste the same for you.Here you go.Sample way to create a Excel file and then download it to a local pc using a FileUI Download element.
We are developing a generic component for the same requirement which will download data to a excel from any table.
Anyway here is something which will give you some kind of idea as to how you can write the data from WebDynpro to a excel file.
For running this application
Ensure that the requisite JAR files are set for the Excel API's. See the blog link below.
Steps :
All your files in the machine running the WAS will be created in the default location
Alias : webdynpro/resources
Path : <Drive>:/usr/sap/J2E/JC00/j2ee/cluster/server0/temp/webdynpro/web
You can open your Visual Administrator and go to HTTP provider service and then create your own Alias. say
Alias : myAlias
Path : <Drive>:/mydirectory/myfiles
Once this is done restart your WebAS.
The code explained will perform the following.
There is a button UI element and a Download UI element. On click of the Action associated with the button ui element
The code below will create a excel file in the location mentioned.
On click of the download UI element you can view the excel file that was created.
Now create a New project in your NWDS
Follow the blog for importing the necessary jar files for Excel
/people/perumal.kanthan/blog/2005/03/21/reading-excel-data-from-java-using-hssf-api
Once that is done you can create say a button in your Webdynpro and associate it with a action.
Then you can write some code like the one below.
//Declare this in the end between the Begin others block.
private FileOutputStream out = null;
private HSSFWorkbook workBook = null;
private HSSFSheet hsSheet = null;
private HSSFRow row = null;
private HSSFCell cell = null;
private HSSFCellStyle cs = null;
private HSSFCellStyle cs1 = null;
private HSSFCellStyle cs2 = null;
private HSSFDataFormat dataFormat = null;
private HSSFFont f = null;
private HSSFFont f1 = null;
//Code to create the Excel.
public void onActionExportToExcel(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
//@@begin onActionExportToExcel(ServerEvent)
try
out = new FileOutputStream("C:/mydirectory/myfiles/testexcel.xls");
workBook = new HSSFWorkbook();
hsSheet = workBook.createSheet("My Sheet");
cs = workBook.createCellStyle();
cs1 = workBook.createCellStyle();
cs2 = workBook.createCellStyle();
dataFormat = workBook.createDataFormat();
f = workBook.createFont();
f1 = workBook.createFont();
f.setFontHeightInPoints((short) 12);
// make it blue
f.setColor( (short)HSSFFont.COLOR_NORMAL );
// make it bold
// arial is the default font
f.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
// set font 2 to 10 point type
f1.setFontHeightInPoints((short) 10);
// make it red
f1.setColor( (short)HSSFFont.COLOR_RED );
// make it bold
f1.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
f1.setStrikeout(true);
cs.setFont(f);
cs.setDataFormat(dataFormat.getFormat("#,##0.0"));
// set a thick border
cs2.setBorderBottom(cs2.BORDER_THICK);
// fill w fg fill color
cs2.setFillPattern((short) HSSFCellStyle.SOLID_FOREGROUND);
cs2.setFillBackgroundColor((short)HSSFCellStyle.SOLID_FOREGROUND);
// set the cell format to text see HSSFDataFormat for a full list
cs2.setDataFormat(HSSFDataFormat.getBuiltinFormat("text"));
cs2.setFont(f1);
cs2.setLocked(true);
cs2.setWrapText(true);
row = hsSheet.createRow(0);
hsSheet.createFreezePane(0,1,1,1);
for(int i=1; i<10;i++)
cell = row.createCell((short)i);
cell.setCellValue("Excel Column "+i);
cell.setCellStyle(cs2);
workBook.write(out);
out.close();
//Read the file that was created.
FileInputStream fin = new FileInputStream("C:/mydirectory/myfiles/testexcel.xls");
byte b[] = new byte[fin.available()];
fin.read(b,0,b.length);
fin.close();
wdContext.currentContextElement().setDataContent(b);
catch(Exception e)
wdComponentAPI.getComponent().getMessageManager().reportException("Exception while reading file "+e,true);
//@@end
You can now add a Download UI Element to the layout.
Create a Context Attribute say "dataContent" and this should be of Type Binary.
The Data property of the File UI download element should be mapped to dataContent.
In the init method write code like
This is done for the download element.
IWDAttributeInfo attInfo = wdContext.getNodeInfo().getAttribute("dataContent");
IWDModifiableBinaryType binaryType = (IWDModifiableBinaryType) attInfo.getModifiableSimpleType();
//In addition the FileDownload UI element needs for defined resource types
binaryType.setFileName("testexcel.xls");
binaryType.setMimeType(WDWebResourceType.XLS);
Hope that helps you. Anyway its a sample and it should be helpful for you to see how you can modify it and of course maintain some standards in coding unlike the test sample given above :).
Let me know if you require further clarifications
regards
ravi -
Error while downloading data into excel file.
Hi,
I have a requirement to download data available in xstring to excel file.
I have a RFC which has export parameter 'file_data' of type xstring. When i call RFC
from web dynpro abap application it gives data out pout in xstring format.
I am opening excel file using that xstring data as below
cl_wd_runtime_services=>attach_file_to_response(
i_filename = 'file.xls'
i_content = ls_data_source-data_source ***[xstring data from RFC]
i_mime_type = 'x-excel/application'
i_in_new_window = abap_true ).
But excel file not coming in correct format. its giving an error while download
excel file
Error is
" the file you are trying to open , 'file[1].xls', is in a different format than
specified by the file extension. Verify that the file is not corrupted and is from
a trusted source before opening the file. Do you want to open the file now? "
If i click on 'YES' button file opening but not in proper excel format. Data is coming
in tab delimiter format in excel file.
Please suggest any solution for this problem.
Thanks,
Venkat.Hi Thomas,
Following is the logic implemented in RFC which is giving XSTRING as export parameter
STEP1 create a dynamic internal table
Create field catalog for the table using LVC_FIELDCATALOG_MERGE
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fieldcat
IMPORTING
ep_table = dyn_table.
CREATE EXCEL SHEET BY SENDING FIELD CATALOG AND DATA TAB
STEP2 # Convert text table to xstring.
CALL FUNCTION 'SCMS_TEXT_TO_XSTRING'
IMPORTING
buffer = l_content
TABLES
text_tab = lt_data_tab
EXCEPTIONS
failed = 1
OTHERS = 2.
STEP3 *# Psss Data to Netweaver
PERFORM pass_data_to_nw USING is_import
CHANGING es_attachment_metadata. -
How to change data in decision table using excel file in operating system?
Hello, BRF Experts
I now brf + for the first time in the current project is being developed.
Now, project has been facing a big problem.
Develop system that was developed in the history of decision table in the operating system can be used to update excel file, etc. I do not know whether.
So, I was tested, but can not change data in decision table.
[ error message : system is not change allowed ].
The operating system itself to the current system setting is immutable and check it
: changes and transports for client-specific object -> no changed allowed
: cross-client object changes -> no changes to repository and cross-client customizing object.
Decision table in the operating system can update the details if I want to know what to do.
Maintenance view can be modified in the operating system as a decision table, I wonder if you can create a view.
Edited by: Sung-Wook Ha on Jan 13, 2012 2:02 PMHi ,
Exchanging data with Microsoft Excel is done with the help of the XML-based file format (file extension .XSLX) introduced with Microsoft Excel 2007. If you are using an older version of Microsoft Office, you can download the Microsoft Office Compatibility Pack to upgrade the supported file formats from the Microsoft Download Center ([Exchanging Decision Table Data With Microsoft Excel |http://www.microsoft.com/downloads/details.aspx?familyid=941b3470-3ae9-4aee-8f43-c6bb74cd1466]). Once you have downloaded the Compatibility Pack, you have to install it on every workstation that has an older version of Microsoft Office installed.
Please refer the link-
[BRFplus-Data exchange with MS Office 2007|http://help.sap.com/erp2005_ehp_05/helpdata/en/b8/e03486d1df48c6baa3c4354f5198ee/frameset.htm]
Hope this helps.
Thanks,
Ajay -
Download records to EXCEL file with Leading Zero's for numbers
Hi All,
I am able to download the data to EXCEL file on the presentation server.
There are few fields (Plant,SalesOrder Number ..with Leading Zero's) in the record.
These values are downloaded with out Leading Zero's to excel( EX: 0000004122 as 4122).
Please help me to download the data to EXCEL file with leading zero's.
Thanks and Regards,
KC>
Krishna Chaitanya G wrote:
> The excel file which is to be downloaded..will be used by some other program..to upload the values to the sap.
> It matters there....
> KC
HI KC,
then no need to download the zeros,
after uploading, loop at that uploaded internal table and use CONVERSION_EXIT_APLHA_INPUT and pass the vbeln(without zeros) to this FM, it will return the value with added zeros.
hope this solves your query
a small example
Loop at itab into is.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = is-vbeln "( this is without zeros)
IMPORTING
OUTPUT = is-vbeln. "( this is with leading zeros)
modify itab from is.
endloop.
Edited by: Soumyaprakash Mishra on Oct 6, 2009 2:16 AM -
Problem in Download data into Excel File
Hi Friends,
I have one doubt on WDJ.
I have got the data from the Back and display the data into Table UI Element. Depending upon po_status equals to OA Pending that time conf_Ship_date Column is Empty. That time we can Select All Checkbox Click on Download Button Excel file is not download. Why it not download? Conf_Ship_date Column is Empty. Conf_Ship_date Column is data available that time data download into Excel File.
My Req: if Conf_Ship_date Column is empty that time click on Download that data will download in to Excel. In Excel Conf_Ship_date Column will display in NULL or 00.00.0000 Like this also.
Code:ExcelEle.setConf_Shp_Date(StockEle.getConf_Shp_Date());
This means I am getting date from PoDetails_OutTab(StockEle)this node and add this date to PoDetails_ExcelData(ExcelEle) this node.Finally the date will available in PoDetails_ExcelData this node. By Using this node I will download data.
How to do this work?
Regards
VijayHi Arun,
For Example in Table 4 rows and 14 columns data is available. Select all check boxes click on download button total 4 rows and 14 columns data is downloaded.
Table 4 rows and 14 columns data is available. But in some cells data not available in that time I m getting null values from ECC System. That time I am not able to download.
In Particularly this problem I am getting only date colums.
So now I have develop this code
public void onActiondownloadToExcel(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
//@@begin onActiondownloadToExcel(ServerEvent)
IPrivatePO_Details_ResultView.IPoDetails_ExcelDataNode ExcelNode = wdContext.nodePoDetails_ExcelData();
IPrivatePO_Details_ResultView.IPoDetails_ExcelDataElement ExcelEle;
IPrivatePO_Details_ResultView.IPoDetails_OutTabNode StockNode = wdContext.nodePoDetails_OutTab();
IPrivatePO_Details_ResultView.IPoDetails_OutTabElement StockEle ;
for(int i = 0 ;i<StockNode.size();i++)
StockEle = StockNode.getPoDetails_OutTabElementAt(i);
if(StockEle.getCheckBox()== true)
ExcelEle = ExcelNode.createPoDetails_ExcelDataElement();// Create Element
if(StockEle.getConf_Shp_Date()==null)
java.sql.Date deliverydate1=new java.sql.Date(0,0,0);
ExcelEle.setConf_Shp_Date(deliverydate1);
else
ExcelEle.setConf_Shp_Date(StockEle.getConf_Shp_Date());
By using this code i have to download total Records but in this Conf_Shp_Date colums i am getting 31-12.1899 this output in Excel. But i need in Excel to print Null or 00.00.0000 like
ExcelEle.setQuantity(StockEle.getQuantity());
ExcelEle.setDeliv_Date(StockEle.getDeliv_Date());
if(StockEle.getExpt_Shp_Date()==null)
java.sql.Date deliverydate2=new java.sql.Date(0,0,0);
ExcelEle.setExpt_Shp_Date(deliverydate2);
else
ExcelEle.setExpt_Shp_Date(StockEle.getExpt_Shp_Date());
ExcelEle.setVendor_Material(StockEle.getVendor_Material());
ExcelNode.addElement(ExcelEle);
if(ExcelNode.size()>0)
wdThis.wdGetCO_POPendingController().downloadData(wdContext.nodePoDetails_ExcelData());// This is for Downalod data Method
wdThis.wdGetCO_POPendingController().DownLoadToExcel();// This is for Open Popup Window
wdContext.nodePoDetails_ExcelData().invalidate();
else
wdComponentAPI.getMessageManager().reportException("Please select any one po item from the table",true);
//@@end
Regards
Vijay
Edited by: KalluriVijay on May 18, 2010 10:05 AM
Maybe you are looking for
-
Hi , I know to create infoset in R3 ( SQ02 ), But what is termed as infoset in BI ? How to create infoset in BI ? What is use of it ?
-
I am working with a very large document in Pages and would like to create bookmarks with headings and text that go under those headings. I am not getting the links to work when I try inserting a bookmark. Can someone explain how to link from one part
-
Windows 8.1 System_Memory_Exception BSOD.
Hey guys, I've recently begun experiencing BSODs with the above explanation, and I cannot spot a reason for it.I have uploaded the Minidump files from the BSODS here:- http://1drv.ms/1i2A9Df as I unfortunately have no knowledge of examining BSOD dump
-
I have a problem with SD configuration .TMS sent a shipment idocs through TRFC port to SAP.those idocs are failed due to this error. The error is the departure point is not found for Loc$000001. please tell me where the departure point is saved for t
-
Does my iPhone 4 work with Hands Free Profile (HFP)?
My new car is supposed to send/receive text messages via the new fandangled stereo/navigation unit. The manual says the phone must be compatible with "Hands Free Profile (HFP)" or Message Access Profile (HFP)". Does the iPhone4 use/have this? New