cancel
Showing results for 
Search instead for 
Did you mean: 

Next inspection Date

Former Member
0 Kudos

Hi,

Normally next inspection interval date will be given based on GR date of the material, if i want the system to determine the next inspection interval date based on my UD date is it possible.

If yes what are the settings to be done for the same.

thanks and regards,

srinivas

Accepted Solutions (1)

Accepted Solutions (1)

former_member186399
Active Contributor
0 Kudos

hello,

Tthere is no standard sap solution for this. But with development you can alter the next inspection date. Use this user exit with correct logic

QEVA0003 Calculate "Next inspection date" for batch

regards

Gajesh

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Srini,

Apart from what Gajesh has suggested, what you can do is,,, make it bit flexible.

Create a new follow up action, where you must use the customized function module which will do the task of calculating the next inspection date for the Batch at the time of UD. By doing this what will happen is, it will over right the next inspection date calculation as per STD (at the time of posting GR) and will have a new date at the time of UD. And will be more flexible also, because the Follow up actions are defined at UD Code level. So if you wish the have 1 or 2 batches to have the STD next inspection date, you can create separate UD code for the same.

The code to be written in the Function module is pasted herewith for your reference.

IMPORTING
*"     VALUE(I_QALS) LIKE  QALS STRUCTURE  QALS
*"     VALUE(I_QAVE) LIKE  QAVE STRUCTURE  QAVE
*"     REFERENCE(I_QAPO) TYPE  QAPO OPTIONAL
*"  EXPORTING
*"     VALUE(E_SUBRC) LIKE  SY-SUBRC
*"     VALUE(E_QNDAT_NEU) LIKE  MCHA-QNDAT
*"  TABLES
*"      E_PROTOCOL STRUCTURE  RQEVP
*"----------------------------------------------------------------------

  DATA : l_prfrq LIKE marc-prfrq.
  DATA : l_neudate LIKE mcha-qndat.

  DATA : l_mtart LIKE MARA-MTART.
  DATA : L_HSDAT like mch1-HSDAT.

  SELECT SINGLE prfrq INTO l_prfrq
           FROM marc
           WHERE matnr = i_qals-matnr
           AND   werks = i_qals-werk.

  t_qals = i_qals.
  t_qave = i_qave.

  select single mtart into l_mtart from mara WHERE matnr = i_qals-matnr.
   if sy-subrc = 0.
    if l_mtart eq 'FERT' or l_mtart EQ 'ZERT'.
        SELECT SINGLE HSDAT INTO L_HSDAT
        FROM mch1
        WHERE matnr  = i_qals-matnr
        AND   charg  = i_qals-charg .

       CALL FUNCTION 'CALCULATE_DATE'
        EXPORTING
          days        = '365'
          months      = '0'
          start_date  = L_HSDAT
        IMPORTING
          result_date = l_neudate.

        e_qndat_neu = l_neudate.
    ELSE.

      l_neudate = sy-datum + l_prfrq.

      e_qndat_neu = l_neudate.

    endif.
  endif  .





  "l_neudate = sy-datum + l_prfrq.

  "e_qndat_neu = l_neudate.


  PERFORM bdc_dynpro      USING 'SAPLCHRG' '1000'.
  PERFORM bdc_field       USING 'BDC_OKCODE'
                                '=ENTR'.
  PERFORM bdc_field       USING 'BDC_CURSOR'
                                'DFBATCH-CHARG'.
  PERFORM bdc_field       USING 'DFBATCH-MATNR'
                                i_qals-matnr.
  PERFORM bdc_field       USING 'DFBATCH-CHARG'
                                i_qals-charg.
  PERFORM bdc_field       USING 'DFBATCH-WERKS'
                                i_qals-werk.
  PERFORM bdc_dynpro      USING 'SAPLCHRG' '1000'.
  PERFORM bdc_field       USING 'BDC_OKCODE'
                                '=SAVE'.
  PERFORM bdc_field       USING 'BDC_CURSOR'
                                'MCHA-QNDAT'.
*  PERFORM bdc_field       USING 'MCHA-ZUSTD'
*                                'X'.

  DATA: l_date(10).

  CLEAR l_date.
  WRITE l_neudate TO l_date.

  IF l_prfrq NE 0.

  PERFORM bdc_field       USING 'MCHA-QNDAT'
                                l_date.

  ENDIF.

  CALL TRANSACTION 'MSC2N' USING bdcdata MODE 'E'.


  PERFORM update_retain_sample.

ENDFUNCTION.

Regards,

Shyamal