Skip to Content
0
Former Member
Feb 01, 2012 at 09:35 AM

Profit Center message display in MV45AFZZ

136 Views

In include MV45AFZZ USEREXIT_SAVE_DOCUMENT_PREPARE I have added code to display information message if profit centre is initial/blank for any line item.

Suppose there are 3 line items for a sales order with line item 20 & 30 having profit centers as initial/blank. I get my information message displayed as Profit centre not maintained for line items: 20, 30. Then I press enter and it allows me to add profit centers for the missing line items.

I assign profit centre for line item 20 only and for line item 30 I want it to be blank. Then I save it.

Here comes my issue :

Again information message displays as u201C Profit centre not maintained for line item 30u201D. Unless I enter profit center value in line item 30 the message displays. If I enter some value and save it then document is saved.

I need the message to be displayed only once and user can enter missing profit centre for any line item & save it. Now its mandatory to enter profit center for all line items.

IF FLAG IS INITIAL.
LOOP AT xvbap.
  IF xvbap-prctr IS INITIAL.
     lv_posnr = xvbap-posnr.
     CONDENSE lv_posnr.

     CALL FUNCTION 'BKK_DELETE_LEADING_ZERO'
        CHANGING
          c_field       = lv_posnr.

      IF lv_text IS NOT INITIAL.
        CONCATENATE  lv_text lv_posnr into lv_text SEPARATED BY ','.
      ELSE.
        lv_text = lv_posnr.
      ENDIF.
  ENDIF.
  CLEAR lv_posnr .
 ENDLOOP.
IF lv_text IS NOT INITIAL.
      fcode = 'ENT1'.
      CONCATENATE zmsg_txt lv_text INTO zmsg.
      message i000(ZZ) WITH zmsg.
         FLAG = 1.
         fcode = 'ENT1'.
         LEAVE TO SCREEN 4001.
   ENDIF.
ENDIF.

~Arya

Edited by: arya soumya on Feb 1, 2012 10:36 AM