凡尘clsoho™的博客

E-mail & MSN: clsoho@hotmail.com
QQ1超级群: <101817641已满> QQ2群:<110722895已满>
QQ3超级群:<23765855>QQ4超级群:<85338969>

问题就如下面的网址所描述的,在VK11时,做一些检查,然后返回给用户某些消息

https://forums.sdn.sap.com/message.jspa?messageID=655894

 

解决办法:

参考这里的代码:http://forums.sdn.sap.com/thread.jspa?threadID=1687027

  DATA:  BEGIN OF num_wa ,
    old_number TYPE konh-knumh,
    new_number TYPE konh-knumh,
  END   OF num_wa.
  DATA: num_tab LIKE TABLE OF num_wa.

  FIELD-SYMBOLS: <fs_num> TYPE ANY TABLE.
  DATA: lw_var(40) TYPE c.

 

 *******某些判断,如果出现错误*******

 

   MESSAGE s015 DISPLAY LIKE 'E' WITH  var1 var2.
    "删除主程序中取条件记录号的内表的数据
    lw_var = '(SAPMV13A)NUMBER_CHANGE[]'.
    ASSIGN (lw_var) TO <fs_num>.
    IF sy-subrc = 0 AND <fs_num> IS ASSIGNED.
      num_tab = <fs_num>.
      REFRESH num_tab.
     ENDIF.
      <fs_num> = num_tab.

     LEAVE TO SCREEN sy-dynnr.

 这样虽然解决了在返回屏幕后还能更改数据的操作,但是会造成条件记录号浪费的情况

就是在上面的网址中所描述的那样,在主程序中每次都会取新的条件记录号。修改数据

时取到的条件记录号将会被浪费掉。

如果你有更好的办法解决这个问题,请与我联系。谢谢

 

附:

In BADI ‘SD_COND_SAVE_A’ implementation, a validation check is added to prevent pricing condition from saving if the price entered is lower than the standard price of the material and an error message is issued using Message EXXX to indicate the error to the user. However, in the case of the validation check does fail, after the error message is issued, if user presses enter key or back key to re-activate the field for re-entering data, a cancel popup window is displayed with the error message (from message class NR number 001). Then, the transaction is terminated and user loses all data entered previously.

During our trace in debug mode, we noticed that a change document was generated (in subroutine ‘NUMBERN_VERGABE’) and added to internal table NUMBER_CHANGE during the initial save of the pricing condition, but due to the failure of the validation check placed in BADI implementation ‘SD_COND_SAVE_A’, the actual save did not take place. Then, when user pressed enter key or back key, the PAI event of the transaction VK11 was triggered and the routine NUMMERN_VERGABE’ was called again to generate a new change document. This time, in the routine ‘NUMMERN_VERGABE’, the statement READ TABLE NUMBER_CHANGE WITH KEY NUMBER_CHANGE-OLD NUMBER BINARY SERACH this time has return code ‘0’ because the internal table NUMBER_CHANGE still keeps the record previously stored during the initial save. As a result, the transaction terminated and all data was lost.

Code from Subroutine ‘NUMBER_VERGABE’:

READ TABLE NUMBER_CHANGE WITH KEY NUMBER_CHANGE-OLD_NUMBER

BINARY SEARCH.

* Neue Nummer in den Funktionsteil

MOVE NV_NEW_NUMBER TO NUMBER_CHANGE-NEW_NUMBER.

CASE SY-SUBRC.

* Nummer bereits vergeben

WHEN 0. MESSAGE A001(NR) WITH NUMBER_CHANGE-OLD_NUMBER.

* Einfügen der neuen Nummer

WHEN 4. INSERT NUMBER_CHANGE INDEX SY-TABIX.

WHEN 8. APPEND NUMBER_CHANGE.

ENDCASE.

How to avoid the transaction from being terminated when the user wants to EDIT it.
regards,
Ravi

 

posted on 2010-10-19 15:46  凡尘clsoho  阅读(2086)  评论(0编辑  收藏  举报