Quantcast
Channel: SCN : Document List - SAP CRM: Webclient UI - Framework
Viewing all 189 articles
Browse latest View live

SHOW SMARTFORM IN BROWSER

$
0
0

Here am going to explain how we can show smartform as in pdf format in webui screen.

 

Step 1: Create a BSP Page in your application and give the extension as  .pdf.

clip_image002.jpg

Step 2:Go to OnInitialization Event Handler method in ur page and write the  fallowing  code.

DATA    lv_xlen              TYPE i.
DATA  lv_pdf           TYPE xstring.

CALL FUNCTION 'XXXXXXXXXXXXXXXX'   ”Your FM To Get otf data of your SmartForm
  EXPORTING 

                          iv_status = XXXXXXXX
IMPORTING
                          ev_otf    = lv_pdf.


lv_xlen = xstrlen( lv_pdf ).
response->set_data(
data = lv_pdf length = lv_xlen ).
response->set_header_field( name = if_http_header_fields=>content_type
value = 'application/pdf' ).
response->set_header_field( name  =  if_http_header_fieLds=>CACHE_CONTROL 
value = 'max-age=0' ).
response->set_status(
code = 200 reason = 'OK' ).
response->server_cache_expire_rel( expires_rel =
180 ).


Note:Here lv_pdf is the converted otf data of your smart form.

                                                                                                                                          

Step 3: Change the Mime Type of your BSP Page into application/pdf in properties tab .

 

untitled.JPG


Step 4:   To maintain the session we have 3 options in our bsp page properties tab.

Choose ‘Stateful from Now on radio button’ and make lifetime as ‘Session’ by us

ing dropdown.

 

untitled1.JPG

                                                                                                                                               

Coding in BSP COMPONENT:

Step 5:

data:  gv_url type string.

Add the Fallowing code in the .htm page in view to open smart form in new window.

<%
if controller->gv_url is not initial.
%>
<script language=
"javascript">
window.open(
"<%= controller->gv_url %>").focus();
</script>
<%
clear controller->gv_url.
endif.
%>                   “ We have to pass the URL of your BSP page to the variable gv_url.

 

Step 6:  Finally  call the BSP Page by using the url of the BSP page in handler method.

               Now we have to assign the BSP URL  to gv_url to call the BSP page.

               You will get the URL of BSP page in the properties tab of BSP page.

 

untitled3.JPG  

 


Dynamic modification of Configuration fields ( Part -2) : Table View

$
0
0

In this document we will focus on table views which are widely used in many UI components and provide the user about the brief information regarding the business object in focus. We will use the same technique to modify the configuration data dynamically as discussed in previous document,

 

 

Please check the document http://scn.sap.com/docs/DOC-29342 for information on Dynamic modification of Configuration of form fields ( Part -1).

 

 

Before CRM 7.0 Ehp1 , we can use the same technique to modify the search result which use to have .htm page . But from Ehp1 if the search page is created through wizard an .htm page in the result view will not get generated.

 

 

We mainly use two types of configuration tags in table views.

 

1.  Configurable table tag

 

  &lt;chtmlb:configTable xml              = "<%= lv_xml %>"
                                        id               = "ResTable"
                                   table               = "//RESULT/Table" />

 

2.  Next one is the Configuration Cellerator Tag


     &lt;chtmlb:configCellerator id       = "ConfCellTable"
                                            table       = "//Result/Table"
                                              xml        =  "<%= lv_xml %>"/>

 

 

 

 

In both the tags the XML table configuration data is passed using lv_xml

<%

  DATA:

  lv_xml    TYPE string.

  lv_xml = controller->configuration_descr->get_config_data( ).

%>

 

 

We have a seperate utility class method to read the configuration table data from XML to ABAP . Now we can modify the table configuration data as per our requirement.

 

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

 

<%@page language="abap" %>
<%@extension name="chtmlb" prefix="chtmlb" %>
<%@extension name="thtmlb" prefix="thtmlb" %>
<%@extension name="bsp" prefix="bsp" %>
<%
  DATA: lv_xml_inp TYPE bsp_dlc_xml,
             ls_config TYPE bsp_dlc_table_descr,
             lt_columns TYPE bsp_dlc_column_descr_tab.


  FIELD-SYMBOLS <ls_column> TYPE bsp_dlc_column_descr.

 

 

 

************Read the original configuration data of the table view as an xml file

lv_xml_inp    = controller->CONFIGURATION_DESCR->GET_CONFIG_DATA( ).

 

*********** Convert from XML format to ABAP special table utility class method

ls_config = cl_bsp_dlc_table_utility=>conf_xml_to_abap( lv_xml_inp ).

 

********* LS_CONFIG is of type BSP_DLC_COLUMN_DESCR which stores the details about each table column with its label properties and alignments

 

  loop at LS_CONFIG-COLUMNDEFINITION ASSIGNING <LS_COLUMN>.
  if <ls_column>-name = 'field1'.

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

*** Place the logic to modify each column label or property. We can also hide the field from the view .

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


  endif.
  endloop.

 

******** Now convert the modified table configuration data back to XML format

  lv_xml = cl_bsp_dlc_table_utility=>CONF_ABAP_TO_XML( ls_config ).
%>

 

********* Finally pass the modified configuration data to the tag

<chtmlb:tableExtension tableId = "ResultList"
                       layout  = "FIXED" />
<chtmlb:configTable xml              = "<%= lv_xml %>"
                    id               = "ResTable"
                    navigationMode   = "BYPAGE"
                    onRowSelection   = "select"
                    table            = "//RESULT/Table"
                    width            = "100%"
                    headerVisible    = "FALSE"
                    hasLeadSelection = "TRUE"
                    visibleRowCount  = "10"
                    actionsMaxInRow  = "5"
                    selectionMode    = "<%= RESULT->SELECTION_MODE %>" />

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

 

Now the modified table configuration is rendered overriding the configuration created for the view.

In the next document we will continue to focus on Search View and Overview .

Upload a CSV Excel File or Text File in SAP CRM WebUI

$
0
0

Upload a CSV Excel File or Text File in SAP CRM WebUI

 

SAP CRM Technical Consultants sometimes comes across a requirement from the clients on business scenarios where they are asked to upload a File from the Presentation Server ( e.g Desktop, PC, Laptop, etc. ) into Application Server i.e SAP CRM System. This may be due a wide range of business requirements ranging from Mass Operations like bulk upload of Business Partners in the system and mass upload of data from external sources for Lead Generation. Based on the business case either a plain and simple flat file is used or a CSV File can also be fed into. Text File has the flexibility of platform independence and can be used and downloaded across multiple environments.

 

In the sample code below, either a CSV File can be used or a text file can also be used. I have created my own Z Component and have used the SAP Standard Component - GS_FILE_UPLOAD as a component usage in my component. Here the only intention is to upload a table of Business Partners into the system.

 

Assumptions

 

I have made the following assumptions regarding the technical skill which I feel is a prerequisite in order to execute the sample example provided in this document.

 

  • Have knowledge on SAP CRM Web UI Programing
  • Have knowledge on Component creation, View and Runtime Repository Editors
  • Have knowledge on Component Usage

 

If you don't have extensive skills in the above mentioned topics still you can proceed with this document. But you may need to refer some document on basics of SAP CRM Web UI programming.

 

I guess there must be some existing component in the system. If you don't have an existing component then you can create a sample component with any model node. This is just for your reference and will brush up your old skills of component creation.

 

Execute the CRM Web UI workbench Transaction Code : BSP_WD_CMPWB. Create a component here and toggle off the enhancement set button as we will not be enhancing any standard component here. 

 

ScreenHunter_01 Sep. 25 00.22.gif

Next step is to create a new View as shown below :

 

ScreenHunter_02 Sep. 25 00.28.gif

 

Add or create a New Node with the structure already defined as shown below and then complete the subsequent steps to complete the view creation. Then add the view into the Runtime Repository.

 

ScreenHunter_03 Sep. 25 00.32.gif

ScreenHunter_04 Sep. 25 00.35.gif

Then complete the configuration by adding the fields in the result list.

ScreenHunter_05 Sep. 25 00.38.gif

Add two buttons for upload and clearing the uploaded data as shown below:

 

ScreenHunter_08 Sep. 25 00.42.gif

 

If you have an already existing Web UI Component, then in order to upload Text/CSV Excel Files in SAP CRM Web Client UI the following steps needed to be performed. We will be using an already existing Web UI Component as component usage and there is no further requirement of JavaScript Coding. The excel files that need to be uploaded must be of type CSV – comma separated values excel. In additional plain text files can also be used. The uploaded data is stored as content in a string.

 

Use an already existing SAP CRM Web UI component

ScreenHunter_12 Oct. 29 03.16.gif

Create a New View

 

ScreenHunter_03 Oct. 29 03.01.gif

Add the following 2 Events in the View

 

ScreenHunter_05 Oct. 29 03.02.gif

In the Upload method add the following piece of code

 

