hemir_abap

学习ABAP的小小博客

My Links

Blog Stats

Cached @ 2025/4/25 21:05:23Control ASP.skins_mtclean_controls_blogstats_ascx

留言簿(1)

随笔分类

随笔档案

文章分类

文章档案

搜索

最新评论

阅读排行榜

评论排行榜

Cached @ 2025/4/25 21:05:23Control ASP.skins_mtclean_controls_singlecolumn_ascx

2009年6月5日 #

Data transport at point of time PAI (SAP HELP)

If the statement FIELD is used in the event block at point of time PAI, then the statement controls the data transport for the specified dynpro field. By default, all dynpro fields are transported to the ABAP program at the event PAI and before the processing of the corresponding event block. If you use one or multiple FIELD-statements, only such dynpro fields are transported directly at the event PAI, which are not listed after a FIELD-statement.

The transport of the content of a dynpro field dynp_field specified after FIELD to the homonymous global ABAP data object takes place at execution of the corresponding FIELD-statement. If a dynpro field is listed in more than one FIELD-statement, its value is transfered when the first corresponding FIELD-statement is executed. There are the following exceptions:

  • The statement FIELD has no effect for the OK-field. The OK-field is always transported directly at the event PAI.
  • A field, whose content is initial to PBO, and which is not changed by the user, is not transported by the FIELD-statement. If this field in a PAI-module is filled with a value before execution of the FIELD-statement, then the value is not overwritten with the initial value by the FIELD statement.

Note

  • The effect of the statement FIELD upon the data transport to the event PAI is independent from the link to a MODULE-statement.
  • A dynpro field must not be used in a PAI-module, before it is transported by the dynpro. Otherwise, the ABAP field contains the same value as at the end of the previous dialog step.
  • When dynpro fields are defined with reference to flat structures in the ABAP Dictionary, the homonymous global data objects of the ABAP-program must be declared with the statement TABLES as interface work area. Otherwise, no data transport takes place, neither with or without FIELD.
  • If a dynpro field is defined with reference to a data element in the ABAP-Dictionary, to which is assigned an obsolete field-exit on a customer system, then the function module of the field-exit can be executed during transport, which in general changes the value of the dynpro field.

posted @ 2009-06-05 17:30 hemir 阅读(1215) | 评论 (0)编辑 收藏

Data transport at point of time PAI (SAP HELP)

If the statement FIELD is used in the event block at point of time PAI, then the statement controls the data transport for the specified dynpro field. By default, all dynpro fields are transported to the ABAP program at the event PAI and before the processing of the corresponding event block. If you use one or multiple FIELD-statements, only such dynpro fields are transported directly at the event PAI, which are not listed after a FIELD-statement.

The transport of the content of a dynpro field dynp_field specified after FIELD to the homonymous global ABAP data object takes place at execution of the corresponding FIELD-statement. If a dynpro field is listed in more than one FIELD-statement, its value is transfered when the first corresponding FIELD-statement is executed. There are the following exceptions:

  • The statement FIELD has no effect for the OK-field. The OK-field is always transported directly at the event PAI.
  • A field, whose content is initial to PBO, and which is not changed by the user, is not transported by the FIELD-statement. If this field in a PAI-module is filled with a value before execution of the FIELD-statement, then the value is not overwritten with the initial value by the FIELD statement.

Note

  • The effect of the statement FIELD upon the data transport to the event PAI is independent from the link to a MODULE-statement.
  • A dynpro field must not be used in a PAI-module, before it is transported by the dynpro. Otherwise, the ABAP field contains the same value as at the end of the previous dialog step.
  • When dynpro fields are defined with reference to flat structures in the ABAP Dictionary, the homonymous global data objects of the ABAP-program must be declared with the statement TABLES as interface work area. Otherwise, no data transport takes place, neither with or without FIELD.
  • If a dynpro field is defined with reference to a data element in the ABAP-Dictionary, to which is assigned an obsolete field-exit on a customer system, then the function module of the field-exit can be executed during transport, which in general changes the value of the dynpro field.

posted @ 2009-06-05 17:30 hemir 阅读(1464) | 评论 (0)编辑 收藏

2009年4月1日 #

RHEL 5 安装序列号

RHEL 5 安装序列号(源于网络收集,请勿用于商业目的,否则后果自负)

Server:
* Red Hat Enterprise Linux (Server including virtualization):
2515dd4e215225dd

+ Red Hat Enterprise Linux Virtualization Platform:
49af89414d147589

Client:

* Red Hat Enterprise Linux Desktop:
660266e267419c67

+ Red Hat Enterprise Linux Desktop + Workstation Option:
da3122afdb7edd23

+ Red Hat Enterprise Linux Desktop + Workstation + DualOS Option
(Virtualization):
7fcc43557e9bbc42

+ Red Hat Enterprise Linux Desktop + DualOS Option (Virtualization):
fed67649ff918c77

posted @ 2009-04-01 16:40 hemir 阅读(1727) | 评论 (0)编辑 收藏

2009年3月26日 #

OLE 操作Excel 详解(转)

