report Print_Tab.
* Ini : Print_Tab v0.1 --------------- 14.09.2004
define print_tab_create.
data: pt_edx(30) occurs 0 with header line,
pt_esi(30),
pt_eax type i,
pt_edi(6) type n,
pt_ebx type i,
begin of pt_tab occurs 0,
tab like dd03l-tabname,
fie like dd03l-fieldname,
lon like dd01l-leng,
end of pt_tab.
field-symbols <pt_fs>.
end-of-definition.
define print_tab_show.
split &4 at ',' into table pt_edx.
pt_eax = 01.
if not &1 is initial.
skip. write: / &3, '->', &2. skip.
endif.
import pt_tab from memory id 'pt_esi'.
loop at pt_edx.
read table pt_tab with key tab = &2 fie = pt_edx.
if sy-subrc ne 0.
select single d~leng into pt_tab-lon from dd03l as k
inner join dd01l as d
on d~domname = k~domname
where k~tabname = &2 and
k~fieldname = pt_edx.
pt_tab-tab = &2.
pt_tab-fie = pt_edx.
append pt_tab.
endif.
pt_edi = pt_tab-lon.
if pt_eax = 1. write / ''. endif.
if pt_edi > 30. pt_edi = 30. endif.
pt_ebx = strlen( pt_edx ).
if pt_ebx > pt_edi. pt_edi = pt_ebx. endif.
if not &1 is initial.
write: at pt_eax pt_edx+0(30).
else.
concatenate &3 '-' pt_edx into pt_esi.
assign (pt_esi) to <pt_fs>.
pt_esi = <pt_fs>.
shift pt_esi left deleting leading ' '.
pt_ebx = pt_edi - strlen( pt_esi ).
* Por si quieres desplazar a la derecha
if pt_ebx > 0. shift pt_esi right by pt_ebx places. endif.
write: at pt_eax pt_esi+0(30).
endif.
pt_eax = pt_eax + 2 + pt_edi .
endloop.
export pt_tab to memory id 'pt_esi'.
check not &1 is initial.
uline at /001(pt_eax).
end-of-definition.
* Fin : Print_Tab v0.1 --------------- 14.09.2004
*--- Slo para el ejemplo
tables: tcurt, tcurr.
data: begin of itabb occurs 0,
spras like tcurt-spras,
waers like tcurt-waers,
ltext like tcurt-ltext,
ktext like tcurt-ktext,
ukurs like tcurr-ukurs,
end of itabb.
end-of-selection.
select * from tcurt where spras = sy-langu.
move-corresponding tcurt to itabb.
select ukurs into itabb-ukurs from tcurr where
kurst = 'EURO' and
fcurr = tcurt-waers.
append itabb.
endselect.
endselect.
print_tab_create.
loop at itabb.
at first.
print_tab_show 'X' 'TCURT' 'ITABB' 'WAERS,KTEXT,LTEXT,SPRAS'.
endat.
print_tab_show ' ' 'TCURT' 'ITABB' 'WAERS,KTEXT,LTEXT,SPRAS'.
endloop.