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: 

file genration problem in backgroud job

Former Member
0 Kudos
143

Hello all

I am running an ABAP report in background which creates an CSV file on a application server..running it in background is not creting any file.Even I have tried with local file location instead of server ..the result is same.In foreground the result is fine,,,pls suggest

Thanks

Vipin

14 REPLIES 14

Former Member
0 Kudos
96

Vipin,

If you are using WS_DOWNLOAD, GUI_DOWNLOAD functions these will not work in the background mode. Make sure you are using OPEN DATASET.

Regards,

Ravi

Note : Please reward the posts that help you.

0 Kudos
96

yes i m using the WS_DOWNLOAD after that OPEN DATASET for transfering the data in file as you have also written.

Thanx

Vipin

0 Kudos
96

Vipin,

I am clear what exactly are you doing. If you using WS_DOWNLAD it will not even get executed. Make sure you are using OPEN DATASET only.

If you can post the code here, that will help.

Regards,

Ravi

0 Kudos
96

Hi Vipin,

As already mentioned WS_DOWNLOAD is not supported in background jobs

0 Kudos
96

HI vipin

try this code

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = 'D:\Personal\material.txt'

  • FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

DATA_TAB = RECORD

  • EXCEPTIONS

  • FILE_OPEN_ERROR = 1

  • FILE_READ_ERROR = 2

  • NO_BATCH = 3

  • GUI_REFUSE_FILETRANSFER = 4

  • INVALID_TYPE = 5

  • NO_AUTHORITY = 6

  • UNKNOWN_ERROR = 7

  • BAD_DATA_FORMAT = 8

  • HEADER_NOT_ALLOWED = 9

  • SEPARATOR_NOT_ALLOWED = 10

  • HEADER_TOO_LONG = 11

  • UNKNOWN_DP_ERROR = 12

  • ACCESS_DENIED = 13

  • DP_OUT_OF_MEMORY = 14

  • DISK_FULL = 15

  • DP_TIMEOUT = 16

  • OTHERS = 17

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

open dataset V_DATA FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

LOOP AT RECORD.

TRANSFER RECORD TO V_DATA.

ENDLOOP.

CLOSE DATASET V_DATA.

WRITE: /10 'SUCCESSFULLY WRITTEN IN THE APPLICATION SERVER'.

regards

kishore

0 Kudos
96

hi kishore

code given by you gives error dump in log saying 'Can not

execute fronend function in background'..also

using ws_download in background with certain chenges does not creates file but creates corresponding spool request.

Pls advice

Regards & thanks

Vipin

0 Kudos
96

Vipin,

I don't know where are you getting confused. These functions cannot be executed in background.

Regards,

Ravi

0 Kudos
96

HI vipin

YOu should not use ws_download. you should only use

OPEN DATASET.

the example i show have shown is used for upload data from the presentation then save it in the internal table then save the internal table in hte application server.

for your purpose use only the OPEN DATASET to save the data to the presentation server

regards

kishore

0 Kudos
96

hi Ravi,

Kindly let me know which function can be used to create a CSV file on the server.As told by you I am already using Ws_download along with open dataset function

Thanx & regards

Vipin

0 Kudos
96

Hi,

You have to create an internal table with files seperated by comma.


DATA ds(128) VALUE 'filepath'.

DATA : BEGIN OF itab1 OCCURS 0,
  str(256),
 END OF itab1.

LOOP AT itab.
 CONCATENATE itab-field1 itab-field2 itab-field3
     INTO itab1-str SEPARATED BY ','.
 APPEND itab1.
ENDLOOP.

OPEN dataset ds FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
LOOP AT itab1.
TRANSFER itab1 TO ds.
ENDLOOP.
CLOSE dataset ds.

I have tried it out and it works. <b>Try this program...

Modify the logic to suit your needs...</b>

DATA itab LIKE TABLE OF mara WITH HEADER LINE.
DATA: BEGIN OF itab1 OCCURS 0,
        str(256),
      END OF itab1.
PARAMETERS ds(128). "Enter your file path


SELECT *
  FROM mara
  INTO TABLE itab
  UP TO 10 ROWS.

LOOP AT itab.
CONCATENATE itab-matnr itab-ernam
  INTO itab1-str SEPARATED BY ','.
APPEND itab1.
ENDLOOP.

BREAK-POINT.

OPEN dataset ds FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
LOOP AT itab1.
TRANSFER itab1 TO ds.
ENDLOOP.
CLOSE dataset ds.

Message was edited by: Wenceslaus G

Former Member
0 Kudos
96

Hi,

I guess you are using GUI_UPLOAD or GUI_DOWNLOAD.

GUI_UPLOAD or GUI_DOWNLOAD FMs are not supported in background jobs.

You can create the files in application sever Using OPEN DATASET ... TRANSFER ... etc.

Former Member
0 Kudos
96

As Ravi pointed out, first thing to check is what are you using to download to application server.

If you are already using open dataset and still you cannot download, then your problem most probably is

1) invalid directory. remember unix directories are case sensitive

2) authorization. May be you don't have the necessary authorizations to create files in this directory.

If it not either of them, then please provide us more info.

Srinivas

Former Member
0 Kudos
96

Hi Vipin,

WS_DOWNLOAD <b>cannot</b> be run in background.

You can either transfer the file to the application server using....

DATA ds(128) VALUE 'filepath'.

DATA wa LIKE LINE OF itab.

OPEN dataset ds FOR INPUT IN TEXT MODE ENCODING DEFAULT.

LOOP AT itab INTO wa.

TRANSFER itab TO ds.

ENDLOOP.

CLOSE dataset ds.

Then you can download the file manually using CG3Z transaction.

former_member188685
Active Contributor
0 Kudos
96

Hi Vipin,

did you check the filepath in al11,make sure that the file name should match exactly, and also did you check the same filepath in foreground with the same variant, ...

Regards

vijay