0% found this document useful (0 votes)
243 views27 pages

Update TVARVC Table Dynamically in SAP

Tvarvc

Uploaded by

amol
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
243 views27 pages

Update TVARVC Table Dynamically in SAP

Tvarvc

Uploaded by

amol
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

https://s4hclub.com/ © + https://www.youtube.

com/@s4hclubforyou ©

Update TVARVC Table Dynamically in SAP S4HANA

Steps as given below:

1) Maintain Variable in Transaction code STVARV

Maintaining Entries in Table TVARVC

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.

Mickaël QUESNOT © - Copyright

https://www.linkedin.com/in/mickaelquesnot/
1
https://s4hclub.com/ © + https://www.youtube.com/@s4hclubforyou ©

Creating Table Variables from TVARVC

You can choose from existing entries in table TVARVC and then assign the entries to the selection
variant.

Procedure

To assign a variable from table TVARVC to a selection variant:

1. In the Variant field on the initial screen for maintaining variants, enter the name of the
appropriate variant.

2. In the Subobjects group box, select the Attributes radio button.

3. Choose Change.

The Variant Attributes screen for the selected variant appears.


For more information, see Variant Attributes.

4. In the Selection variable column, press F4.

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.

6. In the Name of Variable column, choose the F4 help.

A list with all the possible table variables appears.

7. Select the required entry and choose with the quick info text Continue.

You return to the Variant Attributesscreen.

8. Choose with the quick info text Save.

ZLFGJA
ZNPERI

Mickaël QUESNOT © - Copyright

https://www.linkedin.com/in/mickaelquesnot/
2
https://s4hclub.com/ © + https://www.youtube.com/@s4hclubforyou ©

2) Create Variant and assign variable to the selection field

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.

For more information, see Calling the Initial Screen.

2. In the Variant field, enter the name of the new variant.

Caution

The name of the variant must meet the naming conventions. For more information, see the
constraints below.

3. Choose Create.

Mickaël QUESNOT © - Copyright

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.

6. The (first) selection screen for the report appears.

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.

7. Choose Continue or Attributes to go to the Variant Attributesscreen.

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.

Mickaël QUESNOT © - Copyright

https://www.linkedin.com/in/mickaelquesnot/
4
https://s4hclub.com/ © + https://www.youtube.com/@s4hclubforyou ©

2.2) Go to attribute section of the created variant

Mickaël QUESNOT © - Copyright

https://www.linkedin.com/in/mickaelquesnot/
5
https://s4hclub.com/ © + https://www.youtube.com/@s4hclubforyou ©

2.3) Go to parameter/selection option for which variant should be manipulated dynamically

2.3.1) In ‘Selection Variable’ press F4 select selection Type as ‘T’

Mickaël QUESNOT © - Copyright

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)

Mickaël QUESNOT © - Copyright

https://www.linkedin.com/in/mickaelquesnot/
7
https://s4hclub.com/ © + https://www.youtube.com/@s4hclubforyou ©

3) Code to updated variable value dynamically

*** Update remaining fields in TVARVC accordingly (Include/Exclude, Sign, option, low, High) ***

Mickaël QUESNOT © - Copyright

https://www.linkedin.com/in/mickaelquesnot/
8
https://s4hclub.com/ © + https://www.youtube.com/@s4hclubforyou ©

Mickaël QUESNOT © - Copyright

https://www.linkedin.com/in/mickaelquesnot/
9
https://s4hclub.com/ © + https://www.youtube.com/@s4hclubforyou ©

Mickaël QUESNOT © - Copyright

https://www.linkedin.com/in/mickaelquesnot/
10
https://s4hclub.com/ © + https://www.youtube.com/@s4hclubforyou ©

Mickaël QUESNOT © - Copyright

https://www.linkedin.com/in/mickaelquesnot/
11
https://s4hclub.com/ © + https://www.youtube.com/@s4hclubforyou ©

Mickaël QUESNOT © - Copyright

https://www.linkedin.com/in/mickaelquesnot/
12
https://s4hclub.com/ © + https://www.youtube.com/@s4hclubforyou ©

Mickaël QUESNOT © - Copyright

https://www.linkedin.com/in/mickaelquesnot/
13
https://s4hclub.com/ © + https://www.youtube.com/@s4hclubforyou ©

DATA : GS_TVARVC TYPE TVARVC.

Mickaël QUESNOT © - Copyright

https://www.linkedin.com/in/mickaelquesnot/
14
https://s4hclub.com/ © + https://www.youtube.com/@s4hclubforyou ©

Mickaël QUESNOT © - Copyright

https://www.linkedin.com/in/mickaelquesnot/
15
https://s4hclub.com/ © + https://www.youtube.com/@s4hclubforyou ©

Mickaël QUESNOT © - Copyright

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.

FIELD-SYMBOLS: <STRUC> TYPE 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.

Mickaël QUESNOT © - Copyright

https://www.linkedin.com/in/mickaelquesnot/
18
https://s4hclub.com/ © + https://www.youtube.com/@s4hclubforyou ©

Mickaël QUESNOT © - Copyright

https://www.linkedin.com/in/mickaelquesnot/
19
https://s4hclub.com/ © + https://www.youtube.com/@s4hclubforyou ©

SQ01

Mickaël QUESNOT © - Copyright

https://www.linkedin.com/in/mickaelquesnot/
20
https://s4hclub.com/ © + https://www.youtube.com/@s4hclubforyou ©

Mickaël QUESNOT © - Copyright

https://www.linkedin.com/in/mickaelquesnot/
21
https://s4hclub.com/ © + https://www.youtube.com/@s4hclubforyou ©

SE16N

Mickaël QUESNOT © - Copyright

https://www.linkedin.com/in/mickaelquesnot/
22
https://s4hclub.com/ © + https://www.youtube.com/@s4hclubforyou ©

SQ03

Mickaël QUESNOT © - Copyright

https://www.linkedin.com/in/mickaelquesnot/
23
https://s4hclub.com/ © + https://www.youtube.com/@s4hclubforyou ©

Mickaël QUESNOT © - Copyright

https://www.linkedin.com/in/mickaelquesnot/
24
https://s4hclub.com/ © + https://www.youtube.com/@s4hclubforyou ©

SM37

Mickaël QUESNOT © - Copyright

https://www.linkedin.com/in/mickaelquesnot/
25
https://s4hclub.com/ © + https://www.youtube.com/@s4hclubforyou ©

Mickaël QUESNOT © - Copyright

https://www.linkedin.com/in/mickaelquesnot/
26
https://s4hclub.com/ © + https://www.youtube.com/@s4hclubforyou ©

Mickaël QUESNOT © - Copyright

https://www.linkedin.com/in/mickaelquesnot/
27

You might also like