Application Development 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: 

Auto Genrated File in Background

Former Member
0 Kudos

Hi Friends,

In a program I am genrating a text file in c: of my desktop. Now the requirement is to schedule the same program in background and to genrate the files automatically somewhere. Can you please suggest, how to genrate text files from ABAP program scheduled in background and what changes I have to do in code.

KRaheja.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Krishnan,

Check this code.

Ref. from library.

Syntax

OPEN DATASET <dsn> FOR OUTPUT.

If the file does not already exist, it is created automatically. If it does already exist, but is closed, its contents are overwritten. If the file exists and is already open (for read or write access, or for appending), the position is reset to the beginning of the file. If the system can open the file <dsn> successfully, SY-SUBRC is set to 0. If not, it is set to 8.

DATA: MESS(60),
      FNAME(10) VALUE '/tmp'.

OPEN DATASET FNAME FOR OUTPUT MESSAGE MESS. 

IF SY-SUBRC <> 0.
  WRITE: 'SY-SUBRC:', SY-SUBRC,
       / 'System Message:', MESS.
ENDIF.

Much Regards,

Amuktha.

5 REPLIES 5

former_member242255
Active Contributor
0 Kudos

you can generate the files in the AL11 application server path..

what ever may be the file,you can fix some path in the AL11 and when you run the program background the files will be generated and placed in the particluar foleder specified by you...

Former Member
0 Kudos

Hi,

You cannot create a file into PC in Background Instead you can write a file into Application Server using

OPEN DATASET

CLOSE DATASET.

Thanks

Partha.

Former Member
0 Kudos

Hi,

You cannot download a file in presentation server anywhere when the program is run in background.

You can download it to the application server, you need to modify your program.

Regards,

Pankaj

Former Member
0 Kudos

Hi,

You will not be able to use GUI function modules in background. Save the file in application server.

One other way is [Communication to PresentationServer in Background Mode|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/9831750a-0801-0010-1d9e-f8c64efb2bd2]

Regards

Former Member
0 Kudos

Hi Krishnan,

Check this code.

Ref. from library.

Syntax

OPEN DATASET <dsn> FOR OUTPUT.

If the file does not already exist, it is created automatically. If it does already exist, but is closed, its contents are overwritten. If the file exists and is already open (for read or write access, or for appending), the position is reset to the beginning of the file. If the system can open the file <dsn> successfully, SY-SUBRC is set to 0. If not, it is set to 8.

DATA: MESS(60),
      FNAME(10) VALUE '/tmp'.

OPEN DATASET FNAME FOR OUTPUT MESSAGE MESS. 

IF SY-SUBRC <> 0.
  WRITE: 'SY-SUBRC:', SY-SUBRC,
       / 'System Message:', MESS.
ENDIF.

Much Regards,

Amuktha.