06-19-2008 6:25 AM
Hi Gurus,
How to transfer a file which is output for my report to application layer, its really urgent.
Thanks and Regards,
Varun.K
06-19-2008 6:27 AM
Check the final internal table of your report, and
Loop at itab.
OPEN DATASET (filename) FOR OUTPUT IN TEXT MODE DEFAULT ENCODING.
if sy-subrc eq 0.
TRANSFER itab TO (filename).
endif.
CLOSE DATASET (filename).
Regards
Kannaiah
06-19-2008 6:26 AM
Hi,
Use
OPEN DATASET,
TRANFER DATASET,
CLOSE DATASET.
Check online help for documentation .
Regards,
Subramanian
06-19-2008 6:27 AM
Hi,
you have 2 methods
1) writing internal table data to the application using OPEN DATASET
2) download the file onto the presentation server and then using CG3Z tcode UPLOAD to application server.
Thanks and regards.
06-19-2008 6:27 AM
Check the final internal table of your report, and
Loop at itab.
OPEN DATASET (filename) FOR OUTPUT IN TEXT MODE DEFAULT ENCODING.
if sy-subrc eq 0.
TRANSFER itab TO (filename).
endif.
CLOSE DATASET (filename).
Regards
Kannaiah
06-19-2008 6:39 AM
Hi,
I want the output to be displeyed on the output screena and at the same time it should be saved in the App. Layer, can this done using above solutions ?
Thanks for the quick reply.
Thanks again.
Varun.K
06-19-2008 6:29 AM
Example:
parameters: p_app LIKE rlgrap-filename DEFAULT
'/interf/Direct/test/Out/'.
OPEN DATASET p_app FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
TRANSFER t_file TO p_app.
t_file internal table will contain the data.
Regards,
DhanaLakshmi M S
06-19-2008 6:29 AM
Hi Varun,
Here is the sample program to upload the file intothe applicaiton server.
IF NOT it_success[] IS INITIAL .
CLEAR v_unix .
CONCATENATE '/tmp/' 'SAP_TRAVEL_SUCCESS_' v_dformat '_' sy-uzeit '.TXT' INTO v_unix .
OPEN DATASET v_unix FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
* If Network file could not be opened, give a message.
IF sy-subrc <> 0.
EXIT.
ELSE.
LOOP AT it_success.
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE it_success TO <field>.
IF sy-subrc <> 0.
EXIT.
ENDIF.
* Look for Pipes in the field value. If it exists, put quotes around
* value so that the file opens correctly with all the columns aligned
* in Excel.
SEARCH <field> FOR '|' IN CHARACTER MODE.
* If search for Pipes was successful.
IF sy-subrc = 0.
CONCATENATE '"' <field> '"' INTO <field> IN CHARACTER MODE.
ENDIF.
IF sy-index = 1.
it_dload-dload = <field>.
ELSE.
* Put Pipe as a separator for values in IT_DLOAD internal table
CONCATENATE it_dload-dload <field> INTO it_dload-dload
SEPARATED BY '|' IN CHARACTER MODE.
ENDIF.
ENDDO.
TRANSFER it_dload-dload TO v_unix .
CLEAR: it_dload-dload.
ENDLOOP.
v_trv_suc = v_unix .
ENDIF.
CLOSE DATASET v_unix .
ENDIF .
06-19-2008 6:29 AM
Hi Varun,
Please check this link
File Handling in ABAP
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3c8c358411d1829f0000e829fbfe/content.htm
Opening a File
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3c99358411d1829f0000e829fbfe/content.htm
Closing a File
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3d1b358411d1829f0000e829fbfe/content.htm
Deleting a File
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3d28358411d1829f0000e829fbfe/content.htm
Best regards,
raam
06-19-2008 6:31 AM
Hi,
First Open data set that means you have to give application server path name and it will open that.
second transfer data set means you are transfer the data into application server path.
third close your data set.
below is the code
DATA: w_temp(25) TYPE c,
BEGIN OF itab OCCURS 0,
f1(2) TYPE c,
f2(6) TYPE c,
f3(16) TYPE c,
END OF itab.
OPEN DATASET <file name and path> FOR OUTPUT IN TEXT MODE ENCODE DEFAULT.
IF sy-subrc EQ 0.
LOOP AT itab.
w_temp = itab-f1.
CONCATENATE w_temp
itab-f2
INTO w_temp.
CONCATENATE w_temp
itab-f3
INTO w_temp.
TRANSFER w_temp TO <file name and path>.
ENDLOOP.
CLOSE DATASET <file name and path>.
ENDIF.
Thanks
Vikranth
06-19-2008 6:35 AM
Hi,
use
data : l_line type string.
Open dataset p_filename for output in text mode encoding default.
If sy-subrc = 0.
loop at t_output into w_output.
concatenate w_output-field1
w_output-field2
.
.
into l_line seperated by ','.
transfer l_line to p_filename.
endloop.
endif.
close dataset p_filename.
06-19-2008 7:07 AM
06-19-2008 7:18 AM
hi....
in whatver internal table you get the data,tranft the data from internal table to application server using open dataset and close dataset.
CALL FUNCTION 'SAP_CONVERT_TO_CSV_FORMAT'
EXPORTING
i_field_seperator = ';'
I_LINE_HEADER =
I_FILENAME =
I_APPL_KEEP = ' '
TABLES
i_tab_sap_data = tfile_data
CHANGING
i_tab_converted_data = it_trans
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.
IF sy-subrc NE 0.
MESSAGE e000(yw) WITH 'Data is not available'.
ENDIF.
SELECT SINGLE paramval FROM zmm_params
INTO path
WHERE pgmna = 'ZREP_SAP_TO_CLRTY'
AND paramid = 'PATH'
AND fromdt <= sy-datum
AND todt >= sy-datum.
IF sy-mandt EQ '300'.
path = '/statd40/'.
ENDIF.
CONDENSE path.
CONCATENATE path 'BNP_SAP_SCR_STATUS_' sy-datum '.CSV' INTO dsn.
CONDENSE dsn.
OPEN DATASET dsn FOR OUTPUT IN TEXT MODE.
IF sy-subrc EQ 0.
LOOP AT it_trans INTO wt_trans.
CLEAR line.
TRANSLATE wt_trans-truxs_t_text_data USING ';,'.
MOVE wt_trans-truxs_t_text_data TO line.
TRANSFER line TO dsn.
ENDLOOP.
CLOSE DATASET dsn.
*ENDIF.
CLEAR : cmdtxt.
concatenate 'chmod 777' '/infocomm/mm/getfile' into
CONCATENATE 'chmod 777' dsn INTO
cmdtxt SEPARATED BY space.
CALL 'SYSTEM' ID 'COMMAND' FIELD cmdtxt
ID 'TAB' FIELD i_tty[].
MESSAGE i001(yw) WITH 'File is downloaded successfully'.
ENDIF.
ENDFORM. " FILE_DOWNLOAD
something like this....You can transfr the data on application server using this.
06-19-2008 7:30 AM
Hi varun follow the code it may help you.....
PARAMETERS : p_unfil LIKE rlgrap-filename DEFAULT '/temp/abc.txt'.
OPEN DATASET p_unfil FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
ig_download is the final internal table that you want to display.
LOOP AT ig_download.
TRANSFER ig_download TO p_unfil.
ENDLOOP.
CLOSE DATASET p_unfil.
ENDIF.
LOOP AT IG_DOWNLOAD.
WRITE:/ IG_DOWNLOAD-F1, IG_DOWNLOAD-F2,
IG_DOWNLOAD-F3.
ENDLOOP.
Thanks