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: 

Unable to create a file in Application Server using OPEN DATASET stattement.

Former Member
0 Kudos

I am unable to create a file in Application Server using the following statement.

OPEN DATASET filename FOR OUTPUT

IN TEXT MODE ENCODING DEFAULT

MESSAGE msg.

The message I'm getting is "Permission Denied". I have checked authorisation using SU53 which says "The last authorization check was successful". Please help.

 

1 ACCEPTED SOLUTION

vamsixk
Active Participant
0 Kudos

Hi Ankit,

The Application server permissions are handled at the OS level and not captured by SU53.

Please check with Your BASIS team for the proper authorisations.

Regards,

Vamsi

17 REPLIES 17

gouravkumar64
Active Contributor
0 Kudos

Hi,

If you have proper authorization,then

Check you use close_dataset or not,see this link for details.

http://scn.sap.com/thread/1409662

Hope it will solve.

Thanks

Gourav.

himanshu_gupta13
Employee
Employee
0 Kudos

Dear Ankit,

If you want to add any file in application server then why are you going it through code, use the GOS services to create and display the files... on server... it's very useful service tool...

Go through this link... https://scn.sap.com/docs/DOC-39470 and use it, if it doesn't fulfills your requirement then revert back on this, then I will try for other thing.....

Many Thanks / Himanshu Gupta

former_member195402
Active Contributor
0 Kudos

Hi,

this issue is independent from your Application authorities.

filename is the complete filename including the pathname.

There must be writing authority in the path for the SAP system user.

Regards,

Klaus

vamsixk
Active Participant
0 Kudos

Hi Ankit,

The Application server permissions are handled at the OS level and not captured by SU53.

Please check with Your BASIS team for the proper authorisations.

Regards,

Vamsi

Former Member
0 Kudos

Yes, either your BASIS team or network administrators will need to solve this.

Former Member
0 Kudos

Yes, the BASIS team finally solved the problem by set the permissions of the directory

Former Member
0 Kudos

Hi Ankit,

In usual case,

CONCATENATE p_dir1 '\LOG\' sy-datum '_' sy-uzeit '_' p_file1 INTO lv_logfile.

OPEN DATASET lv_logfile FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.



should work. Are you able to create file in application server manually ?

Make sure that the file location is appropriate.

0 Kudos

Hi Nivedita,

Thanks for your suggestion. The file path is appropriate. And I also tried creating file in Application server using the T-code EG3Z, but there also I got the error "cannot open file <filename>" although I was able to overwrite existing files at the same location using the same T-Code.

Former Member
0 Kudos

Hi,

I think that your issue is caused by a missing authorization to write a file on the application server.

Please, verify with your basis team.

Cheers

Ivan

Former Member
0 Kudos

You can use following code to capture the error.

TRY.

      OPEN DATASET filename FOR OUTPUT IN BINARY MODE MESSAGE V_MSG.

      CATCH CX_ROOT
      INTO EXCEPTION.

      CALL METHOD O_EXCEPTION ->IF_MESSAGE~GET_TEXT
        RECEIVING
        RESULT = V_MSG.

      MESSAGE v_msg
      TYPE 'E'.

ENDTRY.

You can capture error in v_msg.

Following are the exceptions for the same:

Exceptions

Catchable Exceptions

CX_SY_FILE_OPEN

  • Cause: The file is already open.
    Runtime Error: DATASET_REOPEN

  CX_SY_CODEPAGE_CONVERTER_INIT   

  • Cause: The desired conversion is not supported. (Due to specification of invalid code page or of language not supported in the conversion, with SET LOCALE LANGUAGE.)
    Runtime Error: CONVT_CODEPAGE_INIT

CX_SY_CONVERSION_CODEPAGE

  • Cause: Internal error in the conversion.
    Runtime Error: CONVT_CODEPAGE

CX_SY_FILE_AUTHORITY

  • Cause: No authorization for access to file
    Runtime Error: OPEN_DATASET_NO_AUTHORITY
  • Cause: Authorization for access to this file is missing in OPEN DATASET with addition FILTER.
    Runtime Error: OPEN_PIPE_NO_AUTHORITY

  CX_SY_PIPES_NOT_SUPPORTED   

  • Cause: The operating system does not support pipes.
    Runtime Error: DATASET_NO_PIPE

CX_SY_TOO_MANY_FILES

  • Cause: Maximum number of open files exceeded.
    Runtime Error: DATASET_TOO_MANY_FILES   Non-Catchable Exceptions   
    • Cause: An attempt was made to open a pipe that is already open.
      Runtime Error: DATASET_PIPE_POSITION

Hope that will help you.

Please reward if useful.

gops249
Explorer
0 Kudos

Hi Ankit,

Ask your basis person to check the authorization for the directory where you are writing the file. The directory should have 'WRITE' permission for the following user.

  1. <SID>adm
  2. SAPService<SID>

Hope this will solve your problem.

Regards,

Gopi.

Former Member
0 Kudos

Gopi,

Thanks for you Suggestion. User <SID>adm has WRITE permission and there's no user SAPService<SID> in the Unix Systems. But the problem is still there.

Former Member
0 Kudos

I am not sure if you have done the following debugging steps.

  • Write the file to a different directory.
  • Check out the directory permissions.
  • Check if there is a file already existing with a similar name created by a different user id.
  • Ask the basis to create a file, change and delete from the os level using the <SID>adm id.
  • Last but not the least, banging your keyboard or shaking your monitor violently will do the trick.

0 Kudos

Hi @Ankit Shaw,

So you have denied 2-3 possibilities,which was given by us .

Did You check CLOSE_DATASET?

Show us your code portion.

Thanks

Gourav.

Former Member
0 Kudos

Hi Vikas,

Please note the following points with respect to your suggestions:

  • I am able to write files in some other directories. But I have to write files in the same directory.
  • The Basis guy says I do have the permissions
  • There's no such file already present in the given directory
  • The Basis team already created a file in the directory from the os level using the <SID>adm id. Interestingly, I am able to read and even write/overwrite the file using standard T-Code CG3Z. It's just that am unable to create any file even using the same T-Code.
  • Thats not funny... although I liked it. But, I need help seriously.

vamsixk
Active Participant
0 Kudos

Hi Ankit,

Then PLease Check whether the path in which you are creating your file is being properly filled out or not.  You might inadvertently be tring to create a file in some location that does not exist or you are not authorised for.

Regards,

Vamsi

Former Member
0 Kudos

Hi Gaurav,

It's not about my code only. I tried creating files using the standard T-Code EG3Z. There also I got the same message. I tried giving different file names(which are not already present in the directory) each time. So I think there's no relevance of the CLOSE_DATASET statement. Still, I'll give it a try.

Thanks

Ankit