Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set (unix) permissions when creating a file in SAP ABAP?

Tags:

unix

abap

you would think this would be obvious, but searching through documentation, SAP forums, Googling, etc., I've been spectacularly unsuccessful. I'm creating a file in ABAP on a solaris filesystem using the following code:

OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

the resulting file is owned and grouped according to a pre-defined admin user, which is fine, but the sticky wicket is that the permissions are set to 660/rw-rw----, meaning I can't examine the results. is there a way (possibly using that vaguely defined TYPE addition?) I can specify the resulting permissions on the new file?

thanks!

like image 230
wise Avatar asked Nov 10 '08 19:11

wise


People also ask

How do I give permission to a file in Unix?

To change file and directory permissions, use the command chmod (change mode). The owner of a file can change the permissions for user ( u ), group ( g ), or others ( o ) by adding ( + ) or subtracting ( - ) the read, write, and execute permissions.

How do I give permission to execution a file?

Changing File Permissions with chmod To change the file permissions using chmod, run chmod <permission> <directory or filename> , swapping in the desired file permissions and the directory or file.

What does chmod 444 do?

444 = (r-- r-- r--): owner/group/others are all only able to read the file. They cannot write to it or execute it.


1 Answers

Go to SM69, create a logical system command, you could call it ZCHMOD.

Map that command to chmod, then call with the proper parameter (man chmod on the command line is your friend).

CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
  EXPORTING
    commandname                   = 'ZCHMOD'
    additional_parameters         = l_par
    operatingsystem               = l_os
  TABLES
    exec_protocol                 = it_log
  EXCEPTIONS
    no_permission                 = 1
    command_not_found             = 2
    parameters_too_long           = 3
    security_risk                 = 4
    wrong_check_call_interface    = 5
    program_start_error           = 6
    program_termination_error     = 7
    x_error                       = 8
    parameter_expected            = 9
    too_many_parameters           = 10
    illegal_command               = 11
    wrong_asynchronous_parameters = 12
    cant_enq_tbtco_entry          = 13
    jobcount_generation_error     = 14
    OTHERS                        = 15.

Obviously, that would be a 2 step process, but it works.

like image 110
tomdemuyt Avatar answered Sep 19 '22 13:09

tomdemuyt