Академический Документы
Профессиональный Документы
Культура Документы
Written by
ukasz Pgiel
Published:
17 April 2013
Hits:
299
Category:
How to...
start-of-selection.
fs_code = 'PROGRAM DYNAMIC_FORMS.'.
append fs_code to ft_code.
fs_code = 'form test changing f_string type string.'.
append fs_code to ft_code.
fs_code = 'f_string = sy-uname.'.
append fs_code to ft_code.
fs_code = 'endform.'.
*&--------------------------------------------------------------------*
*&
Form set_pf
*&--------------------------------------------------------------------*
form set_pf ."using EDITORMODE.
set pf-status 'OUR_GUISTATUS'.
if g_okcode = 'ED_INS_FRA'. "Insert Pattern
call function 'SAPGUI_SET_FUNCTIONCODE'
exporting
functioncode
= 'ED_INS_FRAME'
exceptions
function_not_supported = 1
others
= 2.
if sy-subrc <> 0.
endif.
elseif g_okcode = 'PRETTY'.
"set dummy okcode to avoid messages "Function not found"
call function 'SAPGUI_SET_FUNCTIONCODE'
exporting
FUNCTIONCODE
= 'DUMY'
exceptions
FUNCTION_NOT_SUPPORTED
= 1
others
= 2.
if sy-subrc <> 0.
endif.
endif.
endform.
"set_pf
*&--------------------------------------------------------------------*
*&
Form ucomm
*&--------------------------------------------------------------------*
form ucomm .
field-symbols: <editor> type ref to cl_wb_editor.
data: fo_source type ref to cl_wb_source.
data: ft_sourcetab type standard table of char255.
data: ft_sourcetab_pretty type standard table of char255.
data: f_editor type string.
f_editor = '(SAPLS38E)ABAP_EDITOR'.
assign (f_editor) to <editor>.
move sy-ucomm to g_okcode.
sy-ucomm = 'DUMY'.
case g_okcode.
when 'PRETTY'.
data: line type i.
<editor>->get_source_instance( importing source_object = fo
_source ).
fo_source->get_source_tab( importing source = ft_sourcetab[
] ).
call function 'PRETTY_PRINTER'
exporting
inctoo
= space
*
IMPORTING
*
INDENTATION_MAYBE_WRONG
= INDENTATION_MAYBE_WRONG
tables
ntext
= ft_sourcetab_pretty[]
otext
= ft_sourcetab[]
exceptions
enqueue_table_full
= 1
include_enqueued
= 2
include_readerror
= 3
include_writeerror
= 4
others
= 5
.
if sy-subrc <> 0.
endif.
fo_source->set_source_tab( exporting source = ft_sourcetab_
pretty[]
not_actualize_control = 'X' ).
<editor>->visualize_source( ).
endcase.
suppress dialog.
endform.
"ucomm
You should take care about saving function but that should not be a problem as you
already seen in the code how to get the table with the code to local table. You can also
add more functions for example: 'Where used list' (FM 'RS_TOOL_ACCESS') or syntax
check (SYNTAX-CHECK).
When you have your final code you can then generate a temporary program from it using
syntax found below and then call dynamically your forms created there.
generate subroutine pool ft_code name g_prog message f_msg.