‎2010 Mar 19 1:45 PM
Hello all,
Good day. I'm new to ABAP and wish to get your advice.
I understand that there is no array concept in ABAP as internal table is used instead.
I just read a topic on "Ranges table" and I came accross to this piece of code:
============================================================
ranges: it_period for mcs0-sptag. (the data type of sptag is DATS)
IF it_period-LOW+4(2) LT '52'.
it_period-LOW4(2) = it_period-LOW4(2) + 1.
APPEND it_period.
ENDIF.
============================================================
May I know what is the meaning of the above piece of coding?
I know that it_period-LOW means lower limit for a range. BUT "it_period-LOW+4(2)" means what?
In C or C++, normally () means single dimension of an array, e.g. A(0) is the first item of array A, A(1) is the second item and etc. I am confused what is the usage of "()" in the ranges table.
Also, can we loop at a Ranges table such as follow? If yes, appreciate you can provide an example when we can loop at a Ranges table.
loop at it_period.
...
ENDLOOP.
Thank you.
‎2010 Mar 19 1:51 PM
Hello,
In it_period-LOW+4(2) , the 4(2) refers to the offset addition and its not specific to ranges. And yes you can loop at ranges table just as you do to a internal table. You should be getting the offset explanation easily from the SAP documentation
Vikranth
‎2010 Mar 19 1:50 PM
Hi Kim,
Grand Welcom to SCN/SDN
for Example it_period-low = 123450
IF it_period-LOW+4(2) LT '52'. " Means the 5th and 6th chars here it is 50
it_period-LOW+4(2) " the Same
= it_period-LOW+4(2) + 1. Adding one to the Existing one then becomes 51
APPEND it_period.
ENDIF.
and regarding loop at ranges
if r_month contains Month names like JAN, FEB etc from T247 Table
loop at r_month.
write :/ r_month-low.
endloop.Cheerz
Ram
‎2010 Mar 19 1:51 PM
Hello,
In it_period-LOW+4(2) , the 4(2) refers to the offset addition and its not specific to ranges. And yes you can loop at ranges table just as you do to a internal table. You should be getting the offset explanation easily from the SAP documentation
Vikranth
‎2010 Mar 19 1:52 PM
The values here are 201052 where the first 4 digits are the year and the last two, are the week. So in this code block they are simply incrementing the last two digits. The use of the +4 means to skip the first four characters, and the (2) means use the last two for the condition.
And yes, you can simply loop the range table as you have coded.
Regards,
Rich Heilman
‎2010 Mar 19 1:52 PM