Test

gichee

New Member
Hi evryone, this is a question from a progress test. I would like to know what is wrong with this code.

The following code snippet is used in another program when creating call_data records. There are several problems with this code that should be fixed. What's wrong with it, how bad is it, why and how would you fix the problems?



abc_data.sys_code = sv_sys_code.

abc_data.call_date = today.

abc_data.call_time = substring(string(time,"hh:mm:ss"),1,2)

+ substring(string(time,"hh:mm:ss"),4,2)

+ substring(string(time,"hh:mm:ss"),7,2).
 

Kchari

New Member
The code should use "assign" statement , this will reduce the compile code size and increase program efficency.



gichee said:
Hi evryone, this is a question from a progress test. I would like to know what is wrong with this code.

The following code snippet is used in another program when creating call_data records. There are several problems with this code that should be fixed. What's wrong with it, how bad is it, why and how would you fix the problems?



abc_data.sys_code = sv_sys_code.

abc_data.call_date = today.

abc_data.call_time = substring(string(time,"hh:mm:ss"),1,2)

+ substring(string(time,"hh:mm:ss"),4,2)

+ substring(string(time,"hh:mm:ss"),7,2).
 

gichee

New Member
Thanks for answering that was my answer; however the person who did the coding said there is five error and I can't find them.



Kchari said:
The code should use "assign" statement , this will reduce the compile code size and increase program efficency.
 

kiran

New Member
The second one, if he is trying to assign the time to abc_data.call_time field he could have just done as abc_data.call_time = STRING(time,"HH:MM:SS") no need to extra use substrings. 3 extra substrings elimiated and one assign statement - total of 4 errors.
 

gichee

New Member
Maybe, that is what he means.

kiran said:
The second one, if he is trying to assign the time to abc_data.call_time field he could have just done as abc_data.call_time = STRING(time,"HH:MM:SS") no need to extra use substrings. 3 extra substrings elimiated and one assign statement - total of 4 errors.
 

cecsno

Member
abc_data.call_time should be defined as a integer. The code should be:

assign
abc_data.sys_code = sv_sys_code
abc_data.call_date = today
abc_data.call_time = time.


I guess if you add all this up there would be 5 "errors", but there are really only 2 bad practices.
 

Krokodile

New Member
ASSIGN

call_data.sys_code = sv_sys_code

call_data.call_date = today

call_data.call_time =

REPLACE(STRING(TIME,"hh:mm:ss"),":","").

If call_time field can't be changed to numeric then this is the ONLY answer.
 
Top