ABAP--SAP的SYSTEM的函数列表和代码示例

This chapter contains functions that could be associated with BASIS type of operations, such
as finding the IP address of a terminal and opening FTP sessions.
ABAP4_CALL_TRANSACTION
Summary
Initiates a transaction in a separate window.
Description
Basically a wrapper to CALL TRANSACTION. Within an ABAP program, this will start
an additional transaction. The normal rules of authorisation to run the transaction naturally
still apply.
Parameters
EXPORTING
TCODE Contains the transaction code to be called.
SKIP_SCREEN If set, will skip the first screen of the transaction.
MODE_VAL Display mode:
Value Meaning
A (default) Display the screens
E Only display screens if an error occurs
N Do not display (background mode)
UPDATE_VAL Update mode:
Value Meaning
A (default) Asynchronous update
S Synchronous update
L Local update
TABLES
USING_TAB BDC data for the transaction
SPAGPA_TAB Holds SPA/GPA parameters to fill input fields
MESS_TAB Contains any error messages from the transaction
2 Common SAP R/3 Functions Manual
Example
REPORT ZEXAMPLE.
DATA: BEGIN OF IMESS OCCURS 0.
INCLUDE STRUCTURE BDCMSGCOLL.
DATA: END OF IMESS.
CALL FUNCTION ‘ABAP4_CALL_TRANSACTION’ STARTING NEW TASK ‘ZTSK’
EXPORTING
TCODE = ‘SE38’ “START ABAP DEVELOPMENT
TABLES
MESS_TAB = IMESS
EXCEPTIONS
CALL_TRANSACTION_DENIED = 1
TCODE_INVALID = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
LOOP AT IMESS.
WRITE:/IMESS-MSGV1,
IMESS-MSGV2,
IMESS-MSGV3.
ENDLOOP.
ENDIF.
See Also
HLP_MODE_CREATE, TH_REMOTE_TRANSACTION, TRANSACTION_CALL
ARFC_GET_TID
Summary
Returns the IP address of the server in hexadecimal.
Description
The IP address is returned from the function in hexadecimal, so this should be formatted to
the normal dotted notation of an IP address before being displayed to the user. The example
will do this for you.
Parameters
IMPORTING
TID Contains the IP address of the user’s computer that runs the function.
Example
REPORT ZEXAMPLE.
DATA: TERM_IP LIKE ARFCTID,
IP_ADDR(20) TYPE C,
IP_BIT(3) TYPE C,
HOSTADDR(4) TYPE X,
HEX_CHAR TYPE X,
HADDR_X(8) TYPE X,
IP_LEN TYPE I,
HEXIP_LEN TYPE I VALUE 0,
HEXIP TYPE I,
CHAR_HEX TYPE I.
CALL FUNCTION ‘ARFC_GET_TID’
IMPORTING
TID = TERM_IP.
HOSTADDR = TERM_IP(8).
HADDR_X = HOSTADDR.
DESCRIBE FIELD HOSTADDR LENGTH HEXIP_LEN.
HEXIP_LEN = HEXIP_LEN – 1.
DO HEXIP_LEN TIMES.
HEX_CHAR = HADDR_X + HEXIP(1).
CHAR_HEX = HEX_CHAR.
IP_BIT = CHAR_HEX.
CONDENSE IP_BIT.
IP_LEN = STRLEN(IP_ADDR).
IP_ADDR + IP_LEN = IP_BIT.
IP_LEN = STRLEN(IP_ADDR).
IP_ADDR + IP_LEN = ‘.’.
HEXIP = HEXIP + 1.
ENDDO.
HEX_CHAR = HADDR_X + HEXIP(1).
CHAR_HEX = HEX_CHAR.
IP_BIT = CHAR_HEX.
CONDENSE IP_BIT.
IP_LEN = STRLEN(IP_ADDR).
IP_ADDR + IP_LEN = IP_BIT.
WRITE:/ ‘SERVER IP ADDRESS IS:’, IP_ADDR.
See Also
TERMINAL_ID_GET, TH_USER_INFO
AUTHORITY_CHECK_DATASET
Summary
Checks file access authorisation.
Chapter 1 • System 3
4 Common SAP R/3 Functions Manual
Description
This function module allows you to check the user’s authorisation to access files (with commands
OPEN DATASET, READ DATASET, TRANSFER and DELETE DATASET). A check
should be performed before opening a file. This function is well documented.
Parameters
EXPORTING
PROGRAM Program containing file access command (default: current program)
ACTIVITY Access type required to file:
Value Meaning
READ Read file
WRITE Change file
READ_WITH_FILTER Read file with filter function
WRITE_WITH_FILTER Change file with filter function
DELETE Delete file
FILENAME Name of accessed file
Example
REPORT ZEXAMPLE.
DATA: BEGIN OF ITAB OCCURS 0,
ATYPE(20),
END OF ITAB.
PARAMETER P_FNAME LIKE AUTHB-FILENAME.
PARAMETERS:P_READ AS CHECKBOX DEFAULT ‘X’,
P_WRITE AS CHECKBOX DEFAULT ‘X’,
P_RWF AS CHECKBOX DEFAULT ‘X’,
P_WWF AS CHECKBOX DEFAULT ‘X’,
P_DELETE AS CHECKBOX DEFAULT ‘X’.
CLEAR: ITAB, ITAB[].
IF P_READ EQ ‘X’.
ITAB-ATYPE = ‘READ’.
APPEND ITAB.
ENDIF.
IF P_WRITE EQ ‘X’.
ITAB-ATYPE = ‘WRITE’.
APPEND ITAB.
ENDIF.
IF P_RWF EQ ‘X’.
ITAB-ATYPE = ‘READ_WITH_FILTER’.
APPEND ITAB.
ENDIF.
IF P_WWF EQ ‘X’.
ITAB-ATYPE = ‘WRITE_WITH_FILTER’.
APPEND ITAB.
ENDIF.
IF P_DELETE EQ ‘X’.
ITAB-ATYPE = ‘DELETE’.
APPEND ITAB.
ENDIF.
LOOP AT ITAB.
CALL FUNCTION ‘AUTHORITY_CHECK_DATASET’
EXPORTING
ACTIVITY = ITAB-ATYPE
FILENAME = P_FNAME
EXCEPTIONS
NO_AUTHORITY = 1
ACTIVITY_UNKNOWN = 2
OTHERS = 3.
CASE SY-SUBRC.
WHEN 0.
WRITE:/ ‘You have’, ITAB-ATYPE, ‘access to’, P_FNAME.
WHEN 1.
WRITE:/ ‘You do not have’, ITAB-ATYPE, ‘access to’, P_FNAME.
WHEN OTHERS.
WRITE:/ ‘Error with function’.
ENDCASE.
ENDLOOP.
BP_EVENT_RAISE
Summary
Triggers an event in the background-processing system from an ABAP program.
Description
Events let you start background jobs under defined conditions. The event IDs are defined in
transaction SM62 (event arguments are specified when the job is scheduled).
When you define a new event, a transport request must be manually created if it is to be
transported to another system.
Parameters
EXPORTING
EVENTID The event name, defined in SM62
EVENTPARM Job can be scheduled to wait for an EVENTID or combination of EVENTID
and EVENTPARM
Example
REPORT ZEXAMPLE.
DATA: Q_EVENT LIKE TBTCJOB-EVENTID VALUE ‘SAP_QEVENT’,
Q_EVENTPARM LIKE TBTCJOB-EVENTPARM.
Chapter 1 • System 5
6 Common SAP R/3 Functions Manual
CALL FUNCTION ‘BP_EVENT_RAISE’
EXPORTING
EVENTID = Q_EVENT
EVENTPARM = Q_EVENTPARM
EXCEPTIONS
BAD_EVENTID = 1
EVENTID_DOES_NOT_EXIST = 2
EVENTID_MISSING = 3
RAISE_FAILED = 4
OTHERS = 5.
IF SY-SUBRC NE 0.
WRITE:/ ‘EVENT’, Q_EVENT, ‘NOT RAISED’.
ELSE.
WRITE:/ ‘EVENT’, Q_EVENT, ‘RAISED SUCCESSFULLY’.
ENDIF.
See Also
GET_JOB_RUNTIME_INFO
CAT_CHECK_RFC_DESTINATION
Summary
Checks for the RFC destinations and connections on a client.
Description
RFC destinations are defined within SAP using transaction code SM59.
Parameters
EXPORTING
RFCDESTINATION System to be tested
IMPORTING
MSGV1 RFC message
MSGV2 RFC message
RFC_SUBRC RFC return code
Example
REPORT ZEXAMPLE.
DATA: RFCDESTINATION LIKE RSCAT-RFCDEST,
V_MSGV1 LIKE SY-MSGV1,
V_MSGV2 LIKE SY-MSGV2,
V_SUBRC LIKE SYST-SUBRC.
CALL FUNCTION ‘CAT_CHECK_RFC_DESTINATION’
EXPORTING
RFCDESTINATION = RFCDESTINATION
IMPORTING
MSGV1 = V_MSGV1
MSGV2 = V_MSGV2
RFC_SUBRC = V_SUBRC.
IF V_SUBRC NE 0.
WRITE:/ ‘ERROR:’, V_MSGV1, V_MSGV2.
ELSE.
SET PARAMETER ID ‘RFC’ FIELD RFCDESTINATION.
WRITE:/ ‘CONNECTION TO’, RFCDESTINATION, ‘IS WORKING’.
ENDIF.
See Also
CAT_PING, TH_SERVER_LIST
CAT_PING
Summary
Checks RFC system and configuration.
Description
Tests if an RFC system is reachable and returns configuration data if possible.
Parameters
EXPORTING
RFCDESTINATION System to be tested
IMPORTING
SYSINFO Structure with RFC system configuration information
Example
REPORT ZEXAMPLE.
DATA: BEGIN OF SYSINFO.
INCLUDE STRUCTURE CATFR.
DATA: END OF SYSINFO.
DATA RFC_DESTINATION LIKE RFCDES-RFCDEST.
SYSINFO = SPACE.
CALL FUNCTION ‘CAT_PING’ DESTINATION RFC_DESTINATION
IMPORTING
SYSINFO = SYSINFO
Chapter 1 • System 7
8 Common SAP R/3 Functions Manual
EXCEPTIONS
COMMUNICATION_FAILURE = 1
SYSTEM_FAILURE = 2.
IF SY-SUBRC NE 0.
WRITE:/ ‘COULD NOT CONNECT TO’, RFC_DESTINATION.
ELSE.
WRITE:/ SYSINFO.
ENDIF.
See Also
CAT_CHECK_RFC_DESTINATION
DEQUEUE_ES_PROG
Summary
Releases program locks.
Description
This function releases a lock in a program that has been set by ENQUEUE_ES_PROG.
Parameters
EXPORTING
NAME Program name to lock
Example
REPORT ZEXAMPLE.
DATA V_PGM TYPE PROGRAMM.
CALL FUNCTION ‘DEQUEUE_ES_PROG’
EXPORTING
NAME = V_PGM.
WRITE:/ ‘PROGRAM’, V_PGM, ‘IS UNLOCKED’.
See Also
DEQUEUE_ESFUNCTION, ENQUEUE_ES_PROG
ENQUEUE_ES_PROG
Summary
Prevents the parallel execution of a program.
Description
This function creates a lock in a program that should not be processed more than once, simultaneously.
The lock remains in place until either the DEQUEUE_ES_PROG function module
is called or the transaction is completed (with an implicit DEQUEUE_ALL call).
Parameters
EXPORTING
NAME Program name to lock
SCOPE Controls how the lock is passed to the update program:
Value Meaning
1 The lock is not passed to the update program. The lock
is removed when the transaction ends.
2 (default) The lock is passed to the update program. The update
program is responsible for removing the lock.
3 The lock is passed to the update program. The lock must
be removed in both the interactive program and in the
update program.
Example
REPORT ZEXAMPLE.
DATA V_PGM TYPE PROGRAMM.
CALL FUNCTION ‘ENQUEUE_ES_PROG’
EXPORTING
NAME = V_PGM
SCOPE = ‘3’
EXCEPTIONS
FOREIGN_LOCK = 1
SYSTEM_FAILURE = 2
OTHERS = 3.
IF SY-SUBRC NE 0.
WRITE:/ ‘LOCK FAILED ON PROGRAM ZPROGRAM’.
ELSE.
WRITE:/ V_PGM, ‘SUCCESSFULLY LOCKED AGAINST SIMULTANEOUS PROCESSING’.
ENDIF.
See Also
DEQUEUE_ES_PROG, ENQUEUE_ESFUNCTION
FTP_COMMAND
Summary
Executes a command on an FTP server.
Chapter 1 • System 9
10 Common SAP R/3 Functions Manual
Description
Passes an FTP command to an FTP server for processing.
Parameters
EXPORTING
HANDLE Unique ID identifying FTP session (from FTP_CONNECT)
COMMAND Any FTP command. For example, DIR lists files in a directory
TABLES
DATA Results from FTP command. For example, f

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值