注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

XINBO'S SAP BLOG

你所浪费的今天,是昨天死去的人奢望的明天。你所厌恶的现在,是未来的你回不去的曾经

 
 
 

日志

 
 

POV事件下获取TC当前行号并动态确定搜索帮助  

2013-10-25 16:48:12|  分类: ABAP DICTIONARY |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
一、需求: 
1)需要在PROCESS ON VALUE-REQUEST事件下获取当前字段在TC中的行号;
2)根据行内其他字段的值动态确定搜索帮助

二、解决办法:
1)调用SHL2函数组下的DYNP_GET_STEPL函数或者GET CURSOR LINE获取TC当前行号
2)调用SDHI函数组下的F4IF_INT_TABLE_VALUE_REQUEST函数确定搜索帮助

三、代码示例:
1)屏幕流代码
PROCESS ON VALUE-REQUEST.
  FIELD GT_ZEQUIPMENT-VALUE  MODULE GET_RELATION.

2)程序代码
*&---------------------------------------------------------------------*
*&      Module  GET_RELATION  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE GET_RELATION INPUT.
  DATA:GT_ZEQUIPMENT_1 LIKE ZEQUIPMENT OCCURS WITH HEADER LINE,
       POVSTEPL LIKE  SY-STEPL,
       L_INDEX  LIKE  SY-STEPL.

  CALL FUNCTION 'DYNP_GET_STEPL'
    IMPORTING
      POVSTEPL        POVSTEPL
    EXCEPTIONS
      STEPL_NOT_FOUND 1.

*GET CURSOR LINE POVSTEPL

  L_INDEX TC1-TOP_LINE + POVSTEPL 1"当前行号 = TC(包括翻页)的首行行号 + 本页当前行号 - 1

  READ TABLE GT_ZEQUIPMENT INDEX L_INDEX.

  SELECT FROM ZEQUIPMENT INTO CORRESPONDING FIELDS OF TABLE GT_ZEQUIPMENT1 WHERE ZPARAMETER GT_ZEQUIPMENT-ZPARAMETER.
  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
      RETFIELD         'VALUE'
      DYNPROFIELD      'GT_ZEQUIPMENT-VALUE'
      DYNPPROG         SY-REPID
      DYNPNR           SY-DYNNR
      VALUE_ORG        'S'
      CALLBACK_PROGRAM SY-REPID
    TABLES
      VALUE_TAB        GT_ZEQUIPMENT_1
    EXCEPTIONS
      PARAMETER_ERROR  1
      NO_VALUES_FOUND  2
      OTHERS           3.
ENDMODULE.                 " GET_RELATION  INPUT

四、相关函数官方解释
1)DYNP_GET_STEPL

短文本

Current sy-stepl at event POV

Functionality

In a module at the time Process On Value-Request (POV) or Process On Help-Request (POH), the function module defines the current step loop line from which the F4 or F1 help was called.

Example
  data: step_line like sy-stepl.
  call function 'DYNP_GET_STEPL'
       importing
            povstepl        = step_line
       exceptions
            stepl_not_found = 1
            others          = 2.

Notes

The function module should always be called if one of the modules DYNP_VALUES_READ or DYNP_VALUES_UPDATE is used afterward.

The value of the field STEP_LINE must be stored in field STEPL of table DYNPFIELDS of these two modules.


2)F4IF_INT_TABLE_VALUE_REQUEST

短文本

F4 help also returning the value to be displayed in internal table

Functionality

This module implements the standard help at POV while passing the values to be displayed in a table. The entire dialogue behaves as for a standard F4 help. This module also supports input help control.

Note: Before you use this module at POV (Process on Value-Request), reconsider whether a search help could not carry out the same task. You can implement self-defined value selection in a search help exit. This has the advantage that you can attach the search help to a data element or a field of a structure. The F4 help is then automatically available for all users of the data element or structure.

The values to be displayed are passed in table VALUE_TAB. There are different ways to organize the data in VALUE_TAB. These are mainly defined with the parameter VALUE_ORG.

    1. VALUE_ORG = 'S' (Structure)
    This option should be used for new developments (despite other default values).
    VALUE_TAB is an internal table with a (flat) structure. Every line in VALUE_TAB then corresponds to one line in the list to be displayed.
    How the definition of the data struture is passed to the module is described below.
    The data in VALUE_TAB is available in internal representation.
    2. VALUE_ORG = 'C' (Column)
    Each line of VALUE_TAB contains the contents of a single field. The contents of VALUE_TAB are copied to the hit list line by line. The description of the columns is passed in FIELD_TAB. When all fields of FIELD_TAB have been edited, the next line is processed.
    In this case the values in VALUE_TAB must be passed in external representation. This means that for types whose external and internal representation differ, the values should be passed to VALUE_TAB with the ABAP command WRITE and not with MOVE (These are for example all the numeric types, date, fields with conversion exit, etc.). Use the extension LEFT-JUSTIFIED for numbers.
    Caution: Do not copy any constants directly to VALUE_TAB. For example, if a date is defined as constant "01.01.1998", it can no loner be interpreted for other user-specific settings.

Definition of the data structure of VALUE_TAB.

