使用弹窗批量修改数据POPUP_GET_VALUES

转自:https://blog.csdn.net/huanglin6/article/details/81231215

业务场景:在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.
————————————————
版权声明:本文为CSDN博主「SAP-Joker」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/huanglin6/article/details/81231215

原文地址:https://www.cnblogs.com/rainysblog/p/11792956.html

时间: 2024-10-06 18:36:07

使用弹窗批量修改数据POPUP_GET_VALUES的相关文章

关于项目中批量修改数据

一.在项目中批量修改数据时应该写一条Update的Sql语句来执行,不能先将所要修改的数据筛选出来,然后再遍历修改. 原因: 1.这样只操作一次数据库,而后者需要操作无数次,性能很差. 2.绕圈子.需要修改数据时直接修改就行,不需要先全部查出来再逐条修改. 3.修改数据时时可以使用join的,例如: 1 update acc set acc.Creator = '滕晓梅' 2 from Accidents acc 3 inner join CompensationCase cc on acc.I

批量修改数据sql

--insert into P_ZPROMOTION_DOC_ITEMS (AKTNR,MATNR,MINGROSS,MCRANK,MCUPRICE,MAXBAKTNR,MAXBPAMONT,MAXBPRICE,MINBAKTNR,MINBPAMONT,MINBPRICE) SELECT AKTNR4,MATNR,MINGROSS,MCRANK,MCUPRICE,MAXBAKTNR,MAXBPAMONT,MAXBPRICE,MINBAKTNR,MINBPAMONT,MINBPRICE FROM

MySQL+MyBatis下批量修改数据的问题

今天处理数据批量的更新,场景是这样子的,web站管理的字典功能,需要添加一个记录的整体描述,以及详细内容的描述.一个字典整体概述只有一组信息,但是其详细内容,会有很多项,不确定. 这个场景,在关系型数据库操作中,就是典型的1vN的问题,即一对多的问题. 做内容修改时,涉及到批量的更新过程.这里,只针对具体的问题描述细节,不过多介绍字典的设计. 字典的查询没有问题,mybatis的mapper函数如下: <resultMap id="FullConfResultMap" type=

mongodb 里 查询数据,批量修改数据

一.查询 某某日期后面的数据 db.salon_information.find({"create_time":{$lt:ISODate("2019-02-19T01:53:01")}}).count(); 二.修改xx日期后的数据,某个字段的值 db.salon_information.update({"create_time":{$lt:ISODate("2019-02-19T01:53:01")}},{$set:{&qu

Phoenix批量修改数据

很简单的一个东西,查了挺久的,浪费了很多的时间 直接用Upsert Into Select就可以了 例:把tables表中cloumn2列等于bbb的都改成aaa Upsert Into Table (cloumn1,cloumn2,cloumn3) Select Cloumn1,'aaa',Cloumn3 From Table where Cloumn2='bbb'

批量修改mysql表、表、数据库的字符校对规则

记录一个在工作中遇到的问题,也不算是问题,为的是找一种简便的方法批量修改数据表字段的排序规则,在MySQL中叫collation,常常和编码CHARACTER一起出现的.collation有三种级别,分辨是数据库级别,数据表级别和字段级别. 1.The database level 2.The table level 3.The column level https://confluence.atlassian.com/display/CONFKB/How+to+Fix+the+Collatio

sql优化实战:从1353秒到135秒(删除索引+修改数据+重建索引)

最近在优化日结存储过程,日结存储过程中大概包含了20多个存储过程. 发现其有一个存储过程代码有问题,进一步发现结存的数据中有一个 日期字段business_date 是有问题的,这个字段对应的类型是varchar,但是存储过程传入参数的类型是char,导致最后结存进去的数据末尾多了几个空格. 比如,应该是'2016-12'的,但现在是'2016-12  '. 为了解决这个问题,要修改这个字段的值,去掉尾部的空格,于是运行如下语句: [sql] view plain copy print? upd

phpMyAdmin批量修改Mysql数据表前缀的方法

多个网站共用一个Mysql数据库时,为使数据库管理不混乱,一般采用不同的网站使用不同前缀名的方式进行区分.而如何批量修改已有数据库的前缀名 呢?全部导出修改后再导入?还是一个表一个表的修改?今天我要介绍的是相对简单的批量修改数据库中表前缀的方法,适用于修改数据库中相同前缀且数据表较多 的情况. 此例中假定修改名为“www_sdck_cn”的数据库中前缀为“phpcms_”的表,并将所有符合条件表的前缀修改为“sdck_”. 1.        用phpMyAdmin打开要修改前缀的数据库www_

ASP.NET MVC用存储过程批量添加修改数据

用Entity Framework 进行数据库交互,在代码里直接用lamda表达式和linq对数据库操作,中间为程序员省去了数据库访问的代码时间,程序员直接可以专注业务逻辑层的编写.但是对于比较复杂的表关系关联查询或者修改就比较费劲了.通常可以采用的方式是用EF执行SQL语句或者"存储过程",特别是执行复杂批量任务,当然也可以在MVC底层用ADO.NET,这里就不多说了.怎么做批量呢?这里讲讲在EF下用存储过程批量添加修改数据. 需求是这样的:需要批量添加修改产品类别的投放任务数额,每