How to… Documents in SEM-BPS and BW-BPS SEM-BPS/BW-BPS Applicable Releases: SEM 3.1B - SEM-BPS 3.5, BW-BPS 3.5 SAP (SAP America, Inc. and SAP AG) assumes no responsibility for errors or omissions in these materials. These materials are provided “as is” without a warranty of any kind, either express or implied, including but not limited to, the implied warranties of merchantability, fitness for a particular purpose, or non-infringement. SAP shall not be liable for damages of any kind including without limitation direct, special, indirect, or consequential damages that may result from the use of these materials. SAP does not warrant the accuracy or completeness of the information, text, graphics, links or other items contained within these materials. SAP has no control over the information that you may access through the use of hot links contained in these materials and does not endorse your use of third party web pages nor provide any warranty whatsoever relating to third party web pages. mySAP BI “How-To” papers are intended to simplify the product implementation. While specific product features and procedures typically are explained in a practical business context, it is not implied that those features and procedures are the only approach in solving a specific business problem using mySAP BI. Should you wish to receive additional information, clarification or support, please refer to SAP Professional Services (Consulting/Remote Consulting). HOW TO … DOCUMENTS IN SEM-BPS AND BW-BPS 1 Sample Scenarios - Description __________________________________________________________ 2 1.1 Copy Documents using a Planning Function ___________________________________________ 2 1.2 Delete Documents using a Planning Function __________________________________________ 2 2 General Hints ________________________________________________________________________ 2 3 Sample Scenarios: The Step By Step Solution _______________________________________________ 6 3.1 Introduction _____________________________________________________________________ 6 3.2 Basics __________________________________________________________________________ 6 3.3 The Delete Function _______________________________________________________________ 6 3.4 The Copy Function _______________________________________________________________ 7 3.4.1 Creating the planning function _______________________________________________________ 7 3.4.2 Creating the parameter group ________________________________________________________ 8 2002 SAP AMERICA, INC. AND SAP AG 1 HOW TO … DOCUMENTS IN SEM-BPS AND BW-BPS 1 Sample Scenarios - Description 1.1 Document handling in the SEM-BPS/BW-BPS In the SEM-BPS/BW-BPS the user can attach documents (type MS Word, MS PowerPoint, MS Excel or Plain Text) to certain combinations of characteristic values and keyfigure values. One way to use documents is to enable the document functionality in the manual planning and to create documents that are attached to the characteristic combination (including a keyfigure) that is defined by a cell in a layout. The documents are stored in the Knowledge Warehouse and thus are accessible in the BW as well. As the Knowledge Warehouse offers functionality for document management (such as copying, deleting, etc.) the SEM-BPS/BW-BPS only provides the following functionality: to create, view, or delete single documents. The key that is used to store the documents is made up from characteristic values and possibly keyfigures. Only those characteristics can be used as keys that are “commentable”. You can switch that feature on in the BW Info Object maintenance by setting the flag “Characteristic is document attrib.”. 1.2 Copy Documents using a Planning Function As the documents hold comments about specific plan data and thus are closely related to the data customers also want to treat documents together with the data, e.g. copy documents to a new versions whenever the plan data is copied to that version. This should be done with a planning function, as thus the functionality is accessible in all front ends alike and also can be combined with a copy function (for plan data) in a planning sequence. The planning function must do a physical copy of the documents on the database. If you want to access the same document in say two different versions it is better not to mark version as being commentable as thus the version will be ignored when selecting the documents. 1.3 Delete Documents using a Planning Function In the SEM-BPS/BW-BPS documents can only be deleted one by one. If data records are deleted the documents related to that data are not deleted. There are a number of reasons why the system behaves this way. On the other hand sometimes the documents should be deleted together with the plan data. Again this functionality should be realized in a planning function. 2 General Hints The SEM-BPS/BW-BPS offers two different ways to display documents: 2002 SAP AMERICA, INC. AND SAP AG 2 HOW TO … DOCUMENTS IN SEM-BPS AND BW-BPS 1. The document functionality in the Planning Framework (predefined method 0-DOC). The functionality is accessible via a node in the lower tree and displays all documents that belong to a certain selection given by the selected package. This function displays a list of all documents that contain relevant selections for all (commentable) characteristics that are in the planning level. If a document has selections for additional characteristics (and thus being defined in a level that is implicitly contained in the planning level) it will be shown as well. Documents created or displayed with this functionality need not contain a keyfigure in the selection. 2. The document functionality in the Manual Planning/Web. The functionality is available for a layout if it is switched to “read documents” in the layout builder. Documents can be attached to plan data in cells (or columns in the Web). Only those documents will be shown that have relevant selections for exactly the commentable characteristics of the planning level and that also have a selection for a keyfigure. Documents that have additional characteristics in the selection or do not have a keyfigure in the selection will not be shown. 2002 SAP AMERICA, INC. AND SAP AG 3 HOW TO … DOCUMENTS IN SEM-BPS AND BW-BPS Example: Characteristics in the planning level (all commentable): 0VERSION 0CUSTOMER 0COUNTRY Keyfigure in the planning level: 0REVENUE Selection (planning package/level) 0VERSION: 1-2 0CUSTOMER: 0001-1000 0COUNTRY: GB, DE, FR, US Selection for Document 1: 0VERSION: 1 0CUSTOMER: 0002 2002 SAP AMERICA, INC. AND SAP AG 4 HOW TO … DOCUMENTS IN SEM-BPS AND BW-BPS 0COUNTRY: GB Keyfigure: 0REVENUE The document can be seen in both cases Selection for Document 2: 0VERSION: 1 0CUSTOMER: 0002 0COUNTRY: GB 0REGION: 001 Keyfigure: 0REVENUE If the characteristic 0REGION is commentable then the document will NOT appear in a layout but can be seen using the document functionality (0-DOC) in the framework. If on the other hand the characteristic 0REGION is NOT commentable then the characteristic will be ignored and the document can be seen in both cases. Selection for Document 2: 0VERSION: 1 0CUSTOMER: 0002 0COUNTRY: GB The selection does not contain a keyfigure and therefore the document will NOT be visible in a layout but in the framework document functionality 0-DOC. 2002 SAP AMERICA, INC. AND SAP AG 5 HOW TO … DOCUMENTS IN SEM-BPS AND BW-BPS 3 Sample Scenarios: The Step By Step Solution 3.1 Introduction In this paper we want to show how a copy function and a delete function for documents can be used in the SEM-BPS/BW-BPS. From release 3.1B, Support Package 14 and release 3.2, Support Pack 10 and higher releases there are shipped realizations for such functions done as planning functions type exit. The same function modules are described in OSS Note 583994. The logic how these functions work and how they are to be used will be explained in this paper. 3.2 Basics The shipped versions of the planning functions for copying and deleting documents can be found in the function group UPFX. If you do not find the function modules in your system you can also create exit and init function modules (with the proper interfaces!) and copy the coding included further down. Note that both function save the changes in the documents to the database after execution automatically! 3.3 The Delete Function We start with the planning function that is deleting documents, as this one is easier to understand and to handle. In order to create this planning function go to the framework (transaction BPS0) and in an appropriate level create a planning function type Exit. Enter “UPF_DOC_DEL_INIT” as name of the Init function and “UPF_DOC_DEL_EXIT” for the Exit function itself (note that the Exit function module is empty – all the work will be done in the Init function module). The Exit function will select the plan data specified by the planning package. The shipped implementation of the function modules will on the other hand not change the plan data. In order to speed the execution of the planning function one should select all fields as fields to be changed. Thus the exit is only called once as only one subset is formed and as the plan data is not changed no master data checks will be performed. The shipped implementation for the delete function does not require any exit parameters. The selection for the documents to be deleted will be taken from the package selection. You can use the planning function like a normal planning function in any Web Interface, planning folder or planning sequence. 2002 SAP AMERICA, INC. AND SAP AG 6 HOW TO … DOCUMENTS IN SEM-BPS AND BW-BPS 3.4 The Copy Function If you use the standard copy function in the BPS you have to define the source and the target of the copying process. The target has to be contained in the selection of the planning package, the information which source will be copied to which target is given in the parameter group. The exit function delivered in the function group UPFX is based on the same concept. 3.4.1 Creating the planning function In order to create the planning function you again have to access the planning framework and create a planning function type Exit. Enter “UPF_DOC_COPY_INIT” as name of the init function and “UPF_DOC_COPY_EXIT” for the Exit function itself (note that the Exit function module again is empty – all the work will be done in the Init function module). As we have no other option to define the parameter group we will use the exit parameters. For defining the rules for the copying you have to specify the characteristic, the “from” value and the “to” value. Thus the exit parameters will be used as triples: the first value specifies the characteristic, the second value is the “from” value, and the third value is the “to” value. The next value again specifies a characteristic and so on. As the actual values for the exit parameters in the parameter group might get reordered when saving to the database the names of the exit parameters should start with numbers. As data elements you can use some standard SEM-BPS/BW-BPS data elements: UPC_Y_CHANM for the name of the characteristics and UPC_Y_LOW for the “from” and the “to” values. You can also define and use your own data elements (they should be of type character and length 60) with “From value” and “To value” as text. 2002 SAP AMERICA, INC. AND SAP AG 7 HOW TO … DOCUMENTS IN SEM-BPS AND BW-BPS You can use as many of those triples as necessary provided that the characteristic is contained in the level. Triples for characteristics that are not commentable will be ignored. As the fields to be changed will not be used within the exit you should choose all characteristics as to be changed for performance reasons (see above). 3.4.2 Creating the parameter group As with a normal planning function type copy you can use different parameter groups. In the parameter groups the exit parameters are filled with the name of the characteristic(s), the “from” and the “to” values. Characteristics: For the characteristics you have to use the technical name (e.g. 0BPS_CNTRY). If you want to copy from one keyfigure to another you have to enter “_BKENNZAHL” for the characteristic. “From” and “to” values: In these fields you enter the value for the characteristic in the external format. Please make sure that the value is not longer than 60 characters (a value might be up to 70 characters) as by definition exit parameters can only have 60 characters. If you want to copy between keyfigures and have entered “_BKENNZAHL” as characteristic please enter the technical names of the keyfigures. 2002 SAP AMERICA, INC. AND SAP AG 8 HOW TO … DOCUMENTS IN SEM-BPS AND BW-BPS You can also use variables for specifying the “from” and the “to” value. Enter manually the name of the variable in the relevant field. Please make sure that your variable has a name that is not identical with some characteristic value. The system will check at runtime that the variable contains only one single value. If the variable contains an interval and/or several single values the system will stop the execution of the planning function. In this example we copy documents from country ‘DE’ to a country that is specified by a variable called “VARCOUNT” and from the keyfigure “0BPS_COGS” to the keyfigure “0BPS_DMEXP”. Please note that the target must be contained in the package that you use for executing the planning function. As with normal planning functions the “from” values do not have to be contained in the selection. If you do not fill the “from” or the “to” value for some characteristic the planning function will produce an error. 4 Coding of the shipped Exits 4.1 The Delete Function 4.1.1 UPF_DOC_DEL_INIT 2002 SAP AMERICA, INC. AND SAP AG 9 HOW TO … DOCUMENTS IN SEM-BPS AND BW-BPS FUNCTION UPF_DOC_DEL_INIT. *"---------------------------------------------------------------------*"*"Interface: *" IMPORTING *" REFERENCE(I_AREA) TYPE UPC_Y_AREA *" REFERENCE(I_PLEVEL) TYPE UPC_Y_PLEVEL *" REFERENCE(I_PACKAGE) TYPE UPC_Y_PACKAGE *" REFERENCE(I_METHOD) TYPE UPC_Y_METHOD *" REFERENCE(I_PARAM) TYPE UPC_Y_PARAM *" REFERENCE(IT_EXITP) TYPE UPF_YT_EXITP *" REFERENCE(ITO_CHASEL) TYPE UPC_YTO_CHASEL *" REFERENCE(ITO_CHA) TYPE UPC_YTO_CHA *" REFERENCE(ITO_KYF) TYPE UPC_YTO_KYF *" EXPORTING *" REFERENCE(ETO_CHAS) TYPE ANY TABLE *" REFERENCE(ET_MESG) TYPE UPC_YT_MESG *"---------------------------------------------------------------------* * * * * This planning function deletes all documents selected in the planning package. This applies to all documents that are defined on the same level of aggregation as the planning function, i.e. only those documents are deleted that are visible in a layout using the same package. * * * * * The framework does only call the save method for documents iff any document functionality is started from the framework. As the framework does not know about the documents created in this customer exit function the save must be called here. Thus documents are always saved when this function is called. data: lr_doc type ref to CL_SEM_MP_DOCUMENTS, lr_area_attr type ref to cl_sem_planarea_attributes. data: lto_doc type UPC_YTO_DOC, lto_document_long type upc_yto_document_long, lto_cha type upc_yto_cha, lto_cha_com type upc_yto_cha, lto_plevelk type UPC_YTO_KYF, lto_chasel like ito_chasel, ls_cha type upc_ys_cha, ls_chapro type upc_ys_chapro, ls_mesg type upc_ys_mesg, ls_doc type upc_ys_doc, ls_document_long type upc_ys_document_long, ls_kyf type UPC_YS_KYF, ls_chasel type UPC_YS_CHASEL, ls_charng type upc_ys_charng. lto_chasel = ito_chasel. * get the list of characters from the level CALL FUNCTION 'UPC_PLEVEL_GET' EXPORTING I_AREA = i_area I_PLEVEL = i_plevel IMPORTING ETO_PLEVELC = lto_cha ETO_PLEVELK = lto_plevelk EXCEPTIONS NO_EXISTENCE = 1 LOCKED = 2 2002 SAP AMERICA, INC. AND SAP AG 10 HOW TO … DOCUMENTS IN SEM-BPS AND BW-BPS NO_CONSISTENCE = 3 OTHERS = 4. IF SY-SUBRC <> 0. ls_mesg-msgid = sy-msgid.ls_mesg-msgty = sy-msgty. ls_mesg-msgno = sy-msgno.ls_mesg-msgv1 = sy-msgv1. ls_mesg-msgv2 = sy-msgv2.ls_mesg-msgv3 = sy-msgv3. ls_mesg-msgv4 = sy-msgv4. append ls_mesg to et_mesg. exit. ENDIF. * get an instance of the planarea CALL METHOD CL_SEM_PLANAREA_ATTRIBUTES=>GET_INSTANCE EXPORTING I_AREA = i_area RECEIVING ER_INSTANCE = lr_area_attr EXCEPTIONS FAILED = 1 others = 2. IF SY-SUBRC <> 0. ls_mesg-msgid = sy-msgid.ls_mesg-msgty = sy-msgty. ls_mesg-msgno = sy-msgno.ls_mesg-msgv1 = sy-msgv1. ls_mesg-msgv2 = sy-msgv2.ls_mesg-msgv3 = sy-msgv3. ls_mesg-msgv4 = sy-msgv4. append ls_mesg to et_mesg. exit. ENDIF. clear lto_cha_com. * fill the table of chars that can have a comment loop at lto_cha into ls_cha. read table lr_area_attr->to_chapro into ls_chapro with table key chanm = ls_cha-chanm. if ls_chapro-BDSFL is initial. delete lto_chasel where chanm = ls_cha-chanm. else. insert ls_cha into table lto_cha_com. endif. endloop. * if lto_cha_com is initial. message i008 raising failed. exit. endif. ls_cha-chanm = cl_sem_mp_documents=>c_name_keyf. insert ls_cha into table lto_cha_com. * we insert a selection for the keyfigure - exactly the ones that are * in the level clear ls_chasel. ls_chasel-chanm = cl_sem_mp_documents=>c_name_keyf. loop at lto_plevelk into ls_kyf. ls_charng-sign = 'I'. ls_charng-option = 'EQ'. ls_charng-low = ls_kyf-kyfnm. clear ls_charng-high. append ls_charng to ls_chasel-t_charng. 2002 SAP AMERICA, INC. AND SAP AG 11 HOW TO … DOCUMENTS IN SEM-BPS AND BW-BPS endloop. if not ls_chasel-t_charng is initial. insert ls_chasel into table lto_chasel. endif. * get a object of the buffer class CALL METHOD CL_SEM_MP_DOCUMENTS=>GET_INSTANCE EXPORTING I_AREA = i_area RECEIVING ER_INSTANCE = lr_doc. * load the documents CALL METHOD LR_DOC->GET_DOCUMENT_LIST EXPORTING ITO_CHA = lto_cha_com ITO_CHASEL = lto_chasel IMPORTING ETO_DOCUMENT_LONG = lto_document_long EXCEPTIONS FAILED = 1 others = 2. IF SY-SUBRC <> 0. ls_mesg-msgid = sy-msgid.ls_mesg-msgty = sy-msgty. ls_mesg-msgno = sy-msgno.ls_mesg-msgv1 = sy-msgv1. ls_mesg-msgv2 = sy-msgv2.ls_mesg-msgv3 = sy-msgv3. ls_mesg-msgv4 = sy-msgv4. append ls_mesg to et_mesg. exit. ENDIF. clear lto_doc. loop at lto_document_long into ls_document_long. ls_doc-DOC_ID = ls_document_long-DOC_ID. ls_doc-DOC_SOURCE = 'D'. ls_doc-DOC_TITLE = ls_document_long-DOC_TITLE. ls_doc-DOC_SIZE = ls_document_long-DOC_SIZE. ls_doc-DOC_TYPE = ls_document_long-DOC_TYPE. ls_doc-TO_CHAVL = ls_document_long-TO_CHAVL. ls_doc-AREA = i_area. ls_doc-todo = 'D'. insert ls_doc into table lto_doc. endloop. *write to buffer CALL METHOD lr_doc->UPDATE_DOCUMENT_LIST EXPORTING ITO_DOC = lto_doc ITO_CHA = lTO_CHA_COM EXCEPTIONS FAILED = 1 others = 2. IF SY-SUBRC <> 0. ls_mesg-msgid = sy-msgid.ls_mesg-msgty = sy-msgty. ls_mesg-msgno = sy-msgno.ls_mesg-msgv1 = sy-msgv1. ls_mesg-msgv2 = sy-msgv2.ls_mesg-msgv3 = sy-msgv3. ls_mesg-msgv4 = sy-msgv4. append ls_mesg to et_mesg. exit. ENDIF. 2002 SAP AMERICA, INC. AND SAP AG 12 HOW TO … DOCUMENTS IN SEM-BPS AND BW-BPS * * * * * The framework does only call the save method for documents iff any document functionality is started from the framework. As the framework does not know about the documents created in this customer exit function the save must be called here. Thus documents are always saved when this function is called. CALL METHOD CL_SEM_MP_DOCUMENTS=>SAVE EXPORTING I_SAVE_MODE = 'D' EXCEPTIONS FAILED = 1 others = 2. IF SY-SUBRC <> 0. ls_mesg-msgid = sy-msgid.ls_mesg-msgty = sy-msgty. ls_mesg-msgno = sy-msgno.ls_mesg-msgv1 = sy-msgv1. ls_mesg-msgv2 = sy-msgv2.ls_mesg-msgv3 = sy-msgv3. ls_mesg-msgv4 = sy-msgv4. append ls_mesg to et_mesg. exit. ENDIF. ENDFUNCTION. 4.1.2 UPF_DOC_DEL_EXIT FUNCTION UPF_DOC_DEL_EXIT. *"-------------------------------------------------------------------*"*"Interface: *" IMPORTING *" REFERENCE(I_AREA) TYPE UPC_Y_AREA *" REFERENCE(I_PLEVEL) TYPE UPC_Y_PLEVEL *" REFERENCE(I_METHOD) TYPE UPC_Y_METHOD *" REFERENCE(I_PARAM) TYPE UPC_Y_PARAM *" REFERENCE(I_PACKAGE) TYPE UPC_Y_PACKAGE *" REFERENCE(IT_EXITP) TYPE UPF_YT_EXITP *" REFERENCE(ITO_CHASEL) TYPE UPC_YTO_CHASEL *" REFERENCE(ITO_CHA) TYPE UPC_YTO_CHA *" REFERENCE(ITO_KYF) TYPE UPC_YTO_KYF *" EXPORTING *" REFERENCE(ET_MESG) TYPE UPC_YT_MESG *" CHANGING *" REFERENCE(XTH_DATA) TYPE HASHED TABLE *"-------------------------------------------------------------------exit. ENDFUNCTION. 2002 SAP AMERICA, INC. AND SAP AG 13 HOW TO … DOCUMENTS IN SEM-BPS AND BW-BPS 4.2 4.2.1 The Copy Function UPF_DOC_COPY_INIT FUNCTION upf_doc_copy_init . *"---------------------------------------------------------------------*"*"Interface: *" IMPORTING *" REFERENCE(I_AREA) TYPE UPC_Y_AREA *" REFERENCE(I_PLEVEL) TYPE UPC_Y_PLEVEL *" REFERENCE(I_PACKAGE) TYPE UPC_Y_PACKAGE *" REFERENCE(I_METHOD) TYPE UPC_Y_METHOD *" REFERENCE(I_PARAM) TYPE UPC_Y_PARAM *" REFERENCE(IT_EXITP) TYPE UPF_YT_EXITP *" REFERENCE(ITO_CHASEL) TYPE UPC_YTO_CHASEL *" REFERENCE(ITO_CHA) TYPE UPC_YTO_CHA *" REFERENCE(ITO_KYF) TYPE UPC_YTO_KYF *" EXPORTING *" REFERENCE(ETO_CHAS) TYPE ANY TABLE *" REFERENCE(ET_MESG) TYPE UPC_YT_MESG *"---------------------------------------------------------------------* * * * * * * This function is used for copying documents from a set of characteristic combinations to another. As with a normal planning function of type copy the TARGET is specified by the planning package. The "from" and "to" values are specified by the parameter group. Note that only documents are copied that are defined in the same level of aggregation, i.e. all documents are copied that are visible in a layout in the same planning level. * For specifying the "from" and "to" values we use the exit parameters * in the parameter group. For each characteristic we use 3 parameters: * 1. Name of the characteristic * 2. From-value (single value required) * 3. To-value (single value required) * This group has to be repeated for every characteristic used. * * * * * * * * * * * The values have to be entered in the external format. Each field has to be filled. Make sure that the external value is not longer than 60 characters as this is the limit for the fields in the exit parameters. * * * * If the system detects a variable it will check that the variable is filled with exactly one value. If the variable is not filled or it is filled with mor than a single value the system will stop the planning function. * * * * Here an example how the definition of the function should look like using two characteristics. Please follow the naming convention with the leading digits in order to have a clear grouping and order: * Instead of entering a characteristic value you can enter the name of a variable defined in the same planning area (you cannot use the variable button but have to enter the name manually). At runtime the system will first check whether the entry in an exit parameter is the name of a variable. Thus you should not create variables that have the same name as a characteristic value. Parameter name Data element 2002 SAP AMERICA, INC. AND SAP AG 14 HOW TO … DOCUMENTS IN SEM-BPS AND BW-BPS * * * * * * * * * * * 11CHANM 12FROM 13TO 21CHANM 22FROM 23TO UPC_Y_CHANM UPC_Y_LOW UPC_Y_LOW UPC_Y_CHANM UPC_Y_LOW UPC_Y_LOW The framework does only call the save method for documents iff any document functionality is started from the framework. As the framework does not know about the documents created in this customer exit function the save must be called here. Thus documents are always saved when this function is called. DATA: lr_doc TYPE REF TO cl_sem_mp_documents, lr_area_attr TYPE REF TO cl_sem_planarea_attributes. DATA: lto_doc TYPE upc_yto_doc, lto_cha TYPE upc_yto_cha, lto_cha_com TYPE upc_yto_cha, lto_plevelk TYPE upc_yto_kyf, lto_document_long TYPE upc_yto_document_long, lto_chasel LIKE ito_chasel, ls_cha TYPE upc_ys_cha, ls_chasel TYPE upc_ys_chasel, ls_charng TYPE upc_ys_charng, ls_chapro TYPE upc_ys_chapro, ls_exitp LIKE LINE OF it_exitp, ls_chavl TYPE upc_ys_chadep, ls_kyf TYPE upc_ys_kyf, ls_mesg TYPE upc_ys_mesg, ls_doc TYPE upc_ys_doc, ls_document_long TYPE upc_ys_document_long. TYPES: BEGIN OF ys_from_to, chanm TYPE upc_y_chanm, from TYPE upc_y_low, to TYPE upc_y_low, END OF ys_from_to, yt_from_to TYPE STANDARD TABLE OF ys_from_to. DATA: ls_from_to TYPE ys_from_to, lt_from_to TYPE yt_from_to. DATA: l_cntr TYPE n, l_subrc LIKE sy-subrc, l_exit TYPE c, l_lines type i. lto_chasel = ito_chasel. * get the list of characters from the level CALL FUNCTION 'UPC_PLEVEL_GET' EXPORTING i_area = i_area i_plevel = i_plevel IMPORTING eto_plevelc = lto_cha eto_plevelk = lto_plevelk EXCEPTIONS 2002 SAP AMERICA, INC. AND SAP AG 15 HOW TO … DOCUMENTS IN SEM-BPS AND BW-BPS no_existence = 1 locked = 2 no_consistence = 3 OTHERS = 4. IF sy-subrc <> 0. ls_mesg-msgid = sy-msgid.ls_mesg-msgty = sy-msgty. ls_mesg-msgno = sy-msgno.ls_mesg-msgv1 = sy-msgv1. ls_mesg-msgv2 = sy-msgv2.ls_mesg-msgv3 = sy-msgv3. ls_mesg-msgv4 = sy-msgv4. APPEND ls_mesg TO et_mesg. EXIT. ENDIF. * get an instance of the planarea CALL METHOD cl_sem_planarea_attributes=>get_instance EXPORTING i_area = i_area RECEIVING er_instance = lr_area_attr EXCEPTIONS failed = 1 OTHERS = 2. IF sy-subrc <> 0. ls_mesg-msgid = sy-msgid.ls_mesg-msgty = sy-msgty. ls_mesg-msgno = sy-msgno.ls_mesg-msgv1 = sy-msgv1. ls_mesg-msgv2 = sy-msgv2.ls_mesg-msgv3 = sy-msgv3. ls_mesg-msgv4 = sy-msgv4. APPEND ls_mesg TO et_mesg. EXIT. ENDIF. CLEAR lto_cha_com. * fill the table of chars that can have a comment LOOP AT lto_cha INTO ls_cha. READ TABLE lr_area_attr->to_chapro INTO ls_chapro WITH TABLE KEY chanm = ls_cha-chanm. IF ls_chapro-bdsfl IS INITIAL. DELETE lto_chasel WHERE chanm = ls_cha-chanm. ELSE. INSERT ls_cha INTO TABLE lto_cha_com. ENDIF. ENDLOOP. * IF lto_cha_com IS INITIAL. message i008 raising failed. EXIT. ENDIF. ls_cha-chanm = cl_sem_mp_documents=>c_name_keyf. INSERT ls_cha INTO TABLE lto_cha_com. * we insert a selection for the keyfigure - exactly the ones that are * in the level CLEAR ls_chasel. ls_chasel-chanm = cl_sem_mp_documents=>c_name_keyf. LOOP AT lto_plevelk INTO ls_kyf. ls_charng-sign = 'I'. ls_charng-option = 'EQ'. ls_charng-low = ls_kyf-kyfnm. 2002 SAP AMERICA, INC. AND SAP AG 16 HOW TO … DOCUMENTS IN SEM-BPS AND BW-BPS CLEAR ls_charng-high. APPEND ls_charng TO ls_chasel-t_charng. ENDLOOP. IF NOT ls_chasel-t_charng IS INITIAL. INSERT ls_chasel INTO TABLE lto_chasel. ENDIF. * build up at table for copying describe table it_exitp lines l_lines. l_lines = l_lines mod 3. if l_lines <> 0. exit. endif. CLEAR l_exit. LOOP AT it_exitp INTO ls_exitp. ADD 1 TO l_cntr. CASE l_cntr. WHEN '1'. ls_from_to-chanm = ls_exitp-chavl. WHEN '2'. * check for variables PERFORM replace_variable USING ls_exitp-chavl i_area ls_from_to-chanm CHANGING ls_from_to-from l_subrc et_mesg. IF l_subrc <> 0. l_exit = 'X'. EXIT. ENDIF. WHEN '3'. * check for variables PERFORM replace_variable USING ls_exitp-chavl i_area ls_from_to-chanm CHANGING ls_from_to-to l_subrc et_mesg. IF l_subrc <> 0. l_exit = 'X'. EXIT. ENDIF. * check that the charactaristic is commentable READ TABLE lto_cha_com TRANSPORTING NO FIELDS WITH KEY chanm = ls_from_to-chanm. IF sy-subrc = 0. APPEND ls_from_to TO lt_from_to. ENDIF. CLEAR l_cntr. ENDCASE. ENDLOOP. CHECK l_exit IS INITIAL. * * * * as with planning functions the selection in the package determines the TARGET! Exchange the values in the selection by the from values in the table from_to. If the selection in the package is bigger the we restrict it. LOOP AT lt_from_to INTO ls_from_to. ls_chasel-chanm = ls_from_to-chanm. ls_charng-sign = 'I'. 2002 SAP AMERICA, INC. AND SAP AG 17 HOW TO … DOCUMENTS IN SEM-BPS AND BW-BPS ls_charng-option = 'EQ'. ls_charng-low = ls_from_to-from. CLEAR ls_charng-high. CLEAR ls_chasel-t_charng. APPEND ls_charng TO ls_chasel-t_charng. DELETE lto_chasel WHERE chanm = ls_from_to-chanm. INSERT ls_chasel INTO TABLE lto_chasel. ENDLOOP. * get a object of the buffer class CALL METHOD cl_sem_mp_documents=>get_instance EXPORTING i_area = i_area RECEIVING er_instance = lr_doc. * load the documents CALL METHOD lr_doc->get_document_list EXPORTING ito_cha = lto_cha_com ito_chasel = lto_chasel IMPORTING eto_document_long = lto_document_long EXCEPTIONS failed = 1 OTHERS = 2. IF sy-subrc <> 0. ls_mesg-msgid = sy-msgid.ls_mesg-msgty = sy-msgty. ls_mesg-msgno = sy-msgno.ls_mesg-msgv1 = sy-msgv1. ls_mesg-msgv2 = sy-msgv2.ls_mesg-msgv3 = sy-msgv3. ls_mesg-msgv4 = sy-msgv4. APPEND ls_mesg TO et_mesg. EXIT. ENDIF. CLEAR lto_doc. LOOP AT lto_document_long INTO ls_document_long. CLEAR ls_doc. * change the selection LOOP AT ls_document_long-to_chavl INTO ls_chavl. READ TABLE lt_from_to INTO ls_from_to WITH KEY chanm = ls_chavl-chanm FROM = ls_chavl-chavlint. IF sy-subrc <> 0. CONTINUE. ENDIF. DELETE TABLE ls_document_long-to_chavl FROM ls_chavl. ls_chavl-chavlint = ls_from_to-to. INSERT ls_chavl INTO TABLE ls_document_long-to_chavl. ENDLOOP. * create a guid CALL FUNCTION 'GUID_CREATE' IMPORTING ev_guid_22 = ls_doc-doc_id. ls_doc-todo = 'I'. 2002 SAP AMERICA, INC. AND SAP AG 18 HOW TO … DOCUMENTS IN SEM-BPS AND BW-BPS ls_doc-doc_source = 'D'. ls_doc-to_chavl = ls_document_long-to_chavl. ls_doc-doc_title = ls_document_long-doc_title. ls_doc-doc_size = ls_document_long-doc_size. ls_doc-doc_type = ls_document_long-doc_type. ls_doc-area = i_area. * get the content CALL METHOD lr_doc->get_document_content EXPORTING i_doc_id = ls_document_long-doc_id IMPORTING et_content = ls_doc-t_content et_as_content = ls_doc-t_as_content EXCEPTIONS failed = 1 no_document_found = 2 OTHERS = 3. IF sy-subrc <> 0. ls_mesg-msgid = sy-msgid.ls_mesg-msgty = sy-msgty. ls_mesg-msgno = sy-msgno.ls_mesg-msgv1 = sy-msgv1. ls_mesg-msgv2 = sy-msgv2.ls_mesg-msgv3 = sy-msgv3. ls_mesg-msgv4 = sy-msgv4. APPEND ls_mesg TO et_mesg. EXIT. ENDIF. INSERT ls_doc INTO TABLE lto_doc. ENDLOOP. *write to buffer CALL METHOD lr_doc->update_document_list EXPORTING ito_doc = lto_doc ito_cha = lto_cha_com EXCEPTIONS failed = 1 OTHERS = 2. IF sy-subrc <> 0. ls_mesg-msgid = sy-msgid.ls_mesg-msgty = sy-msgty. ls_mesg-msgno = sy-msgno.ls_mesg-msgv1 = sy-msgv1. ls_mesg-msgv2 = sy-msgv2.ls_mesg-msgv3 = sy-msgv3. ls_mesg-msgv4 = sy-msgv4. APPEND ls_mesg TO et_mesg. EXIT. ENDIF. * * * * * The framework does only call the save method for documents iff any document functionality is started from the framework. As the framework does not know about the documents created in this customer exit function the save must be called here. Thus documents are always saved when this function is called. CALL METHOD cl_sem_mp_documents=>save EXPORTING i_save_mode = 'D' EXCEPTIONS failed = 1 OTHERS = 2. IF sy-subrc <> 0. ls_mesg-msgid = sy-msgid.ls_mesg-msgty = sy-msgty. ls_mesg-msgno = sy-msgno.ls_mesg-msgv1 = sy-msgv1. ls_mesg-msgv2 = sy-msgv2.ls_mesg-msgv3 = sy-msgv3. 2002 SAP AMERICA, INC. AND SAP AG 19 HOW TO … DOCUMENTS IN SEM-BPS AND BW-BPS ls_mesg-msgv4 = sy-msgv4. APPEND ls_mesg TO et_mesg. EXIT. ENDIF. ENDFUNCTION. *&--------------------------------------------------------------------* *& Form replace_variable *&--------------------------------------------------------------------* * text *---------------------------------------------------------------------* * -->I_CHAVL text * -->I_AREA text * -->I_CHANM text * -->X_VALUE text * -->X_SUBRC text * -->XT_MESG text *---------------------------------------------------------------------* FORM replace_variable USING i_chavl TYPE upc_y_chavlint i_area TYPE upc_y_area i_chanm TYPE upc_y_chanm CHANGING x_value TYPE upc_y_low x_subrc LIKE sy-subrc xt_mesg TYPE upc_yt_mesg. DATA: lto_value TYPE upc_yto_charsel, ls_value TYPE upc_ys_charsel, lr_variable TYPE REF TO cl_sem_variable, ls_mesg TYPE upc_ys_mesg, l_chavlext TYPE upc_y_chavlext, l_varnm TYPE upc_y_variable, l_lines TYPE i. CLEAR: x_subrc, x_value. CLASS cl_sem_mp_documents DEFINITION LOAD. * maybe we have a variable - try to replace it * does the variable exist? l_varnm = i_chavl. CALL METHOD cl_sem_variable=>get_instance EXPORTING i_area = i_area i_variable = l_varnm RECEIVING rr_variable = lr_variable EXCEPTIONS OTHERS = 1. IF sy-subrc = 1. * the variable does not exist - use the value as a char value * convert from external into internal format if it is not a keyf. IF i_chanm = cl_sem_mp_documents=>c_name_keyf. x_value = i_chavl. ELSE. l_chavlext = i_chavl. 2002 SAP AMERICA, INC. AND SAP AG 20 HOW TO … DOCUMENTS IN SEM-BPS AND BW-BPS CALL FUNCTION 'UPC_CHAVL_EX_IN_CONVERT' EXPORTING i_area = i_area i_chanm = i_chanm i_chavlext = l_chavlext IMPORTING e_chavlint = x_value EXCEPTIONS invalid_format = 1 chanm_not_found = 2 rfc_error = 3 failed = 4 OTHERS = 5. IF sy-subrc <> 0. x_subrc = 1. ls_mesg-msgid = sy-msgid. ls_mesg-msgty ls_mesg-msgno = sy-msgno. ls_mesg-msgv1 ls_mesg-msgv2 = sy-msgv2. ls_mesg-msgv3 ls_mesg-msgv4 = sy-msgv4. APPEND ls_mesg TO xt_mesg. ENDIF. "sy-subrc ENDIF. "keyfigure ELSE. * we have a variable CALL METHOD lr_variable->get_value RECEIVING rto_value = lto_value EXCEPTIONS error = 1. x_subrc = sy-subrc. IF sy-subrc <> 0. ls_mesg-msgid = sy-msgid. ls_mesg-msgty = ls_mesg-msgno = sy-msgno. ls_mesg-msgv1 = ls_mesg-msgv2 = sy-msgv2. ls_mesg-msgv3 = ls_mesg-msgv4 = sy-msgv4. APPEND ls_mesg TO xt_mesg. EXIT. ENDIF. "sy-subrc "#EC DOM_EQUAL = sy-msgty. = sy-msgv1. = sy-msgv3. sy-msgty. sy-msgv1. sy-msgv3. * the variable must contain a single value DESCRIBE TABLE lto_value LINES l_lines. READ TABLE lto_value INDEX 1 INTO ls_value. IF l_lines <> 1 OR NOT ls_value-high IS INITIAL. CLEAR ls_mesg. ls_mesg-msgid = 'UPP_LB'. ls_mesg-msgty = 'E'. ls_mesg-msgno = '075'. ls_mesg-msgv1 = l_varnm. APPEND ls_mesg TO xt_mesg. x_subrc = 1. EXIT. ELSE. * set the value x_value = ls_value-low. ENDIF. ENDIF. ENDFORM. " replace_variable 2002 SAP AMERICA, INC. AND SAP AG 21 HOW TO … DOCUMENTS IN SEM-BPS AND BW-BPS 4.2.2 UPF_DOC_COPY_EXIT FUNCTION UPF_DOC_COPY_EXIT. *"-------------------------------------------------------------------*"*"Lokale Schnittstelle: *" IMPORTING *" REFERENCE(I_AREA) TYPE UPC_Y_AREA *" REFERENCE(I_PLEVEL) TYPE UPC_Y_PLEVEL *" REFERENCE(I_METHOD) TYPE UPC_Y_METHOD *" REFERENCE(I_PARAM) TYPE UPC_Y_PARAM *" REFERENCE(I_PACKAGE) TYPE UPC_Y_PACKAGE *" REFERENCE(IT_EXITP) TYPE UPF_YT_EXITP *" REFERENCE(ITO_CHASEL) TYPE UPC_YTO_CHASEL *" REFERENCE(ITO_CHA) TYPE UPC_YTO_CHA *" REFERENCE(ITO_KYF) TYPE UPC_YTO_KYF *" EXPORTING *" REFERENCE(ET_MESG) TYPE UPC_YT_MESG *" CHANGING *" REFERENCE(XTH_DATA) TYPE HASHED TABLE *"-------------------------------------------------------------------Exit. ENDFUNCTION. 2002 SAP AMERICA, INC. AND SAP AG 22
© Copyright 2024