2008 Jul 11 9:49 AM
Hai friends,
Plz refer my code.
w-directory = '/usr/sap/trans/'.
w-filename = 'ZMAHESH1.XLS'.
CONCATENATE w-directory w-filename INTO w-file.
*open file
OPEN DATASET w-file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc = 0.
*Transfer the data into excel sheet
CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'
EXPORTING
I_FIELD_SEPERATOR =
I_LINE_HEADER =
i_filename = w-file
I_APPL_KEEP = ' '
TABLES
i_tab_sap_data = tab_file_data
CHANGING
I_TAB_CONVERTED_DATA =
EXCEPTIONS
conversion_failed = 1
OTHERS = 2
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
*close file
CLOSE DATASET w-file.
Here I want to transfer the data which is in tab_file_data to excel file which I am trying to generate in application server.of-course the excel file is getting generated wirh the same name(zmahesh1).but when I double click on the filename in appln server it is saying that no contents in the file.
Can anybody give the immediate reply for this.
Regards
mahesh
2008 Jul 11 10:30 AM
Hi ,
there are 2 ways for doing that.
1) Remove that function module and modify the code as follows:
open dataset.
loop the internal table.
transfer internal table workarea to file.
endloop.
close dataset
2) By using that FM generate an excel file on to the presentation server. remember to save the path of presentation aswellas application server paths.
Now using the following function module, you can upload it to the application server.
'C13Z_FRONT_END_TO_APPL'
This particular FM opens a dialog box to select the source file from presentation and destination on application server.
Thanks and regards.
Hai friends,
Plz refer my code.
w-directory = '/usr/sap/trans/'.
w-filename = 'ZMAHESH1.XLS'.
CONCATENATE w-directory w-filename INTO w-file.
*open file
OPEN DATASET w-file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc = 0.
*Transfer the data into excel sheet
CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'
EXPORTING
I_FIELD_SEPERATOR =
I_LINE_HEADER =
i_filename = w-file
I_APPL_KEEP = ' '
TABLES
i_tab_sap_data = tab_file_data
CHANGING
I_TAB_CONVERTED_DATA =
EXCEPTIONS
conversion_failed = 1
OTHERS = 2
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
*close file
CLOSE DATASET w-file.
Here I want to transfer the data which is in tab_file_data to excel file which I am trying to generate in application server.of-course the excel file is getting generated wirh the same name(zmahesh1).but when I double click on the filename in appln server it is saying that no contents in the file.
Can anybody give the immediate reply for this.
Regards
mahesh
2008 Jul 11 10:13 AM
Hi,
I think you are not writing any contents from the internal table to file . i mean you are not using any TRANSFER statement to write to the application server file.
Use transfer stmt for writing the contents of the internal table to the application server file.
open dataset in write mode.
transfer workarea contents to file.
close dataset.
Hope this is clear.
Moreover I think that there is no need of that Function module which you used .
thanks and regards.
2008 Jul 11 10:19 AM
hai murthy,
thanx for ur reply.
a small clarity from my side to u.
Here in my requirement when i execute my interface program.
it should generate an excel file and it should b transferred to application server.that's why i used fm.
still if my requirement is not clear to u.plz reply back.
2008 Jul 11 10:16 AM
Hi Mahesh,
to transfer into application server you have to do it by transfer options, take your file into internal table, then loop the itab and get it into your specified file in app server. as below, there is nothing like excel format in app server.
OPEN DATASET w-file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
loop itab into wa.
transfer wato w-directory.
endloop.
CLOSE DATASET w-file.
regards,
ptitam.
2008 Jul 11 10:21 AM
hai pritam,
thanx for ur reply.
a small clarity from my side to u.
Here in my requirement when i execute my interface program.
it should generate an excel file and it should b transferred to application server.that's why i used fm.
2008 Jul 11 10:30 AM
Hi ,
there are 2 ways for doing that.
1) Remove that function module and modify the code as follows:
open dataset.
loop the internal table.
transfer internal table workarea to file.
endloop.
close dataset
2) By using that FM generate an excel file on to the presentation server. remember to save the path of presentation aswellas application server paths.
Now using the following function module, you can upload it to the application server.
'C13Z_FRONT_END_TO_APPL'
This particular FM opens a dialog box to select the source file from presentation and destination on application server.
Thanks and regards.
2008 Jul 11 5:05 PM
hi do like this..
open dataset for p_file for output in text mode encoding default .
outrec+0(10) = it_final-field.
transfer outrec to p_file.
close dataset for p_file.
2008 Jul 14 9:06 AM
Hi Mahesh,
There is no concept of Excel file on application server.May be they want it as '.CSV ' file on application server.Which can be viwed as XLS file when they download into Presentation server.
So you can only Transfer File to application server in Text format.If you want .CSV file then use comma seperator between and upload to Application server.Which can be used as CSV file on presentation server.
I hope you know how to download to Application server
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |