当前位置:网站首页>ABAP interview questions: how to use the System CALL interface of the ABAP programming language, direct execution ABAP server operating System's shell command?
ABAP interview questions: how to use the System CALL interface of the ABAP programming language, direct execution ABAP server operating System's shell command?
2022-08-09 13:03:00 【Wang Zixi】
Suppose we want to view the details of a certain file directory in the Linux system where the ABAP application server is installed. If you log in directly to the Linux Shell, use the `ls -l` command.
Example: `ls -l //bas/CGC5/src/krn/abap/runt`
In fact, we can use the CALL keyword provided by ABAP to initiate a call to the operating system shell command line directly at the ABAP application layer.The execution result of the latter is returned to the ABAP layer, so that ABAP application developers can perform some processing and develop some tools on this basis.
I wrote a simple ABAP report to wrap this call of the CALL keyword:
REPORT zlinux.PARAMETERS: command TYPE string LOWER CASE DEFAULT 'ls -l //bas/CGC5/src/krn/abap/runt'.DATA: commtext(120) ,itab(255) OCCURS 10 WITH HEADER LINE,lv_folder TYPE string.START-OF-SELECTION.PERFORM init.CALL 'SYSTEM' ID 'COMMAND' FIELD commtext ID 'TAB' FIELD itab[].LOOP AT itab ASSIGNING FIELD-SYMBOL().FIND REGEX '^.*\.c|^.*\.cpp|^.*\.h' IN .IF sy-subrc = 0.WRITE: / COLOR COL_NEGATIVE.DATA(lv_line) = CONV char255( ).HIDE lv_line.ELSE.WRITE: / .ENDIF.ENDLOOP.AT LINE-SELECTION.PERFORM display_source.FORM display_source.SPLIT lv_line AT space INTO TABLE DATA(lt_file).DATA(index) = lines( lt_file ).DATA(lv_file_name) = lv_folder && '/' && lt_file[ index ].DATA(lv_op) = |cat { lv_file_name } |.SUBMIT zlinux WITH command EQ lv_op.ENDFORM.FORM init.commtext = command.SPLIT commtext AT space INTO TABLE DATA(lt_table).CHECK lines( lt_table ) = 3.lv_folder = lt_table[3].ENDFORM. After execution, you can specify the Linux command to be executed, such as pwd, which is the command line for printing the current working path in Linux, that is, the meaning of Print Working Directory.
The result is /usr/sap/AG3/DVEBMGS54/work
Execute `ps -aux` to print the process details of the current operating system in ABAP:

For the syntax of CALL, you can check SAP official help [document](CALL, System Function Call - ABAP Keyword Documentation).
The CALL keyword is generally used for the internal implementation of the SAP system and cannot be used in the development of SAP ABAP applications.CALL will call the system function cfunc. You can specify a data object containing the function name for cfunc. This data object must be a Flat Character like type.
This function must be entered in the sapactab.h file.Modifying a function or creating a new one requires recompiling and linking the ABAP kernel.Hence the need to be able to access the C source code files.
边栏推荐
猜你喜欢

Ways to prevent data fraud

shell脚本------函数的格式,传参,变量,递归,数组

ABAP 报表中如何以二进制方式上传本地文件试读版

数字化转型之支撑保障单元

金融业“限薪令”出台/ 软银出售过半阿里持仓/ DeepMind新实验室成立... 今日更多新鲜事在此...

2022 Niu Ke Duo School (6) M. Z-Game on grid

Batch大小不一定是2的n次幂!ML资深学者最新结论

Common gadgets of Shell (sort, uniq, tr, cut)

Too much volume... Tencent was asked on the side that the memory was full, what would happen?

MongoDB-查询中$all的用法介绍
随机推荐
JD.com architects tidy up: what are the core technical knowledge points of jvm and performance tuning
MySQL 原理与优化,Group By 优化 技巧
ARP协议原理
WPF 实现带蒙版的 MessageBox 消息提示框
正则表达式(规则,匹配,和实际使用)
The grep command Shell regular expressions, the three musketeers
西湖大学教授怎么看AI制药革命?|量子位智库圆桌实录
FFmpeg在win10上编译安装(配置libx264)
告别手摇织布机的AI时代
"Digital Economy Panorama White Paper" Special Analysis of Banking Industry Intelligent Marketing Application Released
微信一面:一致性哈希是什么,使用场景,解决了什么问题?
腾讯欲成育碧最大股东/ 米哈游招NLP内容生成研究员/ AI发现四千余物种濒临灭绝...今日更多新鲜事在此...
放下手机吧:实验表明花20分钟思考和上网冲浪同样快乐
goalng-sync/atomic原子操作
[Microservice ~ Remote Call] Integrate RestTemplate, WebClient, Feign
The redis library cannot be imported
HAproxy: load balancing
00后写个暑假作业,被监控成这笔样
Recommend a free 50-hour AI computing platform
研发需求的验收标准应该怎么写? | 敏捷实践