Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Help needed

Former Member
0 Likes
603

Hello gurus,

I have requirement like this..

The Program what has been written should run

Every day at 00:00 and the program must be executed and the result should be stored at the following location: e:\.....csv.

The output that store in the location should de in csv file

How this can be done ??

If u have sample code that would be very

helpful to me..

Waiting for your replies

senthil

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
561

Hi Senthil,

Chnadra provided some code. It is helpful to define the report.

Schedule at 00:00 the report as background job.

I hope will problem will be solved

Regards

Bhupal reddy

6 REPLIES 6
Read only

Former Member
0 Likes
561
Check this , this will convert to CSV and download to text file



TYPE-POOLS: truxs.
TYPES:
  BEGIN OF ty_Line,
    vbeln LIKE vbap-vbeln,
    posnr LIKE vbap-posnr,
  END OF ty_Line.
  ty_Lines TYPE STANDARD TABLE of ty_Line WITH DEFAULT KEY.
DATA: itab   TYPE ty_Lines.
DATA: itab1  TYPE truxs_t_text_data.

SELECT
  vbeln
  posnr
  UP TO 10 ROWS
  FROM vbap
  INTO TABLE itab.

CALL FUNCTION 'SAP_CONVERT_TO_CSV_FORMAT'
  EXPORTING
    i_field_seperator    = ';'
  TABLES
    i_tab_sap_data       = itab
  CHANGING
    i_tab_converted_data = itab1
  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.

CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
    filename = 'C:TEMPtest.txt'
  TABLES
    data_tab = itab1
  EXCEPTIONS
    OTHERS   = 1.
Read only

Former Member
0 Likes
562

Hi Senthil,

Chnadra provided some code. It is helpful to define the report.

Schedule at 00:00 the report as background job.

I hope will problem will be solved

Regards

Bhupal reddy

Read only

Former Member
0 Likes
561

the report can't be downloaded using GUI_DOWNLOAD in background.

Use OPEN DATASET AND CLOSE DATASET.

Read only

Former Member
0 Likes
561

Hi Senthil ,

For the program to run at a perticular time you will have to schedule the program to run at that time .

What is it you want to download an internal tabel of the output report.

Regards

Arun

Read only

0 Likes
561

thanx for all your replies

anymore comment on this issue

senthil

Read only

Clemenss
Active Contributor
0 Likes
561

Hi Senthil,

background jobs can not use any GUI functionality. Inbackhround there is no client and so there is no dowlnload.

Only OPEN DATASET and TRANSFER can be used to store data on a server that is directly connected to the SAP server.

I hope e:\ is a windows drive mapped to SAP system running on WINDOWS server.

Otherwise you may consider to use ftp server or send as email attachment.

[This is an addition to the gelpful comments already posted].

Regards,

Clemens