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

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.


this works in 4.6B:

        CONCATENATE 'chmod ugo=rw ' lc_filename
          INTO lc_chmod SEPARATED BY space.
        CALL 'SYSTEM' ID 'COMMAND' FIELD lc_chmod.

Hope this helps.

Cheers, Heiko

Tags:

Unix

Abap