Skip to end of metadata
Go to start of metadata

Some pages may also concern SAP Solution Manager because it shares the same technology layer (Web UI pages/BSPWD).

List of all pages

Pages at first level

Author: Ashim Chowdhury
Submitted: 14-Feb-2007
Related Links:

  • BAPI BAPI_SLSTRANSACT_CREATEMULTI
Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
*&---------------------------------------------------------------------*
*& Report YCREATE_DEBITMEMO_TEST_2
*&---------------------------------------------------------------------*
REPORT ycreate_debitmemo_test_2.
* This program is used to create debit memo in CRM using
* BAPI BAPI_SLSTRANSACT_CREATEMULTI
* Data declaration
DATA:
wa_header TYPE bapibus20001_header_ins,
it_header TYPE STANDARD TABLE OF
bapibus20001_header_ins,
it_retu TYPE STANDARD TABLE OF bapiret2,
wa_retu TYPE bapiret2,
wa_input_fields TYPE bapibus20001_input_fields,
it_input_fields TYPE STANDARD TABLE OF
bapibus20001_input_fields,
it_created_process TYPE bapibus20001_header_ins OCCURS 10
WITH HEADER LINE,
it_saved_process TYPE bapibus20001_object_id OCCURS 10
WITH HEADER LINE,
it_org TYPE STANDARD TABLE OF bapibus20001_orgman_ins,
wa_org TYPE bapibus20001_orgman_ins,
it_item TYPE STANDARD TABLE OF bapibus20001_item,
wa_item TYPE bapibus20001_item,
* Internal table for partner
it_partner TYPE STANDARD TABLE OF bapibus20001_partner_ins,
wa_partner TYPE bapibus20001_partner_ins,
* Internal table for status
it_status TYPE STANDARD TABLE OF bapibus20001_status_ins,
wa_status TYPE bapibus20001_status_ins,
* Internal table for status line
it_scd_line TYPE STANDARD TABLE OF bapibus20001_schedlin,
wa_scd_line TYPE bapibus20001_schedlin.

START-OF-SELECTION.
* Data population
* Header section -->
* The handle is some uniqey wat to identify header
  wa_header-handle = '0000000001'.
* Process type is the Business Transaction Type.
* Master table CRMC_PROC_TYPE
* Here we are using Process type DMRR (Debit Memo)
  wa_header-process_type = 'DMRR'.
* Description
  wa_header-description = 'Test Debit Memo'.
  APPEND wa_header TO it_header.
* Item level data
* Handle 0000000002 has been used for item level
  wa_item-handle = '0000000002'.
* This is the header handle
  wa_item-header_handle = '0000000001'.
* Product id of the debit memo
  wa_item-ordered_prod = '7FGU15'.
* Mode is the Processing mode of Transaction
* For creation it is A, change - B, Display - C, Delete - D
  wa_item-mode = 'A'.
  APPEND wa_item TO it_item.
* Partner data
* As partnet is a header data, we should use the Header Handle
  wa_partner-ref_handle = '0000000001'.
* Ref kind is the object type. A is administration header
  wa_partner-ref_kind = 'A'.
* Ref partner handle is to count parameters
  wa_partner-ref_partner_handle = '0001'.
* Partner function - Master table CRMC_PARTNER_FCT
* and CRMC_PARTNER_FT
* Sold-to party - 00000001
  wa_partner-partner_fct = '00000001'.
  wa_partner-partner_no = '0100000737'.
  wa_partner-no_type = 'BP'.
  wa_partner-display_type = 'BP'.
  wa_partner-kind_of_entry = 'C'.
  APPEND wa_partner TO it_partner.
* Ship to party - 00000002
  wa_partner-ref_partner_handle = '0002'.
  wa_partner-partner_fct = '00000002'.
  APPEND wa_partner TO it_partner.
* Bill to party - 00000003
  wa_partner-ref_partner_handle = '0003'.
  wa_partner-partner_fct = '00000003'.
  APPEND wa_partner TO it_partner.
* Payer - 00000004
  wa_partner-ref_partner_handle = '0004'.
  wa_partner-partner_fct = '00000004'.
  APPEND wa_partner TO it_partner.
* Vendor - 00000035
  wa_partner-ref_partner_handle = '0005'.
  wa_partner-partner_fct = '00000035'.
  APPEND wa_partner TO it_partner.
* Status
  wa_status-ref_handle = '0000000001'.
  wa_status-ref_kind = 'A'.
  wa_status-status = 'I1026'.
  wa_status-activate = 'X'.
  APPEND wa_status TO it_status.
* Schedule line
  wa_scd_line-item_handle = '0000000002'.
  wa_scd_line-handle = '0000000000'.
  wa_scd_line-quantity = '1.000'.
  wa_scd_line-schedlin_no = '0000'.
  wa_scd_line-parent_sdln_hndl = '0000000000'.
  wa_scd_line-mode = 'A'.
  APPEND wa_scd_line TO it_scd_line.
* Input fields
* All the fields for which data needs to be entered should be mentioned in the input fields
* REF Handle is the handle for THE ENTIRE OBJECT FOR CREATION
* Process type
  wa_input_fields-ref_handle = '0000000001'.
  wa_input_fields-ref_kind = 'A'.
  wa_input_fields-objectname = 'ORDERADM_H'.
  wa_input_fields-fieldname = 'PROCESS_TYPE'.
  APPEND wa_input_fields TO it_input_fields.
  wa_input_fields-fieldname = 'DESCRIPTION'.
  APPEND wa_input_fields TO it_input_fields.
* Partner
  CLEAR wa_input_fields.
  wa_input_fields-ref_handle = '0000000001'.
  wa_input_fields-ref_kind = 'A'.
  wa_input_fields-objectname = 'PARTNER'.
  wa_input_fields-logical_key = '0001'.
  wa_input_fields-fieldname = 'DISPLAY_TYPE'.
  APPEND wa_input_fields TO it_input_fields.
  wa_input_fields-logical_key = '0002'.
  APPEND wa_input_fields TO it_input_fields.
  wa_input_fields-logical_key = '0003'.
  APPEND wa_input_fields TO it_input_fields.
  wa_input_fields-logical_key = '0004'.
  APPEND wa_input_fields TO it_input_fields.
  wa_input_fields-logical_key = '0005'.
  APPEND wa_input_fields TO it_input_fields.
* Kind of entry
  CLEAR wa_input_fields.
  wa_input_fields-ref_handle = '0000000001'.
  wa_input_fields-ref_kind = 'A'.
  wa_input_fields-objectname = 'PARTNER'.
  wa_input_fields-logical_key = '0001'.
  wa_input_fields-fieldname = 'KIND_OF_ENTRY'.
  APPEND wa_input_fields TO it_input_fields.
  wa_input_fields-logical_key = '0002'.
  APPEND wa_input_fields TO it_input_fields.
  wa_input_fields-logical_key = '0003'.
  APPEND wa_input_fields TO it_input_fields.
  wa_input_fields-logical_key = '0004'.
  APPEND wa_input_fields TO it_input_fields.
  wa_input_fields-logical_key = '0005'.
  APPEND wa_input_fields TO it_input_fields.
  CLEAR wa_input_fields.
  wa_input_fields-ref_handle = '0000000001'.
  wa_input_fields-ref_kind = 'A'.
  wa_input_fields-objectname = 'PARTNER'.
  wa_input_fields-logical_key = '0001'.
  wa_input_fields-fieldname = 'NO_TYPE'.
  APPEND wa_input_fields TO it_input_fields.
  wa_input_fields-logical_key = '0002'.
  APPEND wa_input_fields TO it_input_fields.
  wa_input_fields-logical_key = '0003'.
  APPEND wa_input_fields TO it_input_fields.
  wa_input_fields-logical_key = '0004'.
  APPEND wa_input_fields TO it_input_fields.
  wa_input_fields-logical_key = '0005'.
  APPEND wa_input_fields TO it_input_fields.
  CLEAR wa_input_fields.
  wa_input_fields-ref_handle = '0000000001'.
  wa_input_fields-ref_kind = 'A'.
  wa_input_fields-objectname = 'PARTNER'.
  wa_input_fields-logical_key = '0001'.
  wa_input_fields-fieldname = 'PARTNER_FCT'.
  APPEND wa_input_fields TO it_input_fields.
  wa_input_fields-logical_key = '0002'.
  APPEND wa_input_fields TO it_input_fields.
  wa_input_fields-logical_key = '0003'.
  APPEND wa_input_fields TO it_input_fields.
  wa_input_fields-logical_key = '0004'.
  APPEND wa_input_fields TO it_input_fields.
  wa_input_fields-logical_key = '0005'.
  APPEND wa_input_fields TO it_input_fields.
  CLEAR wa_input_fields.
  wa_input_fields-ref_handle = '0000000001'.
  wa_input_fields-ref_kind = 'A'.
  wa_input_fields-objectname = 'PARTNER'.
  wa_input_fields-logical_key = '0001'.
  wa_input_fields-fieldname = 'PARTNER_NO'.
  APPEND wa_input_fields TO it_input_fields.
  wa_input_fields-logical_key = '0002'.
  APPEND wa_input_fields TO it_input_fields.
  wa_input_fields-logical_key = '0003'.
  APPEND wa_input_fields TO it_input_fields.
  wa_input_fields-logical_key = '0004'.
  APPEND wa_input_fields TO it_input_fields.
  wa_input_fields-logical_key = '0005'.
  APPEND wa_input_fields TO it_input_fields.
* ITEM
  CLEAR wa_input_fields.
  wa_input_fields-ref_handle = '0000000002'.
  wa_input_fields-objectname = 'ORDERADM_I'.
  wa_input_fields-fieldname = 'MODE'.
  APPEND wa_input_fields TO it_input_fields.
  wa_input_fields-fieldname = 'ORDERED_PROD'.
  APPEND wa_input_fields TO it_input_fields.
  CLEAR wa_input_fields.
  wa_input_fields-ref_handle = '0000000002'.
  wa_input_fields-ref_kind = 'B'.
  wa_input_fields-objectname = 'SCHEDLIN'.
  wa_input_fields-fieldname = 'LOGICAL_KEY'.
  APPEND wa_input_fields TO it_input_fields.
  wa_input_fields-fieldname = 'QUANTITY'.
  APPEND wa_input_fields TO it_input_fields.
  wa_input_fields-objectname = 'SCHEDLIN_I'.
  wa_input_fields-fieldname = 'MODE'.
  APPEND wa_input_fields TO it_input_fields.
  CLEAR wa_input_fields.
  wa_input_fields-ref_handle = '0000000001'.
  wa_input_fields-ref_kind = 'A'.
  wa_input_fields-objectname = 'STATUS'.
  wa_input_fields-logical_key = 'I1026'.
  wa_input_fields-fieldname = 'ACTIVATE'.
  APPEND wa_input_fields TO it_input_fields.
* Calling bapi
* 'BAPI_SLSTRANSACT_CREATEMULTI' will create sales transaction in CRM
  CALL FUNCTION 'BAPI_SLSTRANSACT_CREATEMULTI'
    TABLES
      header          = it_header
      item            = it_item
      return          = it_retu
      partner         = it_partner
      status          = it_status
      input_fields    = it_input_fields
      scheduleline    = it_scd_line
      created_process = it_created_process
      saved_process   = it_saved_process.
  COMMIT WORK.
  READ TABLE it_retu INTO wa_retu WITH KEY type = 'E'.
  IF sy-subrc NE 0.
    DATA: v_return LIKE bapiret2.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
      IMPORTING
        return = v_return.
    CHECK NOT it_saved_process[] IS INITIAL.
    READ TABLE it_saved_process INDEX 1.
    IF sy-subrc = 0.
      WRITE:/ ' Debit memo no ', it_saved_process-object_id.
    ENDIF.
  ENDIF.

