使用弹窗批量修改数据POPUP_GET_VALUES

ABAP开发 专栏收录该内容
90 篇文章 4 订阅

业务场景:在SAP内,有时候需要用户批量维护某些数据,这时候可以使用标准函数POPUP_GET_VALUES可以进行批量的维护。

效果图

 

FORM CALL_CHANGE CHANGING P_L_RETURN_CODE .

DATA: BEGIN OF FIELDS OCCURS 5.
       INCLUDE STRUCTURE SVAL.
DATA: END   OF FIELDS.

DATA: L_RETURN_CODE TYPE C.
DATA: DATE  LIKE  T5A4A-DLYDY.

CLEAR:FIELDS.
FIELDS-TABNAME    = 'ZTSD_SCXQ_H'.
FIELDS-FIELDNAME  = 'WERKS'.
APPEND FIELDS.

CLEAR:FIELDS.
FIELDS-TABNAME    = 'EKKO'.
FIELDS-FIELDNAME  = 'EKORG'.
APPEND FIELDS.

CLEAR:FIELDS.
FIELDS-TABNAME    = 'EKKO'.
FIELDS-FIELDNAME  = 'EKGRP'.
APPEND FIELDS.

CLEAR:FIELDS.
FIELDS-TABNAME    = 'LFA1'.
FIELDS-FIELDNAME  = 'LIFNR'.
APPEND FIELDS.

*FIELDS-TABNAME    = 'LFA1'.
*FIELDS-FIELDNAME  = 'NAME1'.
*APPEND FIELDS.

CLEAR:FIELDS.
FIELDS-TABNAME    = 'T001L'.
FIELDS-FIELDNAME  = 'LGORT'.
APPEND FIELDS.

CLEAR:FIELDS.
FIELDS-TABNAME    = 'ZTMM_ZMWSKZ'.
FIELDS-FIELDNAME  = 'MWSKZ'.
APPEND FIELDS.

CLEAR:FIELDS.
FIELDS-TABNAME    = 'EKKO'.
FIELDS-FIELDNAME  = 'BSART'.
APPEND FIELDS.

CLEAR:FIELDS.
FIELDS-TABNAME    = 'ZTPP_CPDM'.
FIELDS-FIELDNAME  = 'ZDM'.
FIELDS-FIELDTEXT  = '产品代码'.
APPEND FIELDS.

CLEAR:FIELDS.
FIELDS-TABNAME    = 'ZTPP_SCDM'.
FIELDS-FIELDNAME  = 'ZDM'.
FIELDS-FIELDTEXT  = '生产代码'.
APPEND FIELDS.

CLEAR:FIELDS.
FIELDS-TABNAME    = 'EKKO'.
FIELDS-FIELDNAME  = 'ZYFK'.
APPEND FIELDS.

CLEAR:FIELDS.
FIELDS-TABNAME    = 'ZTMM_ZTERM'.
FIELDS-FIELDNAME  = 'ZTERM'.
APPEND FIELDS.

CLEAR:FIELDS.
FIELDS-TABNAME    = 'BAPIMEPOITEM'.
FIELDS-FIELDNAME  = 'UNDER_DLV_TOL'.
APPEND FIELDS.

CLEAR:FIELDS.
FIELDS-TABNAME    = 'BAPIMEPOITEM'.
FIELDS-FIELDNAME  = 'OVER_DLV_TOL'.
APPEND FIELDS.

CLEAR:FIELDS.
FIELDS-TABNAME    = 'ZTMM_JYD'.
FIELDS-FIELDNAME  = 'ZJYD'.
APPEND FIELDS.

CLEAR:FIELDS.
FIELDS-TABNAME    = 'EKKO'.
FIELDS-FIELDNAME  = 'ZCGXY'.
APPEND FIELDS.

CLEAR:FIELDS.
FIELDS-TABNAME    = 'EKKO'.
FIELDS-FIELDNAME  = 'PINCR'.
FIELDS-FIELDTEXT  = '日期加'.
APPEND FIELDS.

CLEAR:FIELDS.
FIELDS-TABNAME    = 'EKKO'.
FIELDS-FIELDNAME  = 'LPONR'.
FIELDS-FIELDTEXT  = '日期减'.
APPEND FIELDS.

CLEAR:FIELDS.
FIELDS-TABNAME    = 'EKPO'.
FIELDS-FIELDNAME  = 'NETPR'.
FIELDS-FIELDTEXT  = '含税单价'.
APPEND FIELDS.

CLEAR:FIELDS.
FIELDS-TABNAME    = 'EKKO'.
FIELDS-FIELDNAME  = 'WAERS'.
FIELDS-FIELD_ATTR = '04'  .
APPEND FIELDS.


CALL FUNCTION 'POPUP_GET_VALUES'
  EXPORTING
*   NO_VALUE_CHECK        = ' '
    POPUP_TITLE           = '批量赋值'
