Crm_dataexch_after_bapi_fill - CRM to R3

Hi Experts,
We have a requirement to replicate the sales order from CRM to a new sales ordem in R3 system.
The issue is that, some times, in R3 the sales order must have some different informations that the sales order in CRM.
When I create a sales order through CRMD_ORDER transaction, depends on sold-to party that I used, that order is replicated correctly. To some sold-to party the order is not replicated correctly.
When I create a sales order through a Z program, never the sales order is replicated correctly.
I believe that the problem is in sales order data created in CRM, but I check the data from both order created with diferent sold-to party e both seems to be same.
Any suggests?
Thanks
Edited by: Julius Bussche on Feb 26, 2010 9:26 PM
Subject title reformatted

Hi,
    This BAdI is called after save by the MW outbound flow. Please follow the steps below :
1. Deregister the CSA* queue in trx. SMQR (inbound queue)
2. Edit the qoutation doc. and save it.
3. Open the CSA* queue in
SMQR
. You will see a queue name like
CSA_SALESDOCUMENT<document id>
4. Open the queue entry, select it and press the 'Debug LUW' button. Note: make sure the rfc user id and your user id are dialog users.
5. You will see the ABAP debugger.
6. Now put a breakpoint by selecting Breakpoints->set breakpoint at...->method...
7. Enter your BAdi impl. class name and method as
IF_EX_CRM_DATAEXCHG_BADI~CRM_DATAEXCH_AFTER_BAPI_FILL
8. You will see a 'breakpoint set' message.
9. Press f8 and the flow should stop at this method.
Rreward if helpful!
Thanks,
Sudipta.

