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

Ranges table

Former Member
0 Likes
684

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
634

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

4 REPLIES 4
Read only

Former Member
0 Likes
634

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

Read only

Former Member
0 Likes
635

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

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
634

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

Read only

RaymondGiuseppi
Active Contributor
0 Likes
634

Read this document: [Subfield Access|http://help.sap.com/abapdocu_70/en/ABENOFFSET_LENGTH.htm]

NB: it_period-LOW+4(2) is the month in a DATS field, but the code suggests it is a week number ?

Regards,

Raymond