cancel
Showing results for 
Search instead for 
Did you mean: 

MIR4 Tcode User Exit Calling twice

former_member210770
Active Participant
0 Kudos

Hello Experts ,

Actually I am just puting 1 validation in my MIR4 tcode that it's posting date should be greater  than the SES posting date & PO document Date.

I am writing my code in :

User Exit LMR1M005 with include  ZXM08U30

if sy-tcode = 'MIR7' or sy-tcode = 'MIRO' or sy-tcode = 'MIR4'.

  data : v_lifnr type lifnr,

         v_mblnr type mblnr,

         v_budat type budat,

         v_bsart  type esart.

  data : v_bedat type ebdat.

  data : gwa_drseg like line of ti_drseg,

         gwa_drseg1 like line of ti_drseg,

         flag type char1,

         check like flag,

         c_budat like gwa_drseg1-budat,

         post_date like c_budat.

  loop at ti_drseg into gwa_drseg1 .

     select single bedat

            into v_bedat

            from ekko

            where ebeln =  gwa_drseg1-ebeln.

     if sy-subrc = 0 and v_bedat gt gwa_drseg1-budat.

          clear sy-ucomm.

          message : 'POSTING DATE IS WRONG' type 'E'.

          leave list-processing.

     endif

      if i_rbkpv-budat lt gwa_drseg1-bedat.

            clear sy-ucomm.

            message : 'POSTING DATE IS WRONG' type 'E'.

            leave list-processing.

    endif.

  endloop.

endif.

Now i am just Changing my Document type in Detail Tab & Chaging the posting date according to validation .

So first time when my above exits calling it's woking fi9 . But don;t know after some process again my above exits is calling & at this time

i am not getting posting date at run time.. & whatever the data i am geting is the old one..not the same as on scrren.

So Please can anybody tell me that why the above exit is calling twice ..& what could be the possible solution for that.

Accepted Solutions (1)

Accepted Solutions (1)

former_member210770
Active Participant
0 Kudos

Hiii Sanjeet ..

I got the solution ..actually thing is that when i am changing the Doucment Type in Detail Tab of MIR4 tcode at that time in background 1 new invoice number is generated & the old Invoice is reversing it's effects that's why tha exit is calling twice.

when 1st time that exit will call it has on screen data with new Invoice number

when 2nd time it will call it has old screen data with old invoice numbe

when 3rd time it will call it has on screen data with new invoice data..

So moral of the story is when we will change the document type above exit will be called 3 times. and at the end of the save we will get the new invoice number.

Task is closed.

Answers (2)

Answers (2)

Former Member
0 Kudos

The userexit purpose is to add a release function to the parked document.  Not error checking.

Regards

Waza

former_member210770
Active Participant
0 Kudos

Hiii Warren ,

As per my Thinking we can user userexit for Enhancement Purpose ri8.. So Error Checking is again kind of validation , and validation is again a kind of enhancement . So we can use.

Regards,

Sagar Pambhar.

Former Member
0 Kudos

Hi Sagar,

i am not getting posting date at run time..

Ans: here you have mention below code for single, pls check after break point. You program should called during the PAI.


select single bedat

            into v_bedat

            from ekko

            where ebeln =  gwa_drseg1-ebeln.

Moreover if you have a look at the  LMR1M005 - may be there is a further check function which is being used which also calls your Function Exit - So this is the reason why your Function gets executed Twice.

Regards

Sanjeet Kumar