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

Error Log unusable

Former Member
0 Likes
1,299

I am creating an error log using open dataset but I am unable to open it. The usable status is not marked X. The file length is more than 0 though. What could the problem be?

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,275

Post your code.

Regards

RIch Heilman

12 REPLIES 12
Read only

Former Member
0 Likes
1,275

hi,

I guess you are not having authorizations provided ...

Regards,

Santosh

Read only

Former Member
0 Likes
1,275

I have created other text files in the folder so i dont think permissions should be an issue

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,276

Post your code.

Regards

RIch Heilman

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,275

Your coding should be simular to this.



report zrich_0001.

Parameters: d1 type localfile default '/usr/sap/TST/SYS/Data1.txt'.

data: itab type table of string.
data: wa type string.


start-of-selection.

wa = 'This is an error'.        append wa to itab.
wa = 'This is another error'.   append wa to itab.
wa = 'This could be an error'.  append wa to itab.


* Update file
  open dataset d1 for output in text mode encoding DEFAULT.
  loop at itab into wa.
    transfer wa to d1.
  endloop.
  close dataset d1.


Regards,

Rich Heilman

Read only

Former Member
0 Likes
1,275

Here is a snippet.

DATA:   errorlog            TYPE string
                            VALUE '/interfaces/DA1/ErrorLog.txt',

v_header           = '******* CREDIT CHECK ERROR LOG *******'.
v_timestamp        = 'Created On'.

* Write to ErrorLog
OPEN DATASET errorlog FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

      TRANSFER v_header          TO errorlog.
      TRANSFER v_t_timestamp     TO errorlog.
      TRANSFER ''                TO errorlog.

CLOSE DATASET errorlog.

Message was edited by:

Megan Flores

Read only

0 Likes
1,275

Hi,

try the following:

data: os(200).

OPEN DATASET errorlog FOR OUTPUT IN TEXT MODE ENCODING DEFAULT
  message os.

write os.
stop.

And then see, what the Operating System tells you.

Martin

Message was edited by:

Martin Pfeiffer

Read only

ferry_lianto
Active Contributor
0 Likes
1,275

Hi,

Please check the SY-SUBRC.


* Write to ErrorLog
OPEN DATASET errorlog FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.  

IF SY-SUBRC = 0.  
  TRANSFER v_header          TO errorlog.
  TRANSFER v_t_timestamp     TO errorlog.
  TRANSFER ' '               TO errorlog. 
ELSE.
  WRITE: / 'FILE COULD NOT BE OPENED.'.
ENDIF. 

CLOSE DATASET errorlog.

Regards,

Ferry Lianto

Read only

0 Likes
1,275

What do you mean by.....

<i>still is creating the file as unusable.</i>

Regards,

Rich Heilman

Read only

Former Member
0 Likes
1,275
FOR INPUT

opens the file for reading. I need to write to the file

Read only

Former Member
0 Likes
1,275

I tried changing that but it still is creating the file as unusable.

Read only

Former Member
0 Likes
1,275

the file properties are

usable

viewed

changed

the usable is not marked X

I am going to create another filename instead. Lets see if that works.

Read only

Former Member
0 Likes
1,275

That did it .. I changed the name of the error log file and now its opening up. Not sure what the issue was. Thanks for your help guys.