Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Abap Code Help

Former Member
0 Likes
935

Hi Experts,

Am learning abap, could someone please explain the following code;

IF i_step EQ 0 OR " without popup

i_step EQ 1 OR " before popup

i_step EQ 2. " after popup

REFRESH e_t_range.

CLEAR: l_s_range.

CLEAR : s1, s2.

DATA v_pm(6) TYPE c.

s1 = sy-datum.

s2 = sy-datum.

*Date must be in YYYYMM format

IF i_vnam = 'ZUEPOSTM' AND s1+6(2) = '01'.

s1 = s1 - 1.

s1+6(2) = '01'.

s1 = s1 - 1.

v_pm(4) = s1+0(4).

v_pm4(2) = s14(2).

ELSE.

s1+6(2) = '01'.

s1 = s1 - 1.

v_pm(4) = s1+0(4).

v_pm4(2) = s14(2).

ENDIF.

l_s_range-sign = 'I'.

l_s_range-opt = 'EQ'.

l_s_range-low = v_pm.

APPEND l_s_range TO e_t_range.

ENDIF.

I appreciate your time with points,

Thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
900

Hi,

Check the documentation..

      • If the I_STEP is equal to 0 or 1 or 2..Then the do the following..

IF i_step EQ 0 OR " without popup

i_step EQ 1 OR " before popup

i_step EQ 2. " after popup

REFRESH e_t_range.

CLEAR: l_s_range.

CLEAR : s1, s2.

DATA v_pm(6) TYPE c.

      • Store the current date in the variables S1 and S2.

s1 = sy-datum.

s2 = sy-datum.

      • If the i_vnam = 'ZUEPOSTM' and if it is start of the month..Means 01

*Date must be in YYYYMM format

IF i_vnam = 'ZUEPOSTM' AND s1+6(2) = '01'.

      • Decrement the date by 1 day...Means if 01 - feb - 2006 then it will be 01 - Jan - 2006

      • current date = 12/26/2006

s1 = s1 - 1. "s1 = 20061225

s1+6(2) = '01'. "s1 = 20061201

s1 = s1 - 1. "s1 = 20061130

v_pm(4) = s1+0(4). " v_pm = 2006

v_pm4(2) = s14(2). " v_pm = 200611

ELSE.

s1+6(2) = '01'. "s1 = 20061201

s1 = s1 - 1. "s1 = 20061130

v_pm(4) = s1+0(4). " v_pm = 2006

v_pm4(2) = s14(2). " v_pm = 200611

ENDIF.

l_s_range-sign = 'I'.

l_s_range-opt = 'EQ'.

l_s_range-low = v_pm.

APPEND l_s_range TO e_t_range.

ENDIF.

  • Basically it is getting the previous month and year..Build a range with it..

Thanks,

Naren

8 REPLIES 8
Read only

Former Member
0 Likes
900

Hi,

I believe they are building a range with the previous month and year..

Thanks,

Naren

Read only

0 Likes
900

Nothing wrong with the code it was used in one of the reports and am trying to undertstand the code. i need someone to walk me thru the code.

Read only

Former Member
0 Likes
900

Hi,

Or debug the code and check what is happening...

Thanks,

Naren

Read only

Former Member
0 Likes
901

Hi,

Check the documentation..

      • If the I_STEP is equal to 0 or 1 or 2..Then the do the following..

IF i_step EQ 0 OR " without popup

i_step EQ 1 OR " before popup

i_step EQ 2. " after popup

REFRESH e_t_range.

CLEAR: l_s_range.

CLEAR : s1, s2.

DATA v_pm(6) TYPE c.

      • Store the current date in the variables S1 and S2.

s1 = sy-datum.

s2 = sy-datum.

      • If the i_vnam = 'ZUEPOSTM' and if it is start of the month..Means 01

*Date must be in YYYYMM format

IF i_vnam = 'ZUEPOSTM' AND s1+6(2) = '01'.

      • Decrement the date by 1 day...Means if 01 - feb - 2006 then it will be 01 - Jan - 2006

      • current date = 12/26/2006

s1 = s1 - 1. "s1 = 20061225

s1+6(2) = '01'. "s1 = 20061201

s1 = s1 - 1. "s1 = 20061130

v_pm(4) = s1+0(4). " v_pm = 2006

v_pm4(2) = s14(2). " v_pm = 200611

ELSE.

s1+6(2) = '01'. "s1 = 20061201

s1 = s1 - 1. "s1 = 20061130

v_pm(4) = s1+0(4). " v_pm = 2006

v_pm4(2) = s14(2). " v_pm = 200611

ENDIF.

l_s_range-sign = 'I'.

l_s_range-opt = 'EQ'.

l_s_range-low = v_pm.

APPEND l_s_range TO e_t_range.

ENDIF.

  • Basically it is getting the previous month and year..Build a range with it..

Thanks,

Naren

Read only

0 Likes
900

Naren,

Thanks a ton for your time, also could you please tell me what the following will

do;

l_s_range-sign = 'I'.

l_s_range-opt = 'EQ'.

l_s_range-low = v_pm.

APPEND l_s_range TO e_t_range.

Full points to u.

Read only

Former Member
0 Likes
900

Hi,

This will build a range internal table..

l_s_range-sign = 'I'.

l_s_range-opt = 'EQ'.

l_s_range-low = v_pm.

APPEND l_s_range TO e_t_range.

Which means..You can check if the year and month is with in the range..You have to use IN operator to check the data..

The ranges are similar to select-options..Only think is the ranges will not be displayed in the selection-screen..

Example.

-


IF '200611' IN e_t_range.

      • True.

ELSE.

      • False.

ENDIF.

Thanks,

Naren

Read only

0 Likes
900

Basically when u run the report and enter 200612 in variable "ZUEPOSTM", the report output will be from 200611 to 200612. am i correct?

Read only

Former Member
0 Likes
900

Hi,

I am not sure about that..You have to post the entire code for me to check..

But the code building a range with the previous month and year..

Thanks,

Naren