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

How to create sap directories in application server by coding.

Former Member
0 Likes
6,782

Hi Experts,

Please tell me how to create a sap directory via coding in application server.

Please tell me step by step n send the code also.I have tried alot using FM 'SXPG_COMMAND_EXECUTE' but i dont know how to use it n wht are d parameters i need to pass.

Also, i found that we need to create a external command in SM69 to pass in this FM...i dont know how to create this.

Please help me out.

1 ACCEPTED SOLUTION
Read only

awin_prabhu
Active Contributor
4,778

Hi friend,

1. Goto to Transaction SM69.

2. Click on F5.

3. Click on F6.

4. Enter a name in Command Name box ex: z_com

5. Enter a os command in Operating system command box. ex: mkdir (creating a directory)

6. Give location in application server in Parameters for operating system command box ex: /C dir

7. Click Save.

Goto SE 38 and develop a report using FM 'SXPG_COMMAND_EXECUTE' .

Ex:

REPORT zawi_demodownload .

data: g_out like BTCXPM occurs 0,

z_com type SXPGCOLIST-NAME value 'mkdir'.

CALL FUNCTION 'SXPG_COMMAND_EXECUTE'

EXPORTING

commandname = z_com

TABLES

exec_protocol = g_out

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.

IF sy-subrc = 0.

.......

ENDIF.

Thanks.......

Hi Experts,

Please tell me how to create a sap directory via coding in application server.

Please tell me step by step n send the code also.I have tried alot using FM 'SXPG_COMMAND_EXECUTE' but i dont know how to use it n wht are d parameters i need to pass.

Also, i found that we need to create a external command in SM69 to pass in this FM...i dont know how to create this.

Please help me out.

10 REPLIES 10
Read only

viquar_iqbal
Active Contributor
4,778

Hi

You must use SM69 to define operating system command. For example ZMKDIR and then the operating system command would be mkdir. You would have to check the box additional parameters allowed.

The from your ABAP program you can call function module SXPG_COMMAND_EXECUTE passing the command ZMKDIR and the path.

Hope this helps.

Thanks

Viquar Iqbal

Read only

0 Likes
4,778

can u gimme a complete program code.I am askin this bcoz i have tried this earlier bt its not working.May be i am not passing the right values.Please if u gimme me, dat will be a gr8 help.

Read only

0 Likes
4,778

if you are system is a Unix based system.. the command in SM69 would be

mkdir --- create directory

The commands keep changing as per your server Operating system.. and the command can be executed using the FM you already have it.

Read only

Former Member
0 Likes
4,778

Why do you want to do that?

Ask your BASIS consultant for that directory.

He will gladly do it for you. Besides, there are so many things involved, that I would not recommend to try to do it in ABAP at all. Especially, since you cannot be sure that the OS-level SAP user has the authority to create directories where you want them to be created.

Christian

Read only

0 Likes
4,778

If you know the answer , please gimme the asnwer.

Read only

awin_prabhu
Active Contributor
4,779

Hi friend,

1. Goto to Transaction SM69.

2. Click on F5.

3. Click on F6.

4. Enter a name in Command Name box ex: z_com

5. Enter a os command in Operating system command box. ex: mkdir (creating a directory)

6. Give location in application server in Parameters for operating system command box ex: /C dir

7. Click Save.

Goto SE 38 and develop a report using FM 'SXPG_COMMAND_EXECUTE' .

Ex:

REPORT zawi_demodownload .

data: g_out like BTCXPM occurs 0,

z_com type SXPGCOLIST-NAME value 'mkdir'.

CALL FUNCTION 'SXPG_COMMAND_EXECUTE'

EXPORTING

commandname = z_com

TABLES

exec_protocol = g_out

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.

IF sy-subrc = 0.

.......

ENDIF.

Thanks.......

Read only

0 Likes
4,778

Thanks buddy...but still its not working...i think we r very close....whn am debugging the FM, sy-subrc is 2 after pressing F6.....please check this out....

Read only

0 Likes
4,778

>

>sy-subrc is 2 after pressing F6.....please check this out....

EXCEPTIONS

COMMAND_NOT_FOUND = 2

The initial steps might have not been properly execution.. create a command and them call that same command thru FM... sy-subrc 2 is bcoz its not able to find the command you created...

Read only

Former Member
0 Likes
4,778

closed

Read only

0 Likes
4,778

Hi,

I am having the same problem please let me know how to solved it.

Regards,

Nee