Skip to Content
0
Former Member
Jul 23, 2011 at 03:45 PM

RSRPARAMETRIZA - Information Broadcasting - Dynamic Variant update Program

37 Views

Hello everybody,

I got to know that Broadcast setting and variant are saved in table RSRPARAMETRIZA (BI7). Now my requirment is to dynamically update the date variable (MTD calculation) where lower limit would be first date of the current month and upper limit would be today's date

I took reference from below link

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/f048c590-31a4-2c10-8599-bd01fabb93d4?quicklink=index&overridelayout=true

below is value for 'CONTENT" field RSRPARAMETRIZA

<?xml version="1.0" encoding="utf-16"?># <PAGE><item><VNAM>BUSOWN_MI_002</VNAM><DATA_PROV>DATA_PROVIDER_1</DATA_PROV><RANGE/></item><item><VNAM>CLCUST_MI_001</VNAM><DATA_PROV>DATA_PROVIDER_1</DATA_PROV><RANGE/></item><item><VNAM>KEYACNT_1_O_CE_S_0002</VNAM><DATA_PROV>DATA_PROVIDER_1</DATA_PROV><RANGE><RRRANGE><SIGN>I</SIGN><OPT>EQ</OPT><LOW>#</LOW><HIGH/></RRRANGE></RANGE></item><item><VNAM>OPCRN_MI_002</VNAM><DATA_PROV>DATA_PROVIDER_1</DATA_PROV><RANGE/></item><item><VNAM>TRDNAME_MI_002</VNAM><DATA_PROV>DATA_PROVIDER_1</DATA_PROV><RANGE/></item><item><VNAM>0CALDAY_MI_003</VNAM><DATA_PROV>DATA_PROVIDER_1</DATA_PROV><RANGE><RRRANGE><SIGN>I</SIGN><OPT>BT</OPT><LO W>20110702</LOW><HIG H>20110723</HIGH></RRRANGE></RANGE></item><item><VNAM>0CALDAY_MI_004</VNAM><DATA_PROV>DATA_PROVIDER_1</DATA_PROV><RANGE><RRRANGE><SIGN>I</SIGN><OPT>BT</OPT><LO W>20110702</LOW><HIG H>20110723</HIGH></RRRANGE></RANGE></item><

and, below is the pseudo code: Please comment on the code or advise better option

CONSTANTS : lc_pat_low TYPE c LENGTH 4 VALUE 'W>20',

lc_pat_high TYPE c LENGTH 4 VALUE 'H>20',

lc_parameter TYPE c LENGTH 7 VALUE 'ZTEST_ALOK' u201CGive variant name.

DATA : l_count TYPE i,

l_off-low TYPE i,

l_off_high TYPE i,

l_moff TYPE i,

l_mlen TYPE i,

l_firstday_old TYPE sy-datum,

l_lastday_old TYPE sy-datum,

l_firstday_new TYPE sy-datum,

l_lastday_new TYPE sy-datum.

DATA: l_year TYPE i,

l_month TYPE i.

DATA : lt_variant TYPE TABLE OF rsrparametriza,

lw_variant LIKE LINE OF lt_variant.

SELECT * FROM rsrparametriza INTO TABLE lt_variant

WHERE paramnm LIKE lc_parameter AND objvers = 'A'.

LOOP AT lt_variant INTO lw_variant.

sy-subrc = 0.

CLEAR:l_off_low,l_off_high,l_moff,l_month,l_year,l_count.

WHILE sy-subrc = 0.

FIND lc_pat_low IN SECTION OFFSET l_off_low OF

lw_variant-content

MATCH OFFSET l_moff

MATCH LENGTH l_mlen.

IF sy-subrc = 0.

**- counter to track no.of hits

l_count = l_count + 1.

if l_count = 1.

l_firstday_old = lw_variant-content+l_moff(8).

l_today = sy-datum.

l_year = l_today+0(4).

l_month = l_today+4(2).

CALL FUNCTION 'FIRST_DAY_IN_PERIOD_GET'

EXPORTING

i_gjahr = l_year

  • I_MONMIT = 00

i_periv = 'Z1'

i_poper = l_month

IMPORTING

e_date = l_firstday_new

**- set the offset for next search.

endif.

l_off_low = l_moff + 8.

Endif.

Endwhile.

REPLACE ALL OCCURRENCES OF l_firstday_old IN lw_variant-content WITH l_firstday_new.

UPDATE rsrparametriza FROM lw_variant.

l_moff = 0.

l_mlen = 0.

WHILE sy-subrc = 0.

FIND lc_pat_high IN SECTION OFFSET l_off_high OF

lw_variant-content

MATCH OFFSET l_moff

MATCH LENGTH l_mlen.

IF sy-subrc = 0.

**- counter to track no.of hits

l_count = l_count + 1.

if l_count = 1.

l_lastday_old = lw_variant-content+l_moff(8).

l_lastday_new = sy-datum.

endif.

l_off_high = l_moff + 8.

Endif

ENDWHILE.

REPLACE ALL OCCURRENCES OF l_lastday_old IN lw_variant-content WITH l_lastday_new.

UPDATE rsrparametriza FROM lw_variant.

ENDLOOP.