cancel
Showing results for 
Search instead for 
Did you mean: 

How to avoid hard coding in Programming

Former Member
0 Kudos

Hi,

For preparing a Sales report we need to fetch Excise, Tax and

Education cess.

While doing the programming condition types of excise, tax and education cess were given to technical consultants.

It is like hard coding the programming. In future if a new condition type is created then it wont be calculated.

What are the ways to avoid hard coding?

regards,

sathya

Accepted Solutions (1)

Accepted Solutions (1)

former_member70391
Contributor
0 Kudos

Hi Sathya,

You can use Control Break Statements in the ABAP program to avoid these kind of hard codings Like at new condition type, At last, On change of, at first etc. I will be good if you paste a piece of code so that verybody can analyze the same.

May be you can check with your programmer regarding this.

Hope it helps.

Thanks & Regards,

Nagaraj Kalbavi

Former Member
0 Kudos

You can create a Z-Table that you are using for referencing your data e.g. condition type. This way this is customizable.

In a project I worked before we even had a more sophisticated way for avoiding hardcoding. We had one generic table including Program name, "Function to be exextued" (e.g. determination of condition) and the key value. And we had a function module reading these parameters from the gerneric table. Everytime you would need a specific value from this table you called this table via the function module.This way you had a customizable table and no more hardcoding was needed, the function module provided you with the values.

former_member70391
Contributor
0 Kudos

HI,

I agrre creating a ZTABLE is the more clear solution. In this case you can create a table maintenance generator and whenver they are is new condition just update the table via SM30.

Thanks & Regards,

Nagaraj Kalbavi

Answers (2)

Answers (2)

Former Member
0 Kudos

Hello,

This can be effectively discuss with your technical consultnats. Because they might have hard coded because of some specific reasons, check with them. They can give you the alternative more specifically.

Prase

Former Member
0 Kudos

Hi,

You dont need a Z table. You can fetch data from standard table.

To avoid hard coding you would have to use defaulted variables. I mean you can give default values for variables when you define them. However, you would have to update your program once you have a new condition type. Since you want to check the condition.

This way you no longer have to do hard-coding. But, define the variables for the same.

Regards,

Srilatha.