2007 Nov 14 10:32 PM
form dataset .
DATA:
P_FILE(2000) TYPE C VALUE 'C:AJAY.TXT'.
OPEN DATASET P_FILE FOR OUTPUT IN TEXT MODE.
*--- Display error messages if any.
IF sy-subrc NE 0.
MESSAGE e001(YABC).
EXIT.
ELSE.
*---Data is downloaded to the application server file path
LOOP AT itab2.
TRANSFER itab2 TO P_FILE.
ENDLOOP.
ENDIF.
*Close the Application server file (Mandatory).
CLOSE DATASET P_FILE.
Here in this code neither the text file is getting created nor any record is getting transferred.Plz suggest,it,s urgent.Point will be given undoubtedly.
Hi Ajaya
Your problem is trying to send to C:\. What is actually happening with open dataset is you are working on the Application Server. Speak to your BASIS person for a valid target on the app server (something like /usr/tmp/ajay.txt would work with a UNIX or LINUX server for example).
Cheers
Gareth
2007 Nov 14 10:34 PM
Use OPEN DATASET P_FILE FOR INPUT IN TEXT MODE.
first use GUI_UPLOAD to load the data to internal table
Reward if it helps,
Satish
Message was edited by:
Satish Panakala
2007 Nov 14 10:36 PM
Open dataset is for writing to a file on the application server - not on the presentation server which you are apparently wanting to do.
For this you will need to use the function module WS_DOWNLOAD
2007 Nov 14 10:46 PM
2007 Nov 14 10:37 PM
Actually you are trying to put the file on the presenation server.. and I doubt this is possible with the OPEN DATASET...
Use GUI_DOWNLOAD to download your file.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'C:AJAY.TXT'
filetype = 'DAT'
TABLES
data_tab = itab
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.
Regards,
Naimesh Patel
2007 Nov 14 10:37 PM
Hi Ajaya
Your problem is trying to send to C:\. What is actually happening with open dataset is you are working on the Application Server. Speak to your BASIS person for a valid target on the app server (something like /usr/tmp/ajay.txt would work with a UNIX or LINUX server for example).
Cheers
Gareth
2007 Nov 14 10:50 PM
1) Filename
2) Filetype
3) DATA_TAB ( The name of the internal table you want to download )
2007 Nov 15 4:51 AM
HI
refer this program where i am passing data from EXCEL to INTERNAL TABLE and Then to APPLICATION server
&----
*& Report ZSD_EXCEL_INT_APP
*&
&----
*&
*&
&----
REPORT ZSD_EXCEL_INT_APP.
parameter: file_nm type localfile.
types : begin of it_tab1,
f1(20),
f2(40),
f3(20),
end of it_tab1.
data : it_tab type table of ALSMEX_TABLINE with header line,
file type rlgrap-filename.
data : it_tab2 type it_tab1 occurs 1,
wa_tab2 type it_tab1,
w_message(100) TYPE c.
at selection-screen on value-request for file_nm.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
PROGRAM_NAME = SYST-REPID
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = ' '
STATIC = 'X'
MASK = ' '
CHANGING
file_name = file_nm
EXCEPTIONS
MASK_TOO_LONG = 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.
start-of-selection.
refresh it_tab2[].clear wa_tab2.
file = file_nm.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = file
i_begin_col = '1'
i_begin_row = '1'
i_end_col = '10'
i_end_row = '35'
tables
intern = it_tab
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
loop at it_tab.
case it_tab-col.
when '002'.
wa_tab2-f1 = it_tab-value.
when '004'.
wa_tab2-f2 = it_tab-value.
when '008'.
wa_tab2-f3 = it_tab-value.
endcase.
at end of row.
append wa_tab2 to it_tab2.
clear wa_tab2.
endat.
endloop.
data : p_file TYPE rlgrap-filename value 'TEST3.txt'.
OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
*--- Display error messages if any.
IF sy-subrc NE 0.
MESSAGE e001(zsd_mes).
EXIT.
ELSE.
*---Data is downloaded to the application server file path
LOOP AT it_tab2 INTO wa_tab2.
TRANSFER wa_tab2 TO p_file.
ENDLOOP.
ENDIF.
*--Close the Application server file (Mandatory).
CLOSE DATASET p_file.
loop at it_tab2 into wa_tab2.
write : / wa_tab2-f1,wa_tab2-f2,wa_tab2-f3.
endloop.
| User | Count |
|---|---|
| 6 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |