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

Error for variable in customer Enhancement

Hi Guys,

Requirement is to fetch last date of month for previous 5months based on ket date.

I have written the code without syntax error :facing the Error while running the query:

Error for variable in customer Enhancement.

For Single value its working fine,the problem when we keep do statement.

Can you please guide..

Please check the code.

CASE vnam.

WHEN 'Z5MNTH_LBACK'. "----cmod variable (Multiple single value) based on 0calday

IF i_step = 2.

LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = '0P_KEYDT' ."---------user input variable (based on calday).

l_var_monyr = loc_var_range-low(6).

DO 5 TIMES.

IF l_var_monyr+4(2) = '01'.

l_var_year = loc_var_range-low(4) - 1.

CONCATENATE l_var_year '12' '01' INTO l_kdate.

CLEAR : l_var_monyr.

CONCATENATE l_var_year '12' INTO l_var_monyr.

ELSE.

l_var_monyr = l_var_monyr - 1.

CONCATENATE l_var_monyr '01' INTO l_kdate.

ENDIF.

CALL FUNCTION 'SLS_MISC_GET_LAST_DAY_OF_MONTH'

EXPORTING

day_in = l_kdate

IMPORTING

last_day_of_month = l_last_day.

l_s_range-low = l_last_day.

l_s_range-sign = 'I'.

l_s_range-opt = 'EQ'.

APPEND l_s_range TO e_t_range.

CLEAR: l_s_range, l_kdate.

ENDDO.

ENDLOOP.

ENDIF.

ENDCASE.

Regards,

Suresh

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Mar 14, 2014 at 03:07 AM

    Hi,

    Is your issue resolved? If not can you try with following code?

    CASE i_vname.

    WHEN 'Z5MNTH_LBACK'.

    DATA: l_firstday TYPE D,

    l_lastday TYPE D.

    CLEAR : l_s_range, e_t_range[].

    READ TABLE i_t_var_rane INTO loc_var_range with key vnam = '0P_KEYDT'.

    l_firstday = loc_var_range-low.

    l_firstday+6(2) = '01'. "get first day of the month from key date entered

    l_s_range-sign = 'I'.

    l_s_range-option = 'EQ'.

    DO 5 TIMES.

    l_lastday = l_firstday - 1.

    l_s_range-low = l_lastday.

    APPEND l_s_range TO e_t_range.

    l_firstday = l_lastday.

    "To keep previous last day, NOT the key date for next previous month last date

    l_firstday+6(2) = '01'.

    ENDDO.

    ENDCASE.

    Hope this helps..

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Mar 13, 2014 at 09:21 AM

    Hi suresh,

    Please attach the error screenshot.

    Also you can use the below code.

    WHEN 'Z5MNTH_LBACK'. "----cmod variable (Multiple single value) based on 0calday

    IF i_step = 2.

    data : f_date type d,

    sec_date type d,

    thrid_date type d,

    fourth_date type d,

    fifth_date type d,

    wa2 like line of i_t_var_range,

    wa1 like line of e_t_range.

    read table i_t_var_range into wa2 with key vnam = '0P_KEYDT' .

    f_date = wa2-low.

    fdate+6(2) = '01'.

    f_date = f_date - 1.

    sec_date = fdate.

    sec_date+6(2) = '01'.

    sec_date = sec_date - 1.

    third_date = sec_date.

    third_date+6(2) = '31'.

    third_date = third-date - 1.

    fourth_date = third_date.

    fourth_date+6(2) = '01'.

    fourth_date = fourth_date - 1.

    fifth_date = fourth_date.

    fifth_date+6(2) = '01'.

    fifth_date = fifth_date - 1.

    wa1-low = f_date.

    wa1-sign = 'I'.

    wa1-opt = 'EQ'.

    append wa1 to e_t_range.

    wa1-low = sec_date.

    wa1-sign = 'I'.

    wa1-opt = 'EQ'.

    append wa1 to e_t_range.

    wa1-low = third_date.

    wa1-sign = 'I'.

    wa1-opt = 'EQ'.

    append wa1 to e_t_range.

    wa1-low = fourth_date.

    wa1-sign = 'I'.

    wa1-opt = 'EQ'.

    append wa1 to e_t_range.

    wa1-low = fifth_date.

    wa1-sign = 'I'.

    Endif.

    using Function will degrade the query performance as it will execute some unnecassary piece of code, it should be used only if there is no other alternative.

    Please once with above code.

    regards,
    RaviChandra.

    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.