Applies to:

SAP CRM (tested in version 7.0 Ehp2)

Summary

Alternative version of the source provided by Bruno Garcia (CRM - change document appointment date):

"Simple report that may be used to change an appointment date of a CRM document. The change may be at header level, or at item level."

My goal using the XIF is provide an alternative way to accomplish the same, the major benefit are:

  • Less lines of code, easier to maintain
  • Easy to enhance the code with other fields (the imput parameter type CRMXIF_BUSTRANS provides almost every field you may need to update the OneOrder object)
  • Possibility of porting the mapping into a SXDA-LSMW approach with almost no effort and no custom code (smile)

Keep in mind this approach is for the highest level of application, don't not use it in API level (e.g BADI ORDER_SAVE, BTE. etc.) also don't mix it with the WebUI framwework (e.g Components, BOL, GENIL)

Author(s):  

Company:     Accenutre
Created on:    31 July 2014
Author(s) Bio : Luis Perez is an CRM/ABAP consultant

 

/* 
*----------------------------------------------
* DATA DECLARATION
*----------------------------------------------
INCLUDE crm_direct.

TYPES: BEGIN OF ts_orderadm_h,
         guid         TYPE crmd_orderadm_h-guid,
         object_id    TYPE crmd_orderadm_h-object_id,
         process_type TYPE crmd_orderadm_h-process_type,
         object_type  TYPE crmd_orderadm_h-object_type,
       END OF ts_orderadm_h,
       BEGIN OF ts_orderadm_i,
         object_type  TYPE crmd_orderadm_i-object_type,
         number_int   TYPE crmd_orderadm_i-number_int,
       END OF ts_orderadm_i.


DATA: lt_data   TYPE crmxif_bustrans_t,
      lt_return TYPE  bapiretm.

DATA lv_timestamp_from    TYPE timestamp.
DATA lv_timestamp_to      TYPE timestamp.

DATA: ls_orderadm_h TYPE ts_orderadm_h,
      ls_orderadm_i TYPE ts_orderadm_i.

FIELD-SYMBOLS: <ls_data>  LIKE LINE OF lt_data,
               <ls_dates> LIKE LINE OF <ls_data>-dates-data,
               <ls_item>  LIKE LINE OF <ls_data>-item.

*----------------------------------------------
* SELECTION SCREEN
*----------------------------------------------
SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE text-b01.
PARAMETERS p_id       TYPE crmt_object_id. "Document ID
PARAMETERS p_kind     TYPE crmt_object_kind. "A-Header, B-Item
PARAMETERS p_item     TYPE crmd_orderadm_i-number_int. "Item number. Example: 10
SELECTION-SCREEN: END OF BLOCK b1.


SELECTION-SCREEN: BEGIN OF BLOCK b2 WITH FRAME TITLE text-b02.
PARAMETERS p_type     TYPE crmt_appointment_wrk-appt_type. "Appointment Type
PARAMETERS p_datef    TYPE sy-datlo. "Date from
PARAMETERS p_timef    TYPE sy-timlo. "Time from
PARAMETERS p_datet    TYPE sy-datlo. "Date to
PARAMETERS p_timet    TYPE sy-timlo. "Time to
SELECTION-SCREEN: END OF BLOCK b2.


*----------------------------------------------
* READY, SET... GO!
*----------------------------------------------
START-OF-SELECTION.
*- Check Fields
  IF p_id IS INITIAL OR p_kind IS INITIAL OR p_type IS INITIAL OR p_datef IS INITIAL OR p_timef IS INITIAL.
    MESSAGE 'Please fill all input fields, except date_to and time_to' TYPE 'I'.
    EXIT.
  ENDIF.
  IF p_kind = 'B' AND p_item IS INITIAL.
    MESSAGE 'Please fill item number to update' TYPE 'I'.
  ENDIF.


* Get header logical key
  SELECT SINGLE guid object_id process_type object_type FROM crmd_orderadm_h INTO ls_orderadm_h WHERE object_id = p_id.
  IF sy-subrc NE 0.
    MESSAGE 'Document not found' TYPE 'I'.
    EXIT.
  ENDIF.
* Get item logical key
  IF p_kind = gc_object_kind-orderadm_i.
    SELECT SINGLE object_type number_int FROM crmd_orderadm_i INTO ls_orderadm_i 
      WHERE header = ls_orderadm_h-guid  AND number_int = p_item.
    IF sy-subrc NE 0.
      MESSAGE 'Item not found' TYPE 'I'.
      EXIT.
    ENDIF.
  ENDIF.


*- Calculate timestamp for new date/time
  CONVERT DATE p_datef TIME p_timef INTO TIME STAMP lv_timestamp_from TIME ZONE sy-zonlo.
  CONVERT DATE p_datet TIME p_timet INTO TIME STAMP lv_timestamp_to TIME ZONE sy-zonlo.

  APPEND INITIAL LINE TO lt_data ASSIGNING <ls_data>.
  <ls_data>-object_task = 'U'.
  <ls_data>-object_id  = ls_orderadm_h-object_id.
  <ls_data>-process_type = ls_orderadm_h-process_type.
  <ls_data>-object_type = ls_orderadm_h-object_type.
*  To understand why I marked this, please refer to the following blog: 
*  http://scn.sap.com/community/crm/master-data-and-middleware/blog/2014/06/17/xif-dont-update-my-crmdorderadmh-please  
  <ls_data>-input_fields-object_guid = abap_true.


* Appointment
  IF p_kind = gc_object_kind-orderadm_h.
    <ls_data>-dates-datax = abap_true.
    APPEND INITIAL LINE TO <ls_data>-dates-data ASSIGNING <ls_dates>.
  ELSEIF p_kind = gc_object_kind-orderadm_i.
    APPEND INITIAL LINE TO <ls_data>-item  ASSIGNING <ls_item>.
    <ls_item>-object_task = 'U'.
    <ls_item>-item_number = ls_orderadm_i-number_int.
    <ls_item>-object_type = ls_orderadm_i-object_type.
*    To understand why I marked this, please refer to the following blog: 
*    http://scn.sap.com/community/crm/master-data-and-middleware/blog/2014/06/17/xif-dont-update-my-crmdorderadmh-please  
    <ls_item>-input_fields-item_guid = abap_true.
    <ls_item>-dates-datax = abap_true.
    APPEND INITIAL LINE TO <ls_item>-dates-data ASSIGNING <ls_dates>.
  ENDIF.


  <ls_dates>-object_task = 'U'.
  <ls_dates>-appt_type = p_type  .
  MOVE lv_timestamp_from TO <ls_dates>-timestamp_from.
  MOVE lv_timestamp_to TO <ls_dates>-timestamp_to.
  <ls_dates>-input_fields-appt_type = abap_true.
  <ls_dates>-input_fields-timestamp_from = abap_true.
  <ls_dates>-input_fields-timestamp_to = abap_true.

  CALL FUNCTION 'CRMXIF_ORDER_SAVE'
    EXPORTING
      data   = lt_data
    IMPORTING
      return = lt_return. "Output of errors

  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
 */

Applies to:

SAP CRM (tested in version 7.0 Ehp2)

Summary

Simple Report to create Manual Condition in Transactions (Sales Orders, Opportunities, etc.)

I offer two approach in order to do that:

  • The API approach, this can be used in Actions, Low layer BADIs, etc. 
  • The XIF approach can be used for RFC/WebService Scenario, mass data transfer (LSMW, Custom Reports).

Keep in mind that is a sample, this program was never meant to be a productive one, also think about in which software layer or working on in order to choose one option or the other, Don't use this approach on the WebUI directly.

Author(s):  

Company:     Accenutre
Created on:    29 October 2014
Author(s) Bio : Luis Perez is an CRM/ABAP consultant

 

/* 
*----------------------------------------------
* DATA DECLARATION
*----------------------------------------------
DATA: lt_return          TYPE  bapiretm,
      lt_data            TYPE  crmxif_bustrans_t,
      lt_orderadm_h      TYPE  crmt_orderadm_h_comt,
      lt_orderadm_i      TYPE  crmt_orderadm_i_comt,
      lt_pridoc          TYPE crmt_pridoc_comt,
      lt_input_fields    TYPE  crmt_input_field_tab,
      lt_objects_to_save TYPE crmt_object_guid_tab,
      lt_saved_objects   TYPE crmt_return_objects.

DATA: ls_orderadm_h_db TYPE  crmd_orderadm_h,
      ls_orderadm_i_db TYPE  crmd_orderadm_i,
      ls_orderadm_h    LIKE LINE OF lt_orderadm_h,
      ls_orderadm_i    LIKE LINE OF lt_orderadm_i,
      ls_pridoc        LIKE LINE OF  lt_pridoc,
      ls_cond_add      LIKE LINE OF ls_pridoc-cond_add,
      ls_input_fields  LIKE LINE OF lt_input_fields,
      ls_input_names   LIKE LINE OF ls_input_fields-field_names.


FIELD-SYMBOLS: <ls_data>      LIKE LINE OF lt_data,
               <ls_item>      LIKE LINE OF <ls_data>-item,
               <ls_prcd_cond> LIKE LINE OF <ls_item>-price_conditions-data.


*----------------------------------------------
* SELECTION SCREEN
*----------------------------------------------
SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE text-b01.
PARAMETERS p_id       TYPE crmt_object_id OBLIGATORY. "Document ID
PARAMETERS p_item     TYPE crmd_orderadm_i-number_int OBLIGATORY. "Item number. Example: 10
PARAMETERS: p_kschl   TYPE  prct_cond_type OBLIGATORY,
            p_waers   TYPE  prct_cond_curr OBLIGATORY,
            p_kbetr   TYPE  prct_cond_rate OBLIGATORY.
SELECTION-SCREEN: END OF BLOCK b1.

SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME TITLE text-b02.
PARAMETERS: p_api  TYPE c RADIOBUTTON GROUP grp1,
            p_xif  TYPE c RADIOBUTTON GROUP grp1.
SELECTION-SCREEN END OF BLOCK block1.

*----------------------------------------------
* READY, SET... GO!
*----------------------------------------------
SELECT SINGLE * INTO CORRESPONDING FIELDS OF ls_orderadm_h_db FROM crmd_orderadm_h
  WHERE object_id EQ p_id.
IF sy-subrc EQ 0.
  SELECT SINGLE * INTO CORRESPONDING FIELDS OF ls_orderadm_i_db FROM crmd_orderadm_i
    WHERE header EQ ls_orderadm_h_db-guid
      AND number_int EQ p_item.
  IF sy-subrc NE 0.
    MESSAGE 'Item not found' TYPE 'I'.
    EXIT.
  ENDIF.
ELSE.
  MESSAGE 'Document not found' TYPE 'I'.
  EXIT.
ENDIF.

IF p_api EQ abap_true. "One Order API Approach
  MOVE-CORRESPONDING ls_orderadm_h_db TO ls_orderadm_h.
  MOVE-CORRESPONDING ls_orderadm_i_db TO ls_orderadm_i.
* We need to inform the Header and condition, even if we don't update them
* otherwise the update won't work, this is related how the API internally works
* I can't explain that, you can allways dig into the black box ;)
  INSERT ls_orderadm_h INTO TABLE lt_orderadm_h.
  ls_orderadm_i-mode = |B|.
  INSERT ls_orderadm_i INTO TABLE lt_orderadm_i.

  ls_input_fields-ref_guid = ls_orderadm_h-guid.
  ls_input_fields-ref_kind = |A|. "Header
  ls_input_fields-objectname = |ORDERADM_H|.
  ls_input_names-fieldname = |INPUT_CHANNEL|.
  INSERT ls_input_names INTO TABLE ls_input_fields-field_names.
  INSERT ls_input_fields INTO TABLE lt_input_fields.

  CLEAR ls_input_fields.
  ls_input_fields-ref_guid = ls_orderadm_i-guid.
  ls_input_fields-ref_kind = |B|. "Item
  ls_input_fields-objectname = |ORDERADM_I|.
  ls_input_names-fieldname = |HEADER|.
  INSERT ls_input_names INTO TABLE ls_input_fields-field_names.
  ls_input_names-fieldname = |PRODUCT_KIND|.
  INSERT ls_input_names INTO TABLE ls_input_fields-field_names.
  INSERT ls_input_fields INTO TABLE lt_input_fields.


  ls_pridoc-ref_guid = ls_orderadm_i-guid.
  ls_pridoc-ref_kind = |B|. "Item
* Copy Pricing Elements Unchanged and Redetermine Taxes, for more information
* check the values of the table PRCC_PRIC_PT
  ls_pridoc-pricing_type = |G|.
  ls_cond_add-kschl = p_kschl.
  ls_cond_add-waers = p_waers.
  ls_cond_add-kbetr = p_kbetr.
  INSERT ls_cond_add INTO TABLE ls_pridoc-cond_add.
  INSERT ls_pridoc INTO TABLE lt_pridoc.

  CALL FUNCTION 'CRM_ORDER_MAINTAIN'
    EXPORTING
      it_pridoc         = lt_pridoc
    CHANGING
      ct_orderadm_h     = lt_orderadm_h
      ct_orderadm_i     = lt_orderadm_i
      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 NE 0.
*   Implement suitable error handling here
  ELSE.
    INSERT ls_orderadm_h-guid INTO TABLE lt_objects_to_save.
    CALL FUNCTION 'CRM_ORDER_SAVE'
      EXPORTING
        it_objects_to_save = lt_objects_to_save
      IMPORTING
        et_saved_objects   = lt_saved_objects
      EXCEPTIONS
        document_not_saved = 1
        OTHERS             = 2.
    IF lt_saved_objects IS INITIAL.
*     Something went wrong, investigation time ;)
    ELSE.
      COMMIT WORK. "Be carefull if you can trigger the commit or you must wait that the frameowork triggers it
    ENDIF.
  ENDIF.
ELSEIF p_xif EQ abap_true. "XIF Middleware Approach
  APPEND INITIAL LINE TO lt_data ASSIGNING <ls_data>.
  <ls_data>-object_task = |U|.
  <ls_data>-object_id  = ls_orderadm_h_db-object_id.
  <ls_data>-process_type = ls_orderadm_h_db-process_type.
  <ls_data>-object_type = ls_orderadm_h_db-object_type.
* To understand why I marked this, please refer to the following blog:
* http://scn.sap.com/community/crm/master-data-and-middleware/blog/2014/06/17/xif-dont-update-my-crmdorderadmh-please
  <ls_data>-input_fields-object_guid = abap_true.

  APPEND INITIAL LINE TO <ls_data>-item  ASSIGNING <ls_item>.
  <ls_item>-object_task = |U|.
  <ls_item>-item_number = ls_orderadm_i_db-number_int.
  <ls_item>-object_type = ls_orderadm_i_db-object_type.
* To understand why I marked this, please refer to the following blog:
* http://scn.sap.com/community/crm/master-data-and-middleware/blog/2014/06/17/xif-dont-update-my-crmdorderadmh-please
  <ls_item>-input_fields-item_guid = abap_true.
  <ls_item>-price_conditions-datax = abap_true.

  APPEND INITIAL LINE TO <ls_item>-price_conditions-data ASSIGNING <ls_prcd_cond>.
  <ls_prcd_cond>-object_task = |I|.
  <ls_prcd_cond>-cond_type = p_kschl.
  <ls_prcd_cond>-cond_currency = p_waers.
  <ls_prcd_cond>-cond_rate = p_kbetr.

  CALL FUNCTION 'CRMXIF_ORDER_SAVE'
    EXPORTING
      data   = lt_data
    IMPORTING
      return = lt_return.

  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ENDIF.
 */

