Dong.Ping 亢 亢亢龙龙龙有有有悔悔悔 2008-09 Page 1 of 328
A
A
A
B
B
B
A
A
A
P
P
P
降
降
降
龙
龙
龙
十
十
十
八
八
八
掌
掌
掌
I
I
I
B
B
B
M
M
M
A
A
A
P
P
P
D
D
D
E
E
E
V
V
V
T
T
T
e
e
e
a
a
a
m
m
m
Table of Contents
CHAPTER 1 USEFUL TRANSACTIONS 31.1 EDI SPECIFIC TRANSACTIONS---3
1.1.1 SCHEDULING AGREEMENTS... 3 1.2 MESSAGE CONTROL ---3 1.2.1 DELIVERY... 3 1.2.2 INVOICE... 3 1.2.3 ORDER RESPONSE... 3 1.2.4 IDOC ADMINISTRATION... 3 1.2.5 IDOC DEVELOPMENT... 4 1.2.6 REQUIREMENTS CODING... 4
CHAPTER 2 USEFUL PROGRAMS AND FUNCTION 5 2.1 FUNCTION MODULES ---5
2.1.1 STANDARD FUNCTION MODULE... 5
2.1.2 CUSTOM FUNCTION MODULE... 12
2.2 PROGRAMS --- 18
2.2.1 RHSOBJCH–FIXES PDCONTROL TABLES MISSING IN TX SWU3... 18
2.2.2 RV80HGEN...18
2.2.3 SCHEDULING OF SYSTEM MAINTENANCE JOBS 19 2.2.4 G/LACCOUNT LINE ITEM DISPLAY... 20
2.2.5 FI-SL:REVERSAL OF ACTUAL DOCUMENTS20 2.2.6 SET DOCUMENT SELECT PATH... 20
2.2.7 CHECK IF ALL THE CHARACTER IN A STRING ARE NUMERIC 20 2.2.8 BACKGROUND JOB SET BY PROGRAM... 21
2.2.9 DYNAMIC INTERNAL TABLE DEFINE... 22
2.2.10 INTERNAL TABLE OPTIMIZATION... 23
2.2.11 DOWNLOAD OR UPLOAD FORM... 24
2.2.12 FIND ENHANCEMENT... 24
2.2.13 FIND IMGTCODE... 28
2.2.14 DYNAMIC REFURBISH REPORT... 31
2.2.15 SMW0--WEB REPOSITORY... 34
2.2.16 ALVGROUP...34
2.2.17 SAPSCRIPT...57
2.3 INTEGRATED TRANSACTION--- 100
2.3.1 CREATE INFO TYPE...100
2.3.2 LSMW ...112
2.3.3 BADI...130
2.3.4 REPORT TREE...150
2.3.5 DIS-ACTIVE STANDARD BUTTON...152
2.3.6 SCREEN ENHANCEMENT ON MM01...153
2.3.7 QUERY...154
2.3.8 BTE ...170
2.3.9 发票校验...176
2.3.10 STEP LOOP... 180
CHAPTER 3 GENERAL PROGRAMMING 186 3.1 BAPIS --- 186
3.2 DIALOG PROGRAMMING --- 186
3.2.1 PROCESS ON VALUE REQUEST –F4 ... 186
3.3 REPORTS--- 187
3.3.1 REFRESHING DATA ON REPORTS... 187
3.3.2 TREE REPORTS... 188
3.3.3 INITIALIZING DATE RANGES ON SELECTION -OPTIONS 191 3.3.4 REPORT HEADINGS... 191
3.3.5 POPUP SELECTION –GET FILENAME... 192
3.3.6 CHECKBOXES IN REPORTS... 192
3.3.7 LIST BOXES ON SELECTION SCREENS.... 192
3.3.8 AT LINE SELECTION... 193
3.3.9 TABSTRIPS ON A SELECTION SCREEN... 193
3.3.10 DYNAMIC SELECTION SCREENS... 194
3.4 FILE PROCESSING --- 195
3.4.1 DOWNLOADING TO EXCEL... 195
3.4.2 FTP A FILE TO ANOTHER SERVER... 196
3.4.3 DATASET ... 197
3.4.4 WS_DOWNLOAD... 198
3.4.5 GUI_DOWNLOAD WITH POPUP FILENAME REQUEST 199 3.5 MACROS --- 200 3.6 SELECT STATEMENTS --- 201 3.6.1 JOINS... 201 3.6.2 FOR ALL ENTRIES... 202 3.7 GENERAL--- 203
3.7.1 RETRIEVING THE EMAIL ADDRESS OF AN SAP USER 203 3.7.2 EXECUTING A PROGRAM... 204
3.7.3 CHANGING \CREATING REQUIREMENTS. 204 3.7.4 DISPLAYING TRANSACTION... 204
3.7.5 GUI-STATUS... 204
3.7.6 DOCUMENT FLOW... 204
3.7.7 MAINTAINING TRAILING SPACES WHEN DOWNLOADING TO PC ... 205
3.7.8 HIDING ABAPSOURCE CODE... 205
3.7.9 WHERE IN IMG IS A TABLE CONFIGURED. 205 3.7.10 EDITOR TIPS (*EJECT AND *$*$) ... 205 3.7.11 LIST OF WAYS TO TRANSPORT VARIANTS 206 3.7.12 CHECKING FOR BACKGROUND PROCESSING
206
亢
亢亢龙龙龙有有有悔悔悔
4.1 VIEWING PARTICULAR USERS INBOX 207
CHAPTER 5 OBJECT PROGRAMMING 209
5.1 SAP DEMO REPORTS --- 209
5.2 TREE REPORTS --- 209
5.3 ALV GRID CONTROL--- 219
5.3.1 ADDING CUSTOM BUTTONS ON ALV GRID CONTROLS...219
5.3.2 HIGHLIGHT LINES...223
5.3.3 FIRST LINE VISIBLE...223
5.3.4 READ ONLY TEXT BOX...223
5.3.5 ENTERING TEXT...224
CHAPTER 6 IDOC PROGRAMMING 226 6.1 CREATING AN IDOC--- 226
6.2 SENDING AN IDOC--- 226
6.3 CHANGING AN IDOC --- 226
6.4 CHANGING AN IDOC’S STATUS --- 227
6.5 READING AN IDOC --- 227
6.5.1 EXAMPLE –OPEN DOCUMENT FOR READ227 6.6 DISPLAYING AN IDOC --- 228
6.7 IDOC TYPE POOL --- 228
6.8 LAUNCHING AN ERROR WORKFLOW - 228 6.9 RETURNING IDOCS LINKED TO DOCUMENTS --- 230
6.9.1 *RETURN THE LIST OF IDOCS LINKED TO THE DELIVERY 230 6.9.2 *RETURN THE LIST OF IDOCS LINKED TO THE INVOICE 230 6.9.3 VERSION 4.6X ...230
6.10 EXAMPLES --- 232
6.10.1 WRITE IDOC STATUS...232
6.10.2 BDCPROCESSING &IDOC STATUS UPDATE 232 6.10.3 MAILING IN SAP... 234
6.10.4 PROGRAM EXAMPLE –REPORT TO SHOW EDI STATUS 239 6.10.5 EXAMPLE UPLOAD FILE TO IDOC... 252
6.10.6 IDOC CREATION FROM INBOUND FILE... 259
6.10.7 LIST TRANSACTIONS... 271
6.10.8 REPORT WITH JOINS AND MACROS... 273
6.10.9 GRAPHICAL POPUP PROGRESS DISPLAY279 6.10.10 CHANGE IDOC STATUS TO ERROR STATUS AND SEND TO WORKFLOW... 280
6.10.11 REPORT TO DOWNLOAD PROGRAMS... 287
6.10.12 DISPLAY TABLE IN HTML... 296
6.10.13 TREE REPORTS... 299
6.10.14 SHELL LIST REPORT OFF A TABLE -NAST302 6.10.15 ALVREPORT... 307
6.10.16 SAPGENERATED REPORT \DIALOG PROGRAM 311 6.10.17 LIST OF TRANSACTIONS REPORT... 322
CHAPTER 7 BASIS ERRORS AND RESOLUTIONS 325 7.1 CANNOT ACTIVATE A TABLE --- 325
CHAPTER 8 TEAM CONTRIBUTE 327 8.1 GL --- 327 8.2 OF --- 327 8.3 CRM --- 327 8.4 I2 ECOMMERCE --- 327 8.5 I2 PLANNING --- 327 8.6 PE --- 327 8.7 FI--- 328 8.8 GPDP--- 328
Dong.Ping
亢
亢亢龙龙龙有有有悔悔悔 2008-09 Page 3 of 328
CHAPTER 1 USEFUL TRANSACTIONS
IDoc Development class: SED.1.1 EDI
SPECIFIC
TRANSACTIONS
VOE1 Translation between EDI categories and SD item categories VOE2 Table EDSC view. Customer link to sales area detail.
VOE3 Table view EDPVW. Add partner types that will be transferred to the IDoc. VOE4 Table view EDPAR. Link external partner number with our internal number.
OVAI Create entries for each Vendor / Partner description combination. (Vendors must match sold-to Acct. at Cust., and Partner descriptions must match ship-to Partner descriptions.) This transaction updates table T661W. SAP uses this table to determine the schedule agreement sold-to partner.
1.1.1 Scheduling agreements
OVA9 Create entries for each sold-to customer for which you will receive EDI schedule releases. At implementation, the only field that needs to be maintained is "Check PO number," which causes SAP to make sure that the PO number sent on the release matches the PO number on the schedule agreement. This transaction updates table T663A. SAP will not post an EDI schedule release, if this record is missing. OVAJ If you would like SAP to post schedule requirements using discrete dates only, instead of weekly and/or
monthly buckets, you can indicate the days of the week that you deliver to this customer. SAP will divide the customer's quantity for a week or month evenly into the days of the week specified by the distribution function code. This code must be sent in the DELINS IDoc in field E1EDP16-ETVTF.
1.2 MESSAGE
CONTROL
NACE Links to all the message control transactions via the application area
1.2.1 Delivery
V/36 Maintain output determination for deliveries (Output determination procedures) V10000 (Header output) has condition type LAVA (usually with requirement 1
NB: Use V/84 – V7ALLE – SHAD for grouped ASNs. I.e. Group deliveries into shipments VV21 Create output condition records for shipping.
LAVA – WE (Partner function) - We must add each new partner with VV21 VL71 Reissue output for deliveries
1.2.2 Invoice
V/54 Maintain access sequence for billing documents
VV31 Create condition records for billing documents. (RD00 – RE Billing party) VF31 Reissue output for billing documents
1.2.3 Order response
V/30 Sales document output types (BA00)
V/48, V/32, V/43 Maintain access sequence for sales documents
VV11 Create condition records for sales documents. (BA00 – SP Sold to party)
WE09 / WE02 IDoc lists according to content. View IDocs via specific IDoc number or business application detail contained within the contents of a segment.
WE05 View IDocs
WE60 IDoc type documentation tool
WE20 Partner profile configuration. Add partner detail together with inbound and outbound relationships. We also incorporate message control on the outbound IDocs. Utilize the organizational units to trap functional errors for further processing.
BD87 Reprocess IDocs in error or waiting for action. (Both inbound and outbound in 4.6. Use BD88 in prior versions)
1.2.5 IDoc Development
BD55 Conversion rule user exit. Link conversion rule user exit to the different system \ partner combinations. WE19 EDI test tool. Use to test inbound Function module changes.
WE31 Segment create
WE30 Create IDoc extension type
WE82 Link Release detail to Extension IDoc Type
WE57 Assign function module to logical message and IDoc type
1.2.6 Requirements coding
亢亢龙龙龙有有有悔悔悔
CHAPTER 2 USEFUL PROGRAMS AND FUNCTI
ON
2.1 FUNCTION
MODULES
2.1.1 Standard Function module
函数名称 描述 Example
SD_VBAP_READ_WITH_VBELN 根据销售订单读取表vbap 中的信息
EDIT_LINES 把READ_TEXT 返回的 LINES 中的
行按照TDFORMAT=“*”重新组织 VIEW_MAINTENANCE_CALL 维护表视图 DY_GET_FOCUS 获得屏幕焦点 DY_GET_SET_FIELD_VALUE 获得或者设置屏幕字段的值 F4IF_INT_TABLE_VALUE_REQUEST 显示检索help READ_TEXT 读取长文本 CONVERSION_EXIT_CUNIT_OUTPUT 单位转换 SJIS_DBC_TO_SBC 全角转半角 SJIS_SBC_TO_DBC 半角转换为全角 CO_R0_CHECK_DECIMAL_POINT 根据单位检查数据的小数位 POSTAL_CODE_CHECK 检查邮政编码 CONVERSION_EXIT_ALPHA_INPUT 全数字则在前面补0 GET_JOB_RUNTIME_INFO 获得job 相关信息 TERMINAL_ID_GET 获得端末id DATE_CONVERT_TO_FACTORYDATE 把输入日期转为工厂日历日期 MESSAGE_TEXT_BUILD 把消息转为文本 POPUP_TO_CONFIRM 弹出确认窗口 CONVERSION_EXIT_MATN1_INPUT 物料号码转换函数 CONVERSION_EXIT_MATN1_OUTPUT 同上相反 物料号码转换函数 SSF_FUNCTION_MODULE_NAME 根据form 名取得对应的函数名 (SmartForm) DATE_CHECK_PLAUSIBILITY 日期CHECK cl_gui_frontend_services=>gui_upload 上传到服务器 cl_gui_frontend_services=>gui_download 下载到服本地 SSF_FUNCTION_MODULE_NAME SMARTFORMS 输出报表时,生成一个函数名称,然 后CALL 这个名称 POPUP_TO_DECIDE_LIST 弹出供选择窗口 ABAP_DOCU_DOWNLOAD 以HTML 格式下载 ABAP 文档 BAL_* SAP 应用程序日志所有的函数模块 BP_EVENT_RAISE 在 ABAP/4 程序中触发一个事件
BP_JOBLOG_READ 获得job log 的执行结果
CLOI_PUT_SIGN_IN_FRONT 将负号前置, SAP 默认将负号放在 数字后面 CLPB_EXPORT 从内表导入到剪贴板 CLPB_IMPORT 从剪贴板导入内表 COMMIT_TEXT 写长文本到SAP CONVERSION_EXIT_ALPHA_INPUT 数字串前补0 CONVERSION_EXIT_ALPHA_OUTPUT 消除数字串前的0
CONVERT_OTF 将SAP 文档(SAP Script)转换成其他 Transfer SAP Script.txt
类型 DATE_GET_WEEK 返回一个日期所在的周数 DATE_CHECK_PLAUSIBILITY 检查一个日期是否是SAP 的有效格 式 DYNP_VALUES_READ 读取SCREEN 字段的值,也可以用 来读取报表SELECTION SCREEN DYNP_VALUES_UPDATE 更新屏幕字段的值 ENQUE_SLEEP 在继续处理之前等待一个指定的时间 ENQUEUE_ESFUNCTION 锁定一个ABAP 程序使它不可以被执 行 EPS_GET_FILE_ATTRIBUTES 获得文件属性 EPS_GET_DIRECTORY_LISTING 返回一个本地或网络目录的文件列表 F4_DATE 弹出一个窗口显示一个日历允许用户 选择一个日期 F4IF_SHLP_EXIT_EXAMPLE F4 接口模块 FILENAME_GET 弹出一个文件选择对话框 FTP_CONNECT 打开并登陆FTP 服务器的连接。 FTP_COMMAND 在FTP 服务器上执行一个命令。 FTP_DISCONNECT 关闭指向FTP 服务器的连接。 GET_GLOBAL_SYMBOLS 返回一个程序的tables, select
options, texts, etc 。甚至包含 selection screen 的文本定义 GET_INCLUDETAB 获得一个程序的INCLUDES 列表 WS_FILE_DELETE 删除一个文件 GUI_CREATE_DIRECTORY 在显示服务器端创建一个目录 GUI_REMOVE_DIRECTORY 从显示服务器删除一个目录 cl_gui_frontend_services=>file_delete GUI_DELETE_FILE 在显示服务器端删除一个文件 GUI_DOWNLOAD 从应用服务器下载内表到显示服务器 GUI_EXEC 调用一个文件或程序,取代了 WS_EXECUTE GUI_GET_DESKTOP_INFO 获得客户端桌面信息,取代了 WS_QUERY GUI_RUN 启动一个文件或程序 GUI_UPLOAD 从显示服务器上传文件到应用服务 器,取代了WS_UPLOAD HELP_START
为一个字段显示帮助(Useful for doing AT SELECTION SCREEN ON VALUE REQUEST for those fields that do not provide F4 help at the DDIC level)
HOLIDAY_GET 基于Factory Calendar&/ Holiday
Calendar 提供了一个节日表 INIT_TEXT 上传长文本到SAP POPUP_TO* 弹出一个对话框询问用户是否操作继 续 PRICING 获得定价条件 PROFILE_GET 从INI 文件读取一条记录 PROFILE_SET 往INI 文件写一条记录 READ_TEXT 长文本 REGISTRY_GET 从注册表读取一条记录 REGISTRY_SET 在注册表里设置一条记录 RP_CALC_DATE_IN_INTERVAL 年月日加减 Download.txt Delete.txt
亢亢龙龙龙有有有悔悔悔 RP_LAST_DAY_OF_MONTHS 获得一个月的最后一天 LAST_DAY_IN_PERIOD_GET 特殊日历的最后一天 RPY_DYNPRO_READ 读取屏幕 SXPG_COMMAND_CHECK 检查用户是否有执行某个命令的权限 TH_DELETE_USER 剔除一个用户,效果同SM04 TH_POPUP 在特定用户屏幕上显示一个系统消息 UNIT_CONVERSION_SIMPLE 衡量单位转换 WS_DOWNLOAD 将内表下载到显示服务器 WS_EXCEL 启动EXCEL WS_EXECUTE 执行一个程序 WS_MSG 显示一个对话框显示在线消息 WWW_LIST_TO_HTML 运行一个报表之后,调用这个方法将 列表输出转换成HTML SD_VBAP_READ_WITH_VBELN 根据销售订单读取表vbap 中的信息
EDIT_LINES 把READ_TEXT 返回的 LINES 中的
行按照TDFORMAT=“*”重新组织 VIEW_MAINTENANCE_CALL 维护表视图 DY_GET_SET_FIELD_VALUE 获得或者设置屏幕字段的值 F4IF_INT_TABLE_VALUE_REQUEST 显示检索help CONVERSION_EXIT_CUNIT_OUTPUT 单位转换 SJIS_DBC_TO_SBC 全角转半角 SJIS_SBC_TO_DBC 半角转换为全角 CO_R0_CHECK_DECIMAL_POINT 根据单位检查数据的小数位 POSTAL_CODE_CHECK 检查邮政编码 GET_JOB_RUNTIME_INFO 获得 job 相关信息 TERMINAL_ID_GET 获得终端 idDATE_CONVERT_TO_FACTORYDATE 把输入日期转为工厂日历日期 MESSAGE_TEXT_BUILD 读取系统消息,把消息转为文本 CONVERT_TO_LOCAL_CURRENCY 按照指定日期汇率转换金额为指定货 币类型 SSF_FUNCTION_MODULE_NAME 根据form 名取得对应的函数名 (SmartForm) DATE_CHECK_PLAUSIBILITY 检查日期合法性 CHECKcl_gui_frontend_services=>gui_upload 上传到服务器 cl_gui_frontend_services=>gui_download 下载到本地 SSF_FUNCTION_MODULE_NAME SMARTFORMS 输出报表时,生成一 个函数名称,然后CALL 这个名 DAY_IN_WEEK 通过这个日期得出那天是星期几 RP_CALC_DATE_IN_INTERVAL 用来得到将来/过去的日期的 BKK_ADD_MONTH_TO_DATE 日期的加减 GUI_CREATE_DIRECTORY 在PC 上建立文件目录 GUI_DELETE_FILE 删除PC 上的文件 GUI_DOWNLOAD 文件下载函数 GUI_EXEC 执行PC 上的程序,或者打开文件 GUI_GET_DESKTOP_INFO 得到PC 客户端的系统信息,比如操 作系统等 GUI_RUN 运行PC 程序(ShellExecute) GUI_UPLOAD 从PC 上传程序
GET_CURRENT_YEAR 得到当前的财政年(fiscal year) GET_SF_DUNN_DATA 催款函dunning letter
SAPGUI_PROGRESS_INDICATOR 显示当前运行过程
QSS0_FLTP_TO_CHAR_CONVERSION 转换科学计数为小数计数
RV_DELIVERY_PRINT_VIEW 读delivery
HU_CREATE_ITEM 将序列号写入Handling unit
KOMKBV1_FILL
USEREXIT_KOMKBV1_FILL,User exit to update communication structure at header level. In function module KOMKBV1_FILL called from SAPMV45A
MASTER_IDOC_DISTRIBUTE Application interface to the ALE layer on outbound processing side
IDOC_TYPE_COMPLETE_READ
CA-EDI: IDoc documentation tools API(Reads full IDoc structure and field documentation. Offsets, types, etc…..)
ABAP_DOCU_DOWNLOAD Download ABAP documentation in HTML format ARFC_GET_TID will return the IP address of the terminal in hex
BAL_* All function modules used for SAP's application logging can be found here
BP_EVENT_RAISE Trigger an event from ABAP/4 program BP_JOBLOG_READ Fetch job log executions
CLOI_PUT_SIGN_IN_FRONT
Place the negative sign after a number. SAP default is place the negative sign after the number.
CLPB_EXPORT Export a text table to the clipboard (on presentation server)
CLPB_IMPORT Import a Text Table from the Clipboard (on presentation server)
COMMIT_TEXT To load long text into SAP
CONVERSION_EXIT_ALPHA_INPUT converts any number into a string fill with zeroes-right
CONVERSION_EXIT_ALPHA_OUTPUT converts any number with zeroes-right into a simple integer
CONVERT_OTF Convert SAP documents (SAPScript) to other types
DATE_GET_WEEK will return the week that a date is in
DATE_CHECK_PLAUSIBILITY
Check to see if a date is in a valid format for SAP. Works well when validating dates being passed in from other systems
DOWNLOAD download a file to the presentation server (PC)
DYNP_VALUES_READ
Read the values from a dynpro. This function can be used to read the values from a report's selection screen too
DYNP_VALUES_UPDATE
Similar to DYNP_VALUES_READ, this function will allow the updating of fields on a dynpro. Very useful when you want to change a field based on the value entered for another field.
ENQUE_SLEEP Wait a specified period of time before continuing processing
ENQUEUE_ESFUNCTION Lock an abap program so that it cannot be executed. Set the parameters as follows:
EPS_GET_FILE_ATTRIBUTES Pass in a filename and a path, and will return attributes for the file
EPS_GET_DIRECTORY_LISTING
return a list of filenames from a local or network drive
F4_DATE
displays a calendar in a popup window and allows user to choose a date, or it can be displayed read only.
Progress Indicator.txt 转科学计数为小数 计数.txt Read Delivery.txt
亢亢龙龙龙有有有悔悔悔
F4IF_SHLP_EXIT_EXAMPLE documents the different reasons to use a search help exit, and shows how it is done.
FILENAME_GET popup to get a filename from a user, returns blank filename if user selects cancel
FTP_CONNECT Open a connection (and log in) to an FTP server
FTP_COMMAND Execute a command on the FTP server
FTP_DISCONNECT Close the connection (and log off) the FTP server
FORMAT_MESSAGE
Takes a message id and number, and puts it into a variable. Works better than
WRITE_MESSAGE, since some messages use $ as a place holder, and
WRITE_MESSAGE does not accommadate that, it only replaces the ampersands (&) in the message.
GET_GLOBAL_SYMBOLS
Returns a list of all tables, select options, texts, etc for a program. Even includes the text definitions for the selection screen GET_INCLUDETAB Returns a list of all INCLUDES in a program
G_SET_GET_ALL_VALUES
Fetch values from a set Function Group GRAP is now obsolete. SAP recommends using functions in function group SFES instead. Below is an overview of the changes GUI_CREATE_DIRECTORY Create a directory on the presentation server
GUI_DELETE_FILE Replaces WS_FILE_DELETE. Delete a file on the presentation server
GUI_DOWNLOAD Replaces WS_DOWNLOAD. Download table from the app server to presentation server
GUI_EXEC Replaces WS_EXECUTE. Start a File or Program Asynchronously with WinExec
GUI_GET_DESKTOP_INFO Replaces WS_QUERY. Delivers Information About the Desktop (client)
GUI_REMOVE_DIRECTORY Delete a directory on the presentation server
GUI_RUN Start a File or Program Asynchronously with ShellExecute
GUI_UPLOAD Replaces WS_UPLOAD. Upoad file from presentation server to the app server
HELP_START
Display help for a field. Useful for doing AT SELECTION SCREEN ON VALUE REQUEST for those fields that do not provide F4 help at the DDIC level.
HOLIDAY_GET Provides a table of all the holidays based upon a Factory Calendar &/ Holiday Calendar.
HR_DISPLAY_BASIC_LIST
is an HR function, but can be used for any data. You pass it data, and column headers, and it provides a table control with the ability to manipulate the data, and send it to Word or Excel. Also see the additional documentation here.
HR_GET_LEAVE_DATA Get all leave information (includes leave entitlement, used holidays/paid out holidays)
INIT_TEXT To load long text into SAP
K_WERKS_OF_BUKRS_FIND Return a list of all plants for a given company code
LIST_TO_ASCII convert an ABAP report (displayed on screen) from OTF to ASCII format
LIST_FROM_MEMORY
Retrieves the output of a report from memory when the report was executed using SUBMIT... EXPORTING LIST TO MEMORY. See also WRITE_LIST.
MONTH_NAMES_GET It returns all the month and names in repective language.
MS_EXCEL_OLE_STANDARD_OLE will build a file, and automatically start Excel
OTF_CONVERT wraps several other function modules. Will convert OTF to ASCII or PDF
CONVERT_OTFSPOOLJOB_2_PDF converts a OTF spool to PDF (i.e. Sapscript document)
CONVERT_ABAPSPOOLJOB_2_PDF convert abap spool output to PDF
POPUP_TO_CONFIRM_LOSS_OF_DATA
Create a dialog box in which you make a question whether the user wishes to perform a processing step with loss of data.
POPUP_TO_CONFIRM_STEP
Create a dialog box in which you make a question whether the user wishes to perform the step.
POPUP_TO_CONFIRM_WITH_MESSAGE
Create a dialog box in which you inform the user about a specific decision point during an action.
POPUP_TO_CONFIRM_WITH_VALUE
Create a dialog box in which you make a question whether the user wishes to perform a processing step with a particular object
POPUP_TO_DECIDE Provide user with several choices as radio buttons
POPUP_TO_DECIDE_WITH_MESSAGE
Create a dialog box in which you inform the user about a specific decision point via a diagnosis text.
POPUP_TO_DISPLAY_TEXT Create a dialog box in which you display a two-line message
POPUP_TO_SELECT_MONTH Popup to choose a month
POPUP_WITH_TABLE_DISPLAY
Provide a display of a table for user to select one, with the value of the table line returned when selected.
PRICING
Return pricing conditions in an internal table. Use structure TCOMK for parameter COMM_HEAD_1, and structure TCOMP for parameter COMM_ITEM_1, and set CALCULATION_TYPE to B. The pricing conditions will be returned in XOMV. You must fill TCOMP, and TCOMK with the appropriate values before callling the function in order for it to work.
PROFILE_GET Read an Entry in an INI File on the frontend PROFILE_SET Write an Entry in an INI File on the frontend READ_TEXT To load long text into SAP
REGISTRY_GET Read an Entry from the Registry REGISTRY_SET Set an entry in the Registry
RFC_ABAP_INSTALL_AND_RUN
Runs an ABAP program that is stored in the table PROGRAM when the MODE = 'F'. Table WRITES contains the ouput of the program. Allows you to run a program without having the source code in the target system. RH_GET_ACTIVE_WF_PLVAR Return the active HR Plan
RH_GET_DATE_DAYNAME return the day based on the date provied
RH_START_EXCEL_WITH_DATA
starts Excel with the contents of an internal table. This function finds Excel in the desktop registry. It also uses a local PC working directory to save the file (that's what the "W" value for data path flag does). Very transparent to user!
亢亢龙龙龙有有有悔悔悔
RP_CALC_DATE_IN_INTERVAL Add/subtract years/months/days from a date RP_LAST_DAY_OF_MONTHS Determine last day of month
RPY_DYNPRO_READ Read dynpro, including screen flow
RPY_TRANSACTION_READ
Given a transaction, return the program and screen or given a program and screen, return the transactions that use the program and screen.
RS_COVERPAGE_SELECTIONS
Returns an internal table that contains a formatted list of all the selection parameters entered for a report. Table is ready to print out.
RS_REFRESH_FROM_SELECTOPTIONS Get the current contents of selection screen
RS_SEND_MAIL_FOR_SPOOLLIST Send message from ABAP/4 program to SAPoffice.
RS_VARIANT_CONTENTS Returns the contents of the specified variant in a table.
RZL_SLEEP Hang the current application from 1 to 5 seconds.
RZL_SUBMIT Submit a remote report.
RZL_READ_DIR_LOCAL Read a directory on the Application Server
RZL_READ_DIR
If the server name is left blank, it reads a directory from local presentation server, otherwise it reads the directory of the remote server
RZL_READ_FILE
Read a file from the presentation server if no server name is given, or read file from remote server. Very useful to avoid authority checks that occur doing an OPEN DATASET. This function using a SAP C program to read the data.
RZL_WRITE_FILE_LOCAL
Saves table to the presentation server (not PC). Does not use OPEN DATASET, so it does not suffer from authority checks!
SAPGUI_PROGRESS_INDICATOR Display a progress bar on the SAP GUI, and give the user some idea of what is happening
SAVE_TEXT To load long text into SAP
SCROLLING_IN_TABLE
If you are coding a module pool and using a table-control, you can use this function SCROLLING_IN_TABLE to handle any scrolling. (provided by Paul Kjaer)
SD_DATETIME_DIFFERENCE Give the difference in Days and Time for 2 dates
SO_NEW_DOCUMENT_ATT_SEND_API1
Send a document as part of an email. The documentation is better than normal for this function, so please read it.
SO_SPLIT_FILE_AND_PATH Split a fully pathed filename into a filename and a path.
SO_SPOOL_READ Fetch printer spool according to the spool number informed
SO_WIND_SPOOL_LIST Browse printer spool numbers according to user informed.
SX_OBJECT_CONVERT_OTF_PDF Conversion From OTF to PDF (SAPScript conversion)
SX_OBJECT_CONVERT_OTF_PRT Conversion From OTF to Printer Format (SAPScript conversion)
SXPG_CALL_SYSTEM
you can check the user's authorization for the specified command and run the command. The command runs on the host system on which the function module is executed. The function module is RFC-capable. It can therefore be run on the host system at which a user happens to be active or on another designated host system at which an R/3 server is active.
SXPG_COMMAND_LIST_GET Select a list of external OS command definitions.
SXPG_COMMAND_DEFINITION_GET Read the definition of a single external OS command from the R/3 System's database.
SXPG_COMMAND_CHECK Check whether the user is authorized to execute the specified command on the target host system with the specified arguments.
SXPG_COMMAND_EXECUTE
Check a user's authorization to use a command, as in SXPG_COMMAND_CHECK. If the authorization check is successful, then execute the command on the target host system.
TERMINAL_ID_GET Return the terminal id
TH_DELETE_USER Logoff a user. Similar results to using SM04. TH_ENVIRONMENT Get the UNIX environment
TH_POPUP Display a popup system message on a specific users screen.
TH_REMOTE_TRANSACTION
Run a transaction on a remote server. Optionally provide BDC data to be used in the transaction
TH_USER_INFO Give information about the current user (sessions, workstation logged in from, etc)
TH_USER_LIST Show which users are logged into an app server
UNIT_CONVERSION_SIMPLE convert weights from one UOM to another. UPLOAD upload a file to the presentation server (PC)
UPLOAD_FILES Will load one or more files from app or presentation server
WRITE_LIST Useful for writing out the list contents that result from the function
WS_DOWNLOAD Save Internal Table as File on the Presentation Server
WS_EXCEL Start EXCEL on the PC
WS_EXECUTE execute a program on a windows PC WS_FILE_DELETE Delete File at the Frontend WS_FILENAME_GET Call File Selector
WS_MSG Create a dialog box in which you display an one-line message.
WS_UPLOAD Load Files from the Presentation Server to Internal ABAP Tables
WS_VOLUME_GET Get the label from a frontend device
WWW_LIST_TO_HTML After running a report, call this function to convert the list output to HTML.
2.1.2 Custom function module
2.1.2.1 DOWNLOAD_WEB_OBJECT
( Description: Download a Web Template) Sample: Download Excel module from server
亢亢龙龙龙有有有悔悔悔
DATA: w_temp_file(65), "Temp file path for excel template file.
w_formkey LIKE wwwdatatab,
w_ftemplate LIKE rlgrap-filename,
w_fdata LIKE rlgrap-filename.
w_formkey = 'MIZARR00414B'.
w_ftemplate = 'C:\TEMP\ZARR00414B.XLT'.
w_fdata = 'C:\TEMP\ZARR00414B.TXT'.
CALL FUNCTION 'DOWNLOAD_WEB_OBJECT'
EXPORTING
key = w_formkey
destination = w_ftemplate
CHANGING
temp = w_temp_file.
2.1.2.2 SO_DOCUMENT_SEND_API1
SAPoffice: Send new document with attachments using RFC
Sample:
DATA: it_user TYPE TABLE OF zdepot_mail WITH HEADER LINE,
t_time TYPE char8,
t_date TYPE char10.
DATA: doc TYPE sodocchgi1,
pack TYPE TABLE OF sopcklsti1 WITH HEADER LINE, "package
cont TYPE TABLE OF solisti1 WITH HEADER LINE, "content
recv TYPE TABLE OF somlreci1 WITH HEADER LINE. "user
* user
SELECT * INTO TABLE it_user FROM zdepot_mail.
IF it_user[] IS INITIAL.
EXIT.
ENDIF.
LOOP AT it_user .
recv-receiver = it_user-bname.
recv-rec_type = 'B'. "U-INTERNET
APPEND recv.
ENDLOOP.
* content
WRITE: sy-datum TO t_date,
sy-uzeit TO t_time.
CONCATENATE 'Global link has interfaced to SAP system at '
t_time
t_date
text-011 INTO cont-line
SEPARATED BY space.
APPEND cont.
CLEAR cont-line.
cont-line = 'Thank you.'.
APPEND cont.
* package
pack-transf_bin = space.
pack-head_start = 1.
pack-head_num = 0.
pack-body_start = 1.
pack-doc_type = 'RAW'.
DESCRIBE TABLE cont LINES pack-body_num.
APPEND pack.
* document header
doc-obj_descr = 'Interface Notification'.
* mail function
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = doc
TABLES
packing_list = pack
contents_txt = cont
receivers = recv
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8.
IF sy-subrc <> 0.
ENDIF.
亢亢龙龙龙有有有悔悔悔
2.1.2.3 ALSM_EXCEL_TO_INTERNAL_TABLE
Upload data from Excel directly Sample:
DATA: t1(255).
DATA: i_begin_col TYPE i VALUE '1', i_begin_row TYPE i VALUE '2', i_end_col TYPE i VALUE '90', i_end_row TYPE i VALUE '60000'.
DATA: i_intern LIKE alsmex_tabline OCCURS 10 WITH HEADER LINE.
DATA: i_return LIKE bapireturn1 OCCURS 10 WITH HEADER LINE.
CLEAR: txline.
WRITE 'Upload Excel file from PC,Please wait...' TO txline. write_screen: txline.
DEFINE ins_msg.
add 1 to c_err_no. check_msg-no = c_err_no.
append check_msg. clear check_msg.
c_l_error = 'X'.
END-OF-DEFINITION.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE' EXPORTING filename = p_file i_begin_col = i_begin_col i_begin_row = i_begin_row i_end_col = i_end_col i_end_row = i_end_row TABLES intern = i_intern EXCEPTIONS inconsistent_parameters = 1 upload_ole = 2 OTHERS = 3. IF sy-subrc <> 0.
CALL FUNCTION 'MESSAGE_TEXT_BUILD' EXPORTING msgid = sy-msgid msgnr = sy-msgno msgv1 = sy-msgv1 msgv2 = sy-msgv2 msgv3 = sy-msgv3 msgv4 = sy-msgv4 IMPORTING message_text_output = t1. check_msg-line = t1. ins_msg. ENDIF.
2.1.2.4 G_PERIOD_ALLOWED_CHECK
( Description: Check open posting periods,判断会计期间是否打开) SamPle:
SproÆ财务会计Æ财务会计全局设置Æ凭证Æ过帐期间Æ未清和关闭过帐期间
*All
call function 'G_PERIOD_ALLOWED_CHECK'
EXPORTING
account_type = ‘+’
company = bukrs “company code
period = P_POPER “period
periv_company = 'Z1'
record_type = '0'
to_account = ‘ZZZZZZZZZZ’ “default value
year = P_GJAHR “fiscal year
EXCEPTIONS
period_not_allowed = 1
not_authorized = 2
others = 3.
*Customer
call function 'G_PERIOD_ALLOWED_CHECK'
EXPORTING
account_type = ‘D’ “customer
company = bukrs “company code
period = P_POPER “period
periv_company = 'Z1'
record_type = '0'
to_account = ‘ZZZZZZZZZZ’ “default value
year = P_GJAHR “fiscal year
EXCEPTIONS
period_not_allowed = 1
not_authorized = 2
others = 3.
2.1.2.5 Transfer money to capital RMB
function z_convert_numeric_to_chinese.
*"--- *"*"Local interface:
*" IMPORTING
*" VALUE(PI_MONEY) LIKE BSEG-DMBTR *" EXPORTING
*" REFERENCE(PO_CHINESE) *" EXCEPTIONS
亢亢龙龙龙有有有悔悔悔 *"--- if pi_money = 0. po_chinese = '零'. exit. endif. data:money_str(13). money_str = pi_money. if money_str cn '0123456789. '. raise wrong_money. endif. data:i type i. if money_str cs '.'. i = sy-fdpos + 1. money_str+sy-fdpos = money_str+i. endif.
condense money_str no-gaps. data:units_off type i,
curnt_off type i.
data:lastd type n,curntd type n. data:cword(2),weight(2).
data:units(30) value '分角元拾佰仟万拾佰仟亿拾佰仟万', digts(20) value '零壹贰叁肆伍陆柒捌玖'.
* clear:po_chinese,units_off. lastd = 0.
curnt_off = strlen( money_str ) - 1. while curnt_off >= 0. curntd = money_str+curnt_off(1). i = curntd * 2. cword = digts+i(2). weight = units+units_off(2). i = units_off / 2.
if curntd = 0. "Current digit is 0 if i = 2 or i = 6 or i = 10. clear:cword. if curnt_off = 0. clear:weight. endif. elseif lastd = 0. clear:cword,weight. else. clear:weight. endif. endif.
concatenate cword weight po_chinese into po_chinese. lastd = curntd.
subtract 1 from curnt_off. add 2 to units_off.
endwhile.
if po_chinese ns '分'.
concatenate po_chinese '整' into po_chinese. else.
cword = po_chinese. if cword = '零'.
shift po_chinese by 2 places. endif.
endif. endfunction.
2.1.2.6 Standard function list
常见函数.xls
2.2 PROGRAMS
2.2.1 RHSOBJCH – Fixes PD Control Tables missing in tx SWU3
2.2.2 RV80HGEN
Run this program to generate custom code in to standard SAP code when you have created your own conditions using transaction V/27.
RPR_ABAP_SOURCE_SCAN - Search ABAP code for a string. Has many more options for selecting
the ABAPs to search than RSRSCAN1 or RKCTSEAR.
RSBDCDRU - Prints the contents of a Batch Input session. No options for error transactions only.
RSBDCOS0 - Execute UNIX commands. Looks similar to the old SAPMSOS0 program that
disappeared in 3.0
RSWBO060 - put objects into a request and transport it to any other system
RPUAUD00 - HR Report to list all logged changes for an employee. Uses the PCL4 Audit Cluster.
RPUAUDDL - HR Report to delete audit data from the PCL4 Audit Cluster.
RPDTRA00 - List all HR transactions.
RHGRENZ0 - Delimit IT1000 and related 1001s. Program will delete any 1001 infotypes whose start
date is after the delimit date.
RHGRENZ2 - Delimit IT1001 only.
RHGRENZ1 - Extend the end date on delimited records. Very useful when you delimit a bunch of
records incorrectly, and need to change the end date.
Notes on HRGRENZ0/HRBRENZ2: RHGRENZ0/2 will abend if there are any inconsistencies between PD and PA (i.e. people in a different controlling area than the position they belong to). Controlling area of a person is determined by the cost centre that a person's position is assigned to. When assigning a person to a position, SAP checks to make sure that the Controlling area of the company that the person belongs to is the same as that of the Cost centre that their position belongs to.
亢亢龙龙龙有有有悔悔悔
RKCTSEAR - Search source code for up to two strings. Also see
RSRSCAN1
and
RPR_ABAP_SOURCE_SCAN
.
RPUP1D00/10 - View/Delete data from PCL1 Cluster
RPUP2D00/10 - View/Delete data from PCL2 Cluster
RPUP3D00/10 - View/Delete data from PCL3 Cluster
RPUP4D00/10 - View/Delete data from PCL4 Cluster
RSTXSCRP Save a SAPScript layout set to disk, and load it back into SAP.
RPUDELPN Delete all info for an employee number, including cluster data and infotypes.
RSABAPIV Mass print/display of ABAP/4 help text
RSBDCSUB Release batch-input sessions automatically
RSBDCBTC - Submit a BDC job with an internal batch number and wait for the end of the batch-input
session.
RSCLTCOP Copy tables across clients
RSAVGL00 Table adjustment across clients
RSINCL00 Extended program list
RSTXSCRP Transport SAPscript files across systems
RSORAREL Get the Oracle Release
RSRSCAN1 Search source code for a given string. Will also search includes. Also see
RKCTSEAR
and
RPR_ABAP_SOURCE_SCAN
.
RSTBSERV Compare a contents of a table between clients
RGUGBR00 Substitution/Validation utility
RSPARAM Display all instance parameters
RSUSR003 Check the passwords of users SAP* and DDIC in all clients
RSUSR006 List users last login
RSWBO052 Change development class of a sapscript (provided by
Alan Cecchini
)
2.2.3 Scheduling of system maintenance jobs
RSBTCDEL Clean the old background job records
RSDBCREO Clean batch input session log
RSPO0041 Removing old spooling objects
RSSNAPDL Clean the old ABAP error dumps
2.2.4 G/L Account Line Item Display
TCDDE: FBL3N
2.2.5 FI-SL: Reversal of Actual Documents
Program name: RGUREP13
2.2.6 Set document select path
call method cl_gui_frontend_services=>file_open_dialog Sample:在 report 的屏幕上设定文件选择路径
**--- SELECT SCREEN
selection-screen begin of block b1 with frame title text-000 .
parameters:p_file type file_table-filename . "File name
selection-screen end of block b1.
**---- at selection-screen.
data: t_file type string, t_rt type boolean.
t_file = p_file.
t_rt = cl_gui_frontend_services=>file_exist( t_file ).
* Get file name
at selection-screen on value-request for p_file.
data: t_rc type i, "For class--return code t_it_file type filetable, "For class--internal table t_wa_file type file_table. "For class--work area
* Pop-up the dialog
call method cl_gui_frontend_services=>file_open_dialog exporting
window_title = 'Select file' file_filter = '*.TXT|*.TXT|*.*|*.*|' initial_directory = 'C:' multiselection = c_false changing file_table = t_it_file rc = t_rc exceptions file_open_dialog_failed = 1 cntl_error = 2 error_no_gui = 3 not_supported_by_gui = 4.
* Get single file
read table t_it_file into t_wa_file index 1. p_file = t_wa_file-filename.
2.2.7 Check if all the character in a string are numeric
亢亢龙龙龙有有有悔悔悔
DATA: num TYPE p value ‘3124141’,
ex TYPE REF TO cx_root.
TRY.
num = text.
CATCH cx_root INTO ex.
flag = c_true.
ENDTRY.
2.2.8 Background Job set by program
Sample:
DATA: t_jobname TYPE tbtcjob-jobname, t_jobcount TYPE tbtcjob-jobcount.
* open one job
t_jobname = sy-repid.
CALL FUNCTION 'JOB_OPEN' "#EC * EXPORTING jobname = t_jobname IMPORTING jobcount = t_jobcount EXCEPTIONS cant_create_job = 1 invalid_job_data = 2 jobname_missing = 3 OTHERS = 4. * backgroud execute
SUBMIT ZARI014 AND RETURN WITH p_back = c_true WITH p_sap = c_true WITH p_srv = c_false USER sy-uname VIA JOB t_jobname NUMBER t_jobcount TO SAP-SPOOL
DESTINATION 'TNT_CHINA_FRONTEND' IMMEDIATELY ' '
KEEP IN SPOOL 'X'
WITHOUT SPOOL DYNPRO.
* close job
CALL FUNCTION 'JOB_CLOSE' "#EC * EXPORTING
jobcount = t_jobcount jobname = t_jobname strtimmed = 'X'
EXCEPTIONS cant_start_immediate = 1 invalid_startdate = 2 jobname_missing = 3 job_close_failed = 4 job_nosteps = 5 job_notex = 6 lock_failed = 7 invalid_target = 8 OTHERS = 9. * send message
MESSAGE i208(00) WITH text-005. LEAVE PROGRAM.
2.2.9 Dynamic internal table define
*&---*
*& Report Zdynamic *
*&---*
*&---*
REPORT ZPLATO3 .
parameters:
table type c length 30 .
data: data_ref type ref to data.
field-symbols:
<tab> type any table.
start-of-selection.
create data data_ref type table of (table).
assign:data_ref->* to <tab>.
select * from (table) into table <tab> up to 20 rows.
perform write_table using <tab>.
*&---*
*& Form write_table
*&---*
* text
*---*
* -->P_<TAB> text
亢亢龙龙龙有有有悔悔悔
*---*
FORM write_table USING p_table type any table.
field-symbols:
<line> type data,
<field> type data.
loop at p_table assigning <line>.
do.
assign component sy-index of structure <line> to <field>.
if sy-subrc <> 0.
exit.
endif.
write:<field>.
enddo.
write:/.
endloop.
ENDFORM. " write_table
2.2.10 Internal table optimization
*&---*
*& Report ZPLATO2 *
*&---*
REPORT ZPLATO2 .
types:
begin of my_line_type,
name type string,
birth_date type d,
salary type p decimals 2,
end of my_line_type,
my_table_type type hashed table of my_line_type
with unique key name birth_date.
data:
my_wa type my_line_type,
my_table type my_table_type.
start-of-selection.
my_wa-name = 'plato'.
my_wa-birth_date = '19800506'.
my_wa-salary = '200000.00'.
insert my_wa into table my_table.
my_wa-name = 'April may june'.
my_wa-birth_date = '18904343'.
my_wa-salary = '100000.00'.
insert my_wa into table my_table.
my_wa-name = 'mark tan'.
my_wa-birth_date = '181204343'.
my_wa-salary = '100.00'.
insert my_wa into table my_table.
perform write_table using my_table.
*&---*
*& Form write_table
*&---*
* text
*---*
* --> p1 text
* <-- p2 text
*---*
FORM write_table using p_table type any table.
field-symbols:
<line> type data,
<field> type data.
write / '{'.
loop at p_table assigning <line>.
write /4 '('.
do.
assign component sy-index of structure <line> to <field>.
if sy-subrc <> 0.
exit.
endif.
write /8 <field>.
enddo. "loop at component
write /4 ')'.
endloop. "loop at table
write / '}'.
ENDFORM. " write_table
2.2.11 Download or Upload Form
Program name : RSTXSCRP
2.2.12 Find
Enhancement
亢亢龙龙龙有有有悔悔悔
*& Report Z_FIND_ENHANCEMENT
*&---* REPORT zbadi . TABLES : tstc, tadir, modsapt, modact, trdir, tfdir, enlfdir, sxs_attrt , tstct.
DATA : jtab LIKE tadir OCCURS 0 WITH HEADER LINE. DATA : field1(30).
DATA : v_devclass LIKE tadir-devclass. PARAMETERS : p_tcode LIKE tstc-tcode, p_pgmna LIKE tstc-pgmna .
DATA wa_tadir TYPE tadir. START-OF-SELECTION. IF NOT p_tcode IS INITIAL.
SELECT SINGLE * FROM tstc WHERE tcode EQ p_tcode. ELSEIF NOT p_pgmna IS INITIAL.
tstc-pgmna = p_pgmna. ENDIF.
IF sy-subrc EQ 0.
SELECT SINGLE * FROM tadir WHERE pgmid = 'R3TR' AND object = 'PROG'
AND obj_name = tstc-pgmna.
MOVE : tadir-devclass TO v_devclass. IF sy-subrc NE 0.
SELECT SINGLE * FROM trdir WHERE name = tstc-pgmna. IF trdir-subc EQ 'F'.
SELECT SINGLE * FROM tfdir WHERE pname = tstc-pgmna. SELECT SINGLE * FROM enlfdir WHERE funcname = tfdir-funcname. SELECT SINGLE * FROM tadir
WHERE pgmid = 'R3TR' AND object = 'FUGR'
AND obj_name EQ enlfdir-area. MOVE : tadir-devclass TO v_devclass. ENDIF.
ENDIF.
SELECT * FROM tadir INTO TABLE jtab WHERE pgmid = 'R3TR'
AND object IN ('SMOD', 'SXSD') AND devclass = v_devclass. SELECT SINGLE * FROM tstct WHERE sprsl EQ sy-langu AND tcode EQ p_tcode.
FORMAT COLOR COL_POSITIVE INTENSIFIED OFF. WRITE:/(19) 'Transaction Code - ',
20(20) p_tcode, 45(50) tstct-ttext. SKIP.
IF NOT jtab[] IS INITIAL. WRITE:/(105) sy-uline.
FORMAT COLOR COL_HEADING INTENSIFIED ON.
* Sorting the internal Table SORT jtab BY object. DATA : wf_txt(60) TYPE c, wf_smod TYPE i ,
wf_badi TYPE i , wf_object2(30) TYPE c.
CLEAR : wf_smod, wf_badi , wf_object2.
* Get the total SMOD.
LOOP AT jtab INTO wa_tadir. AT FIRST.
FORMAT COLOR COL_HEADING INTENSIFIED ON. WRITE:/1 sy-vline,
2 'Enhancement/ Business Add-in', 41 sy-vline , 42 'Description', 105 sy-vline. WRITE:/(105) sy-uline. ENDAT. CLEAR wf_txt.
亢亢龙龙龙有有有悔悔悔
AT NEW object.
IF wa_tadir-object = 'SMOD'. wf_object2 = 'Enhancement' . ELSEIF wa_tadir-object = 'SXSD'. wf_object2 = ' Business Add-in'. ENDIF.
FORMAT COLOR COL_GROUP INTENSIFIED ON. WRITE:/1 sy-vline, 2 wf_object2, 105 sy-vline. ENDAT. CASE wa_tadir-object. WHEN 'SMOD'. wf_smod = wf_smod + 1.
SELECT SINGLE modtext INTO wf_txt FROM modsapt
WHERE sprsl = sy-langu
AND name = wa_tadir-obj_name.
FORMAT COLOR COL_NORMAL INTENSIFIED OFF. WHEN 'SXSD'.
* For BADIs
wf_badi = wf_badi + 1 .
SELECT SINGLE text INTO wf_txt FROM sxs_attrt
WHERE sprsl = sy-langu
AND exit_name = wa_tadir-obj_name.
FORMAT COLOR COL_NORMAL INTENSIFIED ON. ENDCASE.
WRITE:/1 sy-vline,
2 wa_tadir-obj_name HOTSPOT ON, 41 sy-vline , 42 wf_txt, 105 sy-vline. AT END OF object. WRITE : /(105) sy-uline. ENDAT. ENDLOOP. WRITE:/(105) sy-uline. SKIP.
FORMAT COLOR COL_TOTAL INTENSIFIED ON. WRITE:/ 'No.of Exits:' , wf_smod.
WRITE:/ 'No.of BADis:' , wf_badi. ELSE.
FORMAT COLOR COL_NEGATIVE INTENSIFIED ON. WRITE:/(105) 'No userexits or BADis exist'.
ENDIF. ELSE.
FORMAT COLOR COL_NEGATIVE INTENSIFIED ON. WRITE:/(105) 'Transaction does not exist'.
ENDIF.
AT LINE-SELECTION.
DATA : wf_object TYPE tadir-object. CLEAR wf_object.
GET CURSOR FIELD field1. CHECK field1(8) EQ 'WA_TADIR'.
READ TABLE jtab WITH KEY obj_name = sy-lisel+1(20). MOVE jtab-object TO wf_object.
CASE wf_object. WHEN 'SMOD'.
SET PARAMETER ID 'MON' FIELD sy-lisel+1(10).
CALL TRANSACTION 'SMOD' AND SKIP FIRST SCREEN. WHEN 'SXSD'.
SET PARAMETER ID 'EXN' FIELD sy-lisel+1(20).
CALL TRANSACTION 'SE18' AND SKIP FIRST SCREEN. ENDCASE.
2.2.13 Find IMG Tcode
REPORT zimgcode_find .TYPES: BEGINOF typ_param,
param TYPE tstcp-param,
ENDOF typ_param.
DATA: tab_dd26s TYPETABLEOF dd26s,
rec_dd26s TYPE dd26s,
tab_param TYPETABLEOF typ_param,
rec_param TYPE typ_param,
tab_tstcp TYPETABLEOF tstcp,
rec_tstcp TYPE tstcp,
tab_tstct TYPETABLEOF tstct,
rec_tstct TYPE tstct,
rec_dd02t TYPE dd02t,
tab_vclstruc TYPETABLEOF vclstruc,
亢亢龙龙龙有有有悔悔悔
DATA: l_tcode LIKE tstct-tcode,
l_tabname TYPE dd25l-roottab.
PARAMETERS: p_root TYPE dd25l-roottab OBLIGATORY.
ATLINE-SELECTION.
GETCURSORFIELD l_tcode.
CHECK l_tcode EQ'REC_TSTCT-TCODE'. CALLTRANSACTION sy-lisel+1(10). EXIT.
AT SELECTION-SCREEN.
SELECTSINGLE * FROM dd02t
INTO rec_dd02t
WHERE ddlanguage = sy-langu
AND tabname = p_root.
START-OF-SELECTION.
PERFORM frm_get_maintanceview. PERFORM frm_get_tcode.
PERFORM frm_output_tcode.
*&---* *& Form FRM_GET_MAINTANCEVIEW *&---* * 读 取 相 关 维 护 视 图 *---* FORM frm_get_maintanceview. " 查 相 关 维 护 VIEW SELECT * FROM dd26s INTOTABLE tab_dd26s WHERE tabname = p_root. SELECT * FROM dd26s
APPENDINGTABLE tab_dd26s WHERE viewname = p_root.
" 查 相 关 视 图 簇
SELECT * FROM vclstruc INTOTABLE tab_vclstruc WHERE predobject = p_root.
IFNOT tab_dd26s[] ISINITIAL.
" 查 相 关 维 护 视 图 的 视 图 簇
SELECT * FROM vclstruc
APPENDINGTABLE tab_vclstruc
FORALL ENTRIES IN tab_dd26s
WHERE predobject = tab_dd26s-viewname. ENDIF.
ENDFORM. " FRM_GET_MAINTANCEVIEW *&---*
*& Form FRM_GET_TCODE
* 根 据 参 照 视 图 找 对 应 的 TCODE *---*
FORM frm_get_tcode.
CHECKNOT tab_dd26s[] ISINITIAL
ORNOT tab_vclstruc[] ISINITIAL.
LOOPAT tab_dd26s INTO rec_dd26s.
CONCATENATE'%'
rec_dd26s-viewname '%'
INTO rec_param-param.
CONDENSE rec_param-param NO-GAPS. APPEND rec_param TO tab_param. ENDLOOP.
LOOPAT tab_vclstruc INTO rec_vclstruc.
CONCATENATE'%'
rec_vclstruc-vclname '%'
INTO rec_param-param.
CONDENSE rec_param-param NO-GAPS. APPEND rec_param TO tab_param. ENDLOOP.
LOOPAT tab_param INTO rec_param.
SELECT * FROM tstcp
APPENDINGTABLE tab_tstcp
WHERE param LIKE rec_param-param. ENDLOOP.
IFNOT tab_tstcp[] ISINITIAL.
SELECT * FROM tstct INTOTABLE tab_tstct
FORALL ENTRIES IN tab_tstcp
WHERE sprsl = sy-langu
AND tcode = tab_tstcp-tcode.
ENDIF.
ENDFORM. " FRM_GET_TCODE *&---* *& Form FRM_OUTPUT_TCODE
*&---*
* 输 出 找 到 的 TCODE
*---*
FORM frm_output_tcode.
IF tab_tstct[] ISINITIAL.
FORMATCOLORCOL_NEGATIVEINTENSIFIEDON. WRITE:/(95) 'Not found any tcode!'.
EXIT. ELSE.
FORMATCOLOR COL_POSITIVE INTENSIFIED OFF. WRITE:/(19) 'Table : ',
20(20) p_root,
45(50) rec_dd02t-ddtext. SKIP.
亢亢龙龙龙有有有悔悔悔 * Listekopf
WRITE:/(95) sy-uline.
FORMATCOLOR COL_HEADING INTENSIFIEDON.
WRITE:/1 sy-vline,
2'T-code', 21 sy-vline , 22'Description', 95 sy-vline.
WRITE:/(95) sy-uline.
LOOPAT tab_tstct INTO rec_tstct.
READTABLE tab_tstcp INTO rec_tstcp
WITHKEY tcode = rec_tstct-tcode.
IF rec_tstcp-param+0(6) = '/*SM34'.
FORMATCOLOR COL_KEY INTENSIFIED OFF.
ELSE.
FORMATCOLORCOL_NORMALINTENSIFIED OFF.
ENDIF. WRITE:/1 sy-vline, 2 rec_tstct-tcode HOTSPOTON, 21 sy-vline , 22 rec_tstct-ttext, 95 sy-vline. ENDLOOP.
WRITE:/(95) sy-uline.
DESCRIBETABLE tab_tstct.
SKIP.
FORMATCOLOR COL_TOTAL INTENSIFIEDON.
WRITE:/ 'T-code founded:' , sy-tfill. ENDIF.
ENDIF.
ENDFORM. " FRM_OUTPUT_TCODE
2.2.14 Dynamic refurbish report
REPORT zauto_refresh . DATA: g_init_once, ok_code(20), g_ref_from_timer.
TYPES: BEGIN OF t_ekko, ebeln TYPE ekpo-ebeln, ebelp TYPE ekpo-ebelp,
statu TYPE ekpo-statu, aedat TYPE ekpo-aedat, matnr TYPE ekpo-matnr, menge TYPE ekpo-menge, meins TYPE ekpo-meins, netpr TYPE ekpo-netpr, peinh TYPE ekpo-peinh, END OF t_ekko.
DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0, wa_ekko TYPE t_ekko.
IF g_init_once <> 'X'. g_init_once = 'X'.
CALL FUNCTION 'Z_ENQUE_SLEEP' STARTING NEW TASK 'WAIT'
PERFORMING when_finished ON END OF TASK. ENDIF.
WRITE:/ 'wait for 10 sec....'. AT USER-COMMAND. CASE ok_code. WHEN 'FCT_R'.
SELECT ebeln ebelp statu aedat matnr menge meins netpr peinh UP TO 10 ROWS
FROM ekpo
INTO TABLE it_ekko. WRITE:/ sy-uzeit. "Time
LOOP AT it_ekko INTO wa_ekko.
亢亢龙龙龙有有有悔悔悔
ENDLOOP. sy-lsind = 0.
IF g_ref_from_timer = 'X'.
CALL FUNCTION 'Z_ENQUE_SLEEP' STARTING NEW TASK 'INFO'
PERFORMING when_finished ON END OF TASK. g_ref_from_timer = ''. ENDIF. ENDCASE. *---* * FORM WHEN_FINISHED * *---* * --> TASKNAME * *---* FORM when_finished USING taskname.
RECEIVE RESULTS FROM FUNCTION 'Z_ENQUE_SLEEP'. g_ref_from_timer = 'X'.
* Trigger an event to run the at user-command SET USER-COMMAND 'FCT_R'. ok_code = 'FCT_R'. sy-ucomm = 'FCT_R'. ENDFORM. " WHEN_FINISHED FUNCTION Z_ENQUE_SLEEP. *"--- *"Local interface: *"--- wait up to 10 seconds.
* EXPORTING * SECONDS = 1. ENDFUNCTION.
2.2.15 SMW0 --Web Repository
Tcode SMW0 ,upload Excel or Word template to SAP server Use Function download the template
CALL FUNCTION 'DOWNLOAD_WEB_OBJECT'
EXPORTING KEY = OBJDATA DESTINATION = L_DESTINATION.
2.2.16 ALV
Group
2.2.16.1 Standard ALV
2.2.16.1.1 What is ALVThe ALV Grid Control (ALV = SAP List Viewer)是一个显示列表的灵活的工具,它提供了基本功能的列表操作,也可以通过自 定义来进行增强,因此可以允许你可以在大型的应用程序中使用.
SAP 提示: 在 SAP 的开发项目中,ALV GRID 也可以作为修改和创建数据的一种工具,然而,目前这个功能只在实验计划中使 用,还没有向客户发布. 下面是一个 ALV GRID 的图片: 它包括3 大部分,工具栏,标题,用于显示数据的网格控制器.如果有必要,用户可以隐藏标题和工具栏. ALV 家族包含 3 中 ALV 工具:简易的,两层 ALV,分等级连续的列表和树形结构的 ALV.
2.2.16.1.2 ALV GRID CONTROL (ALV 网格控制器)
ALV GRID CONTROL 使用了控制器技术以实现艺术性的屏幕显示,象所有的控制器一样,ALV GRID CONTROL 通过系统中 的一个全局的类提供了方法,以响应它的动作.使用了 ABAP 的对象以后,列表是通过 ALV 的一个实例(INSTANCE)来显示的,程
亢亢龙龙龙有有有悔悔悔
2.2.16.1.3 ALV GRID CONTROL 实例
ALV GRID 实例的定义,参照 CL_GUI_ALV_GRID 类 data ALV_GRID1 type ref to cl_gui_alv_grid. ALV GRID 继承结构: 2.2.16.1.4 ALV GRID 相关的几个控制结构 2.2.16.1.4.1 [Field catalog] 字段目录 字段目录是用来控制ALV 显示的网格中每个字段的属性的,比如字段的顺序,对齐方式,可编辑状态,颜色,等等. 常用的控制字段如下: (下面的示例将说明这些字段的使用,参考 STRUCTURE LVC_S_FCAT) 2ROW_POS ALV 控制: 输出行 (内部使用) 3COL_POS ALV 控制: 输出列 列的位置1,2,….. ,第几列,例如 4FIELDNAME ALV 控制: 内部表字段的字段名称 字段名称 5TABNAME LVC 标签名称 表名,如果是内表,是1 6CURRENCY ALV 控制: 货币单位 7CFIELDNAME ALV 控制: 参考的当前单位的字段名称 8QUANTITY ALV 控制: 计量单位 9QFIELDNAME ALV 控制: 参考计量单位的字段名称 10IFIELDNAME ALV 控制: 内部表字段的字段名称 11ROUND ALV 控制: ROUND 值
12EXPONENT ALV 控制:流动表示的指数 13KEY ALV 控制: 关键字段 关键字段,前面变蓝色 14KEY_SEL ALV 控制: 可以被隐藏的关键列 可以被隐藏的关键列 15ICON ALV 控制: 作为图标输出 此列作为图标输出 16SYMBOL ALV 控制: 输出作为符号 17CHECKBOX ALV 控制: 作为复选框输出 复选框输出 18JUST ALV 控制: 对齐 对齐方式: 'R': right justified 'L': left justified 'C': centered 19LZERO ALV 控制: 输出前导零 X' 20NO_SIGN ALV 控制:输出抑制符号 X',不输出符号 21NO_ZERO ALV 控制: 为输出隐藏零 X',隐藏 0 22NO_CONVEXT ALV 控制: 不考虑输出的转换退出 23EDIT_MASK ALV 控制: 为输出编辑掩码 格式 24EMPHASIZE ALV 控制: 带有颜色的高亮列 列的颜色 25FIX_COLUMN ALV 控制: 固定列
26DO_SUM ALV 控制: 总计列值 X',合计 27NO_SUM ALV 控制: 没有总计列值 X' ,没有合计 28NO_OUT ALV 控制: 列没有输出 X' ,隐藏此列 29TECH ALV 控制: 技术字段 X'.也是隐藏,但是有点不一 样 30OUTPUTLEN ALV 控制: 列的字符宽度 输出的长度 31CONVEXIT 转换例程 32SELTEXT ALV 控制: 对话功能的列标识符 33TOOLTIP ALV 控制: 列抬头的工具提示 34ROLLNAME ALV 控制: F1 帮助的数据元素
35DATATYPE ABAP 字典中的数据类型 ABAP 字典中的数据类型
36INTTYPE ABAP 数据类型(C,D,N,...) ABAP 数据类型(C,D,N,...)
37INTLEN 以字节计的内部长度 内容的长度 38LOWERCASE 允许/不允许小写字母 X' 允许大小写 39REPTEXT 标题 40HIER_LEVEL ALV 控制: 内部使用 41REPREP ALV 控制: 价值是补充/补充接口的选择标准 42DOMNAME 定义域名 43SP_GROUP 组代码 44HOTSPOT ALV 控制: 单击敏感 X',下面出现下划线,响应单击 45DFIELDNAME ALV 控制: 数据库中列组的字段名称 46COL_ID ALV 控制: 列 ID 47F4AVAILABL 字段有输入帮助吗 X'.此列有搜索帮助 48AUTO_VALUE ALV 控制: 自动复制值 49CHECKTABLE 表名 50VALEXI 固定值存在 51WEB_FIELD ALV 控制: 内部表字段的字段名称 52HREF_HNDL 自然数 热点连接的句柄 53STYLE ALV 控制: 样式 下面有例子会介绍,比如 PUSHBUTTION 54STYLE2 ALV 控制: 样式 55STYLE3 ALV 控制: 样式 56STYLE4 ALV 控制: 样式 57DRDN_HNDL 自然数 下拉的句柄 58DRDN_FIELD ALV 控制: 内部表字段的字段名称 下拉的字段 59NO_MERGING 字符字段长度 1 相同的值不合并 60H_FTYPE ALV 树控制: 功能类型 (总计,平均,最大.最小 , ...) 61COL_OPT 可选列优化的条目 62NO_INIT_CH 字符字段长度 1 63DRDN_ALIAS 字符字段长度 1 64REF_FIELD ALV 控制: 内部表字段的参考字段名称 65REF_TABLE ALV 控制: 内部表字段的参考表名称 66TXT_FIELD ALV 控制: 内部表字段的字段名称 67ROUNDFIELD ALV 控制: 带有 ROUND 说明的字段名称 68DECIMALS_O ALV 控制: 输出小数位的编号
亢亢龙龙龙有有有悔悔悔
69DECMLFIELD ALV 控制: 带有 DECIMALS 说明的字段名称 70DD_OUTLEN ALV 控制: 输出字符长度 71DECIMALS 小数点后的位数 设置小数的位数 72COLTEXT ALV 控制: 列标题 列标题 73SCRTEXT_L 长字段标签 74SCRTEXT_M 中字段标签 75SCRTEXT_S 短字段标签
76COLDDICTXT ALV 控制: 确定 DDIC 文本参考 77SELDDICTXT ALV 控制: 确定 DDIC 文本参考 78TIPDDICTXT ALV 控制: 确定 DDIC 文本参考
79EDIT ALV 控制: 准备输入 输出状态.'X'可输入 80TECH_COL ALV 控制: 内部使用 81TECH_FORM ALV 控制: 内部使用 82TECH_COMP ALV 控制: 内部使用 83HIER_CPOS ALV 控制: 层次列位置 84H_COL_KEY 树控制: 列名称/项目名称 85H_SELECT 标识是否可以选择树控制中的列 86DD_ROLL 数据元素 (语义域)
87DRAGDROPID ALV 控制: 拖&放处理拖放对象
88MAC 字符字段长度 1 89INDX_FIELD 自然数 90INDX_CFIEL 自然数 91INDX_QFIEL 自然数 92INDX_IFIEL 自然数 93INDX_ROUND 自然数 94INDX_DECML 自然数 95GET_STYLE 字符字段长度 1 96MARK 字符字段长度 1 2.2.16.1.4.2 [ layout ] 布局是用来控制整个ALV 的一个布局,比如 ALV 的标题,是否可编辑,行颜色,列颜色. 参照 ALV 的控制结构[LVC_S_LAYO],以后的例子我将详细介绍如何设置行颜色和列颜色. 详细的结构说明 字段名 描述 Value range CWIDTH_OPT 最优化宽度 SPACE, 'X' SMALLTITLE 小标题,如果设置了这个字段, 则标题与列标题大小一样 SPACE, 'X' GRID_TITLE 标题,在网格和工具条之间 最长70 个字符 NO_HEADERS 如果被设置,列标题隐藏 SPACE, 'X' NO_HGRIDLN 隐藏水平线 SPACE, 'X' NO_MERGING 禁用单元格合并 SPACE, 'X' NO_ROWMARK 如果被设置,选择列在选择模式 为D 和 A 的时候隐藏 SPACE, 'X' NO_TOOLBAR 隐藏工具条 SPACE, 'X' NO_VGRIDLN 隐藏垂直线 SPACE, 'X'
SEL_MODE 选择模式 SPACE, 'A', 'B', 'C', 'D'
EXCP_CONDS 合计例外 SPACE, 'X'
EXCP_FNAME 字段名称带有例外编码 最长30 个字符
EXCP_LED 例外作为 LED SPACE, 'X'
EXCP_ROLLN 例外文档的数据元素 SPACE, 'X'
CTAB_FNAME 带有复杂单元格颜色编码的字段名称 最长30 个字符
INFO_FNAME 带有简单行彩色代码的字段名称 最长30 个字符
ZEBRA 可选行颜色,如果设置了,出现了间隔色带 SPACE, 'X'
NO_TOTLINE 没有总计 SPACE, 'X'
NUMC_TOTAL 可以对NUMC 字段进行合计 SPACE, 'X'
TOTALS_BEF 总计输出在第一行,小计在新的值之前 SPACE, 'X' STYLEFNAME 设置单元格,比如 PUSHBUTTON 最长30 个字符
2.2.16.1.4.3 [ Print, Sort, Filter ]
打印的参数控制请参考结构 [LVC_S_PRNT] 排序的参数控制请参考结构 [LVC_S_SORT] 过滤的参数控制请参考结构 [LVC_S_FILT]
2.2.16.2 Special ALV
2.2.16.2.1 第一次显示以后修改字段目录和布局 在运行的时候,很有可能需要在显示之后,需要设置一个新的布局或者字段目录.有下面这些方法去实现. 字段目录 : get_frontend_fieldcatalog set_frontend_fieldcatalog 布局: get_frontend_layout set_frontend_layout 使用这些方法,你在执行的任何时候,可以获取这些内容,然后修改它们.DATA ls_fcat TYPE lvc_s_fcat . DATA lt_fcat TYPE lvc_t_fcat . DATA ls_layout TYPE lvc_s_layo .
CALL METHOD gr_alvgrid->get_frontend_fieldcatalog IMPORTING
et_fieldcatalog = lt_fcat[] . LOOP AT lt_fcat INTO ls_fcat .
IF ls_fcat-fieldname = 'PAYMENTSUM' . ls_fcat-no_out = space .
MODIFY lt_fcat FROM ls_fcat . ENDIF .
ENDLOOP .
CALL METHOD gr_alvgrid->set_frontend_fieldcatalog EXPORTING
it_fieldcatalog = lt_fcat[] .
CALL METHOD gr_alvgrid->get_frontend_layout IMPORTING
es_layout = ls_layout .
ls_layout-grid_title = 'Flights (with Payment Sums)' . CALL METHOD gr_alvgrid->set_frontend_layout EXPORTING