The Standard Text Editor
The Standard Text Editor
Blogs
Introduction
If you want to enable users editing standard texts in extremely simple and straightforward UI, you can use the component described in this weblog. It's a class (OO
ABAP) which pops up a CL_GUI_TOOLBAR (CFW) control which enables user to enter text and save or close.
Formatting options are good to have. But if they are unneccessary for some functionality, then it's good to hide them from users. What they can't see they can't
break. Look at all the nice confuzing buttons to mess with in SO10:
SO10 occupies the entire session screen - I can't run it in a popup (or any desired) container
www.sdn.sap.com/irj/scn/weblogs?bl… 1/7
17/06/2010 SAP Community Network Blogs
REPORT Z_TEST_ST_TEXT_EDITOR. 5
DATA: o_txe TYPE REF TO zcl_standard_text_editor,
v_caption TYPE char100,
s_thead TYPE thead.
* call screen
CALL SCREEN 0100.
* MODULE s0100_start
MODULE s0100_start OUTPUT.
SET PF-STATUS 'BASIC'.
s_thead-tdname = 'VENDOR0000000011'.
s_thead-tdid = 'ST'.
s_thead-tdobject = 'TEXT'.
s_thead-tdspras = sy-langu.
CONCATENATE 'Standard text:' s_thead-tdname
INTO v_caption SEPARATED BY space.
IF o_txe IS INITIAL.
CREATE OBJECT o_txe
EXPORTING i_thead = s_thead
i_caption = v_caption.
ENDIF.
ENDMODULE.
* MODULE s0100_exit
MODULE s0100_exit INPUT.
LEAVE PROGRAM. 6
ENDMODULE.
...results with a popup screen:
3. Create attributes:
Attribute Level Visibility Typing Assoc. type In.Val.
C_SAVE Constant Public Type UI_FUNC 'P_SAVE'
C_CLOSE Constant Public Type UI_FUNC 'P_CLOSE'
MAIN_CONTAINERInstance Protected Type Ref To CL_GUI_CONTAINER
SPLITTER Instance Protected Type Ref To CL_GUI_EASY _SPLITTER_CONTAINER
TEXTEDIT Instance Protected Type Ref To CL_GUI_TEXTEDIT
TOOLBAR Instance Protected Type Ref To CL_GUI_TOOLBAR
THEAD Instance Protected Type THEAD
CAPTION Instance Protected Type TEXT100
T_INITIAL_TEXT Instance Private Type TY_T_TEXT
3. Create methods:
Parameters
Method Level Visibility
Name TypeOptTyping Assc. Type DefVal
CONSTRUCTOR InstancePublic I_CONTAINERImp X TypeRefToCL_GUI_CONTAINER
I_CAPTION Imp X Type C
I_THEAD Imp Type THEAD
FREE InstancePublic
ON_TOOLBAR_FUNC_SELInstanceProtectedFCODE
SAVE InstanceProtected
ON_CONTAINER_CLOSE InstanceProtected
M_CLOSE InstanceProtected
(continued from the above table):
Event handler for
www.sdn.sap.com/irj/scn/weblogs?bl… 2/7
17/06/2010 SAP Community Network Blogs
Event handler for
Method
Class/interface Event
CONSTRUCTOR
FREE
ON_TOOLBAR_FUNC_SELCL_GUI_TOOLBAR FUNCTION_SELECTED
SAVE
ON_CONTAINER_CLOSE CL_GUI_DIALOGBOX_CONTAINERCLOSE
M_CLOSE
4. Create event (you might need it for unlocking in a calling program)
Parameters
Event Level Visibility
Name TypeOptTyping Assc. Type
CLOSEInstancePublic E_THEAD Exp X Type THEAD
E_OBJECT Exp X Type Ref ToZCL_STANDARD_TEXT_EDITOR
5. Implement methods (create methods' code)
method CONSTRUCTOR. 5
DATA: o_dialogbox TYPE REF TO cl_gui_dialogbox_container,
t_text TYPE STANDARD TABLE OF tdline,
s_event TYPE cntl_simple_event,
t_events TYPE cntl_simple_events,
t_lines TYPE STANDARD TABLE OF tline,
v_text TYPE tdline,
v_text_temp TYPE tdline,
v_line_temp TYPE tdline,
v_line_len TYPE i,
v_index TYPE i.
FIELD-SYMBOLS: <line> TYPE tline.
me->thead = i_thead.
me->caption = i_caption. 6
*------ containers
The end
Well, that's all. Nothing fascinating, but I believe simple and handy. Have fun!
Igor
Igor Barbaric is a BC consultant and ABAPer in G2R, Croatia
I know the Weblog is already old, but I have the same problem Ian had.
The events seem to be registered but the event itself never starts.
Best regards
Joachim
Hi Joachim,
I faced the same situation as you did and finally after some lengthy investigation I found the solution.
When used inside a class it is apparantly not an application event but a system event that should be registered.
www.sdn.sap.com/irj/scn/weblogs?bl… 3/7
17/06/2010 SAP Community Network Blogs
I found this by looking at method FILL_TOOLBAR in std SAP class CL_BUPA_STATUS_ALV. I am on R/3 4.7 BTW.
Johan,
Thanks a lot for your effort and correction!
I have updated the code in weblog according to your findings.
Regards,
Igor
Works great
2005-11-22 08:34:39 Rajesh Dash Business Card [Reply]
Igor,
I could use your code for my design. Thanks for publishing it.
Rajesh
Thanks for your comment, Rajesh! I am happy that people still read old weblogs and find them useful.
Kind regards,
Igor
Hi Igor
I have just implemented your code but the toolbar events do not seem to fire. Any ideas? I have double check the atributes, mthods etc. The code was copied and
pasted in so there should not be any typos etc.
I am on 46B BTW.
Thanks in advance
Ian
Hi, Ian!
First, I'd like to appologize for delayed answer. I have just got hired by a new company (today starts my 2nd week). The transport system was not functioning,
so I had to fix it first (urgent), import the components and then try the program.
However, my sample program works fine. Although I was pretty much certain, I have compared the code again just in case (my class against weblog code) and
it's the same.
I don't know what could cause your toolbar event not firing. By the way, do you mean standard commands (export, import etc), or custom (save and close)? All
the same, it works in my program.
You can debug the code and see what's happening: Try setting the first breakpoint in CONSTRUCTOR method, the part where the event is registered - find the
comment "*------ register events". Is event registered properly?
You can place the second breakpoint at the beginning of the ON_TOOLBAR_FUNC_SEL method. Does program even step in there when you press the Save
button?
www.sdn.sap.com/irj/scn/weblogs?bl… 4/7
17/06/2010 SAP Community Network Blogs
Please tell me how you're doing. I'd love to see it work. Don't hesitate to contact me by email at <firstname>.<lastname>@infotehna.hr (let's avoid spam).
syntax error.
2005-06-07 21:15:36 Salmon Salmon Business Card [Reply]
Dear Igor,
I had used the standard text for default text in the sales transaction, and it would be great if your provided code can be replace the functionally of standard text.
Best Regards,
Salmon
Hi, Salmon!
You can resolve the problem #1 easily. Get into the class ZCL_STANDARD_TEXT_EDITOR (trans SE24) and press the button "Types". Then you get a text
editor and insert the statement
[code]TYPES: ty_t_text TYPE STANDARD TABLE OF tdline.[/code]
and that's all. Please take a look at the instructions in the weblog - it's step 2.
As for the problem #2 - syntax error when trying to concatenate hex value with text, I must admit that I don't know what to do at the moment. It works fine
on my system, and I'm pretty much sure that this is caused by version difference. I'm on 4.7 WAS 620. What's your version?
I'll try to find the alternative way to accomplish this and I'll post the solution as soon as I find it. Meanwhile, you can comment out the entire IF...ELSE...ENDIF
part and leave only the statements
[code]v_line_temp = <line>-tdline.
CONCATENATE v_text v_line_temp INTO v_text_temp.[/code]
You'll temporarily lose the functionality of paragraph breaks, untill I find the version-independant solution to this.
Thanks!
Igor
P.S. By the way, this code does not replace the standard texts. It just enables another way to let the user edit standard texts.
Hi Igor,
The problem #1 has been resolved, I missed the 2nd step when trying the code, sorry....
B.Rgds,
Salmon
www.sdn.sap.com/irj/scn/weblogs?bl… 5/7
17/06/2010 SAP Community Network Blogs
www.sdn.sap.com/irj/scn/weblogs?bl… 6/7
17/06/2010 SAP Community Network Blogs
www.sdn.sap.com/irj/scn/weblogs?bl… 7/7