Similar Messages

  • CRM To ECC Sold to party Communication Details Not populated in ECC

    Hi All
    i have one problem when we create sales order through crmd_order we need to give sold to party and ship to party numbers suppose like
    8000002166 for both and status i keep as order created and in partner tab i i seem all partner funtions(sold to, ship to ,bill to, payer)with 8000002166
    in header overivew i given posting date as feature date like 30-09-2013 then i try to save this order.
    the order generated sucussfully but problem is i am not getting sold to party details in ECC when i check VA03 And open cretaed order in CRM and clicking on sold to party and i seem details for this but i am not getting communication details like telephone number and email id extension number.
    for this sold to party we already maintained all communication details in CRM.When i open this sold to party BP i am able to see all details
    didnt understand why these details not replicated to ECC?
    We implemented one custom class there we implemented badi.
    IF_EX_CRM_DATAEXCHG_BADI~CRM_DATAEXCH_AFTER_BAPI_FILL
    i am not getting BAPI ADDRESS Table values into  CT_BAPIADDR1
    how can i send communciation details to ECC For sold to party?
    The code part we follow like below
    TYPES : BEGIN OF t_otc,                                                        " Type to create a table with the given columns.
              bpid            TYPE bu_partner,                                       " variable of store processed business partner ID's
              otcid           TYPE bu_partner,                                       " variable of store processed OTC ID's
              otcguid         TYPE bu_partner_guid,                                  " variable of store processed OTC GUID's
              address         TYPE bapibus1006_address,
              tel1_numbr      TYPE ad_tlnmbr1,
              tel1_ext        TYPE ad_tlxtns1,
              e_mail          TYPE ad_smtpadr,
              END OF t_otc.
    *&                             V A R I A B L E S                         &*
      DATA : lv_bp_payer      TYPE bu_partner,                                       " Variable To Cast the payer Id into BU_Partner data type.
             lv_partner_fct   TYPE crmt_partner_fct,                                 " Variable To Store Partner Function Number.
             lv_partner       TYPE bu_partner,                                       " Variable To Store Current Business Partner ID.
             lv_process_type  TYPE crmt_process_type,                                " Variable to Store process type.
             lv_sales_org     TYPE crmt_sales_org,                                   " Variable to store sales org. name of order
             lv_dis_channel   TYPE crmt_distribution_channel,                        " Variable to store distribution channel of order.
             lv_division      TYPE crmt_division,                                    " Variable to store division of sales org. data.
             lv_role          TYPE comt_partner_parvw,                               " Variable to store retrieved role from FM.
             lv_role_value    TYPE parvw,                                            " Variable to store the role value of Partner Functions.
             lv_otc_guid      TYPE bu_partner_guid,                                  " Variable to store OTC GUIDs for the OTC ID.
             lv_otc_id        TYPE kunnr.                                            " Varaible to OTC ID revocered from Table.
      DATA: lv_busspartner           TYPE bapibus1006_head-bpartner,
            lw_central_data          TYPE bapibus1006_central,
            lw_centraldata_person    TYPE bapibus1006_central_person.
    *&                             W O R K A R E A S                         &*
      DATA : lw_address       TYPE bapibus1006_address,                              " Work Area to store address recovered for BPID.
    *Start of code change for Defect 904 Fix
             lw_tel           TYPE bapiadtel,
             lw_email         TYPE bapiadsmtp.
    *End of code change for Defect 904 Fix
    *&                          INTERNAL TABLES                              &*
      DATA : li_otc           TYPE TABLE OF t_otc,                                   " Internal Table to Store the OTC IDs and BPS.
             li_values        TYPE          zconst_values_t,
    *Start of code change for Defect 904 Fix
             li_tel           TYPE STANDARD TABLE OF bapiadtel,
             li_email         TYPE STANDARD TABLE OF bapiadsmtp.
    *End of code change for Defect 904 Fix
    *                       F I E L D - S Y M B O L S                         *
      FIELD-SYMBOLS: <f_orderadm>      TYPE bad_orderadm_h_mess,
                     <f_otc>           TYPE t_otc,                                   " Field-Symbol to Read the OTC TABLE data.
                     <f_partner>       TYPE bad_partner_mess,                        " Field-Symbol of Partner Table For Looping.
                     <f_bapiparnr3>    TYPE bapiparnr3,                              " Field-Symbol to Store The Row of BAPIPARNR3.
                     <f_bapiaddr1>     TYPE bapiaddr1,
                     <f_orgman>        TYPE bad_orgman_mess,                         " Field-Symbol to Read the ORGMAN table.
                     <f_values>        TYPE zcr_const_values.
    *&                             C O N S T A N T S                         &*
      CONSTANTS :  lc_program_name     TYPE progname      VALUE 'ZOTC',
                   lc_param_payer      TYPE paramname     VALUE 'PAYER',              " Constant to Store Payer Parameter name.
                   lc_ref_kind         TYPE crmt_object_kind VALUE 'A',
                   lc_req_1            TYPE zrequest_no VALUE '1',
                   lc_req_2            TYPE zrequest_no VALUE '2'.
    * Retrieving the general and Common Data for a Order.
      READ TABLE it_bus_trans_msg-orderadm_h INDEX 1 ASSIGNING <f_orderadm>.
      IF sy-subrc EQ 0.
        lv_process_type = <f_orderadm>-process_type.
      ENDIF.
    * Reading the Orgnisation Details from ORGMAN Table.
      READ TABLE it_bus_trans_msg-orgman WITH KEY ref_kind = lc_ref_kind ASSIGNING <f_orgman>.
      IF sy-subrc EQ 0.
    *   Storing the Sales Organisational Data to find the OTC_ID.
        lv_sales_org = <f_orgman>-sales_org.
        lv_dis_channel = <f_orgman>-dis_channel.
        lv_division = <f_orgman>-division.
      ENDIF.
    * Retrieving the partner function number for the payer by giving requirement no 2 and rule no 1.
      CALL FUNCTION 'ZCRAN_GET_CONSTANT_VALUES'
        EXPORTING
          pi_program_name = lc_program_name
          pi_req_no       = lc_req_2
        IMPORTING
          po_const_values = li_values.
      IF sy-subrc <> 0.
        RETURN.
      ENDIF.
    * Reading the value for the constant with the name as PAYER.
      READ TABLE li_values WITH KEY param_name = lc_param_payer ASSIGNING <f_values>.
      IF sy-subrc NE 0.
        RETURN.
      ENDIF.
    * Retrieving the Partner ID for the PAYER.
      READ TABLE it_bus_trans_msg-partner ASSIGNING <f_partner> WITH KEY ref_partner_fct = <f_values>-constant_value.
      IF sy-subrc EQ 0.
    *   Storing the current partner ID.
        lv_bp_payer = <f_partner>-ref_partner_no.
      ENDIF.
      REFRESH li_values.
    * Retrieving the Partner Function Number which are to be checked for replacing with the OTC ID with request no 1 and rule no 01.
      CALL FUNCTION 'ZCRAN_GET_CONSTANT_VALUES'
        EXPORTING
          pi_program_name = lc_program_name
          pi_req_no       = lc_req_1
        IMPORTING
          po_const_values = li_values.
      IF sy-subrc <> 0.
        RETURN.
      ENDIF.
    * Transferring the constant value to our table for Partner Fucntion.
      LOOP AT li_values ASSIGNING <f_values>.
    * Read Partner table for Header data and the reference partner function retrieved.
        READ TABLE it_bus_trans_msg-partner WITH KEY ref_kind = lc_ref_kind ref_partner_fct = <f_values>-constant_value ASSIGNING <f_partner>.
        IF sy-subrc EQ 0.
    *     Storing Current Partner Function.
          lv_partner_fct = <f_partner>-ref_partner_fct.
    *     Storing Current Partner No.
          lv_partner = <f_partner>-ref_partner_no.
    *     Retrieving the Partner Role (R/3) for the current partner function of CRM.
          CALL FUNCTION

    The problem is in the Lotus Notes security level, not in SAP.

  • What are the steps to send sales order custom field from CRM to ECC

    Hi Xperts,
      We have created a custom field in sales order [ VBAK] and successfully replicate its value from ECC to CRM. But while doing the enhancement to replicate the field value from CRM to ECC [ When the SO is created in CRM ] we are not able to do so.
    We used a FM in CRM0_300, but while replicating the SO from CRM to R/3 it is not getting called.
    Please help us by providing the steps to do the full enhancement to replicate the custom field of SO from CRM to ECC.
    Thanks in Advance.

    Hi Anjaneyulu,
    We are faced with a similar situation as you.
    Here is our scenario with the steps that we performed so far:
    1.  We have added a few custom fields in CRM 7.0 (Ehp1) using AET.
         The BDoc BUS_TRANS_MSG has been automatically extended with these custom fields.
    2.  On ECC side also, same custom fields have been added to VBAK and VBAP, using APPEND STRUCTURE. Fields were added to ADDITIONAL DATA TAB B in VA01 / VA02 transactions.
    3. Extended BAPI structures BAPISDITM and BAPISDITMX in both CRM and R/3 Side.
    4. As mentioned in the note 1053817, we have implemented BADI CRM_DATAEXCHG_BADI -> Method CRM_DATAEXCH_AFTER_BAPI_FILL in CRM (mapped fields from BDOC to BAPI structures)
    5. In the above note, for R/3 BAPI to R/3 API they have given to implement user exit USEREXIT_MOVE_FIELD_TO_VBAP which we found in MV45AFZZ. But in this we are unable to find BAPI Structure to map.
    Our issue is, when a sales order is created in CRM, it is getting replicated on ECC. But, only standard fields are getting replicated. The custom fields that we have added are remaining empty on ECC side.
    In CRM --> txn SMW01, we can see that the BDOC is populated with custom fields also.
    Could you let us know if your issue is solved completely. Are you able to see the value of custom field, in ECC? Did you use AET to add fields in CRM.
    Could you please give us the steps that you have done.

  • Replicating Z fields in an sales order to ECC from CRM

    Hi
    we are trying to replicate Z fields in a SO to ECC from CRM. We have followed the following steps for the same, these are given in one of the threads in SDN:
    1. Append structure to VBAK and VBAP in R/3
    2. Extend the structure BAPE_VBAK and BAPE_VBAP in CRM
    3. Implement BADI 'SALESDOC_MBDOC_BAPI' and implement code in method
    'CRM_DATAEXCH_AFTER_BAPI_FILL' to fill the the above structures and move them into CT_BAPIPAREX that is passed as changing parameter to this structure
    But corresponding fields in backend ECC table are not getting updated.
    Please help me in resolving this.
    If you have any document detailing steps, please forward that to me on [email protected]
    Thanx in advance.
    Cheers
    Hits

    Hello Hitesh,
    What you've done up to now is making sure that the data is passed to ECC. But ECC doesn't know what to do with this extra data you filled in the 'CRM_DATAEXCH_AFTER_BAPI_FILL'  CT_BAPIPAREX structure.
    Look for a similar BADI in ECC (something with DATAEXCH), this BADI is called when data arrives in ECC. Here you will find your value in the CT_BAPIPAREX, fetch the data and write to the desired field in VBAP.
    You just forget a step, that's all.
    Hope this helps!
    Regards,
    Joost

  • Order Replication CRM - R/3  - User Status not replicated - enhancement

    Hello all,
    We wish to synchronize order user status between CRM and R/3 (in fact ECC5). As described in IMG documentation, we should use the BAdI CRM_DATAEXCHG_BADI and methods CRM_DATAEXCH_AFTER_MBDOC_FILL, CRM_DATAEXCH_AFTER_BAPI_FILL for replication from CRM to ECC5 and CRM_DATAEXCH_R3D_MBDOC_FILL for replication from ECC5 to CRM.
    For method CRM_DATAEXCH_AFTER_BAPI_FILL, I was not able to find fields User Status and Status Profile in any of the R/3 structure BAPI*.
    Does anyone have any idea ?
    Thanks
    Laurent PIALOT

    Laurent
    I wonder if you know what the CRM_DATAEXCHG_BADI is for.
    We have a problem between CRM and BW: delta loads from 0CRM_SALES_ACT_1 finds no data. SAP OSS recommended to deactivate badi CRM_DATAEXCHG_BADI, but we don't know what possible side-effect we could face. Any idea?
    thanks,
    Mauricio Cubillos

  • Mapping CRM Field to ECC Field

    Hi,
    I have a requirement to map a field in the CRM Sales Order (Activity Reason) to a field in the ECC (Order Reason).
    Because the CRM doesnt have a order reason field i want to use the Activity Reason field available under Business activity tab for this purpose. This i want to write via a BadI. The BADI has been identified as CRM_DATAEXCHG_BADI
    I am knew to BADI and hence not aware of how to proceed. Any help will be greatly appreciated. Where to start and wat are the changes needed.
    Thanks in advance.
    Regards,
    Pradeep

    Hi Sudha,
    Thanks for the answer. This I have done and already found the interface and the method that needs to be implemented. The method is <b>crm_dataexch_after_bapi_fill.</b>
    Here I have a parameter bapisdhd1x with component ord_reason. Now my question is what exactly is the implementation to map this field (<b>LISTCODE</b> in CRM) to the filed <b>AUGRU</b> (this is a field in the table VBAK on ECC).
    The LISTCODE is a component of the structure and not a database table field. Hence i am stuck at this point. What is the exact mapping needed here?
    Thanks,
    Pradeep

  • Adding new input fields in CRM

    Hello All,
    I have the below requirement.
    I have to introduce new input fields in CRM for sales order creatio. These fields are to capture customer PO line item number and customer material number.
    Is there any standard field already available where we can capture this and replicate to ECC?.
    If not please help me on the below things.
    How can i introduce new fields in CRMD_ORDER and map these fields to ECC fields.
    Please help me.
    Regards,
    Shanto Aloor

    Hello,
    I take a look at the table CRMD_ORDERADM_I and I see that there are two fields for the item number.
    - number_int - Internal position number
    - number_ext - external position number
    Maybe you can use the field number_ext for you customer line number
    For the field customer material number I found the fields:
    ORDERED_PROD - CRM product number and
    PARTNER_PROD - Product number of the business partner
    As well i am not sure, but maybe you can use the field PARTNER_PROD for the customer material number. If this is not working you can enhance the position fields on two ways:
    If this is not working you can enhance the position data:
    (1) Old way using easy enhancement Werkbench
    You can use the transaction AET to generate new fields at the position. On this ocasion you should enhance the CRMD_CUSTOMER_I database table.
    (2) New way using application enhancement workbench
    The AET can be used at the webclient ui. Here you can easily generate new fields for the order. Please use the expert mode, because there you can define the fieldname at the database. Here you enhance the table CRMD_CUSTOMER_I, too.
    For the replication you have to take a look at the BADI CRM_DATAEXCHG_BADI. You can use the method CRM_DATAEXCH_AFTER_BAPI_FILL to fill the bapi structures with your new fields and send it to the ECC.
    Greetings

  • CRM Sales and ECC Delivery and Billing cube ods info

    We have already activated the ODS( OCRM_SALO) and the cube(OCSAL_CO3) for the sales order item level info and loaded data from the CRM system.
    Our next aim is to load the delivery  and Billing data from the ECC( or ERP). This is where we are a little confused.
    We see a lot of ODS in the info area CRM> ERP Analytics> Sales and Distribution Analysis SAP R/3 SD
    Not sure which ODS object and Cubes to activate and load.
    Any help will be rewarded.
    Thanks
    Arun

    Hello,
    You can use BADI CRM_DATAEXCHG_BADI method crm_dataexch_after_bapi_fill.
    In this method the field REQ_DLV_BL in internal table ct_bapischdlx can be cleared when CRM sends a delivery block with value space. When this field is cleared this means for ERP: Do not takeover delivery block and run the logic to determine the delivery block (including from material status).
    Please bear in mind that this will lead to a system behaviour that a value of space for delivery block cannot be transferred anymore from CRM to ERP. This means the delivery block cannot be reset anymore from the CRM side, it can only be removed in ERP.  If you use data exchange scenario A, it should not be a problem for you as the sales order can also be changed in ERP and thus the delivery block can be removed in ERP.
    Best regards,
    Maggie

  • Error in Sales Transaction in CRM 4.0 ?

    Hi All,
    We are working on CRM 4.0 i have created a sales transaction in WEB and  transaction will see in CRM and it is getting downloaded to R/3.
    But when I go back to CRM and check Sales Transaction it is showing me error as "An error has occured in the system XYZCLNT100 while copying the document".
    And i have been check in SMQ1&SMW01 ..in both T codes there is no error ..
    How can i figure out this problem ?
    can anyone help me in this regard?
    Thanks in advance.

    Please look into note 490932 for any issues of this nature
    This note gives an insight into possible error causes during the download or upload of sales transactions between CRM and R/3 and helps you correct these errors. This note is relevant for CRM Release3.0.
    It is also relevant for releases higher than 3.0.
    Other terms
    Download, initial, delta, delta download, SALESDOCUMENT, BUS_TRANS_MSG, event 00501014 501014
    Reason and Prerequisites
    The error causes may be included an incorrect configuration or missing system settings. The note only focuses on the sales transaction-specific configuration of the data exchange, but not on the settings for CRM Middleware in general or for other CRM Server applications.
    Solution
    In CRM Release 3.0, the following sales document items are transferred to the R/3 System:
    Sales items
    Customer return items
    Substitute delivery item
    Credit memo request items
    Debit memo request items
    As a leading system for the order entry, CRM only transfers data to the R/3 System if it is relevant for the logistical subsequent processing (delivery, billing). For this reason, requests for quotations and quotations themselves are not transferred to the R/3 back-end system with the standard delivery. With SAP note 455678, you can use a modification solution to also transfer quotations entered in CRM to the R/3 back-end system.
               Restrictions of note 455678:
    If you are using this solution, you cannot create any sales orders with reference to customer quotations in CRM.
    Mixed document processing (partially customer quotation items and partially sales order items) is not supported in the R/3 System and is therefore not possible during the quotation upload. The solution specified here only performs the upload for documents that consist of quotation items only.
    The quotation items must be defined in the Customizing for copying. This solution does not cover scenarios where the order is generated from the quotation as a result of a status change. Therefore, quotations entered in SAP Internet Sales (in particular) cannot be transferred to the R/3 System.
    Only completion rule 'A' ('Completed with one-time reference') is supported in the R/3 System.
    Sales transaction-specific settings for the data exchange
    1. Basic administrative settings for the replication of sales transactions
    a) The BDoc relevant for the distribution of all transaction types is called BUS_TRANSACTION_MESSAGE. In transaction SMOEAC, the relevant R/3 site must be subscribed to the corresponding publication 'All Business Transactions (MESG)' so that sales documents can be distributed to the R/3 back-end system. (To create a subscription, select the 'Subscription' object type in the 'Object type' selection list in transaction SMOEAC and then select the 'Object -> Create' function from the application menu or the corresponding symbol from the application function bar. The Subscription Wizard, which supports you during the creation of a new subscription, is started as a result.)
    b) Check to see whether the current CRM release has been maintained in the R/3 back-end system in the CRMPAROLTP table. This has to be taken into account in particular after an upgrade. You can maintain the CRMPAROLTP table in transaction SM30 in the R/3 back-end system:
                           Parameter name "CRM_RELEASE"
                           Param. value "30A"
    c) Event 00501014 must be activated in the R/3 back-end system so that the delta download of sales transactions from the R/3 back-end system to CRM works. The event must also be active for the upload of sales transactions from CRM to R/3.
    d) The event is activated automatically after a successful initial download. Call transaction R3AC4 ('Object Class Activation') in CRM and check whether the following entries exist:
                           Object class "BUSPROCESSND"
                           RFC destination <R/3 destination>
                           Select your entry and then choose 'Events by Object Class' (branch to the TBE31 table in the R/3 back-end system). The following entries must exist:
                           Event "00501014"
                           Obj. class "BUSPROCESSND"
                           Function "CRS_SALES_COLLECT_DATA"
                           If you do not see these entries, your initial download was not completed successfully.
    e) In transaction BD97 of your CRM system, the R/3 back-end system must have been maintained as the standard BAPI destination. Check the V_TBDLS view to see whether your R/3 back-end system has been defined as a logical system. A termination message in the SAPLCRM_ DISTRIBUTED_LOCKING program when you call a transaction in CRM indicates the missing destination assignment.
    Refer to notes 597812 and 674487. According to note 597812, the cross-system lock is processed using the RFC destination of the CRM middleware (SMOF_ERPSH table). However, the aforementioned entry in transaction BD97 for the Standard BAPI destination is still used to branch via the document flow to the R/3 system.
    f) In Release 3.1I, you can only have one entry for the RFCDEST field (RFC destination) in the CRMRFCPAR R/3 table.
    2. Definition of sales transaction-related Middleware parameters
    a) If you do not want a BOM explosion to occur for document items in CRM during the transfer to the R/3 back-end system, make the following settings in transaction R3AC6:
                           Key "R3A_SALES"
                           name "NOSTRUCTURE"
                           value "X"
                           This would make sense, for example, if you have already carried out a BOM explosion on the mobile client and if you do not want a new BOM explosion in the R/3 back-end system.
                           Make sure that the assigned item numbers in the sales transaction/sales document are set differently for main items and subitems so that no item numbers are assigned twice after the transfer and the BOM explosion in the R/3 System. The item numbers of the main items must be set identically in CRM and R/3. For more information, see note 496906.
                           Example:
                           CRM sales transaction
                           Pos.Nr.   Item No. Product
                           100 MAT1
                           200 MAT2
                           R/3 order
                           Pos.Nr.   Item No. Material
                           100 MAT1
                           101 Subitem1
                           102 Subitem2
                           103 Subitem3
                           104       ...
                           200 MAT2
                           You can maintain the item number assignment for the transaction types (CRM) or for the sales document types (R/3) in the Customizing.
    b) If a document is created in CRM and transferred to the R/3 back-end system, the warning messages of the transferred R/3 back-end document can also be displayed in the CRM document. In this way, you can recognize, for example, in the CRM document whether the transferred R/3 back-end document is incomplete and has to be postprocessed so that it can be further processed logistically. For this purpose, make the following settings in transaction R3AC6:
                           Key "R3A_SALES"
                           name "COLLECT_WARNINGS"
                           value "X"
    c) When you transfer a CRM document to R/3, you have the following control options with regard to pricing:
                           Key "R3A_SALES"
                           name "PRICINGTYPE"
                           value
                                             'B' = new pricing
                                             or
                                             'C' = copy manual pricecomponents,
                                             redetermine others
                                             or
                                             'G' = Copy price components unchanged,
                                             redetermine taxes (this value is
                                             delivered as a default setting)
    3. Definition of the R/3 dummy division in CRM
                  Note that no division exists in CRM in transactions at header level. In the R/3 order, however, the header division is a mandatory field. Thus, the R/3 dummy division must be maintained in CRM Customizing so that it can be determined during the transfer of a document. Otherwise, the order cannot be transferred to the R/3 back-end system.
                  Customizing path: 'Customer Relationship Management -> Master Data -> Organizational Management -> Division Settings -> Define Use of Division and Dummy Division'.
                  The use of several dummy divisions can be programmed in the CRM_DATAEXCH_AFTER_BAPI_FILL BAdI in the CRM_R3_SALESDOCUMENT_UPLOAD function module.
    Hints for the initial download
    Filter settings
    In transaction R3AC1, you set the filters for the initial/delta download of business objects. In the SALESDOCUMENT business object, you can set the filters for the order download from R/3 to CRM. For successful execution of the initial download, you have to set at least the VBAK-ERDAT filter criterion (document entry date) for the SALESDOCUMENT business object. This filter setting is required for the successful completion of order downloads.
    After you have completed these filter settings, you have to transfer these settings to the R/3 System. Select 'Filter sync.(R/3)'.
    Choose your R/3 System as a source site and check whether you are using the VBAK-ERDAT filter criterion:
    Example:
    Table/Structure Field OP Low
    VBAK ERDAT Greater than <Date>, for example, 20020128
    The date must be entered in the same form as it is stored on the database (YYYYMMDD)!
    The following filter criteria are also available:
    VBAK-AUART Sales document type
    VBAK-SPART Division
    VBAK-VBTYP Sales document category
    VBAK-VKORG Sales organization
    VBAK-VTWEG Distribution channel
    We recommend that you also use sales document numbers (VBAK-VBELN) as a further filter criterion. With this criterion, you can carry out an initial download according to sales document number intervals. The advantage of this filter criterion is that if your initial download terminates due to an error, you can restart the download after correcting the error as of the sales document number for which the error occurred. In this way you avoid having to restart a download for sales documents that have already been replicated.
    Example:
    Table/Structure   Field          OP            Low           High
    VBAK             VBELN          zwisch.        0005000000    0005099999
    Enter the field contents in the same way as it is stored on the R/3 database (leading zeros).
    If you want to use this filter criterion, go to transaction SM30 and make the following entry in the SMOFFILFLD table:
    Object name Table/Structure name Field name
    SALESDOCUMENT VBAK VBELN
    Note 497327 deals with possible filter-specific problems during the delta download that can occur due to missing R/3 back-end entries.
    Block size
    In this context, the block size specifies how many documents are selected in a transaction and transferred to CRM as a BDoc. The block size is defined on the system. The default value may have to be set to a lower value if problems occur (for example, memory overflow during the selection in the R/3 System). If the initial download terminates, check the dump log in the R/3 System (transaction ST22). The TIME_OUT or STORAGE_FREE_FAILED runtime errors indicate that the block size is too large. In this case, reduce the block size and restart the download.  In addition, you can clarify with your Basis Administration whether the rdisp/max_wprun_time kernel parameter is large enough (this avoids a TIME_OUT error).
    Basically, you should only download a few documents during the first download to check whether the system settings are correct. In this way, you can identify possible Customizing errors and correct them before the large load.
    Queue processing during the initial download
    In the case of very large transfer data sets, it may make sense to process the initial download in parallel within one object (object-internal parallel initial download) to complete the initial data transfer faster. Note 350176 describes the corresponding procedure.
    Queue processing during the upload/delta download
    Queues in CRM are defined in the SMOFQFIND table (for example, from CRM to CDB or from CRM to R/3).
    For the BUS_TRANS_MSG BDoc type, the default setting of the queue processing is that all orders for a customer are processed in one queue.
    As an alternative, you can set the queue processing in such a way that each order is processed in a separate queue. As a result, an individual order can no longer block the processing of other orders if an upload problem has occurred.
    If you prefer this queue processing, go to transaction SM30 and make the following change in the SMOFQFIND table:
    Select the BUS_TRANS_MSG BDoc type and change the segment field name from QUEUE_NAME to OBJECT_ID.
    In the same way, you can also set the queues for the delta download in the R/3 back-end system in such a way that each order is processed in a separate queue. If you prefer this queue processing, go to transaction SE16 in the R/3 back-end system and make the following change in the CRMQNAMES table:
    Select the entry for the SALESDOCUMENT object and change the BAPIFLD field from SOLD_TO to DOC_NUMBER (with BAPIOFFSET=3 and BAPIFLDLEN=10). Leave the second entry for the SALESDOCUMENT object (with QOBJPART=SAL_ERR) unchanged.
    In transaction SMQR, check to see whether the queues have been registered or check transaction SMQS to see whether the destinations have been registered because otherwise, the queues are not processed automatically, and this can lead to queue overloads.
    Check the queues regularly.
    Composite SAP Note 504090 covers all notes that solve known problems in the transfer as of Support Package 06 (SP06).
    Document cannot be maintained in online mode
    If you cannot maintain a document, this can have various reasons. Basically, a sales document entered in CRM is locked until the R/3 System has confirmed the update of the order successfully.
    If message CRM_ORDER019 "Document will be distributed - changes are not possible" occurs in CRM, check the queues (transaction SMQ1 and SMQ2). To analyze the data exchange from CRM to R/3, refer to note 431345.
    If message CRM_ORDER013 "Transaction &1 is being processed by user &2" occurs in CRM or if message V1042 "Sales document &1 is currently being processed (by user &2)" occurs in R/3, the document is processed in the other system respectively. To avoid inconsistencies, a cross-system lock is set during the processing of a replicated transaction so that the document cannot be processed simultaneously in two systems.
    Other notes
    Only error-free sales documents are distributed to the R/3 System. If, in R/3, you change a sales document that was originally created in CRM, these changes are not transferred to CRM. That is, you should always make the changes in the original CRM document to ensure the consistency of the document data in both systems. Sales documents entered in the R/3 System are transferred to CRM, but they are locked for processing there. Changes to a document created in R/3 are also transferred to CRM.
    In your settings for the data exchange, also make sure that the document number ranges correspond in both systems. For the successful sales document exchange between the systems, the transaction types and item categories have to be created in exactly the same way in both systems. If these objects do not exist in one system, you have to create them manually.
    In transaction CRMM_BUPA_MAP, you can determine into which R/3 customer number the CRM business partner is converted and vice versa. If you do not receive a conversion for the specified business partner here, this indicates that a transfer problem has not occurred in the sales document but during the business partner download.
    Header Data
    Release Status: Released for Customer
    Released on: 02.05.2006  15:04:13
    Priority: Recommendations/additional info
    Category: Consulting
    Primary Component: CRM-BTX-BF-IF R/3 Interface for Business Transactions

  • BADI for changing fields during Creation of BP in CRM

    Hello to everyone,
      I need to find a BADI (or other way) to default several fields during BP creation in CRM (4.0 SR1 SP9). The fields I will like to set are TAX TYPE, TAX NUMBER, TAX CATEGORY, etc.. I have found the BADI BUPA_TAX_UPDATE but i dont see any suitable parameters (structures) to changes these fields. Please advice and thanks in advance.

    Hi
    If you use function BUPA_NUMBERS_GET then your BP number will already be buffered and you can avoid a DB read. It may also be that the BP is not in the DB yet anyway.
    You can only pass one GUID in at a time - loop through IT_CHANGED_INSTANCES into a variable of type BU_PARTNER_GUID and pass that into the function as input parameter IV_PARTNER_GUID.
    Cheers
    Dom

  • Refresh CRM data in R/3 report

    Hi All,
    I've a report in R/3 where i get the Order Status of CRM through a RFC, but when i'm changing the status in CRM through crmd_order, when the report is open in R/3. When i press the refresh button, the status is not changed, it shows the previous status.
    Below is the code, can any1 help me how to go about
      CALL FUNCTION 'CRM0_READ_RFC_DEST'
        EXPORTING
         i_consumer             = 'CRM'
          i_download_type       = '*'
          i_objname             = '*'
      I_BAPICRMDH2          =
      I_REM_LOGSYS          =
        TABLES
          t_crmrfcpar           = t_crmrfcpar
    EXCEPTIONS
      NO_ENTRY_FOUND        = 1
      OTHERS                = 2
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      IF NOT t_crmrfcpar[] IS  INITIAL.
        READ TABLE t_crmrfcpar INDEX 1.
        l_rfcdst = t_crmrfcpar-rfcdest.
      ENDIF.
    Call RFC
    *loop at z_guid into lguid.
    *endloop.
    *refresh ZORDER_STATUS.
    CALL FUNCTION 'ZCRM_HEADER_STATUS'
      DESTINATION l_rfcdst
    IMPORTING
          ORDER_IDRET       =   l_guid
      tables
          ORD_STATUS        = ZORDER_STATUS
    Regards
    Sanju

    any body?

  • Installation of IPC AP 7.0 Jar is getting Failed when uploading in CRM

    Hello Experts,
    we did some changes in the previosly uploded version of IPC AP 7.0  customer user exit Jar file in eclipse.
    While uploading the new modified jar through transaction /SAPCND/UE_DEV in CRM we are getting error :" installation of module <Jar file name > has failed ".
    when we checked the logs in SM 53 we seen the below mentioned error:
    Message: Exception of type com.sap.sql.log.OpenSQLException caught: Exception of type com.sap.sql.sqlparser.CommonSQLParserException: - statement "DELETE FROM "SVMCRT_MOD_TR_T" WHERE "MODULE_NAME" LIKE ? ESCAPE ^ (reason: Modification of ABAP tables is not permit ted)" is not supported
    caught: - statement "DELETE FROM "SVMCRT_MOD_TR_T" WHERE "MODULE_NAME" LIKE ? ESCAPE ^ (reason: Modification of ABAP tables is not permitted)" is not supported
    --> com.sap.sql.log.OpenSQLException: Exception of type com.sap.sql.sqlparser.CommonSQLParserException: - statement "DELETE FROM "SVMCRT_MOD_TR_T" WHERE "MODULE_NAME" LIKE ? ESCAPE '^' (reason: Modification of ABAP tables is n" is not suppor ted
    caught: - statement "DELETE FROM "SVMCRT_MOD_TR_T" WHERE "MODULE_NAME" LIKE ? ESCAPE '^' (reason: Modification of ABAP tables is not permitted)" is not supported
    at com.sap.sql.log.Syslog.createAndLogOpenSQLException(Ljava/lang/Class;Ljava/lang/String;[Ljava/lang/Object;)Lcom/sap/sql/log/OpenSQLException;(Syslog.java:85)
    at 
    if  required i can post the complete stack trace.
    any inputs/suggestions are most welcome.
    Thanks & regards,
    Siddharth

    Hi Mark,
    Yesterday after Posting the thread we found the same Note ,Issue occured because of  JAVA write access was not enabled on the table ,After enabling it as mentioned in SAP Note, Jar file get successfully uploaded.
    Thanks for your Help also.
    Regards,
    Siddharth

  • Custom message required on log on pop-up in SAP CRM WEB UI

    We required custom message to the log- on popup, right now the message is coming after we give the user ID and password "starting SAP CRM" instead of that
    user required welcome message.., how can achieve this ?
    Please reply as soon as possible.

    Hi Pankaj,
    did you already check the guide in the CRM Wiki:
    https://wiki.sdn.sap.com/wiki/display/CRM/WelcomeUserMessageinWeb+UI
    Hope this answers your question.
    Best Regards,
    Michael

  • Dynamic CRM 2013 Online how to execute Report, generate PDF and email

    Dear All,
    I am using Dynamic CRM 2013 online. For quote, I have workflow and Dialogue processes for review process. On approval, I want the system to generate a PDF of quote report, attach the PDF and email it to the Customer.
    Better I would like, When approver, clicks on the approve button, the system should auto generate a PDF of quote report, attach the PDF and email it to the Customer, without any further input from the user. If its not possible, I may have to put button on
    quote form.
    I am using the attached code, but facing various issues.
    1. Under prepare the SOAP Message coding part, I am not sure what should be the below URL for CRM 2013 Online?
    xHReq.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
    2. What should be the emailid here? Is it Recepient Contact id(Guid) ?
    var emailid = resultXml.selectSingleNode("//CreateResult").nodeTypedValue;
    alert("emailid" + emailid.toString());
    3. Using this code, not able to create Entity for "ActivityMimeAttachment", I am getting newEntity as undefined.
    Below is the code I am using. Please check and help me out, where I am going wrong. Let me know if any better way to implement it. At present, I have put one button on quote form, on click event, below code will get executed.
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title></title>
    <script type="text/javascript">
    var Xrm;
    if (window.opener) { Xrm = window.opener.Xrm; }
    else if (window.parent) { Xrm = window.parent.Xrm; }
    function getReportingSession() {
    var reportName = "Quotation_Report"; //set this to the report you are trying to download
    var reportId = "7C39D18F-1DC6-E311-8986-D89D6765B238"; //set this to the guid of the report you are trying to download
    var recordid = Xrm.Page.data.entity.getId();
    // recordid = recordid.substring(1, 37); //getting rid of curly brackets
    alert(recordid);
    var pth = Xrm.Page.context.getServerUrl() + "/CRMReports/rsviewer/reportviewer.aspx";
    var retrieveEntityReq = new XMLHttpRequest();
    retrieveEntityReq.open("POST", pth, false);
    retrieveEntityReq.setRequestHeader("Accept", "*/*");
    retrieveEntityReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    retrieveEntityReq.send("id=%7B" + reportId + "%7D&uniquename=" + Xrm.Page.context.getOrgUniqueName() + "&iscustomreport=true&reportnameonsrs=&reportName=" + reportName + "&isScheduledReport=false");
    var x = retrieveEntityReq.responseText.indexOf("ReportSession=");
    var ret = new Array();
    ret[0] = retrieveEntityReq.responseText.substr(x + 14, retrieveEntityReq.responseText.indexOf("&", x) - x - 14); //the session id
    x = retrieveEntityReq.responseText.indexOf("ControlID=");
    ret[1] = retrieveEntityReq.responseText.substr(x + 10, retrieveEntityReq.responseText.indexOf("&", x) - x - 10); //the control id
    return ret;
    function createEntity(ent, entName, upd) {
    var jsonEntity = JSON.stringify(ent);
    var createEntityReq = new XMLHttpRequest();
    var ODataPath = Xrm.Page.context.getServerUrl() + "XRMServices/2011/OrganizationData.svc";
    createEntityReq.open("POST", ODataPath + "/" + entName + "Set" + upd, false);
    createEntityReq.setRequestHeader("Accept", "application/json");
    createEntityReq.setRequestHeader("Content-Type", "application/json; charset=utf-8");
    createEntityReq.send(jsonEntity);
    var newEntity = JSON.parse(createEntityReq.responseText).d;
    alert("new entity" + newEntity);
    return newEntity;
    function createAttachment() {
    var params = getReportingSession();
    var recordid = Xrm.Page.data.entity.getId();
    alert("recordid " + recordid);
    var orgName = Xrm.Page.context.getOrgUniqueName();
    var userID = Xrm.Page.context.getUserId();
    //create email record
    // Prepare the SOAP message.
    var xml = "<?xml version='1.0' encoding='utf-8'?>" +"<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'" +
    " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" +
    " xmlns:xsd='http://www.w3.org/2001/XMLSchema'>" +
    "<soap:Header>" +
    "</soap:Header>" +
    "<soap:Body>" +
    "<Create xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>" +
    "<entity xsi:type='email'>" +
    "<regardingobjectid type='quote'>" + recordid + "</regardingobjectid>" +
    "<subject>" + "Email with Attachment4" + "</subject>" +
    "</entity>" +
    "</Create>" +
    "</soap:Body>" +
    "</soap:Envelope>";
    // Prepare the xmlHttpObject and send the request.
    var xHReq = new ActiveXObject("Msxml2.XMLHTTP");
    xHReq.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
    xHReq.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/crm/2007/WebServices/Create");
    xHReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
    xHReq.setRequestHeader("Content-Length", xml.length);
    xHReq.send(xml);
    // Capture the result
    var resultXml = xHReq.responseXML;
    // alert("resultXml " + resultXml);
    // Check for errors.
    var errorCount = resultXml.selectNodes('//error').length;
    if (errorCount != 0) {
    alert("ERROR");
    var msg = resultXml.selectSingleNode('//description').nodeTypedValue;
    alert(msg);
    var emailid = resultXml.selectSingleNode("//CreateResult").nodeTypedValue;
    alert("emailid" + emailid.toString());
    //var emailid = userID;
    var post = Object();
    post.Body = encodePdf(params);
    var email = new Array();
    email[0] =new Object();
    email[0].id = emailid;
    email[0].entityType ='email';
    post.Subject ="File Attachment";
    post.AttachmentNumber = 1;
    post.FileName ="Report.pdf";
    post.MimeType ="application/pdf";
    post.ObjectId = Object();
    post.ObjectId.LogicalName ="email";
    post.ObjectId.Id = email[0].id;
    post.ObjectTypeCode ="email";
    alert(post.ObjectId.Id);
    createEntity(post,"ActivityMimeAttachment", "");
    alert("created successfully");
    email.Subject = "Your Order";
    //Set The current order as the Regarding object
    email.RegardingObjectId = {
    Id: Xrm.Page.data.entity.getId(), //Get the current entity Id , here OrderId
    LogicalName: Xrm.Page.data.entity.getEntityName()//Get the current entity name, here it will be “salesOrder”
    //Create Email Activity
    SDK.JScriptRESTDataOperations.Create(email, "Email", EmailCallBack, function (error) { alert(error.message); });
    // Email Call Back function
    function EmailCallBack(result) {
    email = result; // Set the email to result to use it later in email attachment for retrieving activity Id
    var activityPartyFrom = new Object();
    // Set the From party of the ActivityParty to relate an entity with Email From field
    activityPartyFrom.PartyId = {
    Id: customerId, // id of entity you want to associate this activity with.
    LogicalName: "contact"
    // Set the "activity" of the ActivityParty
    activityPartyFrom.ActivityId = {
    Id: result.ActivityId,
    LogicalName: "email"
    // Now set the participation type that describes the role of the party on the activity).
    activityPartyFrom.ParticipationTypeMask = { Value: 2 }; // 2 means ToRecipients
    // Create the from ActivityParty for the email
    SDK.JScriptRESTDataOperations.Create(activityPartyFrom, "ActivityParty", ActivityPartyFromCallBack, function (error) { alert(error.message); });
    var activityPartyTo = new Object();
    // Set the From party of the ActivityParty to relate an entity with Email From field
    activityPartyTo.PartyId = {
    Id: ownerId, // id of entity you want to associate this activity with.
    LogicalName: "systemuser"
    // Set the "activity" of the ActivityParty
    activityPartyTo.ActivityId = {
    Id: result.ActivityId,
    LogicalName: "email"
    // Now set the participation type that describes the role of the party on the activity). activityPartyTo.ParticipationTypeMask = { Value: 1 }; // 1 means Sender
    // Create the from ActivityParty
    SDK.JScriptRESTDataOperations.Create(activityPartyTo, "ActivityParty", ActivityPartyToCallBack, function (error) { alert(error.message); });
    //ActivityParty From Callback
    function ActivityPartyFromCallBack(result) {
    //ActivityParty To Callback
    function ActivityPartyToCallBack(result) {
    var StringMaker = function () {
    this.parts = [];
    this.length = 0;
    this.append = function (s) {
    this.parts.push(s);
    this.length += s.length;
    this.prepend = function (s) {
    this.parts.unshift(s);
    this.length += s.length;
    this.toString = function () {
    return this.parts.join('');
    var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
    function encode64(input) {
    var output = new StringMaker();
    var chr1, chr2, chr3;
    var enc1, enc2, enc3, enc4;
    var i = 0;
    while (i < input.length) {
    chr1 = input[i++];
    chr2 = input[i++];
    chr3 = input[i++];
    enc1 = chr1 >> 2;
    enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
    enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
    enc4 = chr3 & 63;
    if (isNaN(chr2)) {
    enc3 = enc4 = 64;
    else if (isNaN(chr3)) {
    enc4 = 64;
    output.append(keyStr.charAt(enc1) + keyStr.charAt(enc2) + keyStr.charAt(enc3) + keyStr.charAt(enc4));
    return output.toString();
    var bdy = new Array();
    var bdyLen = 0;
    function concat2Bdy(x) {
    bdy[bdyLen] = x;
    bdyLen++;
    function encodePdf(params) {
    bdy = new Array();
    bdyLen = 0;
    var retrieveEntityReq = new XMLHttpRequest();
    var pth = Xrm.Page.context.getServerUrl() + "/Reserved.ReportViewerWebControl.axd?ReportSession=" + params[0] + "&Culture=1033&CultureOverrides=True&UICulture=1033&UICultureOverrides=True&ReportStack=1&ControlID=" + params[1] + "&OpType=Export&FileName=Public&ContentDisposition=OnlyHtmlInline&Format=PDF";
    retrieveEntityReq.open("GET", pth, false);
    retrieveEntityReq.setRequestHeader("Accept", "*/*");
    retrieveEntityReq.send();
    BinaryToArray(retrieveEntityReq.responseBody);
    return encode64(bdy);
    </SCRIPT>
    <SCRIPT type=text/vbscript>
    Function BinaryToArray(Binary)
    Dim i
    ReDim byteArray(LenB(Binary))
    For i = 1 To LenB(Binary)
    byteArray(i-1) = AscB(MidB(Binary, i, 1))
    concat2Bdy(AscB(MidB(Binary, i, 1)))
    Next
    BinaryToArray = byteArray
    End Function
    </SCRIPT>
    </head>
    <body>
    <input type="button" onclick="createAttachment();" value="Attach Report" />
    </body>
    </html>
    Thanks. and waiting for your valuable comments.
    - Mittal

    Hello,
    Yes, I was able to make my code working as below. Tested on CRM online 2013.
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title></title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
    <script type="text/javascript">
    if (typeof (SDK) == "undefined")
    { SDK = { __namespace: true }; }
    SDK.JScriptRESTDataOperations = {
    _context: function () {
    if (typeof GetGlobalContext != "undefined")
    { return GetGlobalContext(); }
    else {
    if (typeof Xrm != "undefined") {
    return Xrm.Page.context;
    else { return new Error("Context is not available."); }
    _getServerUrl: function () {
    var serverUrl = this._context().getServerUrl()
    if (serverUrl.match(/\/$/)) {
    serverUrl = serverUrl.substring(0, serverUrl.length - 1);
    return serverUrl;
    _ODataPath: function () {
    return this._getServerUrl() + "/XRMServices/2011/OrganizationData.svc/";
    _errorHandler: function (req) {
    return new Error("Error : " +
    req.status + ": " +
    req.statusText + ": " +
    JSON.parse(req.responseText).error.message.value);
    _dateReviver: function (key, value) {
    var a;
    if (typeof value === 'string') {
    a = /Date\(([-+]?\d+)\)/.exec(value);
    if (a) {
    return new Date(parseInt(value.replace("/Date(", "").replace(")/", ""), 10));
    return value;
    Create: function (object, type, successCallback, errorCallback) {
    var req = new XMLHttpRequest();
    req.open("POST", this._ODataPath() + type + "Set", true);
    req.setRequestHeader("Accept", "application/json");
    req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
    req.onreadystatechange = function () {
    if (this.readyState == 4 /* complete */) {
    if (this.status == 201) {
    successCallback(JSON.parse(this.responseText, SDK.JScriptRESTDataOperations._dateReviver).d);
    else {
    errorCallback(SDK.JScriptRESTDataOperations._errorHandler(this));
    req.send(JSON.stringify(object));
    Retrieve: function (id, type, successCallback, errorCallback) {
    var req = new XMLHttpRequest();
    req.open("GET", this._ODataPath() + type + "Set(guid'" + id + "')", true);
    req.setRequestHeader("Accept", "application/json");
    req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
    req.onreadystatechange = function () {
    if (this.readyState == 4 /* complete */) {
    if (this.status == 200) {
    successCallback(JSON.parse(this.responseText, SDK.JScriptRESTDataOperations._dateReviver).d);
    else {
    errorCallback(SDK.JScriptRESTDataOperations._errorHandler(this));
    req.send();
    Update: function (id, object, type, successCallback, errorCallback) {
    var req = new XMLHttpRequest();
    req.open("POST", this._ODataPath() + type + "Set(guid'" + id + "')", true);
    req.setRequestHeader("Accept", "application/json");
    req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
    req.setRequestHeader("X-HTTP-Method", "MERGE");
    req.onreadystatechange = function () {
    if (this.readyState == 4 /* complete */) {
    if (this.status == 204 || this.status == 1223) {
    successCallback();
    else {
    errorCallback(SDK.JScriptRESTDataOperations._errorHandler(this));
    req.send(JSON.stringify(object));
    Delete: function (id, type, successCallback, errorCallback) {
    var req = new XMLHttpRequest();
    req.open("POST", this._ODataPath() + type + "Set(guid'" + id + "')", true);
    req.setRequestHeader("Accept", "application/json");
    req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
    req.setRequestHeader("X-HTTP-Method", "DELETE");
    req.onreadystatechange = function () {
    if (this.readyState == 4 /* complete */) {
    if (this.status == 204 || this.status == 1223) {
    successCallback();
    else {
    errorCallback(SDK.JScriptRESTDataOperations._errorHandler(this));
    req.send();
    RetrieveMultiple: function (type, filter, successCallback, errorCallback) {
    if (filter != null) {
    filter = "?" + filter;
    else { filter = ""; }
    var req = new XMLHttpRequest();
    req.open("GET", this._ODataPath() + type + "Set" + filter, true);
    req.setRequestHeader("Accept", "application/json");
    req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
    req.onreadystatechange = function () {
    if (this.readyState == 4 /* complete */) {
    if (this.status == 200) {
    successCallback(JSON.parse(this.responseText, SDK.JScriptRESTDataOperations._dateReviver).d.results);
    else {
    errorCallback(SDK.JScriptRESTDataOperations._errorHandler(this));
    req.send();
    __namespace: true
    </script>
    <script type="text/javascript">
    //Create Email and link it with Order as Regarding field
    var Xrm;
    var email = new Object();
    var ownerID = "";
    var CustomerId = "";
    if (window.opener) { Xrm = window.opener.Xrm; }
    else if (window.parent) { Xrm = window.parent.Xrm; }
    //Get ownerid who send email of quotation to customer
    function GetOwnerID() {
    var owner = Xrm.Page.getAttribute("ownerid").getValue();
    ownerID = owner[0].id;
    var ownerName = owner[0].name;
    var entityType = owner[0].entityType;
    GetToEmailGUID();
    //Get customerid who receive email of quotation from owner
    function GetToEmailGUID() {
    var Customer = Xrm.Page.getAttribute('customerid').getValue();
    CustomerId = Customer[0].id;
    var CustomerName = Customer[0].name;
    var entityType = Customer[0].entityType;
    //if CustomerId is type of "Account" then get Primary Contact id of that account
    if (entityType == "account") {
    var contact = Xrm.Page.getAttribute("customerid").getValue();
    if (contact === null) return;
    var serverUrl = Xrm.Page.context.getClientUrl();
    var oDataSelect = serverUrl + "/XRMServices/2011/OrganizationData.svc/AccountSet(guid'" + contact[0].id + "')?$select=PrimaryContactId";
    var req = new XMLHttpRequest();
    req.open("GET", oDataSelect, false);
    req.setRequestHeader("Accept", "application/json");
    req.setRequestHeader("Content-Type", "application/json;charset=utf-8");
    req.onreadystatechange = function () {
    if (req.readyState === 4) {
    if (req.status === 200) {
    var retrieved = JSON.parse(req.responseText).d;
    CustomerId = retrieved.PrimaryContactId.Id;
    else {
    alert(this.statusText);
    req.send();
    function CreateEmail() {
    GetOwnerID();
    email.Subject = "Email with Report Attachment";
    //Set The current order as the Regarding object
    email.RegardingObjectId = {
    Id: Xrm.Page.data.entity.getId(), //Get the current entity Id , here OrderId
    LogicalName: Xrm.Page.data.entity.getEntityName()//Get the current entity name, here it will be “salesOrder”
    //Create Email Activity
    SDK.JScriptRESTDataOperations.Create(email, "Email", EmailCallBack, function (error) { alert(error.message); });
    // Email Call Back function
    function EmailCallBack(result) {
    email = result; // Set the email to result to use it later in email attachment for retrieving activity Id
    var activityPartyFrom = new Object();
    // Set the From party of the ActivityParty to relate an entity with Email From field
    activityPartyFrom.PartyId = {
    Id: CustomerId, //"79EBDD26-FDBE-E311-8986-D89D6765B238", // id of entity you want to associate this activity with.
    LogicalName: "contact"
    // Set the "activity" of the ActivityParty
    activityPartyFrom.ActivityId = {
    Id: result.ActivityId,
    LogicalName: "email"
    // Now set the participation type that describes the role of the party on the activity).
    activityPartyFrom.ParticipationTypeMask = { Value: 2 }; // 2 means ToRecipients
    // Create the from ActivityParty for the email
    SDK.JScriptRESTDataOperations.Create(activityPartyFrom, "ActivityParty", ActivityPartyFromCallBack, function (error) { alert(error.message); });
    var activityPartyTo = new Object();
    // Set the From party of the ActivityParty to relate an entity with Email From field
    activityPartyTo.PartyId = {
    Id: ownerID, //"79EBDD26-FDBE-E311-8986-D89D6765B238", // id of entity you want to associate this activity with.
    LogicalName: "systemuser"
    // Set the "activity" of the ActivityParty
    activityPartyTo.ActivityId = {
    Id: result.ActivityId,
    LogicalName: "email"
    // Now set the participation type that describes the role of the party on the activity).
    activityPartyTo.ParticipationTypeMask = { Value: 1 }; // 1 means Sender
    // Create the from ActivityParty
    SDK.JScriptRESTDataOperations.Create(activityPartyTo, "ActivityParty", ActivityPartyToCallBack, function (error) { alert(error.message); });
    //ActivityParty From Callback
    function ActivityPartyFromCallBack(result) {
    //ActivityParty To Callback
    function ActivityPartyToCallBack(result) {
    GetReportId('Quotation');
    //Create attachment for the created email
    function CreateEmailAttachment() {
    //get reporting session and use the params to convert a report in PDF
    var params = getReportingSession();
    //Email attachment parameters
    var activitymimeattachment = Object();
    activitymimeattachment.ObjectId = Object();
    activitymimeattachment.ObjectId.LogicalName = "email";
    activitymimeattachment.ObjectId.Id = email.ActivityId;
    activitymimeattachment.ObjectTypeCode = "email",
    activitymimeattachment.Subject = "File Attachment";
    activitymimeattachment.Body = encodePdf(params);
    activitymimeattachment.FileName = "Report.pdf";
    activitymimeattachment.MimeType = "application/pdf";
    //Attachment call
    SDK.JScriptRESTDataOperations.Create(activitymimeattachment, "ActivityMimeAttachment", ActivityMimeAttachmentCallBack, function (error) { alert(error.message); });
    //ActivityMimeAttachment CallBack function
    function ActivityMimeAttachmentCallBack(result) {
    var features = "location=no,menubar=no,status=no,toolbar=no,resizable=yes";
    var width = "800px";
    var height = "600px";
    window.open(Xrm.Page.context.getServerUrl() + "main.aspx?etc=" + 4202 + "&pagetype=entityrecord&id=" + email.ActivityId, "_blank", features);
    // To open window which works in outlook and IE both
    //openStdWin(Xrm.Page.context.getServerUrl() + "main.aspx?etc=" + 4202 + "&pagetype=entityrecord&id=" + email.ActivityId, "_blank", width, height, features);
    //This method will get the reportId based on a report name that will be used in getReportingSession() function
    function GetReportId(reportName) {
    var oDataSetName = "ReportSet";
    var columns = "ReportId";
    var filter = "Name eq '" + reportName + "'";
    retrieveMultiple(oDataSetName, columns, filter, onSuccess);
    function retrieveMultiple(odataSetName, select, filter, successCallback) {
    var serverUrl = Xrm.Page.context.getServerUrl();
    var ODATA_ENDPOINT = "/XRMServices/2011/OrganizationData.svc";
    var odataUri = serverUrl + ODATA_ENDPOINT + "/" + odataSetName + "?";
    if (select) {
    odataUri += "$select=" + select + "&";
    if (filter) {
    odataUri += "$filter=" + filter;
    $.ajax({
    type: "GET",
    contentType: "application/json; charset=utf-8",
    datatype: "json",
    url: odataUri,
    beforeSend: function (XMLHttpRequest) {
    XMLHttpRequest.setRequestHeader("Accept", "application/json");
    success: function (data) {
    if (successCallback) {
    if (data && data.d && data.d.results) {
    successCallback(data.d.results);
    else if (data && data.d) {
    successCallback(data.d);
    else {
    successCallback(data);
    error: function (XmlHttpRequest, errorThrown) {
    if (XmlHttpRequest && XmlHttpRequest.responseText) {
    alert("Error while retrieval ; Error – " + XmlHttpRequest.responseText);
    function onSuccess(data) {
    reportId = data[0].ReportId.replace('{', ").replace('}', ");
    CreateEmailAttachment(); // Create Email Attachment
    //Gets the report contents
    function getReportingSession() {
    var pth = Xrm.Page.context.getServerUrl() + "/CRMReports/rsviewer/reportviewer.aspx";
    var retrieveEntityReq = new XMLHttpRequest();
    var Id = Xrm.Page.data.entity.getId();
    var quotationGUID = Id.replace('{', ""); //set this to selected quotation GUID
    quotationGUID = quotationGUID.replace('}', "");
    var reportName = "Quotation"; //set this to the report you are trying to download
    var reportID = "7C39D18F-1DC6-E311-8986-D89D6765B238"; //set this to the guid of the report you are trying to download
    var rptPathString = ""; //set this to the CRMF_Filtered parameter
    var strParameterXML = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'><entity name='quote'><all-attributes /><filter type='and'><condition attribute='quoteid' operator='eq' uitype='quote' value='" + quotationGUID + "' /> </filter></entity></fetch>";
    retrieveEntityReq.open("POST", pth, false);
    retrieveEntityReq.setRequestHeader("Accept", "*/*");
    retrieveEntityReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    rptPathString = "id=%7B" + reportID + "%7D&uniquename=" + Xrm.Page.context.getOrgUniqueName() + "&iscustomreport=true&reportnameonsrs=&reportName=" +
    reportName + "&isScheduledReport=false&p:CRMAF_Filteredquote=" + strParameterXML;
    //remove the part starting from &p:salesorderid if your report has no parameters
    retrieveEntityReq.send(rptPathString);
    var x = retrieveEntityReq.responseText.indexOf("ReportSession=");
    var ret = new Array();
    ret[0] = retrieveEntityReq.responseText.substr(x + 14, retrieveEntityReq.responseText.indexOf("&", x) - x - 14); //the session id
    x = retrieveEntityReq.responseText.indexOf("ControlID=");
    ret[1] = retrieveEntityReq.responseText.substr(x + 10, retrieveEntityReq.responseText.indexOf("&", x) - x - 10); //the control id
    return ret;
    var bdy = new Array();
    var bdyLen = 0;
    function concat2Bdy(x) {
    bdy[bdyLen] = x;
    bdyLen++;
    function encodePdf(params) {
    bdy = new Array();
    bdyLen = 0;
    var retrieveEntityReq = new XMLHttpRequest();
    var pth = Xrm.Page.context.getServerUrl() + "/Reserved.ReportViewerWebControl.axd?ReportSession=" + params[0] +
    "&Culture=1033&CultureOverrides=True&UICulture=1033&UICultureOverrides=True&ReportStack=1&ControlID=" + params[1] +
    "&OpType=Export&FileName=Public&ContentDisposition=OnlyHtmlInline&Format=PDF";
    retrieveEntityReq.open("GET", pth, false);
    retrieveEntityReq.setRequestHeader("Accept", "*/*");
    retrieveEntityReq.send();
    BinaryToArray(retrieveEntityReq.responseBody);
    return encode64(bdy);
    var StringMaker = function () {
    this.parts = [];
    this.length = 0;
    this.append = function (s) {
    this.parts.push(s);
    this.length += s.length;
    this.prepend = function (s) {
    this.parts.unshift(s);
    this.length += s.length;
    this.toString = function () {
    return this.parts.join('');
    var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
    function encode64(input) {
    var output = new StringMaker();
    var chr1, chr2, chr3;
    var enc1, enc2, enc3, enc4;
    var i = 0;
    while (i < input.length) {
    chr1 = input[i++];
    chr2 = input[i++];
    chr3 = input[i++];
    enc1 = chr1 >> 2;
    enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
    enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
    enc4 = chr3 & 63;
    if (isNaN(chr2)) {
    enc3 = enc4 = 64;
    } else if (isNaN(chr3)) {
    enc4 = 64;
    output.append(keyStr.charAt(enc1) + keyStr.charAt(enc2) + keyStr.charAt(enc3) + keyStr.charAt(enc4));
    return output.toString();
    </script>
    <script type="text/vbscript">
    Function BinaryToArray(Binary)
    Dim i
    ReDim byteArray(LenB(Binary))
    For i = 1 To LenB(Binary)
    byteArray(i-1) = AscB(MidB(Binary, i, 1))
    concat2Bdy(AscB(MidB(Binary, i, 1)))
    Next
    BinaryToArray = byteArray
    End Function
    </script>
    </head>
    <body>
    <input type="button" onclick="CreateEmail();" value="Attach Report" />
    </body>
    </html>
    Thank you,
    Mittal.

  • Follow up transaction in CRM

    Hi All,
    I want to create an Order in CRM with reference to the Standard Order (which is created in ECC and replicated from ECC to CRM).
    When I open the Transaction (which is created in ECC and replicated from ECC to CRM).
    in CRM and clikc on follow up I am not able to create the follow up transaction.
    The follow up transaction is in display mode.
    Can anybody give me inputs in this regard? where is wrong
    Will award the points for the helpful answer.
    Regards,
    -Rahul.

    Hi Shalini,
    The document is replicated from ECC to CRM without any errors.
    For this document I just want to create follow up transaction in CRM.(I dont want to change the document in CRM)
    The follow up transaction is in display mode. this is my problem.
    Hi Rekha:
    I have done following setting in CRM to create follow up transaction in CRM for the document which is replicated from ECC to CRM.
    1)     Defined the Copying Control for Transaction type
    2)     Defined Copying Control for Item categories
    3)     Defined Item category determination when copying
    Thanks in advance,
    Regards,
    -Rahul.

Maybe you are looking for

  • Purchase Order Delivery Date Vs. Actual delivery date

    I am trying to run a query with PO # and date with Delivery date against MIGO Delivery date. I am missing something here. When I join the tables EKPO,EKKO, EKBE. The results are getting duplicated. Could anyone help me ? In the selection field I choo

  • Forefront protection for exchange 2010 - updates?

    Installed Exchange EDGE server with Forefront Protection for Exchange 2010. Installed hotfix update rollup 4 for forefront (I think it's the latest because I haven't found any newer). We have basically left everything on default in forefront, and if

  • Critical Battery Suspends Incorrectly

    I'm using gnome-power-manager, and my computer suspends wonderfully. I'm not sure which method I'm using since I tried both and I cannot recall what I did on my last effort to get suspend/hibernate to work. However, after my laptop suspends for being

  • KP26 dump due to manual entry on Activity Type Category

    Hello, I keep receiving a dump RAISE_EXCEPTION program_error in the generated programs COCC2001... 03 etc. When I run transaction KP26 for a Cost Center that has no entries yet (with a custom layout), and when I supply or modify the value in column T

  • How to Transfer vids to Phone without Bluetooth or...

    How to Transfer vids to Phone without Bluetooth or Connector?? Don't tell me to go buy a connector and don't ask me why not. I just want to know how to do it without those two.