*   START_COLUMN          = '5'
*   START_ROW             = '5'
  IMPORTING
    RETURNCODE            = L_RETURN_CODE
  TABLES
    FIELDS                = FIELDS
  EXCEPTIONS
    ERROR_IN_FIELDS       = 1
    OTHERS                = 2
          .
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.

READ TABLE FIELDS WITH KEY FIELDNAME = 'WERKS'.
IF SY-SUBRC EQ 0.
  MOVE FIELDS-VALUE TO G_WERKS.
ENDIF.

READ TABLE FIELDS WITH KEY FIELDNAME = 'EKORG'.
IF SY-SUBRC EQ 0.
  MOVE FIELDS-VALUE TO G_EKORG.
ENDIF.

READ TABLE FIELDS WITH KEY FIELDNAME = 'EKGRP'.
IF SY-SUBRC EQ 0.
  MOVE FIELDS-VALUE TO G_EKGRP.
ENDIF.

READ TABLE FIELDS WITH KEY FIELDNAME = 'LIFNR'.
IF SY-SUBRC EQ 0.
  MOVE FIELDS-VALUE TO G_LIFNR.
ENDIF.

READ TABLE FIELDS WITH KEY FIELDNAME = 'NAME1'.
IF SY-SUBRC EQ 0.
  MOVE FIELDS-VALUE TO G_NAME1.
ENDIF.

READ TABLE FIELDS WITH KEY FIELDNAME = 'LGORT'.
IF SY-SUBRC EQ 0.
  MOVE FIELDS-VALUE TO G_LGORT.
ENDIF.

READ TABLE FIELDS INDEX 8."WITH KEY FIELDNAME = 'ZDM'.
IF SY-SUBRC EQ 0.
  MOVE FIELDS-VALUE TO G_ZDM_CP.
ENDIF.

READ TABLE FIELDS INDEX 9."WITH KEY FIELDNAME = 'ZDM'.
IF SY-SUBRC EQ 0.
  MOVE FIELDS-VALUE TO G_ZDM_GS.
ENDIF.


*G_ZDM_CP  LIKE ZTPP_CPDM-ZDM,"产品代码
*  LIKE ZTPP_CPDM-ZDM."生产代码
READ TABLE FIELDS WITH KEY FIELDNAME = 'BSART'.
IF SY-SUBRC EQ 0.
  MOVE FIELDS-VALUE TO G_BSART.
ENDIF.

READ TABLE FIELDS WITH KEY FIELDNAME = 'MWSKZ'.
IF SY-SUBRC EQ 0.
  MOVE FIELDS-VALUE TO G_MWSKZ.
ENDIF.

"是否预付款 ADD BY HANDLH 2018.5.22
READ TABLE FIELDS WITH KEY FIELDNAME = 'ZYFK'.
IF SY-SUBRC EQ 0.
  MOVE FIELDS-VALUE TO G_ZYFK.
ENDIF.

"付款条件 ADD BY HANDLH 2018.5.22
READ TABLE FIELDS WITH KEY FIELDNAME = 'ZTERM'.
IF SY-SUBRC EQ 0.
  MOVE FIELDS-VALUE TO G_ZTERM.
ENDIF.

"交货不足限度 ADD BY HANDLH 2018.5.22
READ TABLE FIELDS WITH KEY FIELDNAME = 'UNDER_DLV_TOL'.
IF SY-SUBRC EQ 0.
  MOVE FIELDS-VALUE TO G_UNTTO.
ENDIF.

"过量交货限度 ADD BY HANDLH 2018.5.22
READ TABLE FIELDS WITH KEY FIELDNAME = 'OVER_DLV_TOL'.
IF SY-SUBRC EQ 0.
  MOVE FIELDS-VALUE TO G_UEBTO.
ENDIF.

"采购单价
READ TABLE FIELDS WITH KEY FIELDNAME = 'NETPR'.
IF SY-SUBRC EQ 0.
  MOVE FIELDS-VALUE TO G_NETPR.
ENDIF.

"检验地点
READ TABLE FIELDS WITH KEY FIELDNAME = 'ZJYD'.
IF SY-SUBRC EQ 0.
  MOVE FIELDS-VALUE TO G_ZJYD.
ENDIF.

"采购协议号
READ TABLE FIELDS WITH KEY FIELDNAME = 'ZCGXY'.
IF SY-SUBRC EQ 0.
  MOVE FIELDS-VALUE TO G_ZCGXY.
ENDIF.

"日期加
READ TABLE FIELDS WITH KEY FIELDNAME = 'PINCR'.
IF SY-SUBRC EQ 0.
  MOVE FIELDS-VALUE TO G_DAY_ADD.
ENDIF.

"日期减
READ TABLE FIELDS WITH KEY FIELDNAME = 'LPONR'.
IF SY-SUBRC EQ 0.
  MOVE FIELDS-VALUE TO G_DAY_DEC.
ENDIF.

