当前位置:网站首页>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.
边栏推荐
猜你喜欢
【面试高频题】可逐步优化的链表高频题
1小时直播招募令:行业大咖干货分享,企业报名开启丨量子位·视点
【Adobe Premiere Pro 2020】pr2020安装和基本操作【PR安装、新建项目流程、导入及管理素材项目文件、添加标记、创建出入点剪辑视频、快速剪接及自动音乐卡点的方法
Programmer's Exclusive Romance - Use 3D Engine to Realize Fireworks in 5 Minutes
报告:想学AI的学生数量已涨200%,老师都不够用了
用皮肤“听”音乐,网友戴上这款装备听音乐会:仿佛住在钢琴里
Shell之常用小工具(sort、uniq、tr、cut)
软件测试——金融测试类面试题,看完直接去面试了
无需精子卵子子宫体外培育胚胎,Cell论文作者这番话让网友们炸了
阻塞、非阻塞、多路复用、同步、异步、BIO、NIO、AIO 一锅端
随机推荐
Nature:猪死亡1小时后,器官再次运转
Scala 高阶(七):集合内容汇总(上篇)
PM2 configuration file
【Adobe Premiere Pro 2020】pr2020安装和基本操作【PR安装、新建项目流程、导入及管理素材项目文件、添加标记、创建出入点剪辑视频、快速剪接及自动音乐卡点的方法
Byte Qiu Zhao confused me on both sides, and asked me under what circumstances would the SYN message be discarded?
数字化转型之支撑保障单元
水能自发变成“消毒水”,83岁斯坦福教授:揭示冬天容易得流感的部分原因...
The redis library cannot be imported
【面试高频题】可逐步优化的链表高频题
从零开始Blazor Server(9)--修改Layout
二重指针-char **、int **的作用
proto3-2语法
Two ways to enter the Oracle database
防止数据冒用的方法
ABAP 面试题:如何使用 ABAP 编程语言的 System CALL 接口,直接执行 ABAP 服务器所在操作系统的 shell 命令?
修改VOT2018.json文件,去掉图片路径中的color
李开复花上千万投的缝纫机器人,团队出自大疆
ThreadLocal的简单理解
阿里云新增三大高性能计算解决方案,助力生命科学行业快速发展
京东架构师呕心整理:jvm与性能调优有哪些核心技术知识点