Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7185507
  • 博文数量: 655
  • 博客积分: 10264
  • 博客等级: 上将
  • 技术积分: 8278
  • 用 户 组: 普通用户
  • 注册时间: 2007-06-04 17:47
个人简介

ABAP顾问

文章分类

全部博文(655)

文章存档

2017年(2)

2014年(8)

2013年(3)

2012年(2)

2011年(18)

2010年(102)

2009年(137)

2008年(274)

2007年(134)

分类:

2007-12-07 14:46:00

 
 
近日有兄弟问我TC中F4的问题,因为忙,一直没有搞,今天清闲些,研究了一下,程序如下:
 
REPORT z_barry_tc_f4 .
CONTROLS: tc01 TYPE TABLEVIEW USING SCREEN 0100.
TYPES: BEGIN OF ty_itab,
         carrid TYPE spfli-carrid,
         connid TYPE spfli-connid,
       END OF ty_itab.
DATA: itab TYPE TABLE OF ty_itab ,
      wa TYPE ty_itab .
DATA: progname TYPE sy-repid,
      dynnum   TYPE sy-dynnr,
      dynpro_values TYPE TABLE OF dynpread,
      field_value LIKE LINE OF dynpro_values .
DATA: ok_code   LIKE sy-ucomm.
START-OF-SELECTION.
  wa-carrid = 'A01'.
  wa-connid = '0001'.
  APPEND wa TO itab.
  CALL SCREEN 100.
*---------------------------------------------------------------------*
*       MODULE TC01_change_tc_attr OUTPUT                             *
*---------------------------------------------------------------------*
MODULE tc01_change_tc_attr OUTPUT.
  DESCRIBE TABLE itab LINES tc01-lines.
ENDMODULE.
*---------------------------------------------------------------------*
*       MODULE TC01_modify INPUT                                      *
*---------------------------------------------------------------------*
MODULE tc01_modify INPUT.
  READ TABLE itab INTO wa INDEX tc01-current_line
                          TRANSPORTING NO FIELDS .
  IF sy-subrc = 0 .
    MODIFY itab FROM wa INDEX tc01-current_line.
  ELSE.
    INSERT wa INTO itab INDEX tc01-current_line.
  ENDIF.
ENDMODULE.
*&---------------------------------------------------------------------*
*&      Module  status_0100  OUTPUT
*&---------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
  SET PF-STATUS 'MAIN100'.
  progname = sy-repid.
  dynnum   = sy-dynnr.
ENDMODULE.                 " status_0100  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
  CASE ok_code.
    WHEN 'BACK'.
      LEAVE PROGRAM.
  ENDCASE.
ENDMODULE.                 " USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*&      Module  showf4  INPUT
*&---------------------------------------------------------------------*
MODULE showf4 INPUT.
  DATA: l_selline LIKE sy-stepl,
        d_values TYPE TABLE OF dynpread,
        f_value LIKE LINE OF dynpro_values .
  DATA: tmpitab LIKE itab.
  CLEAR tmpitab.
  GET CURSOR LINE l_selline.
  CALL FUNCTION 'DYNP_VALUES_READ'
       EXPORTING
            dyname     = progname
            dynumb     = dynnum
            request    = 'A'
       TABLES
            dynpfields = d_values.
  READ TABLE d_values INTO f_value
                        WITH KEY fieldname = 'WA-CARRID'
                                 stepl = l_selline.
  SELECT  carrid connid
    FROM  spfli
    INTO  CORRESPONDING FIELDS OF TABLE tmpitab
    WHERE carrid = f_value-fieldvalue.
  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
       EXPORTING
            retfield    = 'CONNID'
            dynpprog    = progname
            dynpnr      = dynnum
            dynprofield = 'CONNECTION'
            value_org   = 'S'
       TABLES
            value_tab   = tmpitab.
ENDMODULE.                 " showf4  INPUT
 
 
***************

PROCESS BEFORE OUTPUT.
  MODULE status_0100.
  MODULE tc01_change_tc_attr.
  LOOP AT   itab
       INTO wa
       WITH CONTROL tc01
       CURSOR tc01-current_line.
  ENDLOOP.
PROCESS AFTER INPUT.
  MODULE user_command_0100.
  LOOP AT itab.
    CHAIN.
      FIELD wa-carrid.
      FIELD wa-connid.
      MODULE tc01_modify ON CHAIN-REQUEST.
    ENDCHAIN.
  ENDLOOP.
PROCESS ON VALUE-REQUEST.
  FIELD wa-connid MODULE showf4.
阅读(6059) | 评论(2) | 转发(0) |
给主人留下些什么吧!~~

joe.g.r.chen2008-05-14 22:50:05

Hi 兄弟,这个例子好像只能实现对话框的情况。如果我的ID和连接号码(TC里的字段)都是LIST BOX的话,能不能实现呢?也就是说,当用户点击连接号码的LIST BOX的时候,这个LIST BOX时原值会根据ID(这个ID随时会根据用户在屏幕上的输入而改变。)产生一个LIST让用户选择。