Author: Bruno Garcia
Submitted: 26 Nov 2009
Applies to: SAP CRM (tested in version 4.0)
Related Links: Snippet to help in the following thread

Description:

This is a CRM very simple function that automates the assignment of various business partners to positions, in organization structure model. Hope that this may help you as a starting point to develop a more complete automatism.

The importing parameters are:

IV_POSITION_ID - ID of organization model position to which we want to assign business partners
IV_START_DATE - Date from where the new assignment will be available
IT_PARTNERS - Business partner numbers that will be assign to the position (IV_POSITION_ID)

Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
FUNCTION ZCRM_OM_ASSIGN_BP_TO_POSITION.
*"----------------------------------------------------------------------
*"*"Interface local:
*"  IMPORTING
*"     REFERENCE(IV_POSITION_ID) TYPE  REALO
*"     REFERENCE(IV_START_DATE) TYPE  DATUM DEFAULT SY-DATUM
*"     REFERENCE(IT_PARTNERS) TYPE  BBPT_OM_PARTNERS
*"  EXPORTING
*"     REFERENCE(EV_RELATION_CREATED) TYPE  FLAG
*"  TABLES
*"      TT_RELATIONS_TO_CUT STRUCTURE  HRI1001 OPTIONAL
*"  EXCEPTIONS
*"      POSITION_NOT_FOUND
*"      DATA_NOT_SAVED
*"----------------------------------------------------------------------


*- Constants
  DATA lc_plvar           TYPE plvar VALUE '01'.
  DATA lc_bptype          TYPE otype VALUE 'BP'.
  DATA lc_postype         TYPE otype VALUE 'S'.
  DATA lc_begda           TYPE datum VALUE '19000101'.
  DATA lc_endda           TYPE datum VALUE '99991231'.
  DATA lc_rsign           TYPE rsign VALUE 'B'. "top down
  DATA lc_relat           TYPE relat VALUE '270'. "owner

*- Data declaration
  DATA ls_objec_pos       TYPE objec.
  DATA ls_objec_new       TYPE LINE OF objec_t.
  DATA lt_objec_new       TYPE objec_t.
  DATA lv_new_partner     TYPE bu_partner.

*- Prepare new assignments - Business Partners
  ls_objec_new-plvar = lc_plvar.
  ls_objec_new-otype = lc_bptype.
  ls_objec_new-begda = lc_begda .
  ls_objec_new-endda = lc_endda.
  LOOP AT it_partners INTO lv_new_partner.
    ls_objec_new-realo = lv_new_partner.
    APPEND ls_objec_new TO lt_objec_new.
  ENDLOOP.

*- Get objec for position
  ls_objec_pos-otype = lc_postype.
  ls_objec_pos-objid = iv_position_id.
  ls_objec_pos-plvar = lc_plvar.
  ls_objec_pos-realo = iv_position_id.
  CALL FUNCTION 'RH_READ_OBJECT'
    EXPORTING
      plvar     = ls_objec_pos-plvar
      otype     = ls_objec_pos-otype
      objid     = ls_objec_pos-objid
    IMPORTING
      obeg      = ls_objec_pos-begda
      oend      = ls_objec_pos-endda
      ostat     = ls_objec_pos-istat
      short     = ls_objec_pos-short
      stext     = ls_objec_pos-stext
    EXCEPTIONS
      not_found = 1
      OTHERS    = 2.
  IF sy-subrc <> 0.
    RAISE position_not_found.
  ENDIF.

*- Create the relation
  CALL FUNCTION 'OM_CREATE_NEW_RELATIONS'
    EXPORTING
      parent_object    = ls_objec_pos
      child_objects    = lt_objec_new
      vrsign           = lc_rsign
      vrelat           = lc_relat
      vbegda           = iv_start_date
      vendda           = lc_endda
    IMPORTING
      relation_created = ev_relation_created
    TABLES
      relations_to_cut = tt_relations_to_cut.

*- Save changes
  CALL FUNCTION 'NF_GM_SAVE_DATA'
    EXPORTING
      without_popup   = 'X'
    EXCEPTIONS
      action_canceled = 1
      OTHERS          = 2.
  IF sy-subrc <> 0.
    RAISE data_not_saved.
  ENDIF.

ENDFUNCTION.
Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
*** Retrieve the existing partner value from the order wich you want to update
CALL FUNCTION 'CRM_PARTNER_READ_OW'
  EXPORTING
    iv_ref_guid          = iv_guid
    iv_ref_kind          = 'A'
    iv_partner_fct       = "<partner fct value to update>
  IMPORTING
    es_partner_wrk       = ls_partner_wrk
  EXCEPTIONS
    error_occurred       = 1
    parameter_error      = 2
    entry_does_not_exist = 3
    OTHERS               = 4.

ls_partner_wrk-partner_no = <new partner value to update>.
MOVE-CORRESPONDING ls_partner_wrk TO ls_partner_com.
lv_guid =  iv_guid.
ls_input_fields-fieldname = 'PARTNER_NO'.
ls_input_fields-changeable = 'X'.
INSERT ls_input_fields INTO TABLE lt_bapi_input_fields.
ls_input_fields-fieldname = 'PARTNER_FCT'.
ls_input_fields-changeable = 'X'.
INSERT ls_input_fields INTO TABLE lt_bapi_input_fields.
ls_input_fields-fieldname = 'DISPLAY_TYPE'.
INSERT ls_input_fields INTO TABLE lt_bapi_input_fields.
ls_input_fields-fieldname = 'NO_TYPE'.
INSERT ls_input_fields INTO TABLE lt_bapi_input_fields.
ls_input_fields-fieldname = 'KIND_OF_ENTRY'.
INSERT ls_input_fields INTO TABLE lt_bapi_input_fields.
ls_input_fields-fieldname = 'MAINPARTNER'.
INSERT ls_input_fields INTO TABLE lt_bapi_input_fields.
*** Maintain the depot partner function of the normalised items.
ls_input_field-ref_guid = iv_guid.
ls_input_field-ref_kind = 'A'.
ls_input_field-objectname = 'PARTNER'.
DATA : lt_partner2 TYPE crmt_partner_to_display_tab,
       ls_partner2 TYPE crmt_partner_to_display.
CALL FUNCTION 'CRM_PARTNER_TO_DISPLAY_OW'
  EXPORTING
    iv_ref_guid          = iv_guid
    iv_ref_kind          = 'A'
  IMPORTING
    et_partner           = lt_partner2
  EXCEPTIONS
    partnerset_not_found = 1
    parameter_error      = 2
    entry_does_not_exist = 3
    OTHERS               = 4.

READ TABLE lt_partner2 INTO ls_partner2 WITH KEY partner_fct = <partner fct value to update>.
ls_input_field-logical_key  = ls_partner2-logical_key.
APPEND LINES OF lt_bapi_input_fields TO ls_input_field-field_names.
APPEND ls_input_field TO lt_input_fields.
APPEND ls_partner_com TO lt_partner.
*** Maintain the Depot on the header based on the single depot line items.
CALL FUNCTION 'CRM_ORDER_MAINTAIN'
  EXPORTING
    it_partner        = lt_partner
  CHANGING
    ct_input_fields   = lt_input_fields
  EXCEPTIONS
    error_occurred    = 1
    document_locked   = 2
    no_change_allowed = 3
    no_authority      = 4
    OTHERS            = 5.
CHECK sy-subrc = 0.
ls_obj-guid = iv_guid.
APPEND ls_obj TO lt_obj_save.
*** save the case
CALL FUNCTION 'BAPI_BUSPROCESSND_SAVE'
  TABLES
    objects_to_save = lt_obj_save.

COMMIT WORK.

Applies to:

SAP CRM (tested in version 7.0 Ehp2)

Summary

Simple report to delete items of a CRM Document, please note that is just a sample and not a full productive program and be careful, once the items are gone, are gone (wink)

Author(s):  

Company:     Accenutre
Created on:    30 September 2014
Author(s) Bio : Luis Perez is an CRM/ABAP consultant

/* 
*----------------------------------------------
* DATA DECLARATION
*----------------------------------------------
TYPES: BEGIN OF ts_order_index,
         header       TYPE crmd_order_index-header,
         object_id    TYPE crmd_orderadm_h-object_id,
         item         TYPE crmd_order_index-item,
         product_id   TYPE crmd_order_index-product_id,
       END OF ts_order_index.


DATA: gt_order_index     TYPE STANDARD TABLE OF ts_order_index,
      gt_orderadm_i      TYPE crmt_orderadm_i_comt,
      gt_input_fields    TYPE crmt_input_field_tab,
      gt_objects_to_save TYPE crmt_object_guid_tab,
      gt_saved_objects   TYPE crmt_return_objects.


DATA: gs_orderadm_i   LIKE LINE OF gt_orderadm_i,
      gs_input_fields LIKE LINE OF gt_input_fields,
      gs_field_names  LIKE LINE OF gs_input_fields-field_names.


DATA: gv_object_id_w    TYPE crmd_orderadm_h-object_id,
      gv_product_id     TYPE crmt_ordered_prod.


FIELD-SYMBOLS: <gs_order_index> LIKE LINE OF gt_order_index.


*----------------------------------------------
* SELECTION SCREEN
*----------------------------------------------
SELECTION-SCREEN BEGIN OF BLOCK block1.
SELECT-OPTIONS: objid    FOR gv_object_id_w,
                prodid     FOR gv_product_id.
SELECTION-SCREEN END OF BLOCK block1.


*----------------------------------------------
* READY, SET... GO!
*----------------------------------------------
START-OF-SELECTION.

  SELECT crmd_order_index~header crmd_order_index~item crmd_order_index~product_id crmd_orderadm_h~object_id
    INTO CORRESPONDING FIELDS OF TABLE gt_order_index
    FROM crmd_order_index JOIN crmd_orderadm_h ON
         crmd_orderadm_h~guid EQ crmd_order_index~header "Join By Index
    WHERE crmd_orderadm_h~object_id IN objid. "Access By Index

  DELETE gt_order_index WHERE product_id NOT IN prodid.
  SORT gt_order_index BY header.


  LOOP AT gt_order_index ASSIGNING <gs_order_index>.
    AT NEW header.
      CLEAR: gt_orderadm_i, gt_input_fields, gt_saved_objects.
      CLEAR: gs_orderadm_i, gs_input_fields.
    ENDAT.


*   Collect all the items for the each order
    gs_orderadm_i-guid = <gs_order_index>-item.
    gs_orderadm_i-mode = |D|.
    INSERT gs_orderadm_i INTO TABLE gt_orderadm_i.


    CLEAR gs_input_fields.
    gs_input_fields-ref_guid = <gs_order_index>-item.
    gs_input_fields-objectname = |ORDERADM_I|.
    gs_field_names-fieldname = |MODE|.
    INSERT gs_field_names INTO TABLE gs_input_fields-field_names.
    INSERT gs_input_fields INTO TABLE gt_input_fields.

    AT END OF header.
*     Update order in memory
      CALL FUNCTION 'CRM_ORDER_MAINTAIN'
        CHANGING
          ct_orderadm_i     = gt_orderadm_i
          ct_input_fields   = gt_input_fields
        EXCEPTIONS
          error_occurred    = 1
          document_locked   = 2
          no_change_allowed = 3
          no_authority      = 4
          OTHERS            = 5.
      IF sy-subrc NE 0.
*       Error handling as you need
      ELSE.
*       Persist changes to DB
        CLEAR: gt_objects_to_save, gt_saved_objects.
        INSERT <gs_order_index>-header INTO TABLE gt_objects_to_save.
        CALL FUNCTION 'CRM_ORDER_SAVE'
          EXPORTING
            it_objects_to_save = gt_objects_to_save
          IMPORTING
            et_saved_objects   = gt_saved_objects
          EXCEPTIONS
            document_not_saved = 1
            OTHERS             = 2.
        IF sy-subrc NE 0 OR gt_saved_objects IS INITIAL.
*         Error handling as you need
        ELSE.
*         Items Deleted!
          COMMIT WORK.
        ENDIF.
      ENDIF.
    ENDAT.
  ENDLOOP.
 */

Applies to:

SAP CRM (tested in version 7.0 Ehp2)

Summary

Up to SAP CRM 7.0 Ehp2 SAP didn't provide standard tools to remove massively saved searches, I'm providing a Simple demo program to show a way to easily accomplish this GAP. Note I'm using the BOL/GENIL approach because the functionality of remove saved searches is not wrapped at API level instead is wrapped in the GENIL level

Author(s):  

Company:     Accenutre
Created on:    28 August 2014
Author(s) Bio : Luis Perez is an CRM/ABAP consultant

 

/* 
*----------------------------------------------
* DATA DECLARATION
*----------------------------------------------
DATA: go_bol_core  TYPE REF TO cl_crm_bol_core,
      go_bol_trans TYPE REF TO if_bol_transaction_context.

DATA: go_query            TYPE REF TO cl_crm_bol_query_service,
      go_shortcut_manager TYPE REF TO cl_crm_shortcut_manager,
      go_result           TYPE REF TO if_bol_entity_col,
      go_bol_entity       TYPE REF TO cl_crm_bol_entity.

DATA: gs_shortcut TYPE crmt_shortcut.

*----------------------------------------------
* SELECTION SCREEN
*----------------------------------------------
PARAMETERS: user TYPE sy-uname,
            descr TYPE crmt_shortcut-description .

*----------------------------------------------
* READY, SET... GO!
*----------------------------------------------
START-OF-SELECTION.

* We translate the description as input parameter and the one
* selected to upper case in order to avoid case mistakes
  TRANSLATE descr TO UPPER CASE.
  go_bol_core = cl_crm_bol_core=>get_instance( ).
  go_bol_core->start_up( iv_appl_name = 'SAVEDSEARCH' ).
* Note you have also those query objects which can fullfit your requeriment:
* ShortcutSearchByAudience
* ShortcutSearchByKey
* ShortcutSearchByParameter
  go_query = cl_crm_bol_query_service=>get_instance( 'ShortcutSearchByOwner' ).
  go_query->set_property( EXPORTING iv_attr_name =   'OWNER_KEY '
                                    iv_value     = sy-uname ).
* I know there are more elegant ways to select the info, but come on! is just a demo ;-)
  go_result = go_query->get_query_result( ).
  go_bol_entity = go_result->get_first( ).
  WHILE go_bol_entity IS BOUND.
    CLEAR gs_shortcut.
    go_bol_entity->get_properties( IMPORTING es_attributes = gs_shortcut ).
    TRANSLATE gs_shortcut-description TO UPPER CASE.
    IF gs_shortcut-description EQ descr.
      EXIT.
    ENDIF.
    go_bol_entity ?= go_result->get_next( ).
  ENDWHILE.
  IF go_bol_entity IS BOUND.
    IF go_shortcut_manager IS NOT BOUND.
      go_shortcut_manager = cl_crm_shortcut_manager=>get_instance( ).
    ENDIF.
    go_shortcut_manager->delete_shortcut( go_bol_entity ).
    go_bol_core->modify( ).
    go_bol_trans = go_bol_core->get_transaction( ).
    IF go_bol_trans->save( ) EQ abap_true.
      go_bol_trans->commit( ).
    ENDIF.
  ENDIF.
 */

Author: Stephen Johannes

Submitted: 02/23/2007

Description

This will return the RFC destination of the ERP system connected to an SAP CRM 4.0 system.

Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
*&---------------------------------------------------------------------*
*&      Form  get_rfc_destination
*&---------------------------------------------------------------------*
FORM get_rfc_destination CHANGING ev_dest TYPE rfcdest.

  DATA:  lt_siteselect TYPE TABLE OF siteselect INITIAL SIZE 0,
          ls_siteselect TYPE siteselect.

  CALL FUNCTION 'SMOF0_READ_SITESELECT'
    TABLES
      to_siteselect = lt_siteselect.

  READ TABLE lt_siteselect INTO ls_siteselect
         WITH KEY sitetypeid = cl_smw1_siteprovider=>c_sitetype_r3oltp.

  ev_dest = ls_siteselect-rfcdest.
ENDFORM. "get_rfc_destination

Author: Manish Kumar Wasan
Submitted: 05 March @007    The purpose of the document is to describe the technical design specification required for enhancing the search functionality in IC Web client for I-Object (Individual Object) search using additional search criteria like Model Number, Serial Number, City, State and Zip Code.

1.1        DETAIL DESIGN, LOGIC AND DATA FLOW

Making I-Object Views available on IC Web Client:

The steps involved in making the I-Object views available on the IC Web Client are:
-       Copy the standard SAP BSP Application "CRM_IC_FICA" into a new BSP application "ZCF_N_CRMICFICAUTO" and activate this new Application.
-       In  the file "RuntimeRepository.xml" change the value of the tag "Application id" from "CRM_IC_FICA" to "ZCF_N_CRMICFICAUTO". This will call the z-application at runtime.
-       Copy the view "BuPaIdentifyCustomer" from the BSP Application "CRM_IC" to modify this viewset to accommodate vehicle views. The htmlb code to include the Vehicle and Relationship views should be added to this view.
-       Copy the file "AccountIdentificationViewSet.xml" from the BSP Application "CRM_IC_FICA" and add it to the page fragments. Call the "BuPaIdentifyCustomerViewSet" from the new application.

  • Include the following code in the Page Fragment "AccountIdentificationViewSet.xml" to include the views for the I-Object search and the Relationships in the IC Web Client Search screen.                        <ViewArea id="vehicle" views="ZCF_N_CRMICFICAUTO/VehISearch                                                                      ZCF_N_CRMICFICAUTO/VehIDetail"/>
                            <ViewArea id="relationship" views="CRM_IC_AUTO/VehIAddVehicle                                                                      CRM_IC_AUTO/VehIRelationship "/>
    -       Copy the following navigation links from the BSP Application "CRM_IC_AUTO" to the new Application as page fragments.(This is required to accommodate future changes, if required, in the navigation links for vehicle)
    VehINavigationalLinks.xml
    VehMNavigationalLinks1.xml
    VehMNavigationalLinks2.xml
    VehMNavigationalLinks3.xml
    VehMNavigationalLinks4.xml
    VehMNavLinksEventHistory.xml
    VehINavigationalLinksRT.xml
    VehMNavigationalLinks1RT.xml
    VehMNavigationalLinks2RT.xml
    VehMNavigationalLinks3RT.xml
    VehMNavigationalLinks4RT.xml
    VehMNavLinksEventHistoryRT.xml
    -       Add the following viewsets and the corresponding views from the BSP Application "CRM_IC_AUTO" to the new application page fragment. (This is required to accommodate future changes in the viewset if required)
    VehMViewSet0.xml
    VehMViewSet1.xml
    VehMViewSet2.xml
    VehMViewSet3.xml
    VehMViewSet4.xml
    VehMViews0.xml
    VehMViews1.xml
    VehMViews2.xml
    VehMViews3.xml
    VehMViews4.xml
    -       In the file "RuntimeRepository.xml" in the page flow logic of the new application, include the following viewsets as include file (These viewsets can be called from other BSP applications also. But, if there are any changes to be made, then the change should be made in the viewset for this new application and in that case, it should call the changed viewset from the new application)
         <%@ include file="../ZCRM_IC_FICAUTO/VehMViewSet0.xml" %>
         <%@ include file="../ZCRM_IC_FICAUTO/VehMViewSet1.xml" %>
         <%@ include file="../ZCRM_IC_FICAUTO/VehMViewSet2.xml" %>
         <%@ include file="../ZCRM_IC_FICAUTO/VehMViewSet3.xml" %>
         <%@ include file="../ZCRM_IC_FICAUTO/VehMViewSet4.xml" %>
    -       In the file "RuntimeRepository.xml" in the page flow logic of the new application, include the following navigation links as include file (These navigation links can be called from other applications too. But, if there are any changes to be made, then the change should be made in the navigation link for this new application and in that case, it should call the changed navigation link from the new application).
               <%@ include file="../ZCRM_IC_FICAUTO/VehINavigationalLinksRT.xml" %>
               <%@ include file="../ZCRM_IC_FICAUTO/VehMNavigationalLinks1RT.xml" %>
               <%@ include file="../ZCRM_IC_FICAUTO/VehMNavigationalLinks2RT.xml" %>
               <%@ include file="../ZCRM_IC_FICAUTO/VehMNavigationalLinks3RT.xml" %>
               <%@ include file="../ZCRM_IC_FICAUTO/VehMNavigationalLinks4RT.xml" %>
               <%@ include file="../ZCRM_IC_FICAUTO/VehMNavLinksEventHistoryRT.xml" %>
    -       Add the following design time navigation links in the file "crm_ic.xml" of the new application.
               <%@ include file="VehINavigationalLinks.xml" %>
               <%@ include file="VehMNavigationalLinks1.xml" %>
               <%@ include file="VehMNavigationalLinks2.xml" %>
               <%@ include file="VehMNavigationalLinks3.xml" %>
               <%@ include file="VehMNavigationalLinks4.xml" %>
               <%@ include file="VehMNavLinksEventHistory.xml" %>
    -       To activate the navigation from the detail button of the IC Web Client screen after confirming the vehicle, the following activities needs to be done:
    1.       Remove the comment referring to WorksetView.xml from the Viewset include files of the RuntimeRepository.xml for the new application.
    2.       Add the following in the file,Runtimerepository.xml of the new application.
          <ViewSet id="IC_BASE/WorkViewSet">
                      <ViewArea id="WorkViewSetArea"
                       views="<%@include file="../CRM_IC_DT_REP/StdWorkareaOccupation.xml" %>
                              <%@include file="FicaWorkAreaViewSets.xml" %>
                              <%@include file="../CRM_ITIC_ADJREP/WorkAreaContent.xml" %>
                              <%@include file="../CRM_IC_FICA_DIS/FicaDispWorkAreaViewSets.xml" %>
                      CRM_IC_AUTO/VehMDViewSet"/>
          </ViewSet>
    -       Copy the views "VehISearch.htm" and "VehIDetail.htm" from the BSP Application CRM_IC_AUTO to the BSP Application ZCF_N_CRMICFICAUTO.
     CONFIGURATION ACTIVITY
    The following configuration activities involve Technical inputs.The activities are as follows,

Renaming the Search Screen:
Currently, the IC Web Client search screen for I-Object is displayed as "Search Automotive - Vehicles". To change this to "Search Individual Objects", the "Description" field for Object Family 0311 needs to be changed to "Individual Objects" through SAP Reference implementation guide.

Removing unwanted Identifiers from I-Object Search Screen:
The following Identifiers need to be removed from the drop down list for the field 'Id type':
-       External Identification Number
-       Internal Identification Number
 Including additional Search Criteria:

Model Number:
The set type to be used for Model Number and Serial Number is "ZVEHI_INFO". To use this set type for the corresponding BOL entity "ProdVehModel".

To include Model Number as a Search Criteria, an ID Type should be created through SAP Reference implementation guide.
Specify the ID Name as "ZCFNMODEL_NUMBER".
Specify "Model Number" as Short Text.

Serial Number:
To include Serial Number as Search Criteria, follow the steps as mentioned for Model Number, specifying "ZCFNSERIAL_NUMBER" as the ID Name, "ZVEHI_INFO".

Displaying Model Number and Serial Number in the Detail View:
The BSP application to be enhanced is ZCF_N_CRMICFICAUTO. To add new fields Model Number and Serial Number in view VehISearch.htm, the attributes for these fields should be created in Context Node "VEHICLE" in view VehIDetail.htm using transaction "BSP_WD_WORKBENCH". The steps involved in creating the attributes are:
-                      Open the BSP application "ZCF_N_CRMICFICAUTO" in BSP workbench using transaction code "BSP_WD_WORKBENCH".
-                      Select the view VehIDetail.htm.
-                      Go to the context node "VEHICLE" and expand the "Attributes" node which lists all the existing attributes.
-                      To add a new attribute, right click on "Attributes" node and select "Create".
-                      In the wizard "Add Attribute to Existing Context Node", click on "Continue", then select the "Add Model Attribute" and click "Continue".
-                      Specify the attribute name as "Model Number", BOL Entity as "ProdVehModel" and BOL Attribute as "ZMODEL".
For adding the attribute "Serial Number", follow the steps mentioned above specifying the attribute name as "Serial Number", BOL Entity as "ProdVehModel" and BOL Attribute as "ZMODEL_SR_NO".
Once the attributes have been added under context node "VEHICLE", Model Number and Serial Number should be added in the view VehIDetail.htm. The steps to add these two fields are:

  • Create two HTML pages of fragment type. The pages are :
    1. For City, a new page fragment VehIModel.htm
    2. For State, a new page fragment VehISerial.htm
  • Include these htm pages inside VehIDetail.htm instead of the code for the existing Model and Model Key fields. The existing code should be removed or marked as a comment.

"../ZCF_N_CRMICFICAUTO/ VehIModel.htm"  and "../ZCF_N_CRMICFICAUTO/ VehISerial.htm" using               include file statement.
The structure for these htm files are mentioned in the section 2.3 Program Structure

In the page fragment "VehMViews4.xml", include the Model Attribute ID's for Model Number and Serial Number under View ID "VehMMFOwnR" for displaying these fields when the  "More Fields" button is clicked. Also, remove or comment  the Model Attribute ID's for the existing Model Number fields.
City and State:
To add "City and State" as search criteria fields in view VehISearch.htm of BSP application ZCF_N_CRMICFICAUTO, City and State need to be added in BOL entity "ProdICWebAltIDSearch" as new BOL attributes. The attribute structure of BOL entity ProdICWebAltIDSearch is "CRMT_PRIL_QUERY­_ICWEB_ALTID". Copy this structure and create a new structure "ZCFN_PRIL_QUERY_ICWEB_ALTID". This structure should be updated to include City and State. The new fields in the structure will be "ZZCITY" and "ZZSTATE" and the corresponding data elements will be "AD_CITY1" and "REGIO" respectively. After the structure is updated, copy the handler class "CL_CRM_PRIL_QUERY_ICWEB_ALTID" and create a new class "ZCFN_CL_PRIL_QUERY_ICWEB_ALTID". Save and activate the new class. After this, the new structure and class needs to be assigned to the BOL entity ProdICWebAltIDSearch through SAP Reference implementation guide.

The BSP application to be enhanced is ZCF_N_CRMICFICAUTO. To add new fields City and State in view VehISearch.htm, the attributes for these fields should be created in Context Node "SEARCHVEHICLE" in view VehISearch.htm using transaction "BSP_WD_WORKBENCH". The steps involved in creating the attributes are:

  • Open the BSP application "ZCF_N_CRMICFICAUTO" in BSP workbench using transaction code "BSP_WD_WORKBENCH".
  • Select the view VehISearch.htm.
  • Go to the context node "SEARCHVEHICLE" and expand the "Attributes" node which lists all the existing attributes.
  • To add a new attribute, right click on "Attributes" node and select "Create".
  • In the wizard "Add Attribute to Existing Context Node", click on "Continue", then select the "Add Model Attribute" and click "Continue".
  • Specify the attribute name as "City", BOL Entity as "ProdICWebAltIDSearch" and BOL Attribute as "ZZCITY".For adding the attribute "State", follow the steps mentioned above specifying the attribute name as "State", BOL Entity as "ProdICWebAltIDSearch" and BOL Attribute as "ZZSTATE".

Once the attributes have been added under context node "SEARCHVEHICLE", City and State should be added as input fields in the view VehISearch.htm. The steps to add these two fields are:

  • Create two html pages of fragment type. The pages are :
    1. For City, a new page fragment VehICitySearch.htm
    2. For State, a new page fragment VehIStateSearch.htm
  • Include these htm pages inside VehISearch.htm just before the code for the "Search" button:

"../ZCF_N_CRMICFICAUTO/ VehICitySearch.htm" and "../ZCF_N_CRMICFICAUTO/     VehIStateSearch.htm" using Include file statement.
The structure for these htm files are given in section 2.3 Program Structure
The CF user will enter values in input fields City and State and click on "Search" button. If the search is unsuccessful, the system will display the same view page VehISearch.htm of BSP application ZCF_N_CRMICFICAUTO. The error message "No Individual Object found" will also be displayed. If the search is successful, the I-Object details will be displayed in the view VehIDetail.htm of BSP application ZCF_N_CRMICFICAUTO.

To perform the search using City and State, create a function group "ZNICWEB" and a function module "Z_CF_N_COM_PRODUCT_GETLIST_API". This function module will retrieve the list of Product GUID's that satisfy the specified search criteria. To call this function module, redefine the method "EXECUTE_QUERY" of class "ZCFN_CL_PRIL_QUERY_ICWEB_ALTID" to include the call statement.

Zip Code:
To include Zip Code as a Search Criteria, an ID Type should be created through SAP Reference implementation guide.

1.2        PROGRAM STRUCTURE

VehIModel.htm:
This page fragment is needed to display the Model Number field in the view "VehIDetail.htm". Inside this page fragment, add the text field "Model Number", which refers to the attribute "Model Number" under Context Node "VEHICLE" in the view "VehIDetail.htm".
VehISerial.htm:
This page fragment is needed to display the Serial Number field in the view "VehIDetail.htm". Inside this page fragment, add the text field "Serial Number", which refers to the attribute "Serial Number" under Context Node "VEHICLE" in the view "VehIDetail.htm".
VehICitySearch.htm:
This page fragment is needed to add City as an input field in the view "VehISearch.htm". Inside this page fragment, add the text field "City", which refers to the attribute "City" under Context Node "SEARCHVEHICLE" in the view "VehISearch.htm".

VehIStateSearch.htm:
This page fragment is needed to add State as an input field in the view "VehISearch.htm". Inside this page fragment, add the text field "State", which refers to the attribute "State" under Context Node "SEARCHVEHICLE" in the view "VehISearch.htm".

1.3        TRIGGER EVENTS

Standard SAP "Search" Button in the I-Object search screen will trigger the I-Object search.
Display search criteria when identify account link is selected on IC Web client.

1.4        EXECUTION PROCEDURE

The execution procedure is as follows:

  • Authorized CF User will login to IC Web Client and select "Identify Account" in the navigation panel present on the left side of the screen. 
  • This displays a search screen which displays the search fields for the Individual Object on the right side. The user should select the required type of ID from the "ID Type" dropdown box and specify the value for the ID in the text box.
  • The CF User should then click the "Search" button. If the search is unsuccessful, the system displays the message "No Individual Object found" and if the search is successful, the I-Object details will be displayed and the "Confirm" button will be enabled.
  • The User then clicks on "Confirm" button to confirm the I-Object details have been retrieved, so that other information about the particular I-Object can be viewed.
  • This action also enables the "Details" button. Clicking on the "Details" button takes the user to the "Maintain Vehicle" screen.
  • In 'Maintain Vehicle' screen, the user selects the "Category ID" as "Individual Object" from the dropdown box and clicks on the "Continue" button.
  • This displays the details of the particular I-Object.
  • Clicking on the "More Fields" link will display additional details about the I-Object.
DATA: lv_oltp_destination TYPE rfcdest,
      lt_erpsites TYPE TABLE OF smof_erpsh,
      ls_erpsites LIKE LINE OF lt_erpsites.

