Skip to Content
author's profile photo Former Member
Former Member

problem while downloadin in pariticular directory

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...

.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Posted on Apr 26, 2007 at 07: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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Apr 26, 2007 at 07: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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 26, 2007 at 08: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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 26, 2007 at 08: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.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.