Update TVARVC Table Dynamically in SAP
Update TVARVC Table Dynamically in SAP
com/@s4hclubforyou ©
Note that changes to the values of table TVARVC affect all variants that use these
particular variables.
The transactions STVARV and STVARVC are available for maintaining the table variants. With
transaction STVARV you can maintain the entries in table TAVRVC for the current client
(display/change/add). Transaction STVARVC only allows you to maintain the entries in client 000.
https://www.linkedin.com/in/mickaelquesnot/
1
https://s4hclub.com/ © + https://www.youtube.com/@s4hclubforyou ©
You can choose from existing entries in table TVARVC and then assign the entries to the selection
variant.
Procedure
1. In the Variant field on the initial screen for maintaining variants, enter the name of the
appropriate variant.
3. Choose Change.
A new dialog box shows the possible types for the selected field.
5. Select type T for table variables and choose with the quick info text Continue.
7. Select the required entry and choose with the quick info text Continue.
ZLFGJA
ZNPERI
https://www.linkedin.com/in/mickaelquesnot/
2
https://s4hclub.com/ © + https://www.youtube.com/@s4hclubforyou ©
Creating Variants
Prerequisites
You must have defined one or more selection screens for the relevant program. The program can have
any type except type S (subroutine pools).
Procedure
1. Open the initial screen for maintaining variants for the relevant program.
Caution
The name of the variant must meet the naming conventions. For more information, see the
constraints below.
3. Choose Create.
https://www.linkedin.com/in/mickaelquesnot/
3
https://s4hclub.com/ © + https://www.youtube.com/@s4hclubforyou ©
If the program has more than one selection screen, a dialog box for screen assignment
appears. The dialog box does not appear if the program has only one selection screen. The
selection screen appears in this case.
4. If there is more than one selection screen, choose the appropriate radio button.
a. To assign the variant to all selection screens included in the program, choose For All
Selection Screens.
b. To assign the variant to individual selection screens, choose For Indiv. Selection Screens.
Then select the screens for which you want to create the variant, using the indicator in
the Createdcolumn.
5. Choose Continue.
a. If your program has more than one selection screen, use with the quick info text Next
Screen and with the quick info text Previous Screen to navigate between them and to
fill the fields with values.
b. Enter the desired selection values, including multiple selection and dynamic selection.
c. Keep scrolling forwards until the last selection screen appears.
A new button called Continue or Attributes appears on the application toolbar.
You see an overview screen on which you can specify attributes for your variant and save it.
For more information, see Attributes of Variants.
Caution
When you create a new variant, you have to fill in values and attributes.
8. Specify the attributes of the variant and choose with the quick info text Save.
https://www.linkedin.com/in/mickaelquesnot/
4
https://s4hclub.com/ © + https://www.youtube.com/@s4hclubforyou ©
https://www.linkedin.com/in/mickaelquesnot/
5
https://s4hclub.com/ © + https://www.youtube.com/@s4hclubforyou ©
https://www.linkedin.com/in/mickaelquesnot/
6
https://s4hclub.com/ © + https://www.youtube.com/@s4hclubforyou ©
2.3.2) In ‘Name of the Variable’ press F4 and select the newly created varaible (Step 1)
https://www.linkedin.com/in/mickaelquesnot/
7
https://s4hclub.com/ © + https://www.youtube.com/@s4hclubforyou ©
*** Update remaining fields in TVARVC accordingly (Include/Exclude, Sign, option, low, High) ***
https://www.linkedin.com/in/mickaelquesnot/
8
https://s4hclub.com/ © + https://www.youtube.com/@s4hclubforyou ©
https://www.linkedin.com/in/mickaelquesnot/
9
https://s4hclub.com/ © + https://www.youtube.com/@s4hclubforyou ©
https://www.linkedin.com/in/mickaelquesnot/
10
https://s4hclub.com/ © + https://www.youtube.com/@s4hclubforyou ©
https://www.linkedin.com/in/mickaelquesnot/
11
https://s4hclub.com/ © + https://www.youtube.com/@s4hclubforyou ©
https://www.linkedin.com/in/mickaelquesnot/
12
https://s4hclub.com/ © + https://www.youtube.com/@s4hclubforyou ©
https://www.linkedin.com/in/mickaelquesnot/
13
https://s4hclub.com/ © + https://www.youtube.com/@s4hclubforyou ©
https://www.linkedin.com/in/mickaelquesnot/
14
https://s4hclub.com/ © + https://www.youtube.com/@s4hclubforyou ©
https://www.linkedin.com/in/mickaelquesnot/
15
https://s4hclub.com/ © + https://www.youtube.com/@s4hclubforyou ©
https://www.linkedin.com/in/mickaelquesnot/
16
https://s4hclub.com/ © + https://www.youtube.com/@s4hclubforyou ©
REPORT RSAQDVP_TEMPLATE .
*
*---------------------------------------------------------------------*
* declarations
* (insert your declarations in this section)
*---------------------------------------------------------------------*
DATA:
TVARVC TYPE TVARVC,
GV_GJAHR TYPE FTIS_GJAHR,
GV_MONAT TYPE FTIS_MONAT,
IT_DATA TYPE STANDARD TABLE OF TVARVC.
*-------------------------------------------------------------------*
* selection screen statements
*-------------------------------------------------------------------*
* (define your selection-screen here)
SELECT-OPTIONS SO_NAME FOR TVARVC-NAME OBLIGATORY.
PARAMETERS P_BUKRS TYPE BUKRS OBLIGATORY.
* !! the following comment MUST NOT BE CHANGED !!
*<QUERY_HEAD>
*-------------------------------------------------------------------*
* read data into IT_DATA
*-------------------------------------------------------------------*
* (select your data here into internal table IT_DATA)
SELECT * INTO TABLE IT_DATA FROM TVARVC WHERE NAME IN SO_NAME.
*------------------------------------------------------------*
* output of the data
* (this section can be left unchanged)
*------------------------------------------------------------*
LOOP AT IT_DATA ASSIGNING <STRUC>.
MOVE-CORRESPONDING <STRUC> TO TVARVC.
***LOCK TABLE TVARVC***
CALL FUNCTION 'ENQUEUE_E_LOCK_TVARVC'
EXPORTING
MODE_TVARVC = 'E'
MANDT = SY-MANDT
Mickaël QUESNOT © - Copyright
https://www.linkedin.com/in/mickaelquesnot/
17
https://s4hclub.com/ © + https://www.youtube.com/@s4hclubforyou ©
EXCEPTIONS
FOREIGN_LOCK = 1
SYSTEM_FAILURE = 2
OTHERS = 3.
CHECK SY-SUBRC IS INITIAL.
CALL FUNCTION 'FTI_FISCAL_YEAR_MONTH_GET'
EXPORTING
I_BUKRS = P_BUKRS
I_BUDAT = SY-DATUM
IMPORTING
E_GJAHR = GV_GJAHR
E_MONAT = GV_MONAT.
CASE TVARVC-NAME.
WHEN 'ZLFGJA'.
IF TVARVC-LOW <> GV_GJAHR.
TVARVC-LOW = GV_GJAHR.
***Update variable value in table TVARVC***
UPDATE TVARVC FROM TVARVC.
ENDIF.
WHEN 'ZNPERI'.
IF TVARVC-LOW <> GV_MONAT.
TVARVC-LOW = GV_MONAT.
***Update variable value in table TVARVC***
UPDATE TVARVC FROM TVARVC.
ENDIF.
ENDCASE.
***Unlock table TVARVC***
CALL FUNCTION 'DEQUEUE_E_LOCK_TVARVC'
EXPORTING
MODE_TVARVC = 'E'
MANDT = SY-MANDT.
* !! the following comment MUST NOT BE CHANGED !!
*<QUERY_BODY>
ENDLOOP.
https://www.linkedin.com/in/mickaelquesnot/
18
https://s4hclub.com/ © + https://www.youtube.com/@s4hclubforyou ©
https://www.linkedin.com/in/mickaelquesnot/
19
https://s4hclub.com/ © + https://www.youtube.com/@s4hclubforyou ©
SQ01
https://www.linkedin.com/in/mickaelquesnot/
20
https://s4hclub.com/ © + https://www.youtube.com/@s4hclubforyou ©
https://www.linkedin.com/in/mickaelquesnot/
21
https://s4hclub.com/ © + https://www.youtube.com/@s4hclubforyou ©
SE16N
https://www.linkedin.com/in/mickaelquesnot/
22
https://s4hclub.com/ © + https://www.youtube.com/@s4hclubforyou ©
SQ03
https://www.linkedin.com/in/mickaelquesnot/
23
https://s4hclub.com/ © + https://www.youtube.com/@s4hclubforyou ©
https://www.linkedin.com/in/mickaelquesnot/
24
https://s4hclub.com/ © + https://www.youtube.com/@s4hclubforyou ©
SM37
https://www.linkedin.com/in/mickaelquesnot/
25
https://s4hclub.com/ © + https://www.youtube.com/@s4hclubforyou ©
https://www.linkedin.com/in/mickaelquesnot/
26
https://s4hclub.com/ © + https://www.youtube.com/@s4hclubforyou ©
https://www.linkedin.com/in/mickaelquesnot/
27