使用Excel模板进行报表的开发.

 

首先定义一个无内容的Excel报表模板文件.

通过Tcode SMW0 上传至SAP数据库中备用.(: Web对象应该选择’WebRFC 应用程序的二进制数据’)

开发程序:

在程序中需要首先导入下面两项.

INCLUDE ole2incl.    “ 此项根据需要导入不同的对象类

INCLUDE officeintegrationinclude.

INITIALIZATION 中建立文件对象与链接服务器.

参考http://help.sap.com/saphelp_40b/helpdata/en/e9/0be7ed408e11d1893b0000e8323c4f/content.htm

选择需要的报表数据.

检查目标文件是否已经存在,若存在将其删除.

使用FUNCTION 'SAP_OI_LOAD_MIME_DATA' SAP数据库中得到报表模板数据.

使用METHOD factory->get_document_proxy创建文档实例.

使用METHOD document->play_document_from_table 用报表模板数据填入文档内容.

使用METHOD document->save_copy_as 将创建的文档另存为本地文件.

关闭释放文档对象:

METHOD document->is_destroyed

METHOD document->close_document

METHOD document->release_document

FREE document.

关闭释放连接服务器:

METHOD link_server->stop_link_server

FREE link_server.

关闭释放代理对象:

METHOD factory->stop_factory

FREE factory.

下面开始处理保存到本地的报表模板,向其填写具体数据内容.

CREATE OBJECT h_excel 'EXCEL.APPLICATION'. “ 新建OLE对象

SET PROPERTY OF h_excel 'Visible' = 0.                “ 定义其不可见

CALL METHOD OF h_excel 'Workbooks' = h_mapl. “ 得到活动excel对象

CALL METHOD OF h_mapl 'Open'                             “ 打开此活动excel

    EXPORTING

    #1 = p_file.    “ 本地模板文件路径

CALL METHOD OF h_excel 'WORKSHEETS' = H_SHEET. “ 得到活动的worksheet

如果需要生成多张报表则需要建立多个Sheet .

首先判断相应名字的sheet是否已经存在:

GET PROPERTY OF WORKSHEETS 'COUNT' = SHEETCOUNT. “ 得到sheet数量

DO SHEETCOUNT TIMES.    循环判断sheetname是否已经存在,若已经存在则不再创建

    I = I + 1.

    CALL METHOD OF EXCEL 'WORKSHEETS' = TMPSHEET

      EXPORTING #1 = I.

    GET PROPERTY OF TMPSHEET 'NAME' = TMPNAME.

    IF TMPNAME = SHEETNAME.

      EXISTFLAG = 1.

      EXIT.

    ENDIF.

 ENDDO.

sheetname不存在则创建

IF EXISTFLAG = 0.

    CALL METHOD OF EXCEL 'WORKSHEETS' = MODELSHEET   “ 第一个sheet

      EXPORTING #1 = 'Sheet1'.

*     EXPORTING #1 = '模板'.

    PERFORM ERR_HDL.

    CALL METHOD OF EXCEL 'WORKSHEETS' = TMPSHEET     “ 最后一个sheet

      EXPORTING #1 = SHEETCOUNT.

    PERFORM ERR_HDL.

    CALL METHOD OF MODELSHEET 'COPY'                               Copy一个新的sheet

      EXPORTING #1 = TMPSHEET.

    PERFORM ERR_HDL.

    GET PROPERTY OF WORKSHEETS 'COUNT' = NEWSHEETCOUNT. “ 重新得到Sheet数量

    PERFORM ERR_HDL.

    IF NEWSHEETCOUNT > SHEETCOUNT.                                                  “ 判断是否创建sheet成功

      CALL METHOD OF EXCEL 'WORKSHEETS' = NEWSHEET                  “ 如果创建成功则改Sheet的名字

        EXPORTING #1 = SHEETCOUNT.                               

      PERFORM ERR_HDL.

      SET PROPERTY OF NEWSHEET 'NAME' = SHEETNAME.               “注:此处修改的是倒数第二个sheet

      PERFORM ERR_HDL.

*                  SET PROPERTY OF NEWSHEET 'SCENARIOS' = 0.

      PERFORM ERR_HDL.

    ENDIF.

 ENDIF.

将所有的sheet创建完毕后开始逐一向每个sheet添加报表内容.

CALL METHOD OF h_excel 'WORKSHEETS' = h_sheet

        EXPORTING

        #1 = 'Sheet1'.                                                                           “ 首先将第一个sheet也改名字

 

      CALL METHOD OF h_sheet 'ACTIVATE'.

      CALL METHOD OF h_excel 'ACTIVEWINDOW' = activewindow.    “ 得到活动窗口对象

      SET PROPERTY OF activewindow 'DISPLAYGRIDLINES' = 0.      “ 隐藏格线(虚线)

      SET PROPERTY OF h_sheet 'NAME' = sheet_name.                    “ 修改sheet name

 

 LOOP AT TAB_ALL.

    CLEAR sheet_name.

    sheet_name+0(10) = TAB_ALL-NAME.

    sheet_name+10(1) = '-'.

    sheet_name+11(8) = TAB_ALL-pernr.

      CALL METHOD OF h_excel 'WORKSHEETS' = h_sheet

        EXPORTING

        #1 = sheet_name.                                                           

      CALL METHOD OF h_sheet 'ACTIVATE'.                         “ 逐个sheet激活

    PERFORM fill_cell USING 2 3 1 tab_all-name.                    向各个字段添加数值

