04-26-2007 8:40 AM
please check the pgm
there is no logic behind it
iam trying to download set of data present in t_bkpf
internal table in a flat file in the mentioned directory.
just correct me wats wrong in this coding
otherwise give some simple eg like this
&----
*& Report ZPGM1_AR *
*& *
&----
*& *
*& *
&----
REPORT ZPGM1_AR .
tables: bkpf. " Accounting Document Header
*"Selection screen elements............................................
parameters:
p_burks like bkpf-bukrs. " Company Code
select-options:
s_gjahr for bkpf-gjahr. " Fiscal year
"----
Type declaration of the structure to hold Accounting Document Header*
"----
data:
begin of fs_bkpf,
bukrs type bkpf-bukrs, " Company Code
belnr type bkpf-belnr, " Accounting Document Number
gjahr type bkpf-gjahr, " Fiscal year
blart type bkpf-blart, " Document type
bldat type bkpf-bldat, " Document date in document
end of fs_bkpf.
"----
Internal table to hold Accounting Document Header *
"----
data:
t_bkpf like standard table
of fs_bkpf.
"----
Type declaration of the structure to hold file data *
"----
data:
begin of fs_table,
bukrs type bkpf-bukrs, " Company Code
belnr type bkpf-belnr, " Accounting Document Number
gjahr type bkpf-gjahr, " Fiscal year
blart type bkpf-blart, " Document type
bldat type bkpf-bldat, " Document date in document
end of fs_table.
"----
Internal table to hold file data *
"----
data:
t_table like standard table
of fs_table.
field-symbols: <fs>.
*" Data declarations...................................................
"----
Work variables *
"----
data:
w_char(50) type c,
w_file_name(50) type c value '/sapio/aru.txt'.
select bukrs " Company Code
belnr " Accounting Document Number
gjahr " Fiscal year
blart " Document type
bldat " Document date in document
UP TO 10 ROWS
from bkpf
into table t_bkpf
where bukrs eq p_burks
and gjahr in s_gjahr.
if sy-subrc eq 0.
open dataset w_file_name for output in text mode encoding default.
IF sy-subrc EQ 0 .
loop at t_bkpf into fs_table.
transfer fs_table to w_file_name.
endloop.
ENDIF .
endif. " IF SY-SUBRC...
.
04-26-2007 8:54 AM
Hi,
please use close dataset and try again.
open dataset w_file_name for output in text mode encoding default.
IF sy-subrc EQ 0 .
loop at t_bkpf into fs_table.
transfer fs_table to w_file_name.
endloop.
<b>close dataset w_file_name.</b>
ENDIF .
Kostas
Message was edited by:
Kostas Tsioubris
04-26-2007 8:56 AM
Hi,
I have highlighted the change in bold. Name would be starting with '//' and not '/'.
Also ensure that Basis has provided you authorization for that folder to download file else SAP will give an error stating 'No Authorization'.
&----
*& Report ZPGM1_AR *
*& *
&----
*& *
*& *
&----
REPORT ZPGM1_AR .
tables: bkpf. " Accounting Document Header
*"Selection screen elements............................................
parameters:
p_burks like bkpf-bukrs. " Company Code
select-options:
s_gjahr for bkpf-gjahr. " Fiscal year
"----
Type declaration of the structure to hold Accounting Document Header*
"----
data:
begin of fs_bkpf,
bukrs type bkpf-bukrs, " Company Code
belnr type bkpf-belnr, " Accounting Document Number
gjahr type bkpf-gjahr, " Fiscal year
blart type bkpf-blart, " Document type
bldat type bkpf-bldat, " Document date in document
end of fs_bkpf.
"----
Internal table to hold Accounting Document Header *
"----
data:
t_bkpf like standard table
of fs_bkpf.
"----
Type declaration of the structure to hold file data *
"----
data:
begin of fs_table,
bukrs type bkpf-bukrs, " Company Code
belnr type bkpf-belnr, " Accounting Document Number
gjahr type bkpf-gjahr, " Fiscal year
blart type bkpf-blart, " Document type
bldat type bkpf-bldat, " Document date in document
end of fs_table.
"----
Internal table to hold file data *
"----
data:
t_table like standard table
of fs_table.
field-symbols: <fs>.
*" Data declarations...................................................
"----
Work variables *
"----
data:
w_char(50) type c,
w_file_name(50) type c value <b>'//sapio/aru.txt'</b>.
select bukrs " Company Code
belnr " Accounting Document Number
gjahr " Fiscal year
blart " Document type
bldat " Document date in document
UP TO 10 ROWS
from bkpf
into table t_bkpf
where bukrs eq p_burks
and gjahr in s_gjahr.
if sy-subrc eq 0.
open dataset w_file_name for output in text mode encoding default.
IF sy-subrc EQ 0 .
loop at t_bkpf into fs_table.
transfer fs_table to w_file_name.
endloop.
ENDIF .
endif. " IF SY-SUBRC...
Best regards,
Prashant
04-26-2007 9:04 AM
I dont think the file path which you have specified is correct..
If ur Application server is Unix..then I am not sure whether u will have adirectory like "sapio" and even if you do check whether the required authorisation .. Write the return codes and message test of "OPEN DATASET" on the report list and check
cheers
Kareem
04-26-2007 9:33 AM
Hi arun,
1. Since we are using OPEN Dataset,
(and not GUI_DOWNLOAD),
the file will be downloaded to
application server (and not front-end machine)
2. Thru tcode SE11,
just check the proper path.
(the path and the filename are case-sensitive in case of unix/aix OS)
3. Just check in debugging whether sy-subrc is 0,
just after open dataset.
regards,
amit m.