ITPub博客

首页 > 应用开发 > IT综合 > BAdI: Documents

BAdI: Documents

原创 IT综合 作者:zclouis 时间:2007-09-21 23:27:56 0 删除 编辑

BAdI: Documents

Use

This Business Add-In (BAdI) can be utilized in the usage of documents on BW objects.

With this BADI you are able to interrupt when saving or reading BW documents and execute customer specific changes. The following operations are supported:

  • Changing the properties of a document
  • Creating properties for a document
  • Deleting the properties of a document
  • Writing the content of a document to the database
  • Selecting documents from document storage (Administrator Workbench or Web Application)
  • Triggering hierarchy nodes for document selection in reporting

You can find details in the method documentation for the assigned IF_EX_RSOD_DOC_BADI interfaces.

Standard settings

The BAdi can be used more than once and is not dependent on a filter.

Activities

After you call the IMG activity, the system displays a dialog box where you enter a name for the implementation.

If implementations of this Business Add-In have already been created, the system displays them in a dialog box. You then choose one of them by choosing Create, and continue as follows:

    1. In the dialog box, enter a name for the implementation of the Add-In and choose Create.
    The system displays the initial screen for creating Business Add-In implementations.
    2. On this screen, enter a short description for you implementation in the Implementation Short Text field.
    3. If you choose the Interface tab, you will notice that the system has filled in the Name of the Implementing Class field automatically, by assigning a class name based on the name of your implementation.
    4. Save your entries and assign the Add-In to a package.
    5. To edit a method, double-click its name.
    6. Enter your implementation code between the method ~. aund endmethod. statements.
    7. Save and activate your code. Navigate back to the Change Implementation screen.
    Note: You can also create an implementation for an Add-In and not activate it until later. If you want to do this, do not carry out the following step:
    8. Choose Activate.
    When the application program is executed, the system carries out the code in the method you wrote.

Example

Again you can find examples in the method documentation for the IF_EX_RSOD_DOC_BADI interfaces.

Also see:

Methods:

Change the properties of a document

Create properties of a document

Delete properties of a document

Write the content of a document to the DB

Selection of Documents (Administrator Workbench or Web Application)

Controlling triggering hierarchies in reporting

**************************************************

Change of Properties of a Document

Functionality

This method is called up when properties of a document are changed.

Only the logical document properties that were changed are dealt with.

Requirements

An implementation must have been created for BADI RSOD_DOC_BADI via transaction SE19.

Result

The list of properties can be changed in the method.
For example, properties can be changed or deleted.

Parameters

I_R_DOC: Document whose properties are being changed.

C_T_PROP: Changed logical document properties as a name / value pairs. You can see all available properties in the Document Modeling Workbench, under 'BW'.
All logical properties of the document (also the ones that were not changed) can be taken from parameter I_R_DOC in the following way:

DATA: l_t_prop TYPE sdokproptys.

CALL METHOD i_r_doc->get_all_prop_values_loio

* EXPORTING

* I_ONLY_BW_SPECIFIC = RS_C_FALSE

RECEIVING

r_t_prop = l_t_prop.

Exceptions

If you want to prevent properties from being changed, you need to send exception CX_RSOD. A message describing the cause of the error can be given with this exception:

RAISE EXCEPTION TYPE cx_rsod

EXPORTING

MSGID = 'RSOD' "Message Class

MSGNO = '152' "Message Number

MSGTY = 'E' "Message Type Error

MSGV1 = 'Text Variable 1'

MSGV2 = 'Text Variable 2'

MSGV3 = 'Text Variable 3'

MSGV4 = 'Text Variable 4'.

This message is then displayed on the user interface.

**************************************************

Creation of Properties of a Document

Functionality

This method is called up when properties of a document are newly created.

The system only deals with the logical document properties.

Requirements

You need to have created an inplementation for BADI RSOD_DOC_BADI via transaction SE19.

Result

The list of properties can be changed in the method.

For example, the properties can be changed or deleted.

Parameters

I_R_DOC: Document which is being changed or newly created

C_T_PROP: All logical properties of the document as name / value pairs. You can see all available properties in the Document Modeling Workbench, under 'BW'.

Exceptions

If you want to prevent properties from being changed, you need to send exception CX_RSOD. A message describing the cause of the error can be sent with this exception:

RAISE EXCEPTION TYPE cx_rsod

EXPORTING

MSGID = 'RSOD' "Message Class

MSGNO = '152' "Message Number

MSGTY = 'E' "Message Type Error

MSGV1 = 'Text Variable 1'

MSGV2 = 'Text Variable 2'

MSGV3 = 'Text Variable 3'

MSGV4 = 'Text Variable 4'.

This message is then displayed on the user interface.

**************************************************

Deletion of Properties of a Document

Functionality

This method is called up when properties of a document are deleted.

The system only deals with the logical document properties.

Result

The list of properties to be deleted can be changed in the method.

For example, you can prevent the properties from being deleted.

Parameters

I_R_DOC: Document whose properties are being deleted.

C_T_PROP: Logical properties of a document to be deleted as name / value pairs. You can see all available properties in the Document Modeling Workbench, under 'BW'. If entries in this table are deleted, these properties are not deleted with them.

Exceptions

If you want to prevent the document from being saved, exception CX_RSOD needs to be triggered ( see CREATE_PROPERTIES method ).

**************************************************

Writing Document Content to DB

Functionality

Saving the content of a document.

Requirements

This method is called up when the content of a document is to be changed or newly created.

Result

The content can be changed before saving.

Parameters

I_R_DOC: Document whose properties are being deleted.

C_S_FILE_ACCESS_INFO: Information about content (mime type, file name, ....)

C_T_FILE_CONTENT_ASCII: Table with text document content

C_T_FILE_CONTENT_BINARY: SDOK: Table with binary document content

Only one of tables C_T_FILE_CONTENT_ASCII and C_T_FILE_CONTENT_BINARY is filled.

The properties of the document can be read as in method CHANGE_PROPERTIES.

Exceptions

If saving the content is to be prevented, exception CX_RSOD needs to be triggered ( see CREATE_PROPERTIES method ).

**************************************************

Selection of Documents (AWB or Web Application)

Functionality

You can use this method to change the selection condition for documents before they are read by the database. In this way you can influence the number of selected documents.

Example: In a report, figures for the current period and for the previous one are displayed. However, you only want to display documents for the current period and not the previous one. There would normally be two entries for the period in the selection. This method enables you to delete the entry for the previous period. Thus, the system only reads documents for the current period.

This method is called up in the following cases:

  • Displaying documents in the AWB (Documents area) or displaying documents for a BW object in SAP GUI.
    In this case, the parameters I_R_REQUEST I_R_ITEM, I_R_PAGE and C_R_REQ_SEL are empty.
  • Displaying documents in the Web items "List of Documents" and "Single Document" as well as determining document links in the Web items "Table" and "Generic Navigation Block"
    In this case, the parameters I_R_REQUEST and C_R_REQ_SEL are filled.
  • Displaying documents in the Document Browser (after selecting Goto -> Documents via the context menu)
    In this case, the parameter I_R_REQUEST is empty, parameters I_R_ITEM and I_R_PAGE are filled however.

Parameters

I_DOC_CLASS Document class: This parameter can have the following values:

  • TRAN: Documents for transaction data
  • MAST: Documents for master data
  • META: Documents for metadata

I_MODUS Callup mode: the method is called up at the following points in time:

  • 1 Constructor: Call up when generating selection object
  • 2 Changing properties: A property of the selection was changed (selection in the AWB changed or an entry selected in the dropdown box for the Web item "List of Documents")
  • 3 DataProviders changed: The DataProvider was changed with a navigation step. For this reason, the system adjusts the selection of documents.

I_R_REQUEST Request class, which shows the current status of the query or DataProvider:
This parameter is only filled when document selection is called up directly for a Web item or a query. In other words, this parameter is not filled with the document browser or in the AWB.
Useful attributes:

  • I_R_REQUEST->N_S_REPKEY-INFOCUBE: InfoProvider
  • I_R_REQUEST->N_S_REPKEY-COMPID: Query
  • I_R_REQUEST->N_SX_REQUEST-VAR: Variabes defined by the user
    You can use this table to restrict the document selection to the current perid for example, provided that the current period is defined using a variable.
    You can get further variables, which are not entered but are filled automatically, by calling function module RRC_VARIABLES_GET with I_HANDLE = I_R_REQUEST->N_HANDLE.

I_R_ITEM Web item which last selected documents:
This parameter is always filled when document selection was called up from the document browser.
With Web Applications, there are 2 variants:

  • For the DataProvider assigned to the web item, the property "Display Document Links" is activated. In this case, document selection is first called up for the DataProvider. The parameter item has not been set as yet. For the item "List of Documents", document selection is not carried out for a second time.
  • For the DataProvider that is assigned to the Web item, the property "Display Document Links" is deactivated.
    In this case, documeent selection is only carried out for the item. The parameter item is set.

I_R_PAGE Reference to page, that is, to the Web application template :
This parameter is only filled when the parameter I_R_ITEM is filled.
You can use the method I_R_PAGE->GET_TEMPLATE_NAME to get the technical name of the template.

C_TS_QUPROP Filter selection of the document properties:
The entries in this table can be changed, added or deleted to enable you to adjsut the selection to your specific reqiurements.

C_R_REQ_SEL Request selection
This class represents the selection of the DataProvider without the filter selection. This is where the rows and columns are stored.

C_SEARCH_TEXT Such string if a text search (via TREX) is also to be carried out.

**************************************************

Control of Hierarchy Deletion in Reporting

Functionality

This method allows you to control the resolution of hierarchy nodes for the selection of documents in reporting. One option is to have the resolution of hierarchy nodes completely hidden.

Example: You want to save documents on transaction data in a hierarchy

at node level. As documents cannot be stored on hierarchy nodes, use a hierarchy with postable nodes and create the documents at the corresponding characteristic values.
If such a node is restricted, all the documents that match any of its subordinate nodes are selected. The node is then resolved. However, with the restricted hierarchy node you only want to see the documents for the corresponding characteristic value. In order to be able to do this, use this BADI method to hide the hierarchy resolution.

The coding that follows shows how this requirement is implemented - resolution is hidden for all postable nodes. Furthermore, the nodes are transformed into leaves:

FIELD-SYMBOLS: TYPE rsr_s_rangesid.

LOOP AT c_t_range ASSIGNING .

CASE -high.

WHEN space.

* leaf

* ...

WHEN i_field_info-chabasnm.

* postable node

CLEAR: c_t_node_resolve,

-high. "convert to leaf

c_node_resolve = rs_c_false.

WHEN rsd_c_dpanm-hier_node.

* text node

* ...

WHEN OTHERS.

* other characteristic

* ...

ENDCASE.

ENDLOOP.

Parameters

I_INFOPROV: InfoProvider on which the current query or the current DataProvider is based

I_COMPID: Technical name of the query (on which the current DataProvider is based)

I_FIELD_INFO: Information on the hierarchy-defining characteristic (field IOBJNM) and its reference characteristic (field CHABASNM)

I_HIENM: Technical name of the hierarchy

I_VERSION: Hierarchy version

I_HDATE: Selection date (for time-dependant hierarchies)

C_T_RANGE: Selection of hierarchy nodes / characteristic values
When calling the BADI method, this table only contains single values (SIGN = 'I' and OPT = 'EQ')
The characteristic value stands in the field LOW
The characteristic stands in the field HIGH. The following cases are to be differentiated:

  • SPACE: Concerns a leaf in the hierarchy
  • 0HIER_NODE: Concerns an unpostable node (text node)
  • Current basic characteristic (= I_FIELD_INFO-CHABASNM): Concerns a postable node
  • Other characteristic: Concerns a characteristic node with an external characteristic

To transform a postable hierarchy node into a characteristic value it is only necessary to delete the field HIGH.

C_NODE_RESOLVE:
= 'X': Resolve node
= ' ' : Do not resolve node
This parameter is set to 'X' (resolve) by default. Set this parameter to ' '(SPACE), if the node is not to be resolved.

**************************************************

[@more@]

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/7941665/viewspace-970843/,如需转载,请注明出处,否则将追究法律责任。

上一篇: Create RFC Connections
请登录后发表评论 登录
全部评论

注册时间:2011-04-21

  • 博文量
    40
  • 访问量
    126016