I ran into this problem again today, and was surprised anew that there is no script statement to get the folder path of an object. One can
move an object to a particular folder using
MOVE_OBJECT
, but there’s no equivalent
GET_OBJECT_LOCATION
or
GET_OBJECT_FOLDER_PATH
script statement to find out where it is. :smile:
Not deterred by this, I decided to adapt the into something roughly equivalent an AE script statement. Simply create an SQLI VARA object called
UC4.GET_FOLDER_PATH_OF_OBJECT.VARA_SQLI, with the following SQL statement:
select substr(path,2) as "Folder path" from
(select level
,ofs_oh_idnr_f as parent
,ofs_oh_idnr_o as child
,oh_name
,substr(oh_name,10,99)
,SYS_CONNECT_BY_PATH( substr(oh_name,10,99) , '/' ) as path
,ofs.ofs_link
from ofs, oh
where oh.oh_idnr = ofs_oh_idnr_f
and ofs_oh_idnr_o = (select oh_idnr from oh where oh_name = ?)
start with ofs_oh_idnr_f = (select oh_idnr from oh where oh_otype = 'CLNT' and oh_client = ?)
connect by prior ofs_oh_idnr_o = ofs_oh_idnr_f)
where ofs_link = 0
Set the following bind parameters:
&$ARCHIVE_KEY#
&$CLIENT#
Then, you can use this SQLI in your scripts by calling it with
GET_VAR
:
:SET &OBJECT_NAME# = "UC0.LOGIN"
:PUT_ATT ARCHIVE_KEY1 = &OBJECT_NAME#
:SET &FOLDER_PATH# = GET_VAR("UC4.GET_FOLDER_PATH_OF_OBJECT.VARA_SQLI")
:PRINT "Folder path of &OBJECT_NAME#: &FOLDER_PATH#"
The report of this script shows the result:
2016-02-12 16:58:09 - U0020408 Folder path of UC0.LOGIN: /SYSTEM/LOGINS
Note that I’ve written the SQLI VARA to pass the bind parameter for the object name via the predefined variable
&$ARCHIVE_KEY#
because Automation Engine v9 does not properly support using ordinary object variables in SQLI/SQL VARA bind parameters. AE v10 and later do not suffer from this limitation, so if you’re running v10 or later, you can just put
&OBJECT_NAME#
directly in bind parameter 1, and omit the
:PUT_ATT
statement.