| Michael's profileAt world's endBlogGuestbookNetwork | Help |
|
|
October 29 SAP用户密码加密函数REPORT z_barry_user_pass. DATA: msgid LIKE sy-msgid, CALL 'XXPASS' WRITE usr02-bcode . 友情提示:运行CALL 'XXPASS'前最好跟Basis搞好关系,在你运行后好让他给你解除用户锁定,哈哈
利用Excel显示数据REPORT zrs08056 . TABLES: t001,dd02l. START-OF-SELECTION. *&---------------------------------------------------------------------* *&---------------------------------------------------------------------* 通过RFC把本系统程序放入另外一个系统执行并返回结果*&---------------------------------------------------------------------*
*& Report * *& * *&---------------------------------------------------------------------* *& 通过RFC把本系统程序放入另外一个系统执行并返回结果 * *& * *&---------------------------------------------------------------------* REPORT z_barry_insert_abap .
DATA : itab_prog(140) OCCURS 0 WITH HEADER LINE.
DATA : itab_ret(1023) OCCURS 0 WITH HEADER LINE. DATA : err_msg LIKE sy-msgv1. PARAMETER p_report LIKE sy-repid MEMORY ID rid.
PARAMETER p_rfcdes LIKE rfcdes-rfcdest. START-OF-SELECTION.
REFRESH : itab_prog , itab_ret. READ REPORT p_report INTO itab_prog. CALL FUNCTION 'RFC_ABAP_INSTALL_AND_RUN' DESTINATION p_rfcdes EXPORTING mode = 'F' IMPORTING errormessage = err_msg TABLES program = itab_prog writes = itab_ret EXCEPTIONS OTHERS = 1. IF sy-subrc <> 0.
MESSAGE e000(z900) WITH err_msg. WRITE :/ err_msg. ELSE. IF NOT itab_ret[] IS INITIAL. LOOP AT itab_ret. WRITE :/ itab_ret. ENDLOOP. ENDIF. ENDIF. 注:因此函数为RFC函数,可以利用第三方软件做远程程序执行,如Excel。但需要注意的是,如果目标Client设置为不允许修改(SCC4),则会返回错误 用 HTML 输出 LIST 报表*&---------------------------------------------------------------------*
*& Report ZRS08186 * *& * *&---------------------------------------------------------------------* *& 用 HTML 输出 LIST 报表 * *& Submit一个程序,然后把结果保存为HTML文件 * *&---------------------------------------------------------------------* REPORT z_barry_html_out LINE-SIZE 450 .
DATA: mtab_report_list LIKE abaplist OCCURS 0 WITH HEADER LINE,
mtab_report_html LIKE w3html OCCURS 0 WITH HEADER LINE. PARAMETERS: p_fname LIKE rlgrap-filename OBLIGATORY DEFAULT 'C:\testhtm.htm' ,
p_sname(128) DEFAULT '/usr/sap/DEV/DVEBMGS00/work/TESThtml.htm' LOWER CASE NO-DISPLAY . SUBMIT z_barry_html_out_alv EXPORTING LIST TO MEMORY AND RETURN.
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES listobject = mtab_report_list EXCEPTIONS not_found = 1. CALL FUNCTION 'WRITE_LIST'
TABLES listobject = mtab_report_list EXCEPTIONS empty_list = 1 OTHERS = 2. *CALL FUNCTION 'WWW_LIST_TO_HTML'
* TABLES * html = mtab_report_html. CALL FUNCTION 'WWW_HTML_FROM_LISTOBJECT'
TABLES html = mtab_report_html listobject = mtab_report_list. IF sy-subrc NE 0.
WRITE: / 'ERROR IN GENERATING THE HTML FORMAT'. EXIT. ENDIF. *CALL FUNCTION 'WS_DOWNLOAD'
* EXPORTING * filename = p_fname * mode = 'BIN' * TABLES * data_tab = mtab_report_html * EXCEPTIONS * OTHERS = 1. * *IF sy-subrc <> 0. * WRITE:/ 'ERROR DOWNLOADING', p_fname. *ELSE. * WRITE: / 'OUTPUT SAVED IN FILE', p_fname. *ENDIF. OPEN DATASET p_sname FOR OUTPUT IN BINARY MODE.
LOOP AT mtab_report_html. TRANSFER mtab_report_html TO p_sname. ENDLOOP. CLOSE DATASET p_sname. PERFORM down_file USING p_sname p_fname .
IF sy-subrc <> 0.
WRITE:/ 'ERROR DOWNLOADING', p_fname. ELSE. WRITE: / 'OUTPUT SAVED IN FILE', p_fname. ENDIF. *&--------------------------------------------------------------------*
*& Form down_file *&--------------------------------------------------------------------* FORM down_file USING p_path file_name . DATA: path LIKE rcgfiletr-ftappl . DATA: localfile LIKE rcgfiletr-ftfront. path = p_path .
localfile = file_name . CALL FUNCTION 'C13Z_FILE_DOWNLOAD_BINARY' EXPORTING i_file_front_end = localfile i_file_appl = path i_file_overwrite = 'X' EXCEPTIONS fe_file_open_error = 1 fe_file_exists = 2 fe_file_write_error = 3 ap_no_authority = 4 ap_file_open_error = 5 ap_file_empty = 6 OTHERS = 7. IF sy-subrc <> 0. IF sy-msgty = '' . sy-msgty = 'E' . ENDIF . MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. ENDFORM. " DOWN_FILE ME21N/VA01的行项目回车后检查出口
Chart*&---------------------------------------------------------------------* REPORT Z_BARRY_CHART . DATA: BEGIN OF itab_data OCCURS 0, BEGIN OF itab_options OCCURS 0, itab_data-dataname = '电'. itab_data-dataname = '气'. itab_data-dataname = '水'. itab_data-dataname = '米'. itab_options-option = 'P2TYPE = LN'. CALL FUNCTION 'GRAPH_MATRIX_3D' Mail-地文件做为附件发送*&---------------------------------------------------------------------* REPORT zrs08094 .
DATA g_authority LIKE sofa-usracc. DATA : fold_number(12) TYPE c, PARAMETERS ws_file(4096) TYPE c DEFAULT 'c:\AAA.txt'. g_user-sapname = sy-uname. CALL FUNCTION 'SO_USER_READ_API1' IF sy-subrc <> 0. fold_type = g_user_data-outboxfol+0(3). REFRESH : g_objcnt, method1 = 'SAVE'. g_header-objdes = '邮件标题'. CALL FUNCTION 'SO_DOCUMENT_REPOSITORY_MANAGER' * File from the pc to send... g_files-text = ws_file. CALL FUNCTION 'SO_DOCUMENT_REPOSITORY_MANAGER'
g_receipients-recnam = 'BAITZ'. *g_receipients-recnam = 'ZHENGLL'. CALL FUNCTION 'SO_DOCUMENT_REPOSITORY_MANAGER' *write 'aa'. 格式化的日期转为SAP内部日期REPORT z_barry_test_date_format .
DATA: dat TYPE erdat,
str(10) TYPE c, df . dat = '20070803'.
WRITE dat TO str .
SELECT SINGLE datfm INTO df FROM usr01 WHERE bname = sy-uname.
CALL FUNCTION 'DATE_STRING_CONVERT'
EXPORTING date_format = df date_string = str IMPORTING result_date = dat. WRITE dat . Send job to emailREPORT z_barry_job_list . TYPE-POOLS: slis. DATA: BEGIN OF in_wa . DATA: BEGIN OF itab OCCURS 0 . DATA: it_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE, DATA: it_message TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0 SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-010. START-OF-SELECTION. *---------------------------------------------------------------------* ***Job的状态 CALL FUNCTION 'BP_JOB_SELECT_SM37B' CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' *---------------------------------------------------------------------* gd_doc_data-doc_size = 1. LOOP AT itab. CONCATENATE itab-jobname ',' txt INTO it_message . CLEAR it_packing_list. CLEAR it_receivers. CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1' IF sy-subrc = 0 . ZCONVERT_SPOOL_2LOCAL_PDF.FUNCTION ZCONVERT_SPOOL_2LOCAL_PDF. October 27 SAP中如何控制某个report一次只能打印一份SAP中如何控制某个report一次只能打印一份
2008年06月17日 星期二 15:42
PP TransactionAP PP Report
2009-08-28 20:31
October 26 Get Sales document Outstanding Func3FUNCTION ZGET_SO_OUTSTD. Get Sales Outstanding Func2FUNCTION ZGET_SALES_OUSTANDING. October 24 Get Sales order Delivered Qty*&---------------------------------------------------------------------* October 21 ABAP中常用的FUNCTION集合ABAP中常用的FUNCTION集合 -------------------------------------------------------RS_VARIANT_CONTENTS – 获得程序变式的信息 RS_CHANGE_CREATED_VARIANT – 修改程序变式的信息 RZL_SLEEP – 将当前程序挂起 ENQUE_SLEEP – 在继续处理之前等待一个指定的时间。 ENQUEUE_ESFUNCTION – 锁定一个ABAP程序使它不可以被执行: 注意不要用SY-REPID来传递你的报表名字,当把SY-REPID作为参数传递给函数模块的时候,SY-REPID的值实际上已经发生了变化。 RZL_SUBMIT – 提交一个远程报表 GUI_UPLOAD 上传文件到服务器 GUI_DOWNLOAD 下载文件到本地 FILE_GET_NAME 从逻辑文件名得到物理文件路径及文件名。 FILENAME_GET 弹出一个文件选择对话框。 SO_SPLIT_FILE_AND_PATH 将一个包含路径的全文件名分割为文件名和路径。 EPS_GET_FILE_ATTRIBUTES 获得文件属性。 RZL_READ_DIR_LOCAL 读取应用服务器的目录 GUI_CREATE_DIRECTORY 在显示服务器端创建一个目录 。 GUI_DELETE_FILE 在显示服务器端删除一个文件 。 UPLOAD_FILES 上传一个或多个文件 MS_EXCEL_OLE_STANDARD_OLE 创建一个文件并自动启动Excel 。 GUI_REMOVE_DIRECTORY 从显示服务器删除一个目录 。 EPS_GET_DIRECTORY_LISTING 返回一个本地或网络目录的文件列表。 RZL_READ_DIR 如果服务器名字左部为空,从本地读取目录,否则读取远程服务器的目录。 RZL_READ_FILE 如果为给定服务器名字则读取本地文件,否则读取远程服务器文件。 RZL_WRITE_FILE_LOCAL 将内表保存到显示服务器(not PC). 不使用OPEN DATASET因此避免了授权检查。 ------------------------------------------------------- SAPGUI_PROGRESS_INDICATOR – 显示一个进度条 RPY_TRANSACTION_READ – 给定一个事务代码,获得其程序和屏幕;或给定一个程序和屏幕获得事务代码 SCROLLING_IN_TABLE –当编写模块池的时候可以用它来处理滚动 SO_NEW_DOCUMENT_ATT_SEND_API1 - 将文档作为邮件的一部分发送 SO_SPOOL_READ – 根据SPOOL号获得printer spool SO_WIND_SPOOL_LIST – 根据用户浏览printer spool号 LIST_TO_ASCII –将ABAP报表从 OTF形式转换成ASCII 形式。 SX_OBJECT_CONVERT_OTF_PDF – 从OTF转换为PDF (SAP 脚本转换) SX_OBJECT_CONVERT_OTF_PRT – 从OTF转换为打印机格式(SAP 脚本转换) SX_OBJECT_CONVERT_OTF_RAW – 从OTF转换为ASCII(SAP 脚本转换) ------------------------------------------------------- SXPG_CALL_SYSTEM - 检查用户是否有执行某个命令的权限 SXPG_COMMAND_LIST_GET – 获得一个包含所有定义的外部OS命令的列表. SXPG_COMMAND_DEFINITION_GET – 从R/3系统数据库读取单个外部OS命令的定义 SXPG_COMMAND_CHECK - 检查用户是否有执行某个命令的权限 SXPG_COMMAND_EXECUTE -检查用户是否有执行某个命令的权限,拥有授权则执行命令 TERMINAL_ID_GET –返回终端ID TH_DELETE_USER – 剔除一个用户,效果同SM04 TH_ENVIRONMENT – 获得UNIX环境 TH_POPUP –在特定用户屏幕上显示一个系统消息 TH_REMOTE_TRANSACTION – 在远程服务器上运行事务代码 TH_USER_INFO – 获得当前用户的信息 (会话,登陆的工作台等) TH_USER_LIST –显示登陆到应用服务器的用户列表 WRITE_LIST 显示一个列表对象 WS_EXCEL 启动EXCEL WS_VOLUME_GET 获得终端设备标签 WWW_LIST_TO_HTML 运行一个报表之后,调用这个方法将列表输出转换成HTML SD_VBAP_READ_WITH_VBELN 根据销售订单读取表vbap中的信息 ------------------------------------------------------- CO_R0_CHECK_DECIMAL_POINT 根据单位检查数据的小数位 POSTAL_CODE_CHECK 检查邮政编码 VIEW_MAINTENANCE_CALL 维护表视图 F4IF_INT_TABLE_VALUE_REQUEST 显示检索help TERMINAL_ID_GET 获得终端id MESSAGE_TEXT_BUILD 把消息转为文本 ------------------------------------------------------- SSF_FUNCTION_MODULE_NAME 根据form名取得对应的函数名(SmartForm) SSF_FUNCTION_MODULE_NAME SMARTFORMS输出报表时,生成一个函数名称,然后CALL这个名称 RS_COVERPAGE_SELECTIONS 获得一个报表的选择参数列表。 RSLG_WRITE_SYSLOG_ENTRY 往Syslog里写一条记录 RSPO_SX_OUTPUT_TEXTDATA 将内表中的数据输出到SPOOL ALSM_EXCEL_TO_INTERNAL_TABLE将excel文件上传至内表 DYNP_VALUES_READ – 读取SCREEN字段的值,也可以用来读取报表SELECTION SCREEN。 DYNP_VALUES_UPDATE - 更新屏幕字段的值。 GET_GLOBAL_SYMBOLS – 返回一个程序的tables, select options, texts, etc 。甚至包含selection screen的文本定义。 RPY_DYNPRO_READ – 读取屏幕 DY_GET_SET_FIELD_VALUE - 获得或者设置屏幕字段的值 RS_REFRESH_FROM_SELECTOPTIONS –获得当前选择屏幕的内容 DY_GET_FOCUS – 获得屏幕焦点 BP_JOBLOG_READ - 获得job log的执行结果。 GET_JOB_RUNTIME_INFO - 获得job相关信息 CLPB_EXPORT - 从内表导入到剪贴板。 CLPB_IMPORT - 从剪贴板导入内表。 CONVERT_OTF - 将SAP文档(SAP Script)转换成其他类型。 ABAP_DOCU_DOWNLOAD - 以HTML格式下载ABAP文档。 ARFC_GET_TID - 以十六进制形式返回终端的IP地址。 BAL_* - 容纳了SAP的应用程序日志所有的函数模块。 BP_EVENT_RAISE - 在 ABAP/4 程序中触发一个事件。 F4IF_SHLP_EXIT_EXAMPLE – F4接口模块。 FTP_CONNECT – 打开并登陆FTP服务器的连接。 FTP_COMMAND – 在FTP服务器上执行一个命令。 FTP_DISCONNECT –关闭指向FTP服务器的连接。 GET_INCLUDETAB – 获得一个程序的INCLUDES列表。 GUI_EXEC – 调用一个文件或程序,取代了WS_EXECUTE。 GUI_GET_DESKTOP_INFO – 获得客户端桌面信息,取代了WS_QUERY。 GUI_RUN – 启动一个文件或程序。 HELP_START – 为一个字段显示帮助。 K_WERKS_OF_BUKRS_FIND – 返回一个特定公司代码的所有工厂。 POPUP_TO_CONFIRM --standard dialog Popup POPUP_TO_CONFIRM_LOSS_OF_DATA – 弹出一个对话框告知用户有可能丢失数据,询问是否操作继续。 POPUP_TO_CONFIRM_STEP - 弹出一个对话框询问用户是否操作继续。 POPUP_TO_CONFIRM_WITH_MESSAGE POPUP_TO_CONFIRM_WITH_VALUE POPUP_TO_DECIDE POPUP_TO_DECIDE_WITH_MESSAGE POPUP_TO_DISPLAY_TEXT POPUP_TO_SELECT_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。 CONVERSION_EXIT_CUNIT_OUTPUT 单位转换 CLOI_PUT_SIGN_IN_FRONT 将负号前置, SAP默认将负号放在数字后面。 CONVERSION_EXIT_ALPHA_INPUT 数字串前补0 CONVERSION_EXIT_ALPHA_OUTPUT 消除数字串前的0 BAPI_CURRENCY_CONV_TO_EXTERNAL 将金额转换成外部数据格式 BAPI_CURRENCY_CONV_TO_INTERNAL 将金额转换成内部数据格式 UNIT_CONVERSION_SIMPLE 衡量单位转换 SJIS_DBC_TO_SBC 全角转半角 SJIS_SBC_TO_DBC 半角转换为全角 TEXT_SPLIT 字符串分割 CONVERT_TO_LOCAL_CURRENCY 按照指定日期汇率转换金额为指定货币类型 CONVERT_OTFSPOOLJOB_2_PDF 将OTF spool转换为PDF CONVERT_ABAPSPOOLJOB_2_PDF 将ABAP spool转换为PDF ------------------------------------------------------- PRICING 获得定价条件 PROFILE_GET 从INI文件读取一条记录 PROFILE_SET 往INI文件写一条记录 READ_TEXT 读取长文本 SAVE_TEXT 上传长文本 ------------------------------------------------------- REGISTRY_GET 从注册表读取一条记录 REGISTRY_SET 在注册表里设置一条记录 RFC_ABAP_INSTALL_AND_RUN 当MODE参数值为‘F’时运行PROGRAM表中的程序'. RH_GET_ACTIVE_WF_PLVAR 获得激活的HR计划 RH_START_EXCEL_WITH_DATA 启动Excel并用内表给文件赋值 RH_STRUC_GET 返回所有相关的组织信息 ------------------------------------------------------- RP_CALC_DATE_IN_INTERVAL 年月日加减 DATE_CHECK_PLAUSIBILITY 日期有效性检查 SD_DATETIME_DIFFERENCE 两日期作差 DATE_CONVERT_TO_FACTORYDATE 把输入日期转为工厂日历日期 MONTH_NAMES_GET 获得所有的月和名字 ------------------------------------------------------- F4_DATE 弹出一个窗口显示一个日历允许用户选择一个日期。 RP_LAST_DAY_OF_MONTHS 获得一个月的最后一天 FIRST_DAY_IN_PERIOD_GET 获得期间首日 LAST_DAY_IN_PERIOD_GET 获得期间末日 DATE_GET_WEEK 返回一个日期所在的周数。 HOLIDAY_GET 基于工厂日历/节日日历提供了一个节日表。 Dialog Input CheckInput formatThe values entered in the input fields on the screen must correspond to the data format of the corresponding screen field. For example, the format of a date field (type DATS) is eight characters and has the format YYYYMMDD. All of the characters must be numeric. MM must be 12 or less, and DD must be 31 or less. The system also checks that the specified day is valid for the month. ABAP Dictionary ChecksIf you create an input field in the Screen Painter by copying an ABAP Dictionary field, the screen checks whether:· The value satisfies any foreign key relationship to another database table, that is, the system checks whether the value is contained in the check table as a foreign key. This is only checked if the Foreign key attribute is set in the Screen Painter for the input field. The input check is not necessarily identical with the input help. The programmer is responsible for ensuring that the input help presents values that will all pass any foreign key check.· That the value is one of the fixed values of the domain of the fields, that is, the system checks the definition of the underlying domain in the ABAP Dictionary. The fixed values of the domain can also be used as input help. However, the value table of a domain is not checked. It is only used as a default value for the check tables of the fields that refer to the domain.![]() Automatic input checks PROGRAM demo_dynpro_automatic_checks. DATA: ok_code TYPE sy-ucomm, date TYPE d. TABLES demo_conn. CALL SCREEN 100. MODULE init_screen_100 OUTPUT. SET PF-STATUS 'STATUS_100'. ENDMODULE. MODULE cancel INPUT. LEAVE PROGRAM. ENDMODULE. MODULE pai INPUT. MESSAGE i888(sabapdocu) WITH text-001. ENDMODULE. The next screen (statically defined) for screen 100 is 100. It has the following layout: ![]() The date field date from the program is assigned to the input field Date. The other input fields are the CARRID; CONNID, and MARK components of the ABAP Dictionary structure DEMO_CONN. All of the fields are mandatory. The function code of the pushbutton is EXECUTE. In the GUI status STATUS_100, the icon (F12) is active with function code CANCEL and function type E. Furthermore, the function key F8 is assigned to the function code EXECUTE. The screen flow logic is as follows: PROCESS BEFORE OUTPUT. MODULE init_screen_100. PROCESS AFTER INPUT. MODULE cancel AT EXIT-COMMAND. MODULE pai. The user must fill all of the input fields with valid values before the PAI module can be called: · All of the input fields must contain values · The date entry must have the correct format · The airline must be in the check table SCARR · The flight number must exist for the corresponding airline in the check table SPFLI · The selection MARK must be one of the fixed values of the domain S_FLAG. The user can leave the screen using Cancel ( , F12) without entering all values correctly, since the module call is programmed using AT EXIT-COMMAND. Checking Input in the Screen Flow Logic There are two special variants of the FIELDstatement that you can use in PAI processing to check the values of screen fields in the screen flow logic. However, this method is obsolete and should no longer be used. It is only supported for compatibility reasons.Checking a Value ListYou can check a screen field against a value list as follows: FIELD f VALUES (v1, v2,...). The individual entries v1, v2,... in the list can have the following format: · [NOT] val · [NOT] BETWEEN val1 AND val2 You can check against single fields val or intervals between val1 and val2. The comparison fields must have the value range of data type CHAR or NUMC, must be enclosed in inverted commas, and must be written in uppercase. If the check fails, an error message is displayed and the corresponding field is again ready for entry. The input help for f can also use the value list in the FIELD statement. This helps the user to enter only correct values. The functions of the FIELD statement for controlling data transport also apply when you use the VALUES addition. Checking Against Database TablesYou can compare a screen field with a database table follows: FIELD f SELECT * FROM dbtab WHERE k1 = f1 AND k2 = f2 AND... [INTO tables_area] WHENEVER [NOT] FOUND SEND ERRORMESSAGE|WARNING [num [WITH h1 ... h4]]. The FIELD statement is combined with a SELECTstatement. The syntax of the SELECT statement must be entered exactly as shown above. In the WHERE condition, no comparison operators other than the equals sign (=) are allowed, not even EQ. In the WHEREcondition, the fields of the primary key k1 k2 ... of the database table dbtab are checked against the screen fields f1 f2 ... If a matching entry is found, you can write it into the table work area of a screen field, which was defined by transfer from the ABAP Dictionary. You can also send an error or warning message depending on the outcome of the search, which makes the input field for f ready for input again. num allows you to specify a message number from the message class specified in the MESSAGE-ID addition of the first statement in the program. In this case, the message class can only be two characters long. If you do not specify a message class, the system displays a default message. If you use WITH, you can pass literals or screen fields to any placeholders (&) within the message. The input help for f can also use the SELECT statement after FIELD. This helps the user to enter only correct values. You can also use the SELECT statement in screen flow logic without combining it with the FIELD statement. This allows you to fill screen fields with the contents of database tables without calling ABAP modules. The functions of the FIELD statement for controlling data transport also apply when you use SELECT. ![]() Checking Inputs in the Screen Flow Logic PROGRAM demo_dynpro_value_select MESSAGE-ID dw. DATA: ok_code TYPE sy-ucomm, carrier TYPE spfli-carrid, connect TYPE spfli-connid. CALL SCREEN 100. MODULE init_screen_0100 OUTPUT. SET PF-STATUS 'STATUS_100'. ENDMODULE. MODULE cancel INPUT. LEAVE PROGRAM. ENDMODULE. MODULE module_1 INPUT. MESSAGE i888(sabapdocu) WITH text-001 carrier text-002 connect. ENDMODULE. MODULE module_2 INPUT. MESSAGE i888(sabapdocu) WITH text-001 carrier text-002 connect. ENDMODULE. The next screen (statically defined) for screen 100 is 100. It has the following layout: ![]() The program fields carrier and connect are assigned to the input fields. The function code of the pushbutton is EXECUTE. In the GUI status STATUS_100, the icon (F12) is active with function code CANCEL and function type E. Furthermore, the function key F8 is assigned to the function code EXECUTE. The screen flow logic is as follows: PROCESS BEFORE OUTPUT. MODULE init_screen_0100. PROCESS AFTER INPUT. MODULE cancel AT EXIT-COMMAND. FIELD carrier VALUES (NOT 'AA', 'LH', BETWEEN 'QF' AND 'UA'). MODULE module_1. FIELD connect SELECT * FROM spfli WHERE carrid = carrier AND connid = connect WHENEVER NOT FOUND SEND ERRORMESSAGE 107 WITH carrier connect. MODULE module_2. The user must enter a value for carrier that is in the list following VALUES before module_1 is called. When module_1 is called, connect has not yet been transported. Next, the user can only enter a value for connect that exists in the database table SPFLI as part of a primary key together with carrier. If not, error message 107 from message class AT is displayed in the status bar: Unable to find any entries for key & &. Only when a correct value has been entered will connect be transported and module_2 called. Input Checks in Dialog Modules You cannot perform input checks in PAI modules of programs until you have transported the contents of the input fields to the ABAP program. You can then use logical expressions to check the values that the user entered. You should then allow the user to correct any wrong entries before calling further modules.You can do this by sending warning (type W) or error (type E) messages from PAI modules that are called in conjunction with the statements FIELD and CHAIN. Checking Single FieldsIf you send a warning or error message from a module mod that you called using a FIELDstatement as follows: FIELD f MODULE mod. the corresponding input field on the current screen is made ready for input again, allowing the user to enter a new value. If the field is only checked once, the PAI processing continues directly after the FIELDstatement, and the preceding modules are not called again. Checking a Set of FieldsIf a warning or an error message is sent in a module mod1 mod2 … that you called within a processing chain: CHAIN. FIELD: f1, f2,... MODULE mod1. FIELD: g1, g2,... MODULE mod2. ... ENDCHAIN. all of the input fields on the current screen that belong to the processing chain are made ready for input again – including those that are in FIELD statements after the MODULEstatement. All the other fields are not ready for input. Even if a MODULE statement appears within a processing chain, combined with a FIELD statement, all of the input fields in the chain are made ready for input again – not just the field in question. The user can repeat the input. If the fields in the processing chain are only checked once, the PAI processing continues directly after the automatic checks at the CHAINstatement, and the preceding modules are not called again. Controlling Input and Data TransportIf you use the FIELD statement outside a processing chain, only a single field is made ready for input when a warning or error message is displayed. If you use FIELD statements between CHAIN - ENDCHAIN, this controls a set of fields. All of the fields controlled by a FIELDstatement are transported back to the screen, bypassing PBO processing. This means that any changes made to the field contents before the message become visible on the screen. This also applies to information Checking Fields RepeatedlyYou may sometimes need to specify the same field in more than one FIELD or CHAIN statement. If one of the corresponding modules sends a warning or error message, PAI processing resumes with the value that the user corrected. However, in this case, processing cannot simply resume at the corresponding FIELD or CHAIN statement if the field in question has already been included in an earlier FIELD or CHAIN statement. Instead, all of the FIELD and CHAIN statements containing a field in which an error occurred are repeated. PAI processing resumes at the first FIELD or CHAINstatement containing one or several of the fields in which the error occurred and that the user changed the last time the screen was displayed. PROCESS AFTER INPUT.FIELD f1 MODULE m1. FIELD f2 MODULE m2. CHAIN. FIELD: f1, f2, f3. FIELD: f4, f5, f1. MODULE m3. MODULE m4. ENDCHAIN. CHAIN. FIELD: f6. MODULE m5. ENDCHAIN. CHAIN. FIELD f4. MODULE m6. ENDCHAIN. If module m6contains a warning or error message, the screen is displayed again, after which processing resumes with the first CHAIN statement. Module m3 is called since this is the first occurrence of the field f4. Remaining Functions in the FIELD StatementAll of the functions of the FIELD and CHAINstatements for controlling data transport and conditional module calls can also be used in combination with warning and error messages. The contents of each field are transported at the FIELD statement in which the field occurs. If a warning or error message occurs in a conditional module of a processing chain, all of the fields in that chain will be ready for input when the screen is redisplayed, although not all of the fields will have been transported. If a warning or error message occurs in a module that is not linked with a FIELD or CHAIN statement, none of the fields on the screen will be ready for input. In this case, the user can only exit the program, but only if a corresponding unconditional module call is provided. ![]() Input Checks in Dialog Modules PROGRAM demo_dynpro_field_chain. DATA: ok_code TYPE sy-ucomm, input1 TYPE i, input2 TYPE i, input3 TYPE i, input4 TYPE i, input5 TYPE i, input6 TYPE i, sum TYPE i. CALL SCREEN 100. MODULE init_screen_100 OUTPUT. CLEAR: input1, input2, input3, input4, input5, input6. SET PF-STATUS 'STATUS_100'. ENDMODULE. MODULE cancel INPUT. LEAVE PROGRAM. ENDMODULE. MODULE module_1 INPUT. IF input1 < 50. MESSAGE e888(sabapdocu) WITH text-001 '50' text-002. ENDIF. ENDMODULE. MODULE module_2 INPUT. IF input2 < 100. MESSAGE e888(sabapdocu) WITH text-001 '100' text-002. ENDIF. ENDMODULE. MODULE module_3 INPUT. IF input3 < 150. MESSAGE e888(sabapdocu) WITH text-001 '150' text-002. ENDIF. ENDMODULE. MODULE chain_module_1 INPUT. IF input4 < 10. MESSAGE e888(sabapdocu) WITH text-003 '10' text-002. ENDIF. ENDMODULE. MODULE chain_module_2 INPUT. CLEAR sum. sum = sum + : input4, input5, input6. IF sum <= 100. MESSAGE e888(sabapdocu) WITH text-004 '100' text-002. ENDIF. ENDMODULE. MODULE execution INPUT. MESSAGE i888(sabapdocu) WITH text-005. ENDMODULE. The next screen (statically defined) for screen 100 is 100. It has the following layout: ![]() The screen fields input1 through input6 are assigned to the input fields. The function code of the pushbutton is EXECUTE. In the GUI status STATUS_100, the icon (F12) is active with function code CANCEL and function type E. Furthermore, the function key F8 is assigned to the function code EXECUTE with the function type <blank>. The screen flow logic is as follows: PROCESS BEFORE OUTPUT. MODULE init_screen_100. PROCESS AFTER INPUT. MODULE cancel AT EXIT-COMMAND. FIELD input1 MODULE module_1. FIELD input2 MODULE module_2. FIELD input3 MODULE module_3. CHAIN. FIELD input4. MODULE chain_module_1. FIELD input5. FIELD input6 MODULE chain_module_2. ENDCHAIN. MODULE EXECUTION. This program demonstrates how you can check input fields in dialog modules. The fields input1 through input3 are checked independently of each other in the modules module_1 through module_3. As long as the user does not enter a corresponding value, the screen is repeatedly displayed with the appropriate field ready for input. The fields input4 through input6 are checked together in a processing chain. If input4 does not satisfy the condition in chain_module_1, all three fields are again ready for input. The same applies if the three fields do not satisfy the condition in chain_module_2. The EXECUTION module, from which an information message is displayed, is not executed until all six fields satisfy the appropriate conditions. Print out the Additonal Charge in a FORMStep1 : Modify Standard Print program. Step2: Change the condition type's description (Maintain condition type) "Michael 2009.02.20 DATA: BEGIN OF K OCCURS 50. INCLUDE STRUCTURE KOMVD. DATA: P(2) TYPE C. DATA: END OF K. DATA: BEGIN OF IT_KONV OCCURS 50. INCLUDE STRUCTURE KOMVD. DATA: END OF IT_KONV. ---------------------------------------------------------------------* * FORM HEADER_PRICE_PRINT * *---------------------------------------------------------------------* * Printout of the header prices * *---------------------------------------------------------------------* FORM header_price_print. "Michael Adding for item discount separated show 2009.02.20 DATA: lt_VTEXT LIKE TKOMVD-VTEXT. data: l_index like sy-tabix. READ TABLE tkomv with key KSCHL = 'ZDIS'. if sy-subrc eq 0. SELECT * INTO CORRESPONDING FIELDS OF TABLE IT_KONV FROM KONV WHERE KNUMV = VBDKR-KNUMV AND KSCHL = 'ZDIS' and KWERT < 0. if it_konv[] is not INITIAL. READ TABLE TKOMVD WITH KEY kschl = 'ZDIS'. if sy-subrc eq 0. lt_VTEXT = TKOMVD-vtext. Loop at it_konv. it_konv-VTEXT = lt_VTEXT. modify it_konv index sy-tabix. ENDLOOP. TKOMVD[] = IT_KONV[]. endif. ENDIF. ENDIF. "End of adding LOOP AT hkomvd. l_index = sy-tabix. AT FIRST. IF komk-supos NE 0. CALL FUNCTION 'WRITE_FORM' EXPORTING element = 'ITEM_SUM'. ELSE. CALL FUNCTION 'WRITE_FORM' EXPORTING element = 'UNDER_LINE' EXCEPTIONS element = 1 window = 2. IF sy-subrc NE 0. PERFORM protocol_update. ENDIF. ENDIF. ENDAT. komvd = hkomvd. "Michael added 2009.02.20 CLEAR TKOMVD-KOEIN. CLEAR TKOMVD-AWEIN. cleaR TKOMVD-KMEIN. modify Tkomvd index l_index. MOVE-CORRESPONDING TKOMVD TO K. "Michael 2009.02.20 K-P = TKOMVD-KPOSN+4(2). "End of adding ZUPDATE_DATA_OO*&---------------------------------------------------------------------*
*& Report ZUPDATE_DATA_OO *& *&---------------------------------------------------------------------* *& Author : CHUNG NAM INTERNATIONAL CO.,LTD. MICHAELCHOW *& Creation Date : 20.11.2008 *& Program Type : Executable Programs *& Logical DB : [Nil] *& Text Elements *& (Titles&Headers) : [Nil] *& (Selection Texts) : [Nil] *& (Text symbols) : [Nil] *& GUI Status : [Nil] OR [Standard] *& Variants : [Nil] OR Variant *& Message Class : [Nil] *& Description : *& *&---------------------------------------------------------------------* *& Modifications : *& ID Date Programmer Description *& *&---------------------------------------------------------------------* REPORT ZUPDATE_DATA_OO. * Define Screen Container DATA: obj_container TYPE REF TO cl_gui_custom_container. DATA: o_error TYPE REF TO i_oi_error, o_control TYPE REF TO i_oi_container_control, o_document TYPE REF TO i_oi_document_proxy, o_spreadsheet TYPE REF TO i_oi_spreadsheet. * Data declarations. DATA: t_files TYPE filetable, s_files TYPE file_table, v_doc_name TYPE char256, v_changed TYPE int4, v_rcode TYPE int4, t_ranges TYPE soi_range_list, s_ranges TYPE soi_range_item, t_data TYPE soi_generic_table, s_data TYPE soi_generic_item, v_action TYPE int4. * Initialization event. INITIALIZATION. CLASS c_oi_errors DEFINITION LOAD. * Create Instance control for container CALL METHOD c_oi_container_control_creator=>get_container_control IMPORTING control = o_control error = o_error. IF o_error->has_failed = 'X'. CALL METHOD o_error->raise_message EXPORTING type = 'E'. ENDIF. * Create generic container linked to container in screen 100 CREATE OBJECT obj_container EXPORTING container_name = 'CONTAINER' EXCEPTIONS cntl_error = 1 cntl_system_error = 2 create_error = 3 lifetime_error = 4 lifetime_dynpro_dynpro_link = 5 others = 6. IF sy-subrc <> 0. MESSAGE e208(00) WITH 'Error creating container'. ENDIF. * Establish connection to GUI Control CALL METHOD o_control->init_control EXPORTING r3_application_name = 'Excel Document Container' inplace_enabled = 'X' parent = obj_container IMPORTING error = o_error. IF o_error->has_failed = 'X'. CALL METHOD o_error->raise_message EXPORTING type = 'E'. ENDIF. * Create Document Proxy CALL METHOD o_control->get_document_proxy EXPORTING document_type = soi_doctype_excel_sheet IMPORTING document_proxy = o_document error = o_error. IF o_error->has_failed = 'X'. CALL METHOD o_error->raise_message EXPORTING type = 'E'. ENDIF. * Start-of-selection. START-OF-SELECTION. * Call dialog to navigate to file CALL METHOD cl_gui_frontend_services=>file_open_dialog EXPORTING default_extension = '.xls' file_filter = '*.xls' initial_directory = 'C:\' CHANGING file_table = t_files rc = v_rcode user_action = v_action EXCEPTIONS file_open_dialog_failed = 1 cntl_error = 2 error_no_gui = 3 OTHERS = 4. IF sy-subrc <> 0. MESSAGE e208(00) WITH 'FILE_OPEN_DIALOG'. ENDIF. * Only continue if User hasn't cancelled CHECK: v_action = 0. * Determine filename to open Excel document READ TABLE t_files INDEX 1 INTO s_files. IF sy-subrc = 0. CONCATENATE 'FILE://' s_files-filename INTO v_doc_name. ELSE. MESSAGE e208(00). ENDIF. "sy-subrc = 0 * Open Spreadsheet in SAPWORKDIR CALL METHOD o_document->open_document EXPORTING open_inplace = 'X' document_title = 'Excel' document_url = v_doc_name no_flush = '' IMPORTING error = o_error. IF o_error->has_failed = 'X'. CALL METHOD o_error->raise_message EXPORTING type = 'E'. ENDIF. * Open Spreadsheet interface CALL METHOD o_document->get_spreadsheet_interface EXPORTING no_flush = '' IMPORTING sheet_interface = o_spreadsheet error = o_error. IF o_error->has_failed = 'X'. CALL METHOD o_error->raise_message EXPORTING type = 'E'. ENDIF. * Set selection for 1000 rows CALL METHOD o_spreadsheet->set_selection EXPORTING top = 1 left = 1 rows = '1000' columns = '36'. * Define Range in spreadsheet CALL METHOD o_spreadsheet->insert_range EXPORTING name = 'Test' rows = '1000' columns = '36' no_flush = '' IMPORTING error = o_error. IF o_error->has_failed = 'X'. CALL METHOD o_error->raise_message EXPORTING type = 'E'. ENDIF. s_ranges-name = 'Test'. s_ranges-rows = '1000'. s_ranges-columns = '36'. APPEND s_ranges TO t_ranges. * Get data CALL METHOD o_spreadsheet->get_ranges_data EXPORTING all = '' no_flush = '' IMPORTING contents = t_data error = o_error CHANGING ranges = t_ranges. IF o_error->has_failed = 'X'. CALL METHOD o_error->raise_message EXPORTING type = 'E'. ENDIF."* Close document * Close the document CALL METHOD o_document->close_document EXPORTING do_save = '' no_flush = '' IMPORTING has_changed = v_changed error = o_error. IF o_error->has_failed = 'X'. CALL METHOD o_error->raise_message EXPORTING type = 'E'. ENDIF. * Clear Document Resources CALL METHOD o_document->release_document EXPORTING no_flush = '' IMPORTING error = o_error. IF o_error->has_failed = 'X'. CALL METHOD o_error->raise_message EXPORTING type = 'E'. ENDIF. * Clear table of file names FREE: t_files, o_control. * Display the data LOOP AT t_data INTO s_data. AT NEW row. SKIP. ENDAT. WRITE:(10) s_data-value. ENDLOOP. How to find the BADI1. BADIs are storaged in below tables: SXS_INTER --------Exit: Definition side: Interfaces SXC_EXIT --------Exit: Implementation side: Assignment: Exit - Implementation SXC_CLASS --------Exit, implementation side: Class assignment (multiple) SXC_ATTR --------Exit: Implementation side: Attributes 2. SAP program will call "CL_EXITHANDER=>GET_INSTANCE" to check the object if it exists and return the instance, just search data from above tables and its' views V_EXT_IMP and V_EXT_ACT 3.So,we can according those information using ST05 to trace the BADIs. 4. Using SE18 to find the interface, use SE19 to carry out the Implementation. |
|
|