Daniel,
The solution is indicated below check on the *change
DATA: MNT_INDX(20) TYPE C,
HLD_INDX(3) TYPE N,
W_MTH(2) TYPE N,
W_DATE LIKE PROJ-ERDAT.
RANGES: R_YEAR FOR COSP-GJAHR,
R_DATE FOR PROJ-ERDAT.
FIELD-SYMBOLS <FS>.
PARAMETERS FR_MONTH(2) TYPE N OBLIGATORY.
PARAMETERS FR_YEAR(4) TYPE N OBLIGATORY.
PARAMETERS TO_MONTH(2) TYPE N .
PARAMETERS TO_YEAR(4) TYPE N .
data: l_counter type i. "number of month
l_counter = ( to_year - fr_year ) * 12 + ( to_month - fr_month ).
DATA: W_TXT(20) TYPE C.
R_YEAR-LOW = FR_YEAR.
R_YEAR-HIGH = TO_YEAR .
R_YEAR-OPTION = 'BT'.
R_YEAR-SIGN = 'I'.
APPEND R_YEAR.
*change
concatenate FR_YEAR FR_MONTH '01' INTO R_DATE-LOW .
concatenate TO_YEAR TO_MONTH '01'INTO R_DATE-HIGH.
R_DATE-option = 'BT'.
R_DATE-SIGN = 'I'.
APPEND R_DATE.
SELECT * FROM COSP
WHERE OBJNR = PRPS-OBJNR AND
GJAHR IN R_YEAR AND
KSTAR BETWEEN '0000400996' AND '0000400999' AND
VERSN = '014' AND
WRTTP = '01' .
do l_counter times.
W_MTH = SY-INDEX.
*change
CONCATENATE COSP-GJAHR W_MTH '01' INTO W_DATE.
CHECK W_DATE IN R_DATE.
HLD_INDX = SY-INDEX. " (similar to your defn)
CONCATENATE 'COSP-WKG' HLD_INDX INTO W_TXT.
ASSIGN (W_TXT) TO <FS>.
CLEAR ITAB_OUT-PLAN14."where Plan14 is the field wit value
ITAB_OUT-PLAN14 = ITAB_OUT-PLAN14 + <FS>.
APPEND ITAB_OUT.
enddo.
ENDSELECT.
Regards
Anurag
Hi,
Concatenate From_year and From_Month , To_year and To_Month.
While selecting date check whether period field is in between these values.
concatenate from_year from_month into from_period. concatenate to_year to_month into to_period. r_period-low = from_period. r_period-high = to_period. r_period-sign = 'I'. r_period-option = 'BT'. append r_period. clear r_period. select .... where period in r_period.
Then, you will get correct results as you expected.
Regards,
Sailaja.
Hello Daniel,
as some data types are not known to me, I can not give you a full solution. From point of easiest way to code the issue can be solved by deleting unwanted entries just before you do the output.
delete {result] where {year <= {start_year} and {month} < {start_month}. delete {result] where {year >= {end_year} and {month} > {end_month}.
An even better solution is to have these conditions earlier (:=
Regards
Klaus
Hello,
I see the problem in the value of range field only,
try concatenating even the day. I tried this example below and it worked perfect for me.
Data: Begin of ivbak occurs 0,
vbeln like vbak-vbeln,
erdat like vbak-erdat,
end of ivbak.
Ranges : r_erdate for vbak-erdat.
INITIALIZATION.
r_erdate-low = '20010118'.
r_erdate-high = '20010309'.
r_erdate-OPTION = 'BT'.
r_erdate-sign = 'I'.
append r_erdate.
select vbeln erdat from vbak into table ivbak
where erdat in r_erdate.
If that did not work, try for different date formats.
Thanks,
Thirumal
Add comment