Quantcast
Channel: SCN: Message List - Data Warehousing
Viewing all articles
Browse latest Browse all 3366

Re: Dynamic filter in DTP BW 7.4 ( change year for months from April to Dec)

$
0
0

Your comment "take calendar year, and skip day and month, format is: 2016.01.06 is misleading and should be removed or amended. The internal representation of date types (and as you've used in your code) is 20160106. Misleading comments lead to maintenance errors and are dangerous.

 

fyi, as a programmer of far too many years experience in ABAP and BW, this is how I would do it.

 

data: date_range like line of l_t_range.

 

date_range-sign = rs_c_range_sign-including.

date_range-option    = rs_c_range_opt-between.

date_range-fieldname = 'CALYEAR'.

date_range-iobjnm = '0CALYEAR'.

date_range-low = substring( val = sy-datum len = 4 ) && '04'. " April of current year

date_range-high =substring( val = sy-datum len = 4 ) && '12'. " December of current year

APPEND date_range TO l_t_range.

 

The reasons are

1. It is shorter and simpler and, in my view clearer. Clear, simple programming is cheaper and quicker to maintain. "It works" is not a sufficient criterion.

2. String slicing using sy-datum(4) etc. has problems - in some circumstances (assignment) it becomes syntactically incorrect in higher releases of ABAP.


Viewing all articles
Browse latest Browse all 3366

Trending Articles