如何以编程方式从abap中的目录参数获取文件路径? [英] How to get programatically the file path from a directory parameter in abap?
问题描述
事务 AL11 返回目录参数"到应用程序服务器 AFAIK 上的文件路径的映射.事务 AL11 的问题在于它的程序只调用 c 模块,几乎没有任何选择语句或函数调用的痕迹来分析.
The transaction AL11 returns a mapping of "directory parameters" to file paths on the application server AFAIK. The trouble with transaction AL11 is that its program only calls c modules, there's almost no trace of select statements or function calls to analize there.
我希望能够在我的代码中动态执行此操作,例如将DATA_DIR"作为输入并以E:usrsapIDSDVEBMGS00data"作为输出的功能模块.
I want the ability to do this dynamically, in my code, like for instance a function module that took "DATA_DIR" as input and "E:usrsapIDSDVEBMGS00data" as output.
这个线程是关于类似的主题,但没有帮助.
This thread is about a similar topic, but it doesn't help.
其他人也有同样的问题,他很好地解释了这里.
Some other guy has the same problem, and he explains it quite well here.
推荐答案
我强烈怀疑获得这些值的唯一方法是直接通过内核.其中一些可能因应用程序服务器而异,因此您可能无法在数据库中找到它们.你可以试试这个:
I strongly suspect that the only way to get these values is through the kernel directly. some of them can vary depending on the application server, so you probably won't be able to find them in the database. You could try this:
TYPE-POOLS abap.
TYPES: BEGIN OF t_directory,
log_name TYPE dirprofilenames,
phys_path TYPE dirname_al11,
END OF t_directory.
DATA: lt_int_list TYPE TABLE OF abaplist,
lt_string_list TYPE list_string_table,
lt_directories TYPE TABLE OF t_directory,
ls_directory TYPE t_directory.
FIELD-SYMBOLS: <l_line> TYPE string.
START-OF-SELECTION-OR-FORM-OR-METHOD-OR-WHATEVER.
* get the output of the program as string table
SUBMIT rswatch0 EXPORTING LIST TO MEMORY AND RETURN.
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = lt_int_list.
CALL FUNCTION 'LIST_TO_ASCI'
EXPORTING
with_line_break = abap_true
IMPORTING
list_string_ascii = lt_string_list
TABLES
listobject = lt_int_list.
* remove the separators and the two header lines
DELETE lt_string_list WHERE table_line CO '-'.
DELETE lt_string_list INDEX 1.
DELETE lt_string_list INDEX 1.
* parse the individual lines
LOOP AT lt_string_list ASSIGNING <l_line>.
* If you're on a newer system, you can do this in a more elegant way using regular expressions
CONDENSE <l_line>.
SHIFT <l_line> LEFT DELETING LEADING '|'.
SHIFT <l_line> RIGHT DELETING TRAILING '|'.
SPLIT <l_line>+1 AT '|' INTO ls_directory-log_name ls_directory-phys_path.
APPEND ls_directory TO lt_directories.
ENDLOOP.
这篇关于如何以编程方式从abap中的目录参数获取文件路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!