IF L_RETURN_CODE NE 'A'."不是取消 .
  LOOP AT GT_OUTPUT ASSIGNING FIELD-SYMBOL(<FW_OUTPUT>) WHERE SLBOX EQ 'X'.
    IF G_WERKS IS NOT INITIAL.
      MOVE G_WERKS  TO <FW_OUTPUT>-DWERK.
    ENDIF.

    IF G_EKORG IS NOT INITIAL .
      MOVE G_EKORG  TO <FW_OUTPUT>-EKORG.
    ENDIF.

    IF G_EKGRP IS NOT INITIAL .
      MOVE G_EKGRP  TO <FW_OUTPUT>-EKGRP.
    ENDIF.

    IF G_LIFNR IS NOT INITIAL.
      MOVE G_LIFNR  TO <FW_OUTPUT>-LIFNR.
    ENDIF.

    IF G_NAME1 IS NOT INITIAL .
      MOVE G_NAME1  TO <FW_OUTPUT>-NAME1.
    ENDIF.

    IF G_LGORT IS NOT INITIAL.
      MOVE G_LGORT  TO <FW_OUTPUT>-LGORT.
    ENDIF.

    IF G_MWSKZ IS NOT INITIAL.
      MOVE G_MWSKZ  TO <FW_OUTPUT>-MWSKZ.
    ENDIF.

    IF G_BSART IS NOT INITIAL .
      MOVE G_BSART  TO <FW_OUTPUT>-BSART.
    ENDIF.

    IF G_ZDM_CP IS NOT INITIAL.
      MOVE G_ZDM_CP TO <FW_OUTPUT>-ZDM_CP.
    ENDIF.

    IF G_ZDM_GS IS NOT INITIAL.
      MOVE G_ZDM_GS TO <FW_OUTPUT>-ZDM_GS.
    ENDIF.

    IF G_ZDM_GS IS NOT INITIAL.
      MOVE G_ZDM_GS TO <FW_OUTPUT>-ZDM_GS.
    ENDIF.

    IF G_ZYFK IS NOT INITIAL.
      MOVE G_ZYFK TO <FW_OUTPUT>-ZYFK.
    ENDIF.

    IF G_ZTERM IS NOT INITIAL.
      MOVE G_ZTERM TO <FW_OUTPUT>-ZTERM.
    ENDIF.

    IF G_UNTTO IS NOT INITIAL.
      MOVE G_UNTTO TO <FW_OUTPUT>-UNTTO.
    ENDIF.

    IF G_UEBTO IS NOT INITIAL.
      MOVE G_UEBTO TO <FW_OUTPUT>-UEBTO.
    ENDIF.

    IF G_MAKTX IS NOT INITIAL.
      MOVE G_MAKTX TO <FW_OUTPUT>-MAKTX.
    ENDIF.

    IF G_NETPR IS NOT INITIAL.
      MOVE G_NETPR TO <FW_OUTPUT>-NETPR.
    ENDIF.

    IF G_ZJYD IS NOT INITIAL.
      MOVE G_ZJYD TO <FW_OUTPUT>-ZJYD.
    ENDIF.

    IF G_ZCGXY IS NOT INITIAL.
      MOVE G_ZCGXY TO <FW_OUTPUT>-ZCGXY.
    ENDIF.

    IF G_DAY_ADD IS NOT INITIAL .
      MOVE G_DAY_ADD TO DATE.
      CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
          EXPORTING
            date      = <FW_OUTPUT>-ZJHRK_DAT
            days      = DATE  "天数加N或者减N  不加也不减 写0
            months    = 0     "月份加N或者减N  不加也不减 写0
            signum    = '+'   "可以是+或者-
            years     = 0     "年份加N或者减N  不加也不减 写0
          IMPORTING
            calc_date = <FW_OUTPUT>-ZDDJQ."得到加减之后的日期
    ENDIF.

    IF G_DAY_DEC IS NOT INITIAL .
      MOVE G_DAY_DEC TO DATE.
      CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
          EXPORTING
            date      = <FW_OUTPUT>-ZJHRK_DAT
            days      = DATE  "天数加N或者减N  不加也不减 写0
            months    = 0     "月份加N或者减N  不加也不减 写0
            signum    = '-'   "可以是+或者-
            years     = 0     "年份加N或者减N  不加也不减 写0
          IMPORTING
            calc_date = <FW_OUTPUT>-ZDDJQ."得到加减之后的日期
    ENDIF.

    SELECT SINGLE
      NAME1
      INTO <FW_OUTPUT>-NAME1
      FROM LFA1
      WHERE LIFNR EQ <FW_OUTPUT>-LIFNR.

  ENDLOOP.
ENDIF.

ENDFORM.

  • 0
    点赞
  • 0
    评论
  • 1
    收藏
  • 一键三连
    一键三连
  • 扫一扫,分享海报

打赏
文章很值,打赏犒劳作者一下
相关推荐
©️2020 CSDN 皮肤主题: Age of Ai 设计师:meimeiellie 返回首页

打赏

Joker-Full-stack

你的鼓励将是我创作的最大动力

¥2 ¥4 ¥6 ¥10 ¥20
输入1-500的整数
余额支付 (余额:-- )
扫码支付
扫码支付:¥2
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值