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

Folder creation on application server

Former Member
0 Likes
6,700

Hello Everyone,


I have a requirement to create a directory on the application server through programming without BASIS Team approach.

Will it possible?.

5 REPLIES 5
Read only

pranay570708
Active Contributor
4,286

Hi Shankar,

Use function module 'BRAN_DIR_CREATE' for creating folder.

Read only

Former Member
4,286

Hi Shankar,

  • Run N2UX transaction code or RN2LN205N program.
  • Click on EDIT menu->Execute Command->Now enter mkdir /tmp_new/ Where tmp_new is the new directory.
  • If you want to create subfolder in the folder mkdir /tmp/temp_new/ Where tmp is the existing folder. temp_new is the subfolder.

Or

Use the FM which Pranay Informed.

here is the example:

1. Copy FM 'BRAN_DIR_CREATE' to a custom FM 'ZBRAN_DIR_CREATE'.

2. Change the TYPE to STRING from BRANINT-DIRNAME for import parameter DIRNAME

3. Change/Increase the length by 50 or more for the field COMMAND1 in source code line# 11.

4. Change COMMAND1+9(55) = DIRNAME. to COMMAND1+9(105) = DIRNAME.



FUNCTION ZBRAN_DIR_CREATE.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     VALUE(DIRNAME) TYPE  STRING
*"  EXCEPTIONS
*"      ALREADY_EXISTS
*"      CANT_CREATE
*"----------------------------------------------------------------------

DATA: COMMAND1(120),
       SRVNAME(20),
       BEGIN OF TABL OCCURS 0,
         LINE(200),
       END OF TABL.
DATA: BEGIN OF FILE_LIST OCCURS 0.
         INCLUDE STRUCTURE MSXXLIST.
DATA: END OF FILE_LIST.

   CLEAR FILE_LIST.
   SRVNAME = SPACE.

   CALL FUNCTION 'RZL_READ_DIR'
        EXPORTING NAME            = DIRNAME
                  SRVNAME         = SRVNAME
        TABLES    FILE_TBL        = FILE_LIST
        EXCEPTIONS NOT_FOUND      = 1
                   ARGUMENT_ERROR = 2
                   SEND_ERROR     = 3.

   IF SY-SUBRC EQ 0.
     RAISE ALREADY_EXISTS.
   ENDIF.

   COMMAND1(9)    = 'mkdir -p '.
  COMMAND1+9(105) = DIRNAME.

   CALL 'SYSTEM' ID 'COMMAND' FIELD COMMAND1
                 ID 'TAB'     FIELD TABL-*SYS*.

   CLEAR FILE_LIST.
   SRVNAME = SPACE.

   CALL FUNCTION 'RZL_READ_DIR'
        EXPORTING NAME            = DIRNAME
                  SRVNAME         = SRVNAME
        TABLES    FILE_TBL        = FILE_LIST
        EXCEPTIONS NOT_FOUND      = 1
                   ARGUMENT_ERROR = 2
                   SEND_ERROR     = 3.

   IF SY-SUBRC NE 0.
     RAISE CANT_CREATE.
   ENDIF.

ENDFUNCTION.

Read only

Sandra_Rossi
Active Contributor
0 Likes
4,286

If developers are allowed to create directories, this may become a mess in the directories, and I'm surprised that you want to bypass the administrators. At least, they should be implied in the process and agress of what is done. Maybe one day, an program will mass delete the directories, that will be fun . That's a matter of domain of responsibility that you are about to break.

Read only

0 Likes
4,286

Talking of removing directories,  I wonder if anyone will try using the function module SXPG_COMMAND_EXECUTE with a command of rm -r......

Read only

0 Likes
4,286

Hi Sandra Rossi,

                            Being a novice and lack of enough knowledge on this particular concept ,I had given a try ,Finally the issue has been solved with the help of our fellow basis team.

Regards,

Shankar