PERFORM fill_cell USING 2 5 1 tab_all-xb.                          向各个字段添加数值

… … … …

… … … …

ENDLOOP.

 SET PROPERTY OF h_excel 'Visible' = 1.                           “ 取消隐藏

 

 CALL METHOD OF h_sheet 'CLOSE'.                                   “ 关闭

 FREE OBJECT h_excel.                                                         “ 释放

 FREE OBJECT h_mapl.                                                         “ 释放

 FREE OBJECT h_sheet.                                                         “ 释放

 FREE OBJECT activewindow. 

 

调用宏(带参数)

      CALL METHOD OF excel 'RUN' EXPORTING #1 = 'ZMACRO1'

        #2 = param1.                带参数

 

根据列数(123… …)换算Excel列名(a,b,c… …)

      CALL FUNCTION 'ZHRIS_GET_EXCEL_COLUMN'

        EXPORTING

          p_column = l_int

        IMPORTING

          f_column = col.

 

FUNCTION ZHRIS_GET_EXCEL_COLUMN.

*"----------------------------------------------------------------------

*"*"Local interface:

*" IMPORTING

*"     REFERENCE(P_COLUMN) TYPE I

*" EXPORTING

*"     REFERENCE(F_COLUMN) TYPE C

*"----------------------------------------------------------------------

 

data : l_col type string .

data : l_cyc type i .

data : l_mod type i .

data : c1, c2 .

 

 l_col = 'abcdefghijklmnopqrstuvwxyz' .

 

 if p_column >= 1 .

   l_cyc = p_column div 26 .

   l_mod = p_column mod 26 . 

 

   if l_cyc > 1 .

*   l_cyc = l_cyc - 1 .

   endif.

   if l_mod > 1 .

   l_mod = l_mod - 1 .

   endif.

 

 if l_mod = 0 .

 l_cyc = l_cyc - 1 .

 l_mod = 25.

 endif.

 

 if l_cyc >= 1    .

 l_cyc = l_cyc - 1 .

 c1 = l_col+l_cyc(1).

 endif.

 if l_mod >= 1 .

 if l_mod = 1 .

 l_mod = l_mod - 1 .

 endif.

 c2 = l_col+l_mod(1).

 endif.

 

 concatenate c1 c2 into F_COLUMN .

 condense F_COLUMN no-gaps .

 endif.

 

ENDFUNCTION.

 

选择Excel中某个区域

 

      CALL METHOD OF h_sheet 'range' = range

        EXPORTING

        #1 = 'a3'

        #2 = 'b10'.

      CALL METHOD OF range 'Select' NO FLUSH.                       “ 选择

      GET PROPERTY OF range 'borders' = h_borders no flush.        “ 加边框

*      SET PROPERTY OF h_borders 'weight' = '2' no flush.

      SET PROPERTY OF h_borders 'linestyle' = '1' no flush.        “ 框线格式

      CALL METHOD OF excel 'Columns' = column                       “ 选定列

        EXPORTING

        #1 = 1.

      SET PROPERTY OF column 'ColumnWidth' = 3.                     “ 定义列宽

      SET PROPERTY OF column 'rowheight' = 30.                      “ 定义行高

      CALL METHOD OF range 'ClearContents'.                         “ 清空内容

      SET PROPERTY OF range 'MergeCells' = 1.                       “ 合并单元格

      SET PROPERTY OF range 'HorizontalAlignment' = 3.             “ 对齐方式-纵向

      SET PROPERTY OF range 'ShrinkToFit' = 0 .               “ 取消自动缩小字体

 CALL METHOD OF h_mapl 'SAVEAS'                              “ 保存Excel

    EXPORTING

    #1 = 'C:"工资明细表.xls'

    #2 = 1.

 FREE OBJECT excel.

 FREE OBJECT h_sheet.

 

 

*********** 调整Sheet 之间的顺序 *****************

    sheet_name+0(9) = '通知书'.

    sheet_name+9(1) = '-'.

sheet_name+10(2) = '01'.

 

    CALL METHOD OF h_excel 'WORKSHEETS' = h_sheet

      EXPORTING

      #1 = sheet_name.

 

    sheet_name1+0(9) = '通知书'.

    sheet_name1+9(1) = '-'.

    sheet_name1+10(2) = '02'.

 

    CALL METHOD OF h_excel 'WORKSHEETS' = h_move

      EXPORTING

      #1 = sheet_name1.

 

    CALL METHOD OF h_sheet 'Move' EXPORTING #1 = h_move.

 

*********** 调整Sheet 之间的顺序 *****************

 

posted @ 2009-03-26 15:16 hemir 阅读(1339) | 评论 (0)编辑 收藏