09-17-2008 2:16 PM
Hello Friends,
I have an internal table with say for eg : 15 materials. I need to display them on the sapscropt form .
I want to format this internal table into another internal table with 3 columns and each column having 5 materials so that i can fit all the 10 materials on one page.
Please advise .
Thank you ,
Teresa
Eg: itab1
m1
m2
m3
m4
m5
m6
I need the new itab2 to look like
col1 col2 col3
m1 m2 m3
m4 m5 m6
09-17-2008 2:49 PM
Hi Teresa lytle,
Following code solves your problem:
REPORT ZMA_TEST .
Tables: mara, makt.
data: begin of itab occurs 0,
matnr like mara-matnr,
" maktx like makt-maktx,
end of itab.
data: begin of itab2 occurs 0,
matnr like makt-matnr,
matnr2 like makt-matnr,
end of itab2.
select matnr into table itab from makt up to 15 rows where spras eq 'E'.
data: i type i, y type i.
describe table itab lines i.
y = i / 2.
loop at itab from 1 to y.
itab2-matnr = itab-matnr.
append itab2.
endloop.
loop at itab from y to i.
itab2-matnr2 = itab-matnr.
append itab2.
endloop.
loop at itab2.
write: itab2.
endloop.
09-17-2008 2:39 PM
HI,
define itab2 with component col1 col2 col3 .
data: a type i value '0'.
loop at ita1.
a = a + 1.
if a = 1.
itab2-col1 = ita1-matnr.
endif.
if a = 2.
itab2-col2 = ita1-matnr.
endif.
if a = 3.
itab2-col3 = ita1-matnr.
clear a.
endif.
endloop.
hope this will help u.
09-17-2008 2:49 PM
Hi Teresa lytle,
Following code solves your problem:
REPORT ZMA_TEST .
Tables: mara, makt.
data: begin of itab occurs 0,
matnr like mara-matnr,
" maktx like makt-maktx,
end of itab.
data: begin of itab2 occurs 0,
matnr like makt-matnr,
matnr2 like makt-matnr,
end of itab2.
select matnr into table itab from makt up to 15 rows where spras eq 'E'.
data: i type i, y type i.
describe table itab lines i.
y = i / 2.
loop at itab from 1 to y.
itab2-matnr = itab-matnr.
append itab2.
endloop.
loop at itab from y to i.
itab2-matnr2 = itab-matnr.
append itab2.
endloop.
loop at itab2.
write: itab2.
endloop.