Thursday, April 12, 2012

Sample program on using TVARV table


Before using the sample code provided below-make sure of making entry in TVARV table.For this you can use SE11 or the methods as depicted in this article.

 Sample code used for testing the TVARV:


REPORT  ZTVARV MESSAGE-ID /pmpay/pcma.

PARAMETERS: p_cdate    LIKE fpltc-audat,
            p_ctime    LIKE fpltc-autim.

DATA: w_tvarv   TYPE tvarv.


  w_tvarv-name   = 'Ztesttvarv'.

  SELECT SINGLE * FROM tvarv
           INTO w_tvarv
           WHERE name = w_tvarv-name
           AND   type = 'P'.


*-If record exists, update it, otherwise create new entry
  IF sy-subrc = 0.

    w_tvarv-low  = p_cdate.
    w_tvarv-high = p_ctime.
    MODIFY tvarv FROM w_tvarv.

    IF sy-subrc = 0.
      MESSAGE i990 WITH 'Ztesttvarv' 'was updated to'
                        p_cdate p_ctime.
    ENDIF.

  ELSE.

    CLEAR w_tvarv.
    w_tvarv-name = 'Ztesttvarv'.
    w_tvarv-type = 'P'.
    w_tvarv-sign = 'I'.
    w_tvarv-opti = 'EQ'.
    w_tvarv-low  = p_cdate.
    w_tvarv-high = p_ctime.
    INSERT tvarv FROM w_tvarv.

    IF sy-subrc = 0.
      MESSAGE i990 WITH 'ZPCMA_CUTOVER_PERIOD' 'was created with'
                   p_cdate p_ctime.
    ENDIF.
    ENDIF.

Selection Screen:


Once updated with the values, these would alerted with message as shown below.


One can verify the details by checking directly in TVARV table for data entered.


No comments:

Post a Comment