Skip to Content
author's profile photo Former Member
Former Member

Need help for below code

Hi Friends,

I have written belw code to populate the month +2 value.

Here i have kept variable VAR_CL_MNTH (as Manditory and ready for input)

If i put 02.2012 and query result should show the result as 02.2012, 03.2012 and 04.2012.

The problem i am facing that the vairable value (02.2012) is not getting passed to I_T_VAR_RANGE.

==========================================================

WHEN 'VAR_CL_MNTH'.

Data: Year TYPE /BI0/OICALYEAR,
month TYPE N LENGTH 2,
zmonth Type N LENGTH 2,
zyear TYPE /BI0/OICALYEAR,
test LIKE l_s_range-low.

Data: calyear1 TYPE N LENGTH 8,
calyear2 TYPE N LENGTH 8.

IF I_STEP = 2.

READ TABLE I_T_VAR_RANGE INTO loc_var_range WITH KEY VNAM ='VAR_CL_MNTH'.
IF SY-SUBRC = 0.

CLEAR l_s_range.


Year = loc_var_range+0(4).
month = loc_var_range+4(2).
zmonth = month + 2.

concatenate month year into calyear1.
concatenate zmonth year into calyear2.

l_s_range-sign = 'I'.
l_s_range-opt = 'BT'.
l_s_range-low = calyear1.
l_s_range-high = calyear2.
APPEND l_s_range TO e_t_range.

=========================================================

Thanks

Samir.

Add a comment
10|10000 characters needed characters exceeded

Related questions

4 Answers

  • Posted on Dec 17, 2012 at 11:20 AM

    Hi Samir,

    Try adding InfoObject as a selection to read the value in the below statement along with variable name.

    READ TABLE I_T_VAR_RANGE INTO loc_var_range WITH KEY VNAM ='VAR_CL_MNTH'.

    Thanks,

    Umashankar

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 17, 2012 at 12:05 PM

    Hi Samir,

    Insted of customer exit code, you can achieve this using value ranges (instead of variables while restricting) and offset.

    In value ranges, select Between and use same variable (user input variable) in both from and to and use offset 0 and 2.

    Thanks,

    Reshma M.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 18, 2012 at 06:42 AM

    Hi

    Instead of hardcoding , you can make use of offset concept.

    If you use the code then the query performance will be degraded.

    Regards,

    RC

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 18, 2012 at 06:55 AM

    Hi Samir,

    Your code is deficit of validations. Assume the input is 12.2012. Your code will produce output as 12.2012,13.2012,14.2012 which is wrong.

    Try to use offset variables in query instead of customer exit codes.

    Br,

    H

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.