2009 Sep 24 7:11 AM
Hi All,
What would be the better way to manage hard code values in the program .
One option will be create a custom table and store the constant values in it , and retrieve based on the program id.
If such case what would be the best optimum table design for this case?
table structure :
Program ID
constant field name
constant value
But the above design doesn't have the uniqueness .
Any new ideas on this ?
Thanks,
Raghavendra
Hi All,
What would be the better way to manage hard code values in the program .
One option will be create a custom table and store the constant values in it , and retrieve based on the program id.
If such case what would be the best optimum table design for this case?
table structure :
Program ID
constant field name
constant value
But the above design doesn't have the uniqueness .
Any new ideas on this ?
Thanks,
Raghavendra
2009 Sep 24 7:22 AM
Hi,
I don't think it will be a good option as each and evry program will have thier own hardcoded values....and also custom table takes some space in the database as well.The custom table can be helpful if multiple programs use same hardcoded value...
I feel use constants in the indiviudal programs or if you don't want to change the code then specify them in the selection screen and try to use them in ur code.
Regards,
Nagaraj
2009 Sep 24 7:29 AM
Hi Raghavendra,
I think declaring constant values in program will better option rather than using table for constant values.
this is the suggestion of standard sap .
when you go for extended check, if you have used any constant then it shows error.
E.g.
Declare your constant with some suitable char which will indicate it is constant and for particular field.
Thanks and Regards,
Vijay
2009 Sep 24 7:36 AM
I thought this process because of this:
there will be few requirements just to change the value of constants , at that time Maintainability of hard code values in program is cumbersome process.. You need to comment the existing code and then rewrite the same code new constant value. But instead of that if you have a custom table where you do maintain such kind of frequent hard code values change, just changing the table entry will solve the problem .In this case we do can save a lot of effort and time . No need to create a TR , no transport, USER can also do this.
2009 Sep 24 7:45 AM
Hi,
I understand what u said..But for custom table also some one needs to maiantain when there is change in the constant values.... also this needs to be maintained in all the servers... also authorization needs to be given for maintainence of the custom table.
if you are not using SM30 or some tcode to maintain the values then u need to do another program to update the values...once any change comes then once again u need to modify the program.
so my suggestion is use constants or else specify a separate block in the selection screen and then specify the values and use them in ur program, when u do this u don't need to change the program...
Regards,
Nagaraj
2009 Sep 24 7:51 AM
Hi,
In this case i would go for the following fields;
Key Fields
Program
Field
Sequence
No-Key fields
ActiveFlag
Value
Description
Created on
Created by
Last change on
Last Chang by
Regards
Karthik D
2009 Sep 24 9:57 AM
Hi Karthik,
Do you have any example on this? looks like the sequence indicator will do better things
2009 Sep 24 10:19 AM
>
> Hi Karthik,
> Do you have any example on this? looks like the sequence indicator will do better things
Hi,
I hope all fields are self explanatory, so you have to maintain the entry with the program name , field name and sequence 1 for the first time, check the active flag if you want to have this record as active.
In program use a select query to fetch the data value, checking the active flag is set.
Using sequence you can maintain multiple values for a field.
Regards
Karthik D
2009 Sep 24 7:45 AM
what about maintaining the constants in attributes of a class ?
2009 Sep 24 7:56 AM
Always reinventing the wheel......
There's a standard way to deal with constants without repeating coding. Also multi value constants with all features of Selecti-options (Ranges) are applicable there.
Table TVARV (TVARVC on > 4.6C)
Transaction STVARV
These Variables are also useful within Report-Variants.
The only poor is that SAp does not provide a way to compare variables with tose ranges.
We developed a public static method do so and we deal with TVARV variables in the same manner as the IN statement in ABAP
Cheers
carsten
2009 Sep 24 8:06 AM
Hi Raghavendra,
Herewith, I am giving you a small idea. Please use this if it helps you.
Please create a COM PARAM database table with the following structure.
Pgmid - Program name
para1 - Parameter name (Constant name) Data element - PARAM_D
para2 - Parameter name (Variant of constant 1) Data element should be same as para1
Use of this is that, for example PARA1 = Module PARA2 = SD
PARA1 = Module PARA2 = FI
PARA1 = Module PARA2 = MM (Like this variations could be handled)
sign - Data element = DDSIGN (Value can be Included in range / Excluded in Range)
opt - Data element = DDOPTION (Value can be EQ/NE/GE/GT/LT/etc)
low - Data element = SETVAL (Value for the constant)
high - Data element = SETVAL (Value for the constant can be SPACE if the constant is not a range of values)
description - Description for the constant (CHAR255)
This is the way which most of the experts would prefer, instead of hardcoding the values
After creating the table, you can maintain the constants in this table as records.
Thanks and Best Regards,
Suresh
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |