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 TO TABLE ?

Former Member
0 Likes
1,126

Hi,

i have a RANGES in my ABAP code and i want to generate a table from it.

For exemple, i have the following code :

SELECT-OPTIONS P_BUKRS FOR PERNR-BUKRS.

Ok, now, this ranges is filled by this data :

1 I |EQ |0400| |

2 I |BT |0600|0620 |

I want to create an internal table which lists all data like this :

0400

0600

0601

0602

..

0620

Thanks for help.

1 ACCEPTED SOLUTION
Read only

andreas_mann3
Active Contributor
0 Likes
1,102

1) create an itab with field number

and fill it in a do-loop with 1 to 1000 or more

loop that table:

loop at itab where number in p_bukrs.
 append itab-number to outrec.
endloop.

2)

alternative:

(why not immediately)

select bukrs from t001 into table outrec
      where bukrs in p_bukrs.
 endloop.

A.

Message was edited by:

Andreas Mann

Hi,

i have a RANGES in my ABAP code and i want to generate a table from it.

For exemple, i have the following code :

SELECT-OPTIONS P_BUKRS FOR PERNR-BUKRS.

Ok, now, this ranges is filled by this data :

1 I |EQ |0400| |

2 I |BT |0600|0620 |

I want to create an internal table which lists all data like this :

0400

0600

0601

0602

..

0620

Thanks for help.

7 REPLIES 7
Read only

Former Member
0 Likes
1,102

Or better i want to loop on all valid BUKRS.

Read only

andreas_mann3
Active Contributor
0 Likes
1,103

1) create an itab with field number

and fill it in a do-loop with 1 to 1000 or more

loop that table:

loop at itab where number in p_bukrs.
 append itab-number to outrec.
endloop.

2)

alternative:

(why not immediately)

select bukrs from t001 into table outrec
      where bukrs in p_bukrs.
 endloop.

A.

Message was edited by:

Andreas Mann

Read only

Former Member
0 Likes
1,102

DATA : BEGIN OF itab OCCURS 0,
BUKRS LIKE PERNR-BUKRS,
END OF itab.

SELECT BUKRS INTO CORRESPONDING FIELDS OF TABLE itab FROM PERNR WHERE BUKRS IN P_BUKRS.
Read only

0 Likes
1,102

PERNR is a structure not a database table.

Read only

0 Likes
1,102

Then change PERNR with actual table name which stroring BUKRS data.

Read only

Former Member
0 Likes
1,102

select bukrs from t001 into table it_bukrs where bukrs in s_bukrs.

if sy-subrc = 0.

*--u will get all valid bukrs into table it_bukrs

endif.

this is because....t001 is check table for company code...and all valid company codes will be available here.....so u can use this table....

Regards

Vasu

Read only

Former Member
0 Likes
1,102

SELECT bukrs

FROM t001

INTO TABLE i_bukrs

WHERE bukrs IN p_bukrs.