ScreenHunter_09 Oct. 27 00.59.gif

Define the following Popup Access Interface in the Implementation Class of the View

ScreenHunter_07 Oct. 29 03.07.gif

 

In the other Method – EH_ONUPLOAD_POPUP_CLOSED put the following piece of code. Here based on the content we need to classify the data into appropriate structure.

 

ScreenHunter_09 Oct. 29 03.09.gif

METHOD eh_onupload_popup_closed.

 

  TYPES: BEGIN OF l_ty_attr_struct,

            businesspartner TYPE bu_partner,

            partnerdescription TYPE bu_descrip_long,

           END OF l_ty_attr_struct.

 

 

  DATA:l_v_file_content        TYPE string,

       l_i_file_content        TYPE stringtab,

       l_v_file_type           TYPE string,

       l_v_file_name           TYPE string,

       l_o_outputnode          TYPE REF TO cl_bsp_wd_context_node,

       l_o_collection_wrapper  TYPE REF TO cl_bsp_wd_collection_wrapper,

       l_if_property           TYPE REF TO if_bol_bo_property_access,

       l_o_msg_service         TYPE REF TO cl_bsp_wd_message_service,

       l_i_bp                  TYPE  zbupa_desc,

       l_wa_bp                 TYPE    zbupa_desc,

       l_v_status              TYPE zmember_status,

       l_o_entity              TYPE REF TO cl_crm_bol_entity,

       l_i_return              TYPE bapiret2_t,

       l_wa_return             TYPE bapiret2,

       l_v_struct_ref          TYPE REF TO zaccount_upload1,

       l_o_value_node          TYPE REF TO cl_bsp_wd_value_node,

       l_if_bo_coll            TYPE REF TO if_bol_bo_col,

       l_v_fired_plug          TYPE        seocmpname.

 

 

  FIELD-SYMBOLS: <fs_file_content> TYPE string,

                 <l_fs_wa_data>  TYPE zaccount_upload1.

 

 

  l_v_fired_plug = ci_if_popup->get_fired_outbound_plug( ).

 

 

  CASE l_v_fired_plug.

    WHEN 'leave'.

*       get results of popup

      l_o_outputnode ?= ci_if_popup->get_context_node( 'FILE' ). "#EC NOTEXT

 

 

      l_o_collection_wrapper = l_o_outputnode->get_collection_wrapper( ).

      l_if_property           = l_o_collection_wrapper->get_current( ).

 

 

      CALL METHOD l_if_property->get_property_as_value

        EXPORTING

          iv_attr_name = 'FILE_CONTENT_TYPE'                "#EC NOTEXT

        IMPORTING

          ev_result    = l_v_file_type.

 

 

      CALL METHOD l_if_property->get_property_as_value

        EXPORTING

          iv_attr_name = 'FILE_NAME'                        "#EC NOTEXT

        IMPORTING

          ev_result    = l_v_file_name.

 

 

*       Check the MIME file type and the file extension

      IF ( l_v_file_type CP 'text/plain' )

        OR ( l_v_file_type CP 'text/comma-separated-values' )

        OR ( l_v_file_type CP 'application/vnd.ms-excel' AND l_v_file_name CP '*.csv' ). "#EC NOTEXT

 

 

        CALL METHOD l_if_property->get_property_as_value

          EXPORTING

            iv_attr_name = 'FILE_CONTENT_STRING'            "#EC NOTEXT

          IMPORTING

            ev_result    = l_v_file_content.

        IF l_v_file_content IS  INITIAL.

          l_o_msg_service ?= me->view_manager->get_message_service( ).

          l_o_msg_service->add_message( iv_msg_type       = 'E'

                                       iv_msg_id         = 'CRM_UI'

                                       iv_msg_number     = '030' ). "#EC NOTEXT

          EXIT.

        ENDIF.

        IF  me->typed_context->exupd2->collection_wrapper IS BOUND.

          me->typed_context->exupd2->collection_wrapper->clear( ).

        ENDIF.

*   Split filecontent into separate lines and store them in table

        SPLIT l_v_file_content AT cl_abap_char_utilities=>cr_lf INTO TABLE l_i_file_content.

        CLEAR l_v_file_content.

*   Remove empty lines from filecontent table and store on value node

        LOOP AT l_i_file_content ASSIGNING <fs_file_content>.

          IF NOT <fs_file_content> IS INITIAL.

            l_wa_bp-partner = <fs_file_content>.

            APPEND l_wa_bp TO l_i_bp.

          ENDIF.

        ENDLOOP.

 

        IF l_i_bp[] IS NOT INITIAL.

          CREATE OBJECT l_if_bo_coll TYPE cl_crm_bol_bo_col.

 

 

          IF l_if_bo_coll IS BOUND.

            l_if_bo_coll->set_multi_select( abap_true ).

          ENDIF.

 

 

          LOOP AT l_i_bp INTO l_wa_bp.

            REFRESH l_i_return.

            CALL FUNCTION 'BUPA_DESCRIPTION_GET'

              EXPORTING

                iv_partner          = l_wa_bp-partner

              IMPORTING

                ev_description_long = l_wa_bp-partner_desc

              TABLES

                et_return           = l_i_return.

 

 

            IF l_i_return IS NOT INITIAL.

              CLEAR l_wa_return.

              READ TABLE l_i_return INTO l_wa_return WITH KEY type = 'E'.

              IF sy-subrc = 0.

                l_wa_bp-partner_desc = l_wa_return-message.

              ENDIF.

            ENDIF.

 

 

            CREATE DATA l_v_struct_ref.

            ASSIGN l_v_struct_ref->* TO <l_fs_wa_data>.

            <l_fs_wa_data>-partner_id =  l_wa_bp-partner.

            <l_fs_wa_data>-partner_descr =  l_wa_bp-partner_desc.

            CREATE OBJECT l_o_value_node

              EXPORTING

                iv_data_ref = l_v_struct_ref.

 

 

 

 

            l_if_bo_coll->add( l_o_value_node ).

            l_if_bo_coll->if_bol_bo_col_multi_sel~mark( EXPORTING iv_bo = l_o_value_node ).

            UNASSIGN <l_fs_wa_data>.

          ENDLOOP.

        ENDIF.

*        ENDIF.

 

 

        me->typed_context->exupd2->collection_wrapper->set_collection( l_if_bo_coll ).

        me->typed_context->exupd2->collection_wrapper->publish_current( ).

 

 

      ELSE.

*         We assume an incorrect file type: it's neither a plain text file nor a .csv file

*         Therefore -> raise an error message

        l_o_msg_service ?= me->view_manager->get_message_service( ).

        l_o_msg_service->add_message( iv_msg_type       = 'E'

                                     iv_msg_id         = 'CRM_UI'

                                     iv_msg_number     = '018' ). "#EC NOTEXT

      ENDIF.

    WHEN OTHERS.

  ENDCASE.

 

ENDMETHOD.

 

 

Add the following lines of code in the HTML file of the view

 

ScreenHunter_14 Oct. 27 01.06.gif

 

In the Component a new component Usage needs to be added

 

ScreenHunter_11 Oct. 29 03.13.gif

 

Now run the component

 

ScreenHunter_17 Oct. 27 01.08.gif

Click on Upload

 

 

 

ScreenHunter_18 Oct. 27 01.09.gif

 

Click the Upload File

 

ScreenHunter_21 Oct. 27 01.11.gif

 

Upload the File

 

ScreenHunter_22 Oct. 27 01.12.gif

Display Custom Message Based on some Attribute Conditions in Web UI.

$
0
0

Hi Everyone,

 

I would like do some Knowledge Transfer on how can we actually pop-up some custom message based on some conditions in Web-UI level.

 

Think about a scenario where in we have to pop-up some custom messages based on the certain fields value in relation with Status of the Status field.

  

Example  : We'll take the SERVICEPRO business role , here we have two field 1) STATUS 2) REFERENCE DATE.

Condition : When the Status field is set to  " Completed " status , while saving the system should check whether the Reference Date Field have value or not. If the Reference Date field have value in it than it should be successfully saved ,but if the field is empty then it should pop-up a message saying "Reference Date is Initial ".

 

Note : The message should pop-up only if the Status field is set to " Completed " status.

 

Solution : Check for the SAVE event hander in overview page of corresponding BT Component . First enhance the component, View then this following Event.(Copy the code in event before enhancing it)

 

Debug to check for the variables ex: lr_ent which refer to CL_CRM_BOL_ENTITY as like which entity falls under this variable. Check the field 1 and                    field 2 entities and which is the parent entity of the both entity. Since in our example of BT all the entities comes under BTOrder --> BTAdminH from                    there all the other related entities.

 

In our example STATUS comes under BTSTATUS entity and REFERENCE DATE comes under BTSALESET entity.

 

The Hierarchy goes by this way for BT related Components Entities.

Hierarchy.JPG

Lets assume in lr_ent vriable we have the value BTOrder. Since the field status comes under entity BTStatus which is under BTAdminH entity. So to solve the problem we use the method Get_Related_entity ( ) of class CL_CRM_BOL_ENTITY to find the child entity with the help of the export parameter iv_relation_name where we will give the relation name which actually relate prent entity with child entity.

 

CALLMETHOD lr_ent->get_related_entity
EXPORTING
iv_relation_name =
'BTOrderHeader'
*      iv_mode          = NORMAL
RECEIVING
rv_result        = lr_ent1.

 

Here BTOrderHeader is the relation name through which we can identify the child entity and store in variable lr_ent1 which also belong to cl_crm_bol_entity ( ).In our example BTAdminH get stored. since STATUS field comes under BTStatus call the same method again but now the result will store under another variable lo_entity which refer to class If_bol_bo_property_access ( ) since now we’ll use this variable as reference to access method get_property_as_value ( )which is an interface method as mentioned earlier using which we can find the value present in the attribute we just identified.

 

CALLMETHOD lo_entity1->get_property_as_value
EXPORTING
iv_attr_name =
'STATUS'
IMPORTING
ev_result    = lv_ref.


Here the value gets stored in the variable lv_refwhich is of type Data Element of that particular attribute.

 

SOURCE CODE:


lr_ent1    TYPEREFTO cl_crm_bol_entity,
lr_ent2   
TYPEREFTO cl_crm_bol_entity,  " Status.
lo_entity1
TYPEREFTO if_bol_bo_property_access,
lo_entity2
TYPEREFTO if_bol_bo_property_access,
lv_ref1   
TYPE crm_j_status,
lv_ref2   
TYPE crmt_po_date_sold,
lv_msg    
TYPEREFTO cl_bsp_wd_message_service.

To find BTAdminH.

CALLMETHOD lr_ent->get_related_entity
EXPORTING
iv_relation_name =
'BTOrderHeader'
*      iv_mode          = NORMAL
RECEIVING
rv_result        = lr_ent1
.

To find BTStatus.

  CALLMETHOD lr_ent1->get_related_entity
EXPORTING
iv_relation_name =
'BTHeaderStatusSet'
*      iv_mode          = NORMAL
RECEIVING
rv_result        = lo_entity1
.

To find the value of STATUS field.

  CALLMETHOD lo_entity1->get_property_as_value
EXPORTING
iv_attr_name =
'STATUS '
IMPORTING
ev_result    = lv_ref1.


CALLMETHOD lr_ent1->get_related_entity
EXPORTING
iv_relation_name =
'BTHeaderSalesSet'
*      iv_mode          = NORMAL
RECEIVING
rv_result        = lo_entity2
.

CALLMETHOD lo_entity2->get_property_as_value
EXPORTING
iv_attr_name =
'PO_DATE_SOLD'
IMPORTING
ev_result    = lv_ref2.


Check the conditions and display a message.


  IFlv_ref1 = 'Completed'AND
lv_ref2
ISINITIAL.

lv_msg = cl_bsp_wd_message_service=>get_instance( ).

lv_msg->add_message(
iv_msg_type =
'E'
iv_msg_id =
'ZMSGID'
iv_msg_number =
000 ).
ENDIF.

 

Once the value of STATUS and REFERENCE DATE gets now check for the condition and pop-up a message using the message class cl_bsp_wd_message_service ( )

 

Result Before enhancing and After Enhancing the component.

 

1.jpg

Before the error message was developed.

 

2.jpg

After the error message was developed.

 

Hope This Document will Help someone in some Situation when come across such situation.

Add Comments if Anybody have doubt regarding this Document.

 

Thank You & Regards

Rohan



 



 

  

Create a Search Help for an AET Generated Field

$
0
0

Hi, I have come across many SCN post on how to create a search Help for a custom field generated through AET. So i just created a Document which could help people how to create it.

 

Before Creating a AET field with its Search Help, Go to SE 11 and create an Elementary search help for that particular field and SAVE it ( Ex: create a table with one field say COUNTRY and enter some values and create a search help).


Let’s have a scenario where in we have to add a Country Field (though we have a standard COUNTRY field let’s not use it and try to create a custom country field) with AET and provide a search help for that field.

 

Then go to Web UI and follow these steps.


1)Select the Business Role where you want to create an AET field.

1.jpg

2) Select any Business Transaction where you want to create an AET field.

    2.jpg

3) In the Overview Page, click ‘Show Configurable Area Button’ and select the view are where you want to get the field.

   3.jpg

4) Next window pop’s up click on Create Field Button.

4.jpg

5)  Next screen check the package and select the business object where you want the new field to be present and press OK.

 

5.jpg

6)  Next screen provide all the info required like field name (Country), field type (Uppercase Text only for creating search Help), field Length (20), and search help (click on the search help icon).

6.jpg

7) After clicking the search help icon, provide the package name where you have created the Search help in SE11 and click on search button and select the search help. And click BACK on next screen appearing.

 

7.jpg

8) We can see a Yellow triangle logo which indicate that it is inactive, now click on save and generate button.

  8.jpg

9)  Click choose if the Request no. is correct if not click create button to create new request.

  9.jpg

10) Now we can see that a green circle as appeared, this indicate that the field is generated and active, click BACK.

   10.jpg

11) Next screen click on Show available field and search for the field COUNTRY and pass to right side.

    11.jpg

12) Once you get the Field Pass it to the right side.

  12.jpg

13) Click on choose if the request is right.

13.jpg

14)  Here we can see our new Custom AET field created along with the search help.

14.jpg

 

Hope this document will help .

 

Thank You & Regards

  Rohan Poovaiah.

Real Time Data Exchange using URL based Transaction Launcher

$
0
0

This document is for demonstrating how to create an URL based transaction launcher in CRM UI to exchange data between SAP and an external URL in real time.

 

  • Declare URL and the Parameters [SPRO->Customer Relationship Management->UI Framework->Technical Role Definition->Define URLs and Parameters]

1.JPG

 

  • Declare URL Parameters. For this we must remember the meaning of import and Export parameters. For example, here, I'm creating 3 parameters: name (Import), xpos (Export) and ypos (Export).

 

Parameter

Type

Meaning
ImportData to be transferred from SAP CRM UI to external URL
ExportData to be transferred from external URL to SAP CRM UI

 

2.JPG

3.JPG

4.JPG

  • Now launch the Transaction Launcher wizard.[SPRO->Customer Relationship Management->UI Framework->Technical Role Definition->Configure Transaction launcher]

5.JPG

6.JPG

7.JPG

8.JPG

9.JPG

  • Now assign the transaction launcher in CRM UI as Workcenter link following usual process. I'm not detailing them here.[SPRO->Customer Relationship Management->UI Framework->Technical Role Definition->Define Navigation Bar Profile]

 

  • The class ZCL_LAUNCH_URL was created by the wizard. We need to make certain changes for data exchange to work.[Transaction:SE24]
    • Save the class under a transport as it gets created under local object by default.
    • Go to redefined CLASS_CONSTRUCTOR method to change the following code, it is required as we want data to flow back to SAP CRM.

 

10.JPG

    • Go to the redefined method IF_CRM_IC_ACTION_HANDLER~PREPARE_DATA_FLOW to add the following code. This super class method has the code to add the return URL information. The return URL is the SAP CRM URL which the external webpage will send the information to.

11.JPG

 

    • Go to redefined method IF_CRM_IC_ACTION_HANDLER~PROCESS_RETURN to add the code to handle return data. For example here I'm giving a message.

12.JPG

  • For demonstration purpose I've built a HTML webpage and hosted it using Apache in my local machine. Similarly any webpage can be used to exchange data with SAP CRM. This webpage displays the sent information from SAP i.e Name and has 2 input fields XPos and YPos. When "Go" button is clicked on the webpage the data is sent back to SAP CRM UI and displayed.
    • The source code of the webpage using some JavaScript functions.

 

<html><head><title>My Page</title><script type="text/javascript">

function getUrlVars() {
    var vars = {};    var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {        vars[key] = value;    });    return vars;
}
function decode(str) {     return unescape(str.replace(/\+/g, " "));
}
var fullname = getUrlVars()["name"];
var returl    = getUrlVars()["ICRETURNADDRESS"];
var client    = getUrlVars()["ICRETURNCLIENT"];
var comid     = getUrlVars()["COMPONENT_ID"];
var guid      = getUrlVars()["GUID"];
var returl1   = decode(returl);
function submitform(){
this.action=returl1;
}
window.onload = function(){   document.details.onsubmit=submitform;
}</script></head><body><form id="name" name="name" >
Name           : <input type="text" name="fullname" readonly="readonly"/><br />    </form><form id="details" name="details" method="post" action="" >
COMPONENT ID   : <input type="text" name="component_id" readonly="readonly"/><br />
Return address : <input type="text" name="value3" readonly="readonly"/><br />
Return Client  : <input type="text" name="client" readonly="readonly"/><br />
GUID           : <input type="text" name="guid" readonly="readonly"/><br />
XPOS           : <input type="text" name="xpos" value="" />
YPOS           : <input type="text" name="ypos" value="" /><input type="submit" value="go!" /></form><script LANGUAGE="javascript">
document.name.fullname.value        = decode(fullname)
document.details.component_id.value = comid
document.details.value3.value       = returl1
document.details.guid.value         = guid
document.details.client.value       = client</script></body></html>

 

    • Now the Apache has to be running for testing this.

13.JPG

  • Now if we can test our application.

    • Log-in to SAP CRM UI and confirm a Business Partner.

14.JPG

    • Click on "Launch URL" Workcenter link to launch the external URL. You can notice the Fullname of the Business Partner has been transferred to the external webpage.

15.JPG

    • Now enter some data in the input fields XPOS and YPOS and click the "Go" button.

16.JPG

    • It can be seen that data is passed back to in SAP CRM. For demonstration purpose I'm displaying them as message but it can be easily stored in database or it can be used to trigger any business process.

17.JPG

Development and Extension Guide - Launch SAP® GUI Transaction from WebClient UI

Creation Of Navigation Bar Profile

$
0
0

STEP-BY-STEP PROCEDURE FOR CREATING NAVIGATION BAR PROFILE

As many threads were posted on CRM forums asking for some help how to create navigation bar profile.  We decided to list hereafter a couple of basic techniques to do so.

Navigation Bar Profile:  The Navigation Bar profile provides the logical structure to access the internal and external applications within the Web UI. It can be customized as per individual business role.

For Ex: A user with the business role Sales Professional will have different navigation options as compared to a user with the business role Marketing Professional.

Creation of Navigation Bar Profile:

Prerequisites for creating Navigation bar profile are :

  1. 1. Define logical links
  2. 2. Define work center Group links
  3. 3. Define work center
  4. 4. Define direct links groups
  5. 5. Define Navigation Bar profile
  6. 5. Assign logical links to work center links
  7. 6. Assign work center group to work center
  8. 7. Assign work center, direct link groups to Navigation Bar profile
  9. 8. Assign Navigation Bar profile to the Business Role

 

Procedure:

Step 1 : Go to  Transaction CRMc_UI_NBLINKS

Step 2 : Define Logical links by adding new entries as shown below.

 

Untitled25.pngUntitled24.png

Step 3 : Define new Work Center Link Groups as shown.

 

1.png

Untitled2.png

Step 4 : Assign Logical links to the Work center link group as per the requirement .

 

Untitled3.png

Step 5 : Define Work center as shown.

 

Untitled4.png

Untitled5.png

Step 6 : Assign the work center link Groups to the work Center.

 

Untitled6.png

Step 7 : Define Direct link group .

 

Untitled7.png

Untitled8.png

Step 8 : Assign logical links to the Direct link Groups.

 

Untitled9.png

Step 9 : Define Navigation Bar Profile.

 

Untitled10.png

Untitled11.png

Step 10: Assign Work Center to the Navigation Bar Profile.

 

Untitled12.png

Step 11 : Assign direct link groups to the Navigation Bar profile.

 

Untitled13.png

The Navigation Bar Profile created is assigned to the desired Business Role.

The path is :

Goto SPRO -> SAP Refrence IMG -> CRM - > UI Frame Work -> Business Roles -> Define Business Role.

Then Assign the Navigation Bar Profile Created to the Business Role.

 

Untitled14.png

Untitled15.png

We can adjust our links by selecting the Adjust work Center Group links and adjust Direct link Groups. If we check mark the visible and In Menu field then  only the links are displayed in the Web Ui Screen.

 

Untitled16.png

Untitled17.png

Untitled18.png

Then we can assign this business Role to the User as shown below.

 

Untitled19.png

Untitled20.png

The final web ui screen with required Navigation Bar is shown as below.

 

Untitled21.png

Untitled22.png

 

Regards,

HCL Innovators


Removal of Context Node from the Web UI Component

$
0
0

Removal of Context Node from the Web UI component is not a single step process. We can't delete it directly.

When we right-click on the context node we won't find the delete option to delete it.

 

Capture1.JPG

 

In case you create a new context node or enhance an existing one, the reference not only comes in the CTXT at one place but actually goes at other places as well. Once we create a context node a method, an attribute will be created in CTXT class.

Here is the step-by-step procedure of deleting the context node effectively.

The procedure is as follows:

  1. First go to CTXT class and in methods delete the method of the context node which we want to delete. For example , here we will delete the context node ZHEADER.

Capture.JPG

 

  2. Delete the attribute created by the same name(here, ZHEADER) as that of the context node from the attribute Tab of the CTXT class.

 

Capture2.JPG

 

  3. Remove the calling of method (CREATE_ZHEADER) in CTXT class Method CREATE_CONTEXT_NODES. And Activate CTXT Class.

 

Capture3.JPG

Now, the context node ZHEADER is deleted.

Capture4.JPG

 

 

This is how the context node can be deleted.

 

Regards,

HclSparks

Date Management (Using An Example)

$
0
0

Date Management :

Dates are important for the correct processing of all business transactions. In global business processes that cover several countries and time zones, it is particularly necessary to have a date management system that can convert time zones and the factory calendar in documents of business partners involved in a transaction.

The component Date Management enables you to process as many dates as you require in a document. You can either enter dates yourself, or, by using date rules, have the system calculate these. In Customizing, you can define date types, durations, and date rules to meet your requirements.

Date:

A defined time period that consists of a start time and an end time. You use dates in calendar functions (for example, in activities), as well as for all dates that play a role in business transactions (for example, valid-to dates, cancellation dates) and in actions (date-dependent conditions).

Duration:

·         A timeframe between two points in time consisting of a number value and a time unit, for example, 1 month.

·         The system uses durations when calculating dates.

·         Durations are always given in entire numbers. You cannot combine two different units, for example the duration 1 hour 20 minutes must be expressed as 80 minutes.

 

 

Steps for creating date profile:

 

Step 1 : Define date types, date rules and durations.

Step 2 : Determination of date profile

Step 3: Assign the date profile to Transaction type/Item Category. 

 

Step 1 : Define date types, date rules and durations.

 

Path : Spro -->sap reference img -->CRM --> Basic Functions --> Date Management--> Define date types, date rules and durations.

Click on Execute button as shown in figure below:

 

Untitled1.png

Then you are guided to the below screen where we define durations, date types and date rules as shown in following screen shots:

 

Untitled2.pngUntitled3.png

 

Select the checkbox Date profile in order to replicate it in the search help at date profile determination.

 

        If you have activated the Milestone indicator, then your date is a milestone. This means that the beginning and end points are identical. The duration between the two points is zero.

 

Define date rules .

Untitled4.png

Then save it.

 

 

Untitled5.png

 

When you double click on the selected date rule you will be directed to the screen where we can write our custom code for that date rule. We can use the predefined codes which we copy from other date rules.

 

Untitled6.png

Untitled7.png

Similarly we define all date rules.

 

Untitled8.png

 

 

Step 2 : Determination of date profile.

Path : Spro -->sap reference img --> CRM --> Basic Functions --> Date Management  --> Define date profile.

Click on Execute button as shown in figure below:

 

Untitled9.png

 

Click on new entries button and enter date profile name and Name to create new date profile and save it.

 

Untitled10.png

 

 

Reference Objects:

·         To calculate dates, the system needs reference objects. By referencing to a reference object, each time becomes a local date and a local time. Because the system works internally with time tamps (date, time) in global time Universal Time Coordinated (UTC), it needs the reference object to translate the time into UTC.

·         For durations, the system needs a reference object to determine the correct factory calendar (workdays and holidays).

·         You can use the reference object to control the time zone and factory calendar to which a date type or duration refers. For example, you can determine that the date type valid to in quotations is calculated in the time zone of the user who creates the quotation, regardless of the main location of the organization.

·         The reference object for a date or duration is always defined independently of the date profile. Therefore, a date type or duration can have different reference objects, depending on the date profile.

·         Different date types can have different reference objects within a date profile.

 

Define reference objects.

Untitled11.png

 

Define date rules.

Untitled12.png

 

Define durations.

Untitled13.png

 

Give screen position by clicking on screen area.

Untitled14.png

 

 

Then click on date types and add defined date types by clicking on new entries.

Untitled15.png

 

 

Then double click on date type then assign date rules, display format and default values for manual entry fields.

Untitled16.png

 

 

Then click on screen areas of that date type and enter screen area names and positions where we want to see this date type in our transaction.

 

Untitled17.png

 

 

Similarly enter for all date types and enter screen area positions.Untitled18.png

Untitled19.png

 

 

Step 3: Assign the date profile to Transaction type/Item Category. 

 

We can assign date profile either to transaction or to item category.

 

Path: Spro-->sap reference img--> CRM --> Basic Functions--> Date Management--> Assign date profile to transaction type.Untitled20.png

For to assign date profile at item category follow the path below.

 

