如何从abap中的目录参数中获取编程文件路径? [英] How to get programatically the file path from a directory parameter in abap?

查看:333
本文介绍了如何从abap中的目录参数中获取编程文件路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

事务AL11将目录参数映射到应用程序服务器AFAIK上的文件路径。
事务AL11的麻烦在于它的程序只调用c模块,几乎没有任何trace语句或函数调用的痕迹来分析。

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:\usr\sap\IDS\DVEBMGS00\data作为输出。

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:\usr\sap\IDS\DVEBMGS00\data" as output.

This thread is about a similar topic, but it doesn't help.

其他一些人也有同样的问题,他解释得很好< a href =http://www.qnasap.com/al11-directory-parameter/ =nofollow noreferrer> here

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