Posted: Mon Feb 25, 2008 1:22 pm Post subject: Read SAP Menu into Text File
Code:
report zexp_get_menu no standard page heading.
***********************************************************
* Read SAP Menu into Text File
*
* This is freeware. Please read the terms of use.
* Written by Urs Rohner, Rohner IT Consulting & Engineering
*
* Contact Author: Urs Rohner
*
***********************************************************
* Globals
types:
begin of t_menu_e,
seq type i,
level type i,
text type smensapt-text,
end of t_menu_e,
t_menu type t_menu_e occurs 0.
data:
_seq type i,
_menu type t_menu,
_smensapnew like smensapnew occurs 0,
_smensapt like smensapt occurs 0.
parameters:
_file like rlgrap-filename default 'c:\temp\menu.txt'.
* Method: m_traverse_menu>
* Traverse Standard SAP Menu Tree
define m_traverse_menu>.
perform m_traverse_menu using &1 &2 &3 &4 &5 &6.
end-of-definition.
form m_traverse_menu using
seq_ type i
value(level_) type i
value(parent_) like smensapnew-parent_id
smensapnew_ like _smensapnew[]
smensapt_ like _smensapt[]
menu_ type t_menu.
data:
_indent type i,
_child type i,
_start type i,
_menu type t_menu_e,
_smensapnew like smensapnew,
_smensapt like smensapt.
_child = level_ + 1.
read table smensapnew_[] into _smensapnew with key
parent_id = parent_ binary search.
if sy-subrc is initial.
_start = sy-tabix.
loop at smensapnew_[] into _smensapnew from _start.
if _smensapnew-parent_id ne parent_.
exit.
endif.
read table smensapt_[] into _smensapt with key
object_id = _smensapnew-object_id binary search.
if sy-subrc is initial.
add 1 to seq_.
clear _menu.
_menu-seq = seq_.
_menu-level = level_.
_menu-text = _smensapt-text.
_indent = level_ * 2.
shift _menu-text right by _indent places.
append _menu to menu_[].
m_traverse_menu> seq_ _child _smensapnew-object_id
smensapnew_[] smensapt_[] menu_[].
endif.
endloop.
endif.
endform.
*
* P A I ( )
*
start-of-selection.
select * from smensapnew into table _smensapnew[].
select * from smensapt into table _smensapt[]
where spras eq sy-langu.
sort:
_smensapnew[],
_smensapt[].
m_traverse_menu> _seq 1 1 _smensapnew[] _smensapt[] _menu[].
" download to file if required
call function 'WS_DOWNLOAD'
exporting
filename = _file
filetype = 'DAT'
tables
data_tab = _menu[]
exceptions
file_open_error = 1
file_write_error = 2
invalid_filesize = 3
invalid_table_width = 4
invalid_type = 5
no_batch = 6
unknown_error = 7
gui_refuse_filetransfer = 8
others = 9.
if sy-subrc is initial.
message s208(00) with 'complete'.
endif.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.