Skip to Content
0
Former Member
Aug 29, 2005 at 06:20 PM

BADI u0091SD_COND_SAVE_Au0092-Transaction terminated

153 Views

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