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

howto get the sap (application server side) root dir (function module)

Former Member
0 Likes
662


* assume sap home for ex. "C:\MiniWAS\" as implicit

DATA AS_FSYSTEM_SEPARATOR type C
VALUE '\'.



DATA AS_GET_TRIDEDSK_CMD_file type string
VALUE 'gethome.cmd'.

DATA AS_GET_TRIDEDSK_TMP_file type string
VALUE 'TRIDEDSK.tAS'.

DATA: BEGIN OF AS_TRIDEDSKREC,
        PATH(256) type C,
      END OF AS_TRIDEDSKREC.

DATA AS_TRIDEDSK_path type string.

* TOOL AS GET AS_TRIDEDSK_path ---------BEGIN


CONCATENATE AS_GET_TRIDEDSK_CMD_file INTO
AS_GET_TRIDEDSK_CMD_file SEPARATED BY AS_FSYSTEM_SEPARATOR.

CONCATENATE AS_GET_TRIDEDSK_CMD_file AS_GET_TRIDEDSK_TMP_file INTO
AS_GET_TRIDEDSK_CMD_file SEPARATED BY ' '.


OPEN DATASET AS_GET_TRIDEDSK_TMP_file FOR OUTPUT
IN TEXT MODE ENCODING DEFAULT.
CLOSE DATASET AS_GET_TRIDEDSK_TMP_file.


* FILTER[1]: this file must exist (needed by the filter option)
Open Dataset AS_GET_TRIDEDSK_TMP_file for input
     in text mode
     encoding default
filter AS_GET_TRIDEDSK_CMD_file.

CLOSE DATASET AS_GET_TRIDEDSK_TMP_file.


* FILTER[2]: read the result of the system command "echo"
Open Dataset AS_GET_TRIDEDSK_TMP_file for input
     in text mode
     encoding default.

DO.
  READ DATASET AS_GET_TRIDEDSK_TMP_file INTO AS_TRIDEDSKREC.
  IF SY-SUBRC NE 0.
    EXIT.
  ELSE.
    AS_TRIDEDSK_path = AS_TRIDEDSKREC-PATH.
  ENDIF.
ENDDO.

CLOSE DATASET AS_GET_TRIDEDSK_TMP_file.


* TOOL AS GET AS_TRIDEDSK_path -----------END

this is an example of the "gethomecmd.cmd"

called by sap (retreive the full path of sap root),

save it under the SAP ROOT (for ex. "C:\MiniWAS")

it's easy to adapt the code to any os with the

right modifications (use this as a sort of exercise)..

gethomecmd.cmd

-



rem echo %~dp0> TRIDEDSK.tAS
echo %~dp0> %1
rem echo %~dp0> TRIDEDSK.tAS
rem echo %~dp0> c:\TRIDEDSK.tAS

-


Hope this help the comunity ;.-D !

-


Michele Berardi

System Developer

http://berardimichele.interfree.it

2 REPLIES 2
Read only

Former Member
0 Likes
502

Hi Michele Berardi,

If you use the Function Module

RZL_READ_DIR_GLOBAL ,You willl get all the directories on the aplliction server.

Among those The common prex in all the paths gives you the root directory of your application server.

Hope this logic solves your probelm.

Regards,

Rama.

Read only

0 Likes
502

@Rama

as i explained in my old post:

the

RZL_READ_DIR_GLOBAL function module

consider the SAP root path as implicit...

and you don't have a way to retreive it..

i need the "Absolute Path" instead of a simple list

of "relative paths" (in case of you must pass the path

to external programs...)

this is the reason behind my workaround ...

Michele