Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Data Dictionary

Former Member
0 Likes
2,309

How to capture standard domain values ( Ex :- VBTYP EQ 'V' )  OR ( VBTYP EQ 'C' ) in our program instead of hard coding..?

Thanks in advance..............

12 REPLIES 12
Read only

sivaganesh_krishnan
Contributor
0 Likes
2,260

hi mahi,

What do you exactly want.. ? If you don't want to hard code the values in program , then try creating constants and use the constant in program..

Regards,

Sivaganesh

Read only

0 Likes
2,260


i think we should not use even CONSTANTS (keyword) also..

is there any alternative way..?

Can we give on example..?

Read only

0 Likes
2,260

why can't you use constants.. ?

Read only

0 Likes
2,260

Sivaganesh Krishnan wrote:

why can't you use constants.. ?

Good question. If the values are only ever going to be all of the domain, then you should use the function module as already supplied.

Otherwise use constants. It is what they are for. Any other solution is piling up a world of pain when it comes to maintanence.

Do not use TVARVC to store constants. That would be VERY bad program design. The only time to use TVARVC is when you want to be able to alter some aspects of the a program directly in production. Even then, there may be better solutions.

Read only

former_member187748
Active Contributor
0 Likes
2,260

Hi Mahi,

either you declare those fields for a variable in initialization, and whele fetching data

just check these values.

DATA : lv_field type char .

lv_field = { put your all values here for VBTYP }.

at the time of fetching you can check through lv_field, that it matches your record or not.

Read only

Former Member
0 Likes
2,260

Use FM 'DD_DOMVALUES_GET'  to get all the domain values.

Read only

Former Member
0 Likes
2,260

Hi Mahi,

Use function module DD_DOMVALUES_GET.

In your case VBTYP domain has 65 predefined values.

Regards,

Vineesh

Read only

Former Member
0 Likes
2,260

In our projects, the best practise, that was developed is to store the domain values in the atributes part of a global class (static constant). This way you earn the advantage of where-used list (which you lose in e.g. a global constant in a report). You access the constant via expression zcl_classname=>gc_constant_name, which also gives the code another semantic part.

Read only

Former Member
0 Likes
2,260

Hi Every one..thanks for such huge response...

Below is the one want to change..instead of hard coding ( 'v' and 'c' ).

If need to do this with TVARV and reply back with a clear solution.

Thanks....

Read only

0 Likes
2,260

personally, i would probably resolve this issue with a select-option (or data range if select option not possible).

The reason being is

1- it cuts down on more over worked solution - going off to maintain TVARV and remembering it when you want to maintain the program 18 months later etc.

2-flexible for users

create your selection screen.

set the values in an initialisation/load-of-program event (or somewhere before the select is done).

The code remains easy to maintain from one point - the actual program.

Users can 'add/remove' entries if you use a select-option - so it is not rigid.

Whilst there is some element that it is 'hardcoded' you are providing flexible maintenance, user friendly interface allowing deviation to the C / V 'normal' combo. Change the select statement to use the IN operator against the select option - you are avoiding repeated select statements.

dont over engineer a simple requirement - everyone is a winner with this approach!

Read only

0 Likes
2,260

You already was given recommendations (not using TVARV, using global constants). Is there anything you did not understand?

Read only

matt
Active Contributor
0 Likes
2,260

VBTYP isn't part of VBFA... but anyway, 34 years of programming experience, 14 of them with ABAP, tells me:

Define constants for 'V' and 'C' with meaningful names, e.g. c_purchase_order and c_order . This is correct and good programming practice (Note, Jozef's and Steve's answers are good variants of this).. All other solutions are, for this requirement, bad programming.

You do not, and should not do this with TVARVC.