Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to set the word control of SAP Document Builder to read-only mode

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail how to set the word control of SAP Document Builder to read-only mode, the content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.

I've been working on a client project recently, and one of the clients' requirements is that they don't want the word document to be editable in the word control.

This means that all buttons and menus in the toolbar should be disabled.

Image

The first idea comes to my mind is the flag "enableReadWrite".

Image

As documented in sap help,it can fulfill my help but unfortunately it is deprecated. Regardless of this warning I have a try and found it does not work indeed.

Then I speculated that if the uploaded document was read-only, the toolbar would definitely be disabled. Therefore, the problem becomes how to mark the document as read-only during the upload process.

Since word 2007, the format of MS office follows the so-called "Open office" protocol, and its specification can be found here.

If you change the file type extension from. Docx is here. Use WinRAR to compress and open it, and you'll find that the document is actually a package of multiple individual files (called the document section in SAP internal). Editability is controlled by file settings. Xml .

If you don't know the exact grammar, use Google to search. I used this in Google's explanation:

Now the task is very simple, just add the necessary xml tags to the documentation source code. You do not need to parse the documentation source code manually, because SAP has already done the job. You can reuse standard class CL_DOCX_ documents.

Because I need to insert a document protection node in the Settings node, I wrote a simple transformation for this. Magic is between lines 18 and 21.

ReadOnly 1

And find a proper place to call the transformation:

DATA: lr_element TYPE REF TO if_wd_context_element, lv_file_data TYPE xstring, lv_ret TYPE i, lx_temp TYPE xstring, lv_msg TYPE string, lt_parms TYPE / ipro/tt_key_value_pair, ls_parm LIKE LINE OF lt_parms. Lr_element = me- > wd_context- > get_element (). CHECK lr_element IS NOT INITIAL. Lr_element- > get_attribute (EXPORTING name = 'BINARY' IMPORTING value = lv_file_data). DATA (lo_docx) = cl_docx_document= > load_document (lv_file_data). DATA (lo_main_part) = lo_docx- > get_maindocumentpart (). DATA (lo_docx_settings) = lo_main_part- > get_documentsettingspart (). DATA (lx_settings) = lo_docx_settings- > get_data (). / ipro/cl_docx_utilities= > transform (EXPORTING iv_input_xstring = lx_settings iv_transform_name ='/ IPRO/DOCXCC_PROTECT' it_parameters = lt_parms IMPORTING ev_result = lx_temp ev_ret = lv_ret ev_message = lv_msg). Lo_docx_settings- > feed_data (lx_temp). DATA (lx_docx_package) = lo_docx- > get_package_data (). Lr_element- > set_attribute (EXPORTING name = 'BINARY' value = lx_docx_package).

After that the tag will be there in settings.xml:

Image

The word control before upload document looks like below, buttons and menus available:

Image

After upload, menu and button are disabled. If you try to edit the document, there will be notifications in the right pane to give you a hint that is not possible.

Of course, this solution does not apply to earlier versions of MS word, such as word2003. Fortunately, my clients have enough money and they are already using Office 2013, so I don't have to worry about it.

On how to set the word control of SAP Document Builder to read-only mode to share here, I hope the above content can be of some help to you, you can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report