Path: Spro-->sap reference img-->CRM --> Basic Functions -->Date Management--> Assign date profile to Item category.

 

 

Then assign the date profile name to the required transaction.Untitled21.png

 

Then custom date profile is visible in our transaction as shown below:

Untitled22.png

 

This is how the Date Profile can be created and assigned.

Adding Tax Number to Employee Search in SAP CRM 7.0 WebUI

$
0
0

Summary

It is currently not possible to search on Employee Tax Number in SAP CRM 7.0 WebUI. Hence in order to be able to search and confirm an employee based on Tax Number, we have to make some changes, that are shown below.

 

 

 

Steps to Add Tax Number to Employee Search in WebUI

 

Start transaction BSP_WD_CMPWB and open BP_EMPL_SEARCH component. In view Search, open context node SEARCH and verify the BOL Entity bound to this node: BuilEmpAdvancedSearch.

Tela.1.jpg

 

 

Start transaction GENIL_MODEL_BROWSER and display Component BP. Open node Dynamic Query Objects and double click on BuilEmpAdvancedSearch (found in previous step). There you find the structure that you should enhance with the new field so that this field shows up within the search page.

Tela.2.jpg

 

 

Create an append structure to CRMST_EMP_SEARCH_BUIL, add TAXNUMBER field and activate the structure.

Tela.3.jpg

 

 

Open View SEARCH of Component BP_EMPL_SEARCH in transaction BSP_WD_CMPWB, and add the new field to the view configuration.

 

Go to transaction SE18 and open Badi BADI_CRM_BUPA_IL_SEARCH_EXT. Create a new implementation (if it doesn’t exist) and add the filter value BuilEmpAdvancedSearch for employee search.

 

Maintain method SEARCH_CRITERIA_INITIAL with the code below:

 

METHOD if_ex_crm_bupa_il_search_ext~search_criteria_initial.
  DATA:
    ls_bupa_header_search
TYPE crmt_bupa_il_header_search.

 

  MOVE-CORRESPONDING is_parameters TO ls_bupa_header_search.
 
IF ls_bupa_header_search-yytaxnum IS NOT INITIAL.
    cv_is_not_initial
= abap_true.
 
ENDIF.
ENDMETHOD.

 

Maintain method SEARCH_PARTNERS to meet your requirements.

 

Tip: the information about Tax Number is in tables DFKKBPTAXNUM, TFKTAXNUMTYPE, TFKTAXNUMTYPE_C and TFKTAXNUMTYPE_T. Create a database view joining these tables and table BUT000 and select this view from within method SEARCH_PARTNERS.

 

 

 

Steps to Add Tax Number to Employee Search Result in WebUI


Enhance view SearchResult of component BP_EMPL_SEARCH using transaction BSP_WD_CMPWB.

Tela.4.jpg

 

 

Open context node RESULT and right-click on “Attributes” to create a new Model attribute for Tax Number on Search Result screen. Follow the screenshot below to fill the wizard fields.

Tela.5.jpg

 

 

Maintain GET_TAXNUMBER method with the code below:

 

METHOD get_taxnumber.
 
DATA:

    lr_dref       TYPE REF TO data,

    lr_builemp    TYPE REF TO cl_crm_bol_entity,
    lr_builheader
TYPE REF TO cl_crm_bol_entity,
    lr_taxnumber 
TYPE REF TO cl_crm_bol_entity.

  IF iterator IS BOUND.
    lr_builemp
?= iterator->get_current( ).
  ELSE.
    lr_builemp
?= collection_wrapper->get_current( ).
  ENDIF.

 

  TRY.

    TRY.

       lr_builheader = lr_builemp->get_related_entity( 'BuilEmpToHeaderRel' ). "#EC NOTEXT
      lr_taxnumber
= lr_builheader->get_related_entity( 'BuilTaxNumberRel' ). "#EC NOTEXT
      lr_dref
= lr_taxnumber->get_property( 'TAXNUMBER' ). "#EC NOTEXT
    CATCH cx_crm_cic_parameter_error
          cx_crm_genil_model_error
" Error when Accessing Object Model
    ENDTRY.
 
CATCH cx_sy_ref_is_initial cx_sy_move_cast_error
        cx_crm_genil_model_error
.
    RETURN.
  ENDTRY.
  IF lr_dref IS NOT BOUND.
    value = 'BuilTaxNumber/TAXNUMBER not bound'.            "#EC NOTEXT
    RETURN.
  ENDIF.
 
TRY.
   
value = if_bsp_model_util~convert_to_string( data_ref = lr_dref
            attribute_path
= attribute_path ).
  CATCH cx_bsp_conv_illegal_ref.
    F
IELD-SYMBOLS: <l_data> TYPE data.
   
ASSIGN lr_dref->* TO <l_data>.
   
value = '-CURR/QUANT REF DATA MISSING-'.
 
CATCH cx_root.
   
value = '-CONVERSION FAILED-'.                        "#EC NOTEXT
 
ENDTRY.
ENDMETHOD.


That's it! Now you have a Tax Number field in Employee search and also in search result, with the Badi working to fetch the values!

Change data of the partners and delete the partners from Opportunity

$
0
0

Hi all,

 

The below code is going to help us , to change the fields for partners of the Opportunity and delete the partner records from Opportunity.

 

Delete the Particular  partners from Opportunity

 

DATA: ls_guid TYPE crmt_object_guid,
lt_guid
TYPE crmt_object_guid_tab,
lt_adminh
TYPE crmt_orderadm_h_wrkt,
lt_opporth
TYPE crmt_opport_h_wrkt,
ls_adminh
TYPE  crmt_orderadm_h_wrk,
ls_opporth
TYPE crmt_opport_h_wrk,
lt_partner
TYPE crmt_partner_external_wrkt,
ls_partner
TYPE crmt_partner_external_wrk.

DATA :ls_partner_wrk       TYPE crmt_partner_external_wrk.
DATA:  lt_input_fields 
TYPE  crmt_input_field_tab,
ls_input_field  
TYPE  crmt_input_field,
ls_input_field_names
TYPE crmt_input_field_names ,
lt_input_field_names
TYPE crmt_input_field_names_tab.
DATA : lit_partner          TYPE crmt_partner_comt,
wa_partner          
LIKE LINE OF lit_partner.
DATA: ls_logic_partner_key 
TYPE crmt_partner_logic_partner_key.
DATA : lt_order_h TYPE crmt_orderadm_h_comt,
ls_order_h
TYPE crmt_orderadm_h_com.
DATA : lv_partner_no TYPE bu_partner.
DATA : lv_partner_no1 TYPE bu_partner.
REFRESH lt_guid.

ls_guid = guid.
APPEND ls_guid TO lt_guid.
CLEAR ls_guid.

CALL FUNCTION 'CRM_ORDER_READ'
EXPORTING
it_header_guid       = lt_guid
IMPORTING
et_orderadm_h        = lt_adminh
et_opport_h          = lt_opporth
et_partner           = lt_partner
*     et_appointment       = lt_appointment
EXCEPTIONS
document_not_found   =
1
error_occurred       =
2
document_locked      =
3
no_change_authority  =
4
no_display_authority =
5
no_change_allowed    =
6
OTHERS               = 7.
IF sy-subrc EQ 0.
READ TABLE lt_adminh INTO ls_adminh INDEX 1.
IF sy-subrc EQ 0.
MOVE-CORRESPONDING ls_adminh TO ls_order_h.
INSERT ls_order_h INTO TABLE lt_order_h.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input  = partner
IMPORTING
output = lv_partner_no.
.


LOOP AT lt_partner INTO ls_partner_wrk .
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input  = ls_partner_wrk-partner_no
IMPORTING
output = lv_partner_no1.

CHECK    lv_partner_no1  EQ lv_partner_no.


*        MOVE-CORRESPONDING ls_partner_wrk TO wa_partner.

MOVE :ls_partner_wrk-ref_guid   TO               wa_partner-ref_guid,
ls_partner_wrk-ref_handle
TO                  wa_partner-ref_handle,
ls_partner_wrk-ref_kind   
TO                wa_partner-ref_kind,
ls_partner_wrk-ref_partner_handle
TO          wa_partner-ref_partner_handle,
ls_partner_wrk-ref_partner_fct   
TO          wa_partner-ref_partner_fct,
ls_partner_wrk-ref_partner_no   
TO           wa_partner-ref_partner_no,
ls_partner_wrk-ref_no_type       
TO          wa_partner-ref_no_type,
ls_partner_wrk-ref_display_type  
TO          wa_partner-ref_display_type.
*              ls_partner_wrk-kind_of_entry      TO          wa_partner-kind_of_entry.




ls_input_field_names-fieldname =
'PARTNER_FCT'.
INSERT ls_input_field_names INTO TABLE lt_input_field_names.

        CLEAR ls_logic_partner_key.
ls_logic_partner_key-ref_partner_handle = ls_partner_wrk-ref_partner_handle.
ls_logic_partner_key-ref_partner_fct = ls_partner_wrk-ref_partner_fct.
ls_logic_partner_key-ref_partner_no = ls_partner_wrk-ref_partner_no.
ls_logic_partner_key-ref_no_type = ls_partner_wrk-ref_no_type.
ls_logic_partner_key-ref_display_type = ls_partner_wrk-ref_display_type.
ls_input_field-logical_key = ls_logic_partner_key.

ls_input_field-ref_guid    = guid.
ls_input_field-ref_handle =
'0000000000'.
ls_input_field-ref_kind    =
'A'.
ls_input_field-objectname  =
'PARTNER'.
ls_input_field-field_names = lt_input_field_names.
INSERT ls_input_field INTO TABLE lt_input_fields.
INSERT wa_partner INTO TABLE lit_partner.
clear : lt_input_field_names.

ENDLOOP.

CALL FUNCTION 'CRM_ORDER_MAINTAIN'
EXPORTING
it_partner        = lit_partner
CHANGING
ct_orderadm_h     = lt_order_h
ct_input_fields   = lt_input_fields
EXCEPTIONS
error_occurred    =
1
document_locked   =
2
no_change_allowed =
3
no_authority      =
4
OTHERS            = 5.
IF sy-subrc EQ 0.
DATA: lt_guid1
TYPE crmt_object_guid_tab,
lv_header_guid
TYPE crmt_object_guid.

lv_header_guid = guid.
*
APPEND lv_header_guid TO lt_guid1.

CALL FUNCTION 'CRM_ORDER_SAVE'
EXPORTING
it_objects_to_save = lt_guid1.

IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
* IMPORTING
*   RETURN        =


ENDIF.

ENDIF.
ENDIF.

 

Change the data for partners of the opportunity

 

DATA:

lv_ref_handle       TYPEnumc4,

ls_partner_wrk      TYPEcrmt_partner_external_wrk,

lt_partner_wrk      TYPEcrmt_partner_external_wrkt,

ls_partner_com      TYPEcrmt_partner_com,

lt_partner_com      TYPEcrmt_partner_comt,

ls_input_fields     TYPEcrmt_input_field.

DATA: lt_partner_attributesTYPEcrmt_partner_attribute_com_tab,

ls_partner_attributesTYPEcrmt_partner_attribute_com.

DATA: ls_logical_keyTYPEcomt_partner_logic_partner_key.

DATA:  lv_handleTYPEcrmt_handle.

DATA:  lt_input_fields TYPE crmt_input_field_tab,

ls_input_field  TYPE crmt_input_field,

ls_input_field_namesTYPEcrmt_input_field_names ,

lt_input_field_namesTYPEcrmt_input_field_names_tab.

DATA: lit_partner         TYPECRMT_PARTNER_COMT,

wa_partner          LIKELINEOFlit_partner.

DATA: LT_ORDER_HtypeCRMT_ORDERADM_H_COMT,

ls_order_HtypeCRMT_ORDERADM_H_COM.

move-correspondingls_adminhtols_order_h.

   insertls_order_hintotablelt_order_h.

           LOOPATt_partnerINTOls_partner_wrk .

            

ls_partner_wrk-zzfld000010 ='X'.  “ changed DATA

            move-correspondingls_partner_wrktowa_partner.

ls_input_field_names-fieldname ='DISPLAY_TYPE'.

             INSERTls_input_field_namesINTOTABLElt_input_field_names.

ls_input_field_names-fieldname ='KIND_OF_ENTRY'.

             INSERTls_input_field_namesINTOTABLElt_input_field_names.

ls_input_field_names-fieldname ='MAINPARTNER'.

             INSERTls_input_field_namesINTOTABLElt_input_field_names.

ls_input_field_names-fieldname ='NO_TYPE'.

             INSERTls_input_field_namesINTOTABLElt_input_field_names.

ls_input_field_names-fieldname ='PARTNER_FCT'.

             INSERTls_input_field_namesINTOTABLElt_input_field_names.

ls_input_field_names-fieldname ='CALENDAR'.

             INSERTls_input_field_namesINTOTABLElt_input_field_names.

ls_input_field_names-fieldname ='RELATION_PARTNER'.

             INSERTls_input_field_namesINTOTABLElt_input_field_names.

ls_input_field_names-fieldname ='PARTNER_NO'.

             INSERTls_input_field_namesINTOTABLElt_input_field_names.

ls_input_field_names-fieldname ='ZZFLD000010'.

             INSERTls_input_field_namesINTOTABLElt_input_field_names.

DATA: ls_logic_partner_key TYPEcrmt_partner_logic_partner_key.

ls_logic_partner_key-ref_partner_handle = ls_partner_wrk-ref_partner_handle.

ls_logic_partner_key-ref_partner_fct = ls_partner_wrk-ref_partner_fct.

ls_logic_partner_key-ref_partner_no = ls_partner_wrk-ref_partner_no.

ls_logic_partner_key-ref_no_type = ls_partner_wrk-ref_no_type.

ls_logic_partner_key-ref_display_type = ls_partner_wrk-ref_display_type.

   ls_input_field-logical_key = ls_logic_partner_key.

ls_input_field-ref_guid    = iv_guid.

ls_input_field-ref_kind    ='A'.

ls_input_field-objectname  ='PARTNER'.

ls_input_field-field_names = lt_input_field_names.

       INSERTls_input_fieldINTOTABLElt_input_fields.

        insertwa_partnerintotablelit_partner.

ENDLOOP.

             CALLFUNCTION'CRM_ORDER_MAINTAIN'

                  EXPORTING

IT_PARTNER = lit_partner

                  CHANGING

CT_ORDERADM_H = lt_order_h

CT_INPUT_FIELDS = lt_input_fields

                  EXCEPTIONS

ERROR_OCCURRED =1

DOCUMENT_LOCKED =2

NO_CHANGE_ALLOWED =3

NO_AUTHORITY =4

                       OTHERS=5.

 

DATA: lt_guid1 TYPE crmt_object_guid_tab,
lv_header_guid
TYPE crmt_object_guid.

lv_header_guid = guid.
*
APPEND lv_header_guid TO lt_guid1.

CALL FUNCTION 'CRM_ORDER_SAVE'
EXPORTING
it_objects_to_save = lt_guid1.

IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
* IMPORTING
*   RETURN        =


ENDIF.

 

 

regards,

ajayram

Searching Classes and Methods in CRM

$
0
0

Hi All,

 

Problem Behind:

In most of the scenarios we end up using function modules instead of class methods, as there is no proper way of searching class methods as like the function modules. For searching a Function Module we go to SE37 and can search either with Name or with Description.

 

Many of us don't know the proper way of searching the Class-Methods. For Examples the possible reasons might be as follows

  1. 1. Sometimes we know the Method and we don't know the Class.
  2. 2. Sometimes we know what for we are searching, like "Upload a file on our desktop" but we don't know the Method to do this.
  3. 3. Sometimes we know the Class and we don't know the Method.

 

In all the above mentioned scenarios there is a simple possible way to find/search the Class-Methods.

 

Solution:

There is a View Table VSEOMETHOD which will give you the list of Classes and Methods.

For example: We would like to display a URL address and we need a Class method to do so.

Then we can search in the View table as shown in the below screen shots. There are several ways to play around. The below mentioned are just some of the examples that are shown for searching a Class-Method.

1. Enter the Description in the Description field asshown below.

VSEOMETHOD1.jpg

The result for the above search is shown below

VSEOMETHOD1-Result.jpg

2. Another way for searching, Enter the description in the Component as shown below.

VSEOMETHOD2.jpg

The result for the above search is shown below

VSEOMETHOD2-Result.jpg

There are several ways to search class methods. This is the easiest way which we could make use, especially for the people who worked on Procedural programming in ABAP and then moved to CRM which is completely Object Oriented.

Hope this document helps every one.

 

Thanks & Regards,

Venkat Sesha

F4 value Help in refer to another component

$
0
0

Output scenario:

 

 

 

 

 

 

 

 

 

 

 

STEPS TO BE FOLLOWED:

 

  1. Enhance the corresponding component

 

2. Redefine Get_Query_Definitions and code for value help of the particular field

 

 

 

 

 

3. Create global attribute in Implementation class of the view as mentioned below:

 

 

 

4. Create two events namely EH_ONLAST_NAME_F4_CLOS and EH_ONLAST_NAME_F4_OPEN

 

 

 

5. Code for event method EH_ONLAST_NAME_F4_OPEN

 

 

 

 

6.  Code for event method EH_ONLAST_NAME_F4_CLOS

 

 

 

 

 

 

7. Runtime Repository Editor, component usage of the another component

 

 

 

 

Thanks,

 

Savaridasan P

To read the Competitor Texts of Opportunity in webui

$
0
0

Every opportunity contains the Competitor and Bid results assignment block . In that we have 2 text fields are there .

  1. Competitor Strength
  2. Competitor Weak nees.

It is little difficult to find the properties of text in webUI. Here I am documenting those properties to read the Text using the function module Read_TEXT.

 

TDOBJECT            CRM_ORDPTH

TDNAME              005056A9030B1EE187ECFE22D21646710000000000235100000013          BPBP

( TDname = Combination of  <OPPGUID><Reference Handle><Partner function> <Partnernumber><10 spaces><BPBP>.

TDID      O001( strength text) and O002( weak text)

TDSPRAS              EN


Association, Aggregation and Composition

$
0
0

Association, Aggregation, Composition

When we have only one relationship between objects, that is called Association.

Aggregation and Composition both are specialized form of Association.

Composition is again specialize form of Aggregation.


Association is a relationship where all objects have their own life-cycle and there is no owner. Let's take an example of Teacher and Student. Multiple students can associate with single teacher and single student can associate with multiple teachers but there is no ownership between the objects and both have their own life-cycle. Both can create and delete independently.


Aggregation is a specialize form of Association where all object have their own life-cycle but there is ownership and child object can not belongs to another parent object. Let's take an example of Department and teacher. A single teacher can not belongs to multiple departments, but if we delete the department teacher object will not destroy. We can think about "has-a" relationship.


Composition is again specialize form of Aggregation and we can call this as a "death" relationship. It is a strong type of Aggregation. Child object dose not have their life-cycle and if parent object deletes all child object will also be deleted. Let's take again an example of relationship between House and rooms. House can contain multiple rooms there is no independent life of room and any room can not belongs to two different house if we delete the house room will automatically delete. Let's take another example relationship between Questions and options. Single questions can have multiple options and option can not belong to multiple questions. If we delete questions options will automatically delete.

BTF Editor

$
0
0

BTF (Business Text Framework)


 

 

How to Guide for

Title

BTF EDITOR

 

 

NAME

DESIGNATION

Author Name

Nawal Kishore

Consultant Designation

SAP Netweaver consultant

 

 
 

Purpose

This document will help you to

  • Create btf editor which will works like word document which contains all the formatting tools like bold, underline, color, save and etc.

Audience

           Sap crm web ui Consultants, and project team members who are working on crm web ui concept.

Prerequisites

      Required knowledge 

  • Basic knowledge of SAP technology
  • Good knowledge of crm web ui Concept.
  • Basic knowledge of architecture of web ui i.e. views, component, navigation link, component interface and etc.

Introduction

BTF (Business Text Framework)

The editor of BTF is actually works like word document which contains all the formatting tools like bold, underline, color, save and etc.

BTF editor is like WYSIWYG html editor.

BTF Editor.png

 

 

 

 

Advantage

  • Can store any text, images of any size.
  • Works like word documents

 

 

Scenario

Want to store some text information in formatted way in crm than that time we have to store text in BTF editor.

 

Implementation

Q) How to create BTF editor?

Sol: - Create a view in component and write this code in .htm of that view.

<%@page language="ABAP" %>
<%@extension name="btf" prefix="btf" %>
<%@extension name="thtmlb" prefix="thtmlb" %>
<%@extension name="thtmlbx" prefix="thtmlbx" %>
<%
data:   lv_btf_id        type string,
lt_buttons              
type WCFT_BTF_ADDITIONAL_BUTTONS,
ls_button               
type crmt_thtmlb_button,
lv_on_client_click      
TYPE string,
lv_mode                 
type STRING,

  ls_additional_button     type WCFs_BTF_ADDITIONAL_BUTTONS.
lv_btf_id 
= controller->get_id( 'btf_editor' ).
****getting the emode for the editor

**** means editor will open in display or edit mode

**** get display method we have to create in impl class for implementation of this method refers to next question.
lv_mode
= controller->get_display ( ).
%>
<style
type = "text/css">
.th-ta-tv{
height: 100%;}
</style>
<div
class = "th-ta-tv">
<thtmlbx:btf
id                  = "btf_editor"
width               = "100%"
height              = "320"
document            =
"<%= gs_btf_documentdata-btf_doc %>"
onClientInsertImage =
"InsertImage_BTFEditor(id);"
onClientInsertLink  =
"InsertLink_BTFEditor(id);"
sourceView          =
"<%= gv_btf_sourceview %>"
additionalButtons   =
"<%= lt_buttons %>"
navigationType      =
"NEWWINDOW"
disabled            = "<%= lv_mode %>"
secureInsertImage   =
"X" />
</div>
<%-- full component name (e.g. 'V1_') is not known by client --%>
<input type=
"hidden" id="editor_id" name="btf_editor_id" value="<%= lv_btf_id %>">
<%
IF lv_mode = 'FALSE'.
%>

<%-- creating save button --%>
<thtmlb: button
text    = "Save"
onClick = "cancel" />
<%
ENDIF.
%>

Q) How to make btf editor buttons enable and disable?

Sol:-Disabled is the property through which you can make buttons as enable and disable.

We have to change the value of lv_mode as true and false according to condition.

Lv_mode is the variable which we have taken above for enabling and disabling the editor.

DATA:    lv_display_mode    TYPE abap_bool,
lv_changeable     
TYPE        boolean,
lv_status         
TYPE zcdp_txt_lib_status,
lr_entity         
TYPE REF TO cl_crm_bol_entity.


**** we are getting the current entity and based on this entity we identify editable or not
lr_entity? = me
->typed_context->libtext->collection_wrapper->get_current ( ).
CHECK lr_entity IS BOUND.
lv_changeable
= lr_entity->is_locked( ).

    IF lv_changeable = 'X'.
rv_enabled
= 'FALSE'.

    ELSE.
  rv_enabled
= 'TRUE'.
ENDIF.

In above code lr_entity->is_locked ( ) will provide the value whether btf is to be locked or not.

So on that basis we can change the value of lv_mode.

 

Q) How to add btf editor to edit button so that when we click on edit button btf editor should open?

                   

Sol:-Create one view and create one edit button in that view.

         After that add btf view to component uage in your view and create one event in event handler and give name as EDIT.

In this event we will assign name of Main window of btf editor and also assign name of compenent usage and will write one pop up code for poping the btf editor when user click on edit button.

METHOD eh_onedit.
CONSTANTS:
lc_if_view_name 
TYPE string VALUE 'ZCDP_TXT_TEXT/MainWindow',
lc_usage        
TYPE string VALUE 'CUTEXT'.

DATA:
lr_context      
TYPE REF TO cl_bsp_wd_context_node,
lr_current      
TYPE REF TO if_bol_bo_property_access,
lr_qs           
TYPE REF TO cl_crm_bol_dquery_service,
lr_col          
TYPE REF TO if_bol_bo_col,
lv_title        
TYPE string,
lv_role         
TYPE string,
lv_usage_name   
TYPE string,
lv_partner_no   
TYPE string.


* Create POPUP if necessary
IF gv_popup IS NOT BOUND.
lv_usage_name  
= lc_usage.
gv_popup
= comp_controller->window_manager->create_popup(
iv_interface_view_name
= lc_if_view_name
iv_usage_name         
= lv_usage_name
iv_title              
= lv_title ).
ENDIF.


gv_popup
->set_title ( lv_title).
gv_popup
->open ( ).

ENDMETHOD.

Now we will give this event name to onClick property of edit button tag.

For eg.

<thtmlb: button id      = "EDIT"
onClick = "EDIT"
type    = "<%= cl_thtmlb_util=>GC_ICON_EDIT %>"
enabled =
"<%= lv_one %>" />

 

Q) How to save the contents of btf editor when we click on save button?

Sol: - gs_btf_documentdata-btf_doc->get_content( IMPORTING text = lv_text
encoding = lv_encode
language = lv_lang ).

Text will give the contents of btf editor whatever you entered in it.

For saving the contents to our database firstly we have to save the contents to attributes. For saving to attributes write this code.

lr_entity->set_property (
EXPORTING
iv_attr_name
'WYSIWYG_TEXT'   " Component Name
iv_value    
= lv_text  ).

In do_init_context method of IMPL class write this code.

METHOD do_init_context.
DATA:    lv_id                TYPE string,
lr_btf_editor       
TYPE REF TO cl_btf_bsp_editor.

lv_id
= me->get_id ( 'btf_editor' ).
lr_btf_editor? = cl_btf_bsp_manager
=>get_data ( request= request
name   
= 'editor'
id      = lv_id ).
IF lr_btf_editor IS NOT INITIAL.
gs_btf_documentdata
-btf_doc = lr_btf_editor->document.
gv_btf_sourceview
= lr_btf_editor->sourceview.
ENDIF.
ENDMETHOD.

When we click on save button data will be saved but the contents will be gone, so if we want to remain data their only means after pressing save button then

In do_prepare_output method we have to call set_content method which will set the content to btf editor. Code is as follows:

METHOD do_prepare_output.
****Local variables declaration
DATA: lv_display_mode    TYPE        abap_bool,
lv_desc_text    
TYPE xstring,
lv_value        
TYPE crmt_object_id_db,
lv_string       
TYPE string.

****Reference variables
DATA: lr_entity        TYPE REF TO cl_crm_bol_entity,
lr_cuco      
TYPE REF TO zl_zcdp_txt_libcommentscu_impl,
lr_coco         
TYPE REF TO zl_zcdp_txt_bspwdcompone5_impl.

****Getting the value of library id from value attributes
lr_coco ?= me
->comp_controller.
CHECK lr_coco IS BOUND.
lr_entity ?= lr_coco
->typed_context->libtext->collection_wrapper->get_current( ).
*  lr_entity ?= me->typed_context->libtext->collection_wrapper->get_current( ).
CHECK lr_entity IS BOUND.

****getting value from attributes
lr_entity
->get_property_as_value(
EXPORTING
iv_attr_name
'WYSIWYG_TEXT'   " Component Name
IMPORTING
ev_result   
= lv_desc_text).

*****Reading contents of btf editor
gs_btf_documentdata
-btf_doc->set_content( EXPORTING text     = lv_desc_text
encoding = 'utf-8’).

ENDMETHOD.

 


Here we are calling get_property_as_value method to get the contents of editor which is stored in the attribute and after storing that contents to some variable we are setting those values back to editor by calling set_content method.

 

 

                   

                                   

Search and Result view creation

Dynamic Navigation

$
0
0

Navigation can be defined in the following 2 ways:

  1. 1) Direct mapping of Component/Window/Outbound plug to Component /Window/Inbound Plug. 
  2. 2) Fully Generic navigation is for component that cannot define specific outbound plug since their outbound plug is generic means target is not defined. In fully generic navigation target is defined during run time.

      Flow: logical link id -> navigation via a descriptor object

Implementation

First step to create dynamic navigation is to create navigational link.

Go to SPRO transaction

SAP reference IMG->Customer Relationship Management->UI-Framework->Technical Role definition

  ->Define work area component repository.

8.png

Click on new entries and give your component name, window name and description and then save it.

After saving select your component name and click on inbound plug definition.

9.png

Target-ID: Name of target id is user defined means user can give any name.

Inbound Plug: Select inbound plug from f4 help. This f4 help comes automatically because in component definition you have given the name your component name.

Object Type:

  1. Obj.Action: It decides that after navigation our component should open in either in edit mode, display, search, or create mode.

After filling all these value save it.

Now, Click on define navigation bar profile.

                   

10.png

Click on Define navigation Bar Profile and click on new entries.

11.png

Nav Bar Profile : It is user defined name.

Link Id: Link Id is the name of logical link id name.

After filling these values save it select your nav bar profile name and click on define generic outbound plug mappings and click on new entries.

12.png

Object Type: Give name of your object type which you have given in transaction define work area component repository.

  1. Obj.Action: Select value from drop down list. If you want that after navigation your component should open in display mode then select display or if you want open edit mode then select edit option.

Target Id: Give target name as you have given in transaction work area component repository.

 

 

 

 

 

Write this code on any event handler method of ui.

 

DATA: lr_current TYPE REF TO if_bol_bo_property_access,
lr_col               TYPE REF TO if_bol_bo_col,
lr_desc_object       TYPE REF TO if_bol_bo_property_access,
lr_nav               TYPE REF TO if_crm_ui_navigation_service,
lr_data_collection   TYPE REF TO if_bol_bo_col,
lv_guid              TYPE crmt_genil_object_guid,
lr_entity            TYPE REF TO cl_crm_bol_entity,
lr_core              TYPE REF TO cl_crm_bol_core,
lr_root              TYPE REF TO cl_crm_bol_entity.

lr_current = me->typed_context->docflow->collection_wrapper->get_current( ).
CHECK lr_current IS BOUND.
lv_guid = lr_current->get_property_as_string(
iv_attr_name      = 'OBJKEY_A' ).
lr_core ?= cl_crm_bol_core=>get_instance( ).

****  get root entity
lr_entity ?= lr_core->get_root_entity( iv_object_name 'BTOrder'
iv_object_guid = lv_guid  ).

CHECK lr_entity IS BOUND.
****    Create UI based Entity
CALL METHOD cl_crm_ui_descriptor_obj_srv=>create_entity_based
EXPORTING
ir_entity           = lr_entity
iv_ui_object_type   = 'CRM_SRQM_INCIDENT'
iv_ui_object_action = 'B'            "display
RECEIVING
rr_result           = lr_desc_object.

****    Get Instance of Navigation Service
lr_nav = cl_crm_ui_navigation_service=>get_instance( me ).
****    Navigate to Target Component
IF lr_nav->is_dynamic_nav_supported( lr_desc_object ) = abap_true.
****      Create a BOL collection to be passed to the inbound plug of
****      the Called component
CREATE OBJECT lr_data_collection
TYPE
cl_crm_bol_bo_col.

****    Add the UI Descriptor the BOL Collection
lr_data_collection->add( lr_desc_object ).
lr_nav->navigate_dynamically( lr_data_collection ).

ENDIF.

 

You need to change only object type, object action and your root object name in above code.






Creating F4 help from an Internal Table

$
0
0

Sometimes there is a requirement for generating dynamic F4 help without using any SE11 Search Help. Through this document we can create F4 help as a popup window by specifying any table at run time.

 

In this Tutorial we consider a scenario, there is one view having a context node with a single attribute named city (Shown below). Now we need to assign F4 help for that city attribute.


Image1.jpg

Consider an Internal Table ZCITY as below,

Image2.jpg

Now go to the IMPL class of view where you have the attribute for which F4 help is required, and Declare following Attribute

gt_city as global table of type zcity

g_ref_decision_popup type ref to IF_BSP_WD_POPUP.

Image3.jpg

Get the data to be displayed in F4 help popup in to the global table (gt_city) defined in IMPL class of View.Now values needs to be fetched from Database Table to Glodal Table. It is better to write code in the Constructor of IMPL class as it is called once at the time of view object creation.

 

METHOD constructor.
CALL METHOD super->constructor.

* Get all rows from desired tables
SELECT *
FROM zcity
INTO TABLE gt_city.

IF sy-subrc <> 0.
* Error Message
ENDIF.
ENDMETHOD.

 

 

Go to the GET_V method of the field (CITY). Write the following code:

Below code will make your city field look and function as F4 help field. Here we need to specify on clicking of F4 key which outbound will be called.


create object rv_valuehelp_descriptor
               
type cl_bsp_wd_valuehelp_navdescr
               
exporting iv_outbound_plug = 'VALUEHELP'.

 

Create an Outbound plug namely ‘VALUEHELP’ and write the following code. This outbound plug will be called by clicking of F4 function key or clicking on that F4 help icon which is displayed at the right end of the text box.Here we are creating a decision popup by passing a global table and the number of rows to be displayed in the popup.

 

METHOD op_valuehelp.
 
FREE g_ref_decision_popup.
* Create decision popup
g_ref_decision_popup
=

        comp_controller->window_manager->create_decision_popup(
                                                        iv_title
= 'City Selection'
                                                        iv_visible_row_count
= 10
                                                        iv_display_table
= gt_city ).
* Assign close event CONFIRM_POPUP_CLOSED
g_ref_decision_popup
->set_on_close_event(

                            iv_event_name = 'CONFIRM_POPUP_CLOSED'
                            iv_view
= me ).      
* Open popup
g_ref_decision_popup
->open( ).

ENDMETHOD.



Create an event named CONFIRM_POPUP_CLOSED. Write the following code.

On closing of the popup window this event will be called as we have specified in the previous step.

OUTPUTNODE” is the standard context node through which we can access the selected row index and the event generated in Decision Popup Window.

 

 

METHOD eh_onconfirm_popup_closed.
DATA:
ls_city          
TYPE                    zcity,

l_ref_outputnode  TYPE REF TO     cl_bspwdcmp_bspwdcomponen_cn01,
l_ref_entity     
TYPE REF TO     if_bol_bo_property_access,
lv_row_index     
TYPE                    i,
lv_event_name    
TYPE                    string.

* Get context node from popup window
l_ref_outputnode ?=
g_ref_decision_popup->get_context_node( 'OUTPUTNODE' ).


* Get selected row index and event
lv_row_index
= l_ref_outputnode->get_selectedrowindex( ).
lv_event_name
= l_ref_outputnode->get_event_name( ).

* Close popup
g_ref_decision_popup
->close( ).

* Check if any row is selected

IF lv_event_name = 'OK'.
* Get selected row from global table
READ TABLE gt_city INTO ls_city INDEX lv_row_index.
l_ref_entity ?=

          me->typed_context->city->collection_wrapper->get_current( ).
lv_event_name
= ls_city-cityname.

* Assign F4 help value
l_ref_entity
->set_property_as_string(

                     iv_attr_name = 'city'

                                       iv_value = lv_event_name ).

ENDIF.
ENDMETHOD.

 

and you are finally done. This will create a popup with all contents of the table, and on selection of the value it will be filled to the Text Field.


Viewing all 189 articles
Browse latest View live


Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>