Depending on how the internal table VALUE_TAB was defined, there are different ways to pass this structure to the module.

In the end, the data structure is always stored internally in table FIELD_TAB. In addition to passing the value directly in the call, there are different ways for the module to fill the table automatically or to enhance the data automatically.

    1. The structure of internal table VALUE_TAB is defined in the ABAP Dictionary. For example the table is defined as follows:
    DATA: VALUE_TAB LIKE <DDIC structure> OCCURS 0 [WITH HEADER LINE].
    In this case it is sufficient to pass the name of the reference structure to parameter DDIC_STRUCTURE. Table FIELD_TAB should not be passed in this case because it is automatically filled with the information from the ABAP Dictionary in the function module.
    Table FIELD_TAB only has to be defined instead of parameter DDIC_STRUCTURE if for example some of the fields of the structure should not be displayed or if the order of the columns or header texts should be changed.
    If only fields TABNAME and FIELDNAME are filled in FIELD_TAB, the module gets the remaining information from the ABAP Dictionary. As a result you can easily choose individual fields and their order.
    If you want to change text, you should fill FIELD_TAB initially using the module DDIF_FIELDINFO_GET. You can then change for example the text in FIELD_TAB.
    2. Table VALUE_TAB can for example be defined as follows:
    DATA: BEGIN OF VALUE_TAB OCCURS 0,
             FIELD1 LIKE <DDIC FIELD>,
             FIELD2 TYPE <Data element>,
             "etc.
          END OF VALUE_TAB.
    If all the fields have an explicit reference to a DDIC field (mit LIKE) or to a data element (with TYPE), the module itself can determine the structure of VALUE_TAB. In this case do not pass either DDIC_STRUCTURE or FIELD_TAB.
    If you want to pass the field description with FIELD_TAB (for example because you do not want to display all the fields), you normally should not only fill TABNAME and FIELDNAME. The module then gets all the information from the ABAP Dictionary. This also includes the relative position of a field to the beginning of the Dictionary structure. However, this usually will not agree with the relative position of the field in VALUE_TAB.
    In this case it is better to fill table FIELD_TAB using module DDIF_FIELDINFO_GET. The relative position of the fields in VALUE_TAB should then be corrected in FIELD_TAB-OFFSET. You can use for example the ABAP command DESCRIBE DISTANCE here.
    3. The table has only one field that holds the values column by column. 'C' is passed as VALUE_ORG. The definition of VALUE_TAB could be for example:
    DATA: VALUE_TAB(100) TYPE C OCCURS 0 [WITH HEADER LINE].
    The definition of the columns should be passed in FIELD_TAB. Again you can limit yourself to TABNAME and FIELDNAME if the remaining information (type, length, headers) should be obtained from the ABAP Dictionary.
    The relative position of the fields to the beginning of the structure (FIELD_TAB-OFFSET) are of no importance for this type of data transfer.
    Even if you want to pass the entire information in FIELD_TAB yourself, you nevertheless should first fill FIELD_TAB with DDIF_FIELDINFO_GET from the ABAP Dictionary. You can then change individual fields, such as header text, before calling the module.
    If you define parameter DDIC_STRUCTURE, FIELD_TAB is internally given the field description of the DDIC structure passed. This is normally meaningless for column-by-column data transfer.

The field names in FIELD_TAB must be unique. If you need fields with the same name from different structures, you should get the information with the function module DDIF_FIELDINFO_GET yourself and then change the field name.

Return the selection in the screen

If the screen information DYNPPROG, DYNPNR, DYNPROFIELD and possibly STEPL are also defined, the selected value is automatically returned in the screen field.

If possible, you should always give this information because the amodal control version of the F4 help can only be supported with this information. A user who switches on the F4 help control does not see a difference between the standard F4 help and a help implemented with this function module in this case.

If the user activates the ActiveX help, it is started amodally under the following conditions:
1. The screen information DYNPPROG, DYNPNR and DYNPROFIELD must be defined.
2. When the function module is called, the RETURN_TAB may not be defined. (In an amodal call, the function module returns before the user has selected a value).

Normally values are only returned in input fields. This behavior can be changed with parameter DISPLAY (see parameter documentation).

With Release 4.6C the module can automatically recognize an input field.

Notes

  • DYNPPROG and DYNNR cannot be passed as SY-REPID and SY-DYNNR because they are only analyzed after the function module has been called. Instead, first copy the SY fields to local variables and then pass them to the function module.
  • The value for STEPL is not within a step loop 0. Within a step loop, the current line can be defined at time POV with the function module DYNP_GET_STEPL.
  • If you do not want to return the selected value automatically, you should not define parameters DYNPPROG, DYNNR etc. A value is not returned automatically if MULTIPLE_SELECTION is selected either, but this could change in the future!
  • Calls that do not permit a value to be returned automatically can only be implemented modally. The input help control nevertheless can be used for the display, but no other entries can be made in the screen as long as the popup window is displayed. The value is returned in table RETURN_TAB. If the user terminates the F4 help, RETURN_TAB is returned empty (termination does not result in an exception).

Further information

Also read the documentation for the parameters, especially for VALUE and CALLBACK_FORM.

  评论这张
 
阅读(613)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017