* read OLTP destination
CALL FUNCTION 'SMOF_READ_SMOFERPSH'
  EXPORTING
    i_sitetypeid = 'SMOF_ERPSITE'
  TABLES
    t_erpsites   = lt_erpsites.

READ TABLE lt_erpsites INTO ls_erpsites INDEX 1.
lv_oltp_destination = ls_erpsites-rfcdest.

IF lv_oltp_destination IS INITIAL.
  RAISE no_data.
ENDIF.

CALL FUNCTION (rfc fmname)
  DESTINATION lv_oltp_destination.
 

Hi,

Today I'll gonna show how simply is to create a text box in CRM WebUI.

You need to create a context node in the component that you are working. The context node (up to now I'll call CN) must be created as a model text node like BTText. You can create a value node too, but to be easier we'll create a model node.

Go to the GET_P* method of the text line of CN that you created and insert this code. If you are using BTText this field is "CONC_LINES".

GET_P_CONC_LINES Method
CASE iv_property.
   WHEN if_bsp_wd_model_setter_getter=>fp_fieldtype.
     rv_value = cl_bsp_dlc_view_descriptor=>FIELD_TYPE_TEXTAREA.
   WHEN IF_BSP_WD_MODEL_SETTER_GETTER=>FP_TEXTAREA_ROWS.
     rv_value = 5. "Number of lines in you text box
 ENDCASE.

You have to configure the view displaying the field CONC_LINES in the screen. The result should be like this:

http://img838.imageshack.us/img838/7901/conclinesconfig2.gif

 All right! As simple as I mentioned!

Author: Ashish D Patel
Submitted: May 09 2007
Related Links:

  • <link>

Description

/* Category of IC*/SELECT * FROM CRMD_SRV_OSSET
WHERE SUBJECT_PROFILE = IV_SUBJECT_PROFILE
AND GUID_SET in ( SELECT GUID_SET FROM CRMD_LINK
WHERE GUID_HI EQ <CRMD_ORDERADM_H>-GUID
).SELECT * FROM CRMD_SRV_SUBJECT
WHERE GUID_REF = <wa_OrderH_and_OSSET>-GUID.

The categories hierarchy in CRM transaction cannot be read using the universal function module CRM_ORDER_READ. The simple following code allow us to read the categories hierarchy using the transaction GUID.

Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
TYPES: ty_categories_tab_type TYPE TABLE OF  REF TO if_crm_erms_catego_category.
DATA:
lr_aspect  TYPE REF TO if_crm_erms_catego_aspect,
lr_category  TYPE REF TO if_crm_erms_catego_category.

DATA:
  lr_categories TYPE REF TO data.

FIELD-SYMBOLS: <fs_categories> TYPE ty_categories_tab_type.

DATA: ls_cat_lang TYPE crmt_erms_cat_ca_lang.
DATA: lv_cat_string TYPE string.

CREATE DATA lr_categories TYPE ty_categories_tab_type.

CALL METHOD cl_crm_ml_category_util=>get_categoryfirst
  EXPORTING
    iv_ref_guid     = <Transaction GUID>
    iv_ref_kind     = 'A'
    iv_catalog_type = 'D'
  IMPORTING
    er_aspect       = lr_aspect
    er_category     = lr_category.


CALL METHOD cl_crm_ml_category_util=>get_cat_pars_all
  EXPORTING
    ir_aspect     = lr_aspect
    ir_category   = lr_category
  IMPORTING
    er_categories = lr_categories.

ASSIGN lr_categories->* TO <fs_categories>.

*Get texts for the category hierachy
LOOP AT <fs_categories> INTO lr_category.
  CALL METHOD lr_category->get_details
    IMPORTING
      ev_cat_lang = ls_cat_lang.

* Concatenate the categories description into one long string sperated by |
  CONCATENATE  lv_cat_string ls_cat_lang-cat_desc  INTO lv_cat_string
  SEPARATED BY '|'.
ENDLOOP.


Author: Ashish Patel
Submitted: April 7, 2007

Description   Code for Roll back of data in ICWebClient's Interaction record .

**********************************************
*&--   Data Declaration. --&*
**********************************************
DATA:
lr_wrapper TYPE REF TO cl_bsp_wd_collection_wrapper,
lr_current TYPE REF TO if_bol_bo_property_access,
lr_bp TYPE REF TO cl_crm_bol_entity,
lr_transaction TYPE REF TO if_bol_transaction_context.
*&-Fetching the Wrapper data---&*
TRY.
  lr_wrapper = typed_context->customer->get_collection_wrapper( ).
  lr_current = lr_wrapper->if_bol_bo_col~get_current( ).
ENDTRY.
lr_bp ?= lr_current.
CHECK lr_bp IS BOUND.
*&--Fetch transaction no --&*
lr_transaction = lr_bp->get_transaction( ).
*&-- Check if save needed is true --&*
CHECK lr_transaction->check_save_needed( ) EQ abap_true.
*&--Revert the changes made--&*
lr_transaction->revert( ).
 

Author: shilpi_pasricha

Submitted: 15th may,2009

Description : This FM is used to create a service ticket.In the service ticket product,product quantity,descriptuion,partner functions ,text are getting defaulted.

FUNCTION z_ediorderprocessing1.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     REFERENCE(ZPROCESS_TYPE) TYPE  CRMT_PROCESS_TYPE
*"     REFERENCE(DESCRIPTION) TYPE  STRING
*"     REFERENCE(CUSTOMER) TYPE  STRING
*"     REFERENCE(SALESORG) TYPE  CHAR4
*"     REFERENCE(DIS_CHANNEL) TYPE  CHAR2
*"     REFERENCE(MESSAGE) TYPE  ZVCHAR150
*"     REFERENCE(STATUS) TYPE  EDI_STATUS
*"     REFERENCE(VTEXT) TYPE  ZTEXT
*"     REFERENCE(STA_DESC) TYPE  EDI_TEXT60
*"  EXPORTING
*"     REFERENCE(ZOBJECT_ID) TYPE  CRMT_OBJECT_ID_DB
*"----------------------------------------------------------------------
  INCLUDE crm_object_names_con.
  DATA:
  gc_x                  TYPE c,
  ls_fname              TYPE filetable,
  lv_subrc              TYPE i,
    lv_le              TYPE zeew_dataelement0103,
  lv_ba              TYPE zeew_dataelement0104,
  lt_data               TYPE STANDARD TABLE OF string,
  lv_filename           TYPE string,
  lv_text2              TYPE char100,
  lv_soldtoparty TYPE   bu_partner,
  lv_data               TYPE string,
  lv_text1 TYPE char200,
  wa_header             TYPE bapibus20001_header_ins,
  itab_header           TYPE STANDARD TABLE OF bapibus20001_header_ins,
  itab_partner          TYPE STANDARD TABLE OF bapibus20001_partner_ins,
  wa_partner            TYPE bapibus20001_partner_ins,
  ls_address            TYPE bapibus1006_address,
  wa_status             TYPE bapibus20001_status_ins,
  itab_status           TYPE STANDARD TABLE OF bapibus20001_status_ins,
  wa_date               TYPE bapibus20001_appointment_ins,
  itab_appt             TYPE STANDARD TABLE OF bapibus20001_appointment_ins,
  itab_activity         TYPE STANDARD TABLE OF bapibus20001_activity_ins,
  wa_activity           TYPE bapibus20001_activity_ins,
  wa_text               TYPE bapibus20001_text_ins,
  itab_text             TYPE STANDARD TABLE OF bapibus20001_text_ins,
  wa_item               TYPE bapibus20001_item,
  itab_item             TYPE STANDARD TABLE OF bapibus20001_item,
  lv_text               TYPE char200,
  ls_inputfields        TYPE                   bapibus20001_input_fields,
  itab_input_fields     TYPE STANDARD TABLE OF bapibus20001_input_fields,
  lv_status             TYPE string,
  itab_return           TYPE STANDARD TABLE OF bapiret2,
  itab_service          TYPE STANDARD TABLE OF bapibus20001_service_os_ins,
  itab_saved_objects    TYPE STANDARD TABLE OF bapibus20001_object_id,
  itab_created_process  TYPE STANDARD TABLE OF bapibus20001_header_ins,
  wa_created_process    LIKE LINE OF itab_created_process,
  itab_objects_to_save  TYPE STANDARD TABLE OF bapibus20001_guid_dis,
  lv_guid               TYPE crmt_object_guid,
  wa_objects_to_save    LIKE                   LINE OF itab_objects_to_save,
  wa_saved_objects      LIKE LINE OF itab_saved_objects,
  lt_product_i          TYPE crmt_product_i_comt,
  lv_product_i          TYPE crmt_product_i_com,
  lt_appointment        TYPE crmt_appointment_comt,
  ls_appointment        TYPE crmt_appointment_com,
*  lt_schedlin           TYPE crmt_schedlin_i_comt,
  ls_schedlin           TYPE crmt_schedlin_i_com,
  ls_schedlines         TYPE TABLE OF crmt_schedlin_extdt,
  wa_schedlines         TYPE crmt_schedlin_extd,
  ls_orderadm_i         TYPE crmt_orderadm_i_com,
  lt_orderadm_i         TYPE crmt_orderadm_i_comt,
  ls_input_fields       TYPE crmt_input_field,
  ls_field_names        TYPE crmt_input_field_names,
  lt_input_fields       TYPE crmt_input_field_tab,
  lv_tempvar            TYPE crmt_orderadm_i_com,
  lv_item_guid          TYPE crmt_object_guid,
  lv_time_stamp         TYPE timestamp,
  lv_tz                 TYPE ttzz-tzone,
  l_object_to_save      TYPE crmt_object_guid,
  t_object_to_save      TYPE crmt_object_guid_tab,
  t_saved_objects       TYPE crmt_return_objects,
  t_objects_not_saved   TYPE crmt_object_guid_tab,
  t_exceptions          TYPE crmt_exception_t,
  wa_objid              TYPE  hrv1222a-objid,
  it_objid              TYPE TABLE OF hrv1222a-objid,
  lv_objid              TYPE hrv1222a-objid,
  lv_sobid              TYPE hrp1001-sobid,
  lv_resp_group         TYPE bu_partner,
  ls_orderadm_h         TYPE crmt_orderadm_h_com,
  lt_orderadm_h         TYPE crmt_orderadm_h_comt,
  lt_orderadm_i1         TYPE crmt_orderadm_i_wrkt,
  ls_orderadm_i1         TYPE crmt_orderadm_i_wrk,
  lt_product_i1         TYPE crmt_product_i_wrkt,
  ls_product_i1         TYPE crmt_product_i_wrk,
  lv_bpno               TYPE bu_partner,
  lv_salesorgtxt        TYPE string,
  lv_dischanneltxt      TYPE string,
  lv_idocstatustxt      TYPE string,
l_cr(1)               TYPE                   c VALUE cl_abap_char_utilities=>newline,
  wa_service            TYPE                   bapibus20001_service_os_ins,
  lv_bp_guid            TYPE bu_partner_guid.

  DATA:
    lt_bp              TYPE TABLE OF crmt_mktbp_guid_range,
    ls_bp              TYPE crmt_mktbp_guid_range,
    lt_return          TYPE TABLE OF bapiret2,
    lt_result          TYPE crmt_mktbp_alloc_bp_tab,
    lv_tier_value      TYPE string.

  DATA:
  lv_header_guid        TYPE guid_32,
  lv_header_guid16      TYPE guid_16.

  FIELD-SYMBOLS: <ls_allocvalues> TYPE crmt_mktpfchr_attribute_line,
                 <ls_result> TYPE crmt_mktbp_alloc_bp_list.


  gc_x = 'x'.

  CALL FUNCTION 'GUID_CREATE'
    IMPORTING
      ev_guid_16 = lv_header_guid16
      ev_guid_32 = lv_header_guid.
**
  lv_soldtoparty = customer.
**determine country of sold to party**

  CALL FUNCTION 'BUPA_ADDRESS_GET_DETAIL'
    EXPORTING
      iv_partner = lv_soldtoparty
    IMPORTING
      es_address = ls_address.

  zcl_productdetermination=>country = ls_address-country.
  zcl_productdetermination=>timezone = ls_address-time_zone.
***********************************************************************
* Passing the respective values from the Header table to internal table.
***********************************************************************
  wa_header-guid          =  lv_header_guid.
  wa_header-process_type  =  zprocess_type.
  wa_header-description = description.
  APPEND wa_header TO itab_header.
**determine responsible group**
  SELECT objid FROM hrv1222a INTO TABLE it_objid WHERE otype = 'O'
    AND attrib = 'ZPROCTYP_A' AND low = 'ZEDA'.
  IF sy-subrc = 0.
    LOOP AT it_objid INTO wa_objid.
      SELECT SINGLE objid  FROM hrv1222a INTO lv_objid WHERE otype = 'O'
        AND attrib = 'COUNTRY' AND low = ls_address-country AND objid = wa_objid.
      IF sy-subrc = 0.
        SELECT SINGLE sobid FROM hrp1001 INTO lv_sobid WHERE otype = 'O'
          AND plvar = '01' AND sclas = 'BP' AND objid = lv_objid.
        lv_resp_group = lv_sobid.
        EXIT.
      ENDIF.
      CLEAR :lv_sobid,wa_objid.
    ENDLOOP.
  ENDIF.


**header partner details**

  wa_partner-ref_guid = lv_header_guid.
  wa_partner-ref_kind = 'A'.
  wa_partner-ref_partner_handle = '0001'.
  wa_partner-partner_fct = '00000001'.
  wa_partner-partner_no = lv_soldtoparty.
  wa_partner-no_type = 'BP'.
  wa_partner-display_type  =  'BP'.
  APPEND wa_partner TO itab_partner.
  CLEAR wa_partner.

  wa_partner-ref_guid = lv_header_guid.
  wa_partner-ref_kind = 'A'.
  wa_partner-ref_partner_handle = '0001'.
  wa_partner-partner_fct = '00000099'.
  wa_partner-partner_no = lv_resp_group.
  wa_partner-no_type = 'BP'.
  wa_partner-display_type  =  'BP'.
  APPEND wa_partner TO itab_partner.
  CLEAR wa_partner.
********************************************
* Description
********************************************
  ls_inputfields-ref_kind = 'A'.
  ls_inputfields-ref_guid = lv_header_guid.
  ls_inputfields-objectname = 'ORDERADM_H'.
  ls_inputfields-fieldname = 'DESCRIPTION'.
  APPEND ls_inputfields TO itab_input_fields.
  CLEAR ls_inputfields.
*******passing the subject profile******
  wa_service-ref_guid = lv_header_guid.
  wa_service-subject_profile = 'ZEDISUBPA'.
  wa_service-cat_type = 'ZE'.
  wa_service-code_group = 'ZE01'.
  wa_service-code = '01'.
  wa_service-ref_kind = 'A'.
  APPEND wa_service TO itab_service.
  CLEAR wa_service.
**PASSING PRIORITY**
  wa_activity-ref_guid = lv_header_guid.
  wa_activity-category = '202'.
  wa_activity-priority = '1'.
  APPEND wa_activity TO itab_activity.
  CLEAR wa_activity.
**passing sales org and dis channel info to OTHERS TEXT**
  CONCATENATE 'Sales org' salesorg INTO lv_salesorgtxt SEPARATED BY ' '.
  CONCATENATE 'distribution channel' dis_channel INTO lv_dischanneltxt SEPARATED BY ' '.
  CONCATENATE 'IDOC status' status INTO lv_idocstatustxt SEPARATED BY ' '.
  CONCATENATE lv_salesorgtxt lv_dischanneltxt lv_idocstatustxt
*  message vtext sta_desc
  INTO lv_text1 SEPARATED BY ' ' .
  CONCATENATE message vtext sta_desc INTO lv_text2 SEPARATED BY ' ' .
  wa_text-ref_guid = lv_header_guid.
  wa_text-ref_kind = 'A'.
  wa_text-tdid = 'ZSA3'.
  wa_text-tdline   = lv_text1. "'ECC INCOMPLETE ORDER'.
  wa_text-tdformat  = '*'.
  wa_text-tdspras  = 'EN'.
  wa_text-mode = 'A'.
  APPEND wa_text TO itab_text.
  CLEAR: wa_text,lv_salesorgtxt ,lv_dischanneltxt, lv_idocstatustxt.
  wa_text-ref_guid = lv_header_guid.
  wa_text-ref_kind = 'A'.
  wa_text-tdid = 'ZSA3'.
  wa_text-tdline   = lv_text2. "'ECC INCOMPLETE ORDER'.
  wa_text-tdformat  = '*'.
  wa_text-tdspras  = 'EN'.
  wa_text-mode = 'A'.
* Appending the work area to the parameter table.
  APPEND wa_text TO itab_text.
  CLEAR: wa_text,lv_salesorgtxt ,lv_dischanneltxt, lv_idocstatustxt.
*  concatenate lv_text1 lv_text2 into lv_text separated by  '  '.
***input field population**

  ls_inputfields-ref_guid =  lv_header_guid.
  ls_inputfields-ref_kind = 'A'.
  ls_inputfields-objectname = 'SERVICE_OS'.
  ls_inputfields-logical_key = '0001'.
  ls_inputfields-fieldname = 'CONC_KEY'.
  APPEND ls_inputfields TO itab_input_fields.
  CLEAR ls_inputfields.

****REF_PARTNER_HANDLE*************************
  ls_inputfields-ref_guid =  lv_header_guid.
  ls_inputfields-ref_kind = 'A'.
  ls_inputfields-objectname = 'PARTNER'.
  ls_inputfields-logical_key = '0001'.
  ls_inputfields-fieldname = 'REF_PARTNER_HANDLE'.
  APPEND ls_inputfields TO itab_input_fields.
  CLEAR ls_inputfields.

****PARTNER_FCT*********************************
  ls_inputfields-ref_guid =  lv_header_guid.
  ls_inputfields-ref_kind = 'A'.
  ls_inputfields-objectname = 'PARTNER'.
  ls_inputfields-logical_key = '0001'.
  ls_inputfields-fieldname = 'PARTNER_FCT'.
  APPEND ls_inputfields TO itab_input_fields.
  CLEAR ls_inputfields.

****PARTNER_NO**********************************
  ls_inputfields-ref_guid =  lv_header_guid.
  ls_inputfields-ref_kind = 'A'.
  ls_inputfields-objectname = 'PARTNER'.
  ls_inputfields-logical_key = '0001'.
  ls_inputfields-fieldname = 'PARTNER_NO'.
  APPEND ls_inputfields TO itab_input_fields.
  CLEAR ls_inputfields.

****NO_TYPE*************************************
  ls_inputfields-ref_guid =  lv_header_guid.
  ls_inputfields-ref_kind = 'A'.
  ls_inputfields-objectname = 'PARTNER'.
  ls_inputfields-logical_key = '0001'.
  ls_inputfields-fieldname = 'NO_TYPE'.
  APPEND ls_inputfields TO itab_input_fields.
  CLEAR ls_inputfields.

****DISPLAY_TYPE********************************
  ls_inputfields-ref_guid =  lv_header_guid.
  ls_inputfields-ref_kind = 'A'.
  ls_inputfields-objectname = 'PARTNER'.
  ls_inputfields-logical_key = '0001'.
  ls_inputfields-fieldname = 'DISPLAY_TYPE'.
  APPEND ls_inputfields TO itab_input_fields.
  CLEAR ls_inputfields.
**text
  ls_inputfields-ref_guid    = lv_header_guid.
  ls_inputfields-ref_kind    = 'A'.
  ls_inputfields-objectname  = 'TEXTS'.
  ls_inputfields-logical_key = 'ZSA3E'.
  ls_inputfields-fieldname   = 'LINES'.
* Appending the parameter table
  APPEND ls_inputfields TO  itab_input_fields.
  CLEAR ls_inputfields.

  ls_inputfields-ref_kind = 'A'.
  ls_inputfields-ref_guid = lv_header_guid.
  ls_inputfields-objectname = 'ACTIVITY_H'.
  ls_inputfields-fieldname = 'MODE'.
  APPEND ls_inputfields TO itab_input_fields.
  CLEAR ls_inputfields.
  ls_inputfields-ref_kind = 'A'.
  ls_inputfields-ref_guid = lv_header_guid.
  ls_inputfields-objectname = 'ACTIVITY_H'.
  ls_inputfields-fieldname = 'PRIORITY'.
  APPEND ls_inputfields TO itab_input_fields.
  CLEAR ls_inputfields.
*****************************************************************************
*Calling a standard BAPI to create SALES OREDER using the filled internal tables.
*****************************************************************************
  CALL FUNCTION 'BAPI_BUSPROCESSND_CREATEMULTI'
    TABLES
      header          = itab_header
      partner         = itab_partner
      service_os      = itab_service
      input_fields    = itab_input_fields
      text            = itab_text
      activity        = itab_activity
      created_process = itab_created_process.

  READ TABLE itab_created_process INTO wa_created_process WITH KEY guid = lv_header_guid BINARY SEARCH.

  lv_guid = wa_created_process-guid.

* Appending the Guid of the Service ORDER to be saved to the internal table

  wa_objects_to_save = lv_guid.
  APPEND wa_objects_to_save TO itab_objects_to_save.

*****************************************************************************
*   Calling standard BAPI to save the process.
*****************************************************************************
  CALL FUNCTION 'BAPI_BUSPROCESSND_SAVE'
    EXPORTING
      update_task_local = space
      save_frame_log    = gc_x
    TABLES
      objects_to_save   = itab_objects_to_save
      saved_objects     = itab_saved_objects
      return            = itab_return.

*****************************************************************************
* Calling the Standard BAPI to Commit the transcation.
*****************************************************************************
  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

  LOOP AT itab_saved_objects INTO wa_saved_objects.
    zobject_id = wa_saved_objects-object_id.
  ENDLOOP.
  CLEAR : ls_orderadm_h,ls_input_fields,ls_field_names,lt_input_fields.

***TIER 1***

  SELECT SINGLE partner_guid INTO lv_bp_guid FROM but000 WHERE partner = lv_soldtoparty.
  IF sy-subrc EQ 0.
    ls_bp-sign   = 'I'.
    ls_bp-option = 'EQ'.
    ls_bp-low = lv_bp_guid.
    APPEND ls_bp TO lt_bp.

    CALL FUNCTION 'CRM_MKTBP_READ_BP_LIST'
      TABLES
        it_bp_list      = lt_bp
        et_bp_alloclist = lt_result
        et_return       = lt_return.

    LOOP AT lt_result ASSIGNING <ls_result>.
      LOOP AT <ls_result>-allocvalues ASSIGNING <ls_allocvalues>.
        IF <ls_allocvalues>-atname = 'ZCUST_TIER'.
          lv_tier_value = <ls_allocvalues>-atvaluedescr.
          EXIT.
        ENDIF.
      ENDLOOP.
    ENDLOOP.
  ENDIF.

************Business Area and Legal Entity*************************************
  SELECT SINGLE zzorderadm_h0103 zzorderadm_h0104 INTO (lv_le, lv_ba) FROM zcust_le_ba_a
    WHERE partner = lv_bpno.
*******************************************************************************
  ls_orderadm_h-guid = lv_header_guid.
  ls_orderadm_h-zzorderadm_h0102 = lv_tier_value.
  ls_orderadm_h-zzorderadm_h0103 = lv_le.
  ls_orderadm_h-zzorderadm_h0104 = lv_ba.
  INSERT ls_orderadm_h INTO TABLE lt_orderadm_h.

  ls_input_fields-ref_guid = lv_header_guid.
  ls_input_fields-objectname = 'ORDERADM_H'.
  CLEAR ls_field_names.
  ls_field_names-fieldname = 'ZZORDERADM_H0102'.
  APPEND ls_field_names TO ls_input_fields-field_names.
  ls_field_names-fieldname = 'ZZORDERADM_H0103'.
  APPEND ls_field_names TO ls_input_fields-field_names.
  ls_field_names-fieldname = 'ZZORDERADM_H0104'.
  APPEND ls_field_names TO ls_input_fields-field_names.
  INSERT ls_input_fields INTO TABLE lt_input_fields.
  CLEAR: lv_bpno, lv_tier_value,lv_le,lv_ba.

**CALL PRODUCT BADI***
  DATA : gv_exit          TYPE REF TO if_ex_crm_serviceprod_badi,
         ev_product_id TYPE comt_product_id,
                  lt_schedlin_i  TYPE crmt_schedlin_i_comt,
         lv_schedlin_i  TYPE crmt_schedlin_i_com,
         lt_schedlin    TYPE crmt_schedlin_extdt,
         lv_schedlin    TYPE crmt_schedlin_extd,
                  lt_header_guids   TYPE crmt_object_guid_tab,
         lt_req_obj        TYPE crmt_object_name_tab,
         lt_appointment_wrk TYPE  crmt_appointment_wrkt,
         lv_appointment_wrk TYPE crmt_appointment_wrk.


* call badi
  IF gv_exit IS INITIAL.
    CALL METHOD cl_exithandler=>get_instance
      EXPORTING
        exit_name              = 'CRM_SERVICEPROD_BADI'
        null_instance_accepted = abap_true
      CHANGING
        instance               = gv_exit.
  ENDIF.
  IF gv_exit IS BOUND.
    CALL METHOD gv_exit->provide_service_product
      EXPORTING
        iv_process_type = 'ZEDA'
      IMPORTING
        ev_product_id   = ev_product_id.
  ENDIF.
****************
**********item details*******************************
  lv_product_i-ref_handle = '0000000001'.
  lv_product_i-ref_guid = lv_header_guid.
  lv_product_i-process_qty_num = '1'.
  lv_product_i-process_qty_den = '1'.
  INSERT lv_product_i INTO TABLE lt_product_i.


*  wa_schedlines-quantity = '1'.
*  append wa_schedlines to ls_schedlin-schedlines.
*  insert ls_schedlin into table lt_schedlin.

  ls_orderadm_i-header = lv_header_guid.
  ls_orderadm_i-itm_type = 'ZCSA'.
  ls_orderadm_i-number_int = '0000000010'.
*  ls_orderadm_i-ordered_prod = 'SLA_SRV_CS_A'.
  ls_orderadm_i-ordered_prod = ev_product_id.
  ls_orderadm_i-handle = '0000000001'.
  ls_orderadm_i-mode = 'A'.
  ls_orderadm_i-itm_proc_ident = 'SRVC'.
  INSERT ls_orderadm_i INTO TABLE lt_orderadm_i.

  CLEAR ls_input_fields.
  ls_input_fields-ref_handle = '0000000001'.
  ls_input_fields-objectname = 'ORDERADM_I'.

  CLEAR ls_field_names.
  ls_field_names-fieldname = 'HANDLE'.
  APPEND ls_field_names TO ls_input_fields-field_names.
  ls_field_names-fieldname = 'HEADER'.
  APPEND ls_field_names TO ls_input_fields-field_names.
  ls_field_names-fieldname = 'ITM_PROC_IDENT'.
  APPEND ls_field_names TO ls_input_fields-field_names.
  ls_field_names-fieldname = 'ITM_TYPE'.
  APPEND ls_field_names TO ls_input_fields-field_names.
  ls_field_names-fieldname = 'MODE'.
  APPEND ls_field_names TO ls_input_fields-field_names.
  ls_field_names-fieldname = 'NUMBER_INT'.
  APPEND ls_field_names TO ls_input_fields-field_names.
  ls_field_names-fieldname = 'ORDERED_PROD'.
  APPEND ls_field_names TO ls_input_fields-field_names.
  INSERT ls_input_fields INTO TABLE lt_input_fields.

  CLEAR : ls_input_fields,ls_field_names.

*******************Quantity field*********************************
  lv_schedlin-quantity = '1.000'.
  INSERT lv_schedlin INTO TABLE lt_schedlin.
  lv_schedlin_i-schedlines = lt_schedlin.
  lv_schedlin_i-ref_handle = '0000000001'.
  INSERT lv_schedlin_i INTO TABLE lt_schedlin_i.

  ls_input_fields-ref_handle = '0000000001'.
  ls_input_fields-ref_kind = 'B'.
  ls_input_fields-objectname = 'SCHEDLIN'.

  ls_field_names-fieldname = 'LOGICAL_KEY'.
  APPEND ls_field_names TO ls_input_fields-field_names.
  ls_field_names-fieldname = 'QUANTITY'.
  APPEND ls_field_names TO ls_input_fields-field_names.
  INSERT ls_input_fields INTO TABLE lt_input_fields.

*******************************************************************
  WAIT UP TO 1 SECONDS.



  CALL FUNCTION 'CRM_ORDER_MAINTAIN'
    EXPORTING
      it_product_i      = lt_product_i
      it_schedlin_i     = lt_schedlin_i
    CHANGING
      ct_orderadm_i     = lt_orderadm_i
      ct_orderadm_h     = lt_orderadm_h
      ct_input_fields   = lt_input_fields
    EXCEPTIONS
      error_occurred    = 1
      document_locked   = 2
      no_change_allowed = 3
      no_authority      = 4
      OTHERS            = 5.


  LOOP AT lt_orderadm_i INTO lv_tempvar.
    lv_item_guid = lv_tempvar-guid.
  ENDLOOP.

*****************Lets see if dates are coming so that we can copy*******************************
  lv_guid = lv_header_guid.
  INSERT lv_guid INTO TABLE lt_header_guids.
  INSERT gc_object_name-appointment  INTO TABLE lt_req_obj.

  CALL FUNCTION 'CRM_ORDER_READ'
    EXPORTING
      it_header_guid       = lt_header_guids
      it_requested_objects = lt_req_obj
    IMPORTING
      et_appointment       = lt_appointment_wrk
    EXCEPTIONS
      document_not_found   = 1
      error_occurred       = 2
      document_locked      = 3
      no_change_authority  = 4
      no_display_authority = 5
      OTHERS               = 6.

  READ TABLE lt_appointment_wrk INTO lv_appointment_wrk WITH KEY appt_type = 'SRV_RREADY'.

************************************************************************************************
***********Adding dates*******************************
  CLEAR lv_time_stamp.

  CLEAR ls_appointment.
  ls_appointment-ref_guid = lv_header_guid.
  ls_appointment-ref_kind = 'A'.
  ls_appointment-appt_type = 'SRV_CUST_END'.
  ls_appointment-timestamp_from = lv_appointment_wrk-timestamp_from.
  ls_appointment-timezone_from = lv_appointment_wrk-timezone_from.
  ls_appointment-timezone_to = lv_appointment_wrk-timezone_to.
  ls_appointment-mode = 'B'.
  INSERT ls_appointment INTO TABLE lt_appointment.

  CLEAR ls_input_fields.
  CLEAR ls_field_names.

  ls_input_fields-ref_guid = lv_header_guid.
  ls_input_fields-ref_kind = 'A'.
  ls_input_fields-objectname = 'APPOINTMENT'.
  ls_input_fields-logical_key = 'SRV_CUST_END'.

  ls_field_names-fieldname = 'DOMINANT'.
  APPEND ls_field_names TO ls_input_fields-field_names.
  ls_field_names-fieldname = 'DURATION'.
  APPEND ls_field_names TO ls_input_fields-field_names.
  ls_field_names-fieldname = 'MODE'.
  APPEND ls_field_names TO ls_input_fields-field_names.
  ls_field_names-fieldname = 'RULE_NAME'.
  APPEND ls_field_names TO ls_input_fields-field_names.
  ls_field_names-fieldname = 'SHOW_LOCAL'.
  APPEND ls_field_names TO ls_input_fields-field_names.
  ls_field_names-fieldname = 'TIMESTAMP_FROM'.
  APPEND ls_field_names TO ls_input_fields-field_names.
  ls_field_names-fieldname = 'TIMEZONE_FROM'.
  APPEND ls_field_names TO ls_input_fields-field_names.
  ls_field_names-fieldname = 'TIME_UNIT'.
  APPEND ls_field_names TO ls_input_fields-field_names.
  INSERT ls_input_fields INTO TABLE lt_input_fields.
  CLEAR : ls_input_fields,ls_field_names.
******************************************************

  CALL FUNCTION 'CRM_ORDER_MAINTAIN'
    EXPORTING
      it_appointment    = lt_appointment
    CHANGING
      ct_input_fields   = lt_input_fields
    EXCEPTIONS
      error_occurred    = 1
      document_locked   = 2
      no_change_allowed = 3
      no_authority      = 4
      OTHERS            = 5.
********************************************************
  CLEAR : t_object_to_save,t_saved_objects,t_objects_not_saved,t_exceptions.
  IF sy-subrc EQ 0.
    l_object_to_save = wa_objects_to_save-guid.
    INSERT l_object_to_save INTO TABLE t_object_to_save.


    CALL FUNCTION 'CRM_ORDER_SAVE'
      EXPORTING
        it_objects_to_save   = t_object_to_save
        iv_no_bdoc_send      = 'X'
      IMPORTING
        et_saved_objects     = t_saved_objects
        et_exception         = t_exceptions
        et_objects_not_saved = t_objects_not_saved
      EXCEPTIONS
        document_not_saved   = 1
        OTHERS               = 2.

    IF sy-subrc EQ 0.
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
    ENDIF.

  ENDIF.


  CLEAR : zcl_productdetermination=>country ,lv_appointment_wrk,
  zcl_productdetermination=>timezone,l_object_to_save.
  REFRESH : t_saved_objects,t_exceptions,t_objects_not_saved,t_object_to_save,lt_input_fields,lt_appointment,
            lt_header_guids,lt_req_obj,lt_appointment_wrk.
  WRITE : 'Service Ticket '.
  WRITE : zobject_id.
  NEW-LINE.
ENDFUNCTION.
 

Author: Ashish Patel
Submitted: Sept. 24, 2007

To manually update the value of the context nodes attribute you should first get the instance of the core

and set the attribute value and then modify core.Here is a sample code for changing a value of the attribute:

Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
 data: lv_string type string,
        lr_cucoacmg    type ref to cl_crm_ic_cucoacmg_impl.

  data: lr_wrapper       type ref to cl_bsp_wd_collection_wrapper,
        lr_case_entity   type ref to cl_crm_bol_entity,
        lr_core          type ref to cl_crm_bol_core.

* get the core object out of the factory
  lr_core = cl_crm_bol_core=>get_instance( ).

* "ú?t?^?®?Ï?-
  concatenate sy-datum
              sy-uzeit
         into lv_string.

  lr_cucoacmg ?= get_custom_controller( cl_crm_ic_cmg_constants=>cuco_case ).
  check lr_cucoacmg is bound.

* "­s"ú??
  lr_wrapper = lr_cucoacmg->typed_context->case->get_collection_wrapper( ).
  lr_case_entity ?= lr_wrapper->get_current( ).

  if lr_case_entity is bound.

*set the value manually here
    lr_case_entity->set_property( iv_attr_name = 'ZZCASE_ADD_DATT' iv_value = lv_string ).
  endif.

  lr_core->modify( ).

  • No labels