on 12-12-2011 8:46 AM
Hi,
I want to fileter records where VALIDTO < SY-DATUM and VALID FROM > SY-DATUM where VALIDTO and VALID FROM are source fields. How can I write the code in DTP Routine to fileter the data as per the above scenario.
Thanks & regards
Ramesh
Hi,
For Validto :-
read table l_t_range with key fieldname = 'VALIDTO'.
l_idx = sy-tabix.
l_t_range-iobjnm = '0validto'.
l_t_range-fieldnm = 'validto'.
l_t_range-low = sy-datum.
l_t_range-sign = 'I'.
l_t_range-option = 'LT'.
append l_t_range.
For Valid from :-
read table l_t_range with key fieldname = 'VALIDTO'.
l_idx = sy-tabix.
l_t_range-iobjnm = '0validfrom'.
l_t_range-fieldnm = 'validfrom'.
l_t_range-low = sy-datum.
l_t_range-sign = 'I'.
l_t_range-option = 'GT'.
append l_t_range.
Navesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Navesh,
Thanks for your help.
For VALID TO, I coded lik this...
&----
*& Include RSBC_SEL_ROUTINE_TPL
&----
program conversion_routine.
Type pools used by conversion program
type-pools: rsarc, rsarr, rssm.
tables: rssdlrange.
Global code used by conversion rules
$$ begin of global - insert your declaration only below this line -
TABLES: ...
DATA: ...
$$ end of global - insert your declaration only before this line -
-------------------------------------------------------------------
Fieldname = VALIDTO
data type = DATS
length = 000008
-------------------------------------------------------------------
form compute_VALIDTO
tables l_t_range structure rssdlrange
using i_r_request type ref to IF_RSBK_REQUEST_ADMINTAB_VIEW
i_fieldnm type RSFIELDNM
changing p_subrc like sy-subrc.
Insert source code to current selection field
$$ begin of routine - insert your code only below this line -
data: l_idx like sy-tabix.
read table l_t_range with key fieldname = 'VALID TO'.
l_idx = sy-tabix.
l_t_range-iobjnm = '0valid to'.
l_t_range-fieldname = 'validto'.
l_t_range-low = sy-datum.
l_t_range-sign = 'I'.
l_t_range-option = 'LT'.
append l_t_range.
if l_idx <> 0.
modify l_t_range index l_idx.
else.
append l_t_range.
endif.
p_subrc = 0.
$$ end of routine - insert your code only before this line -
endform.
will it work now? Or do I need to un comment anything?
Thanks & regards
Ramesh
Hi ,
Yes the code seems to be correct but following modification needs to be done.
Fieldname = 'VALIDTO'.
There should not be any blank spaces. Field name should be same as given in the attribute list of the routine shown below in the Bold letters :-
$$ end of global - insert your declaration only before this line -
*
Fieldname = VALIDTO*
data type = DATS
length = 000008
*
Remove following line just after updation of l_t_range table as this being taken care by the if statement following it :-
append l_t_range
Navesh
Edited by: navsamol on Dec 12, 2011 1:37 PM
found this on the net with a simple search...you could do the same
DATA: WA_T_RANGE like line of L_T_RANGE.
...
WA_T_RANGE-IOBJNM = '0CALMONTH'.
WA_T_RANGE-FIELDNAME = 'CALMONTH'.
WA_T_RANGE-SIGN = 'I'.
WA_T_RANGE-OPTION = 'BT'.
WA_T_RANGE-LOW = ZDATE.
WA_T_RANGE-HIGH = ZDATE.
APPEND WA_T_RANGE TO L_T_RANGE.
i think you can use LT and GT instead of BT. LOW should be sy-datum. of course you have to change the names of the object and field
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
9 | |
8 | |
6 | |
6 | |
6 | |
5 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.