Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Cloud for Customer Integration with ERP – create and replicate an enhancement field in sales order

Tags: field

In this Blog, I am going to describe step by step how to add an extension Field to the Sales order in ERP and send this extension to Cloud for Customer. This will also include the way back – sending the field from Cloud for Customer to ERP.

Requiered steps on ERP side

Add the enhancement field to the Sales Order Screen

  1. The first step I am doing is to create a new text field as append to table VBAK. This is the field which will contain the data for my replication scenario. In my parallel Blog  I am describing in detail how to create an append for customer master table KNA1 – just to the same steps for table KNA1. On the screenshot below you can see my field.
  2. This field should be made available on a sales order screen. In the SD Sales order, there are is a tab Additional Data B on header level – this is reserved for custom own fields. And that’s where I am putting my field now.The respective Screen for this Tab is number 8309 in program SAPMV45A. Open the screen layout (through transaction SE80 or SE54). And add the Input/Output-Field which should point to your Append in VBAK (e.g. NAME is the field of the Append field). Save and activate the screen changes.
  3. Then navigate to the flow logic tab of the screen 8309 and add a new Module in the PBO logic.I added the new MODULE field_attribute. See my coding for this Module below.
    MODULE field_attribute OUTPUT.
     if t180-trtyp eq 'A'.
    loop at screen.
      if screen-name = 'VBAK-ZZC4CINFO'.
        screen-input = 0.
        MODIFY SCREEN.
       endif.
       endloop.
     else.
      loop at screen.
      if screen-name = 'VBAK-ZZC4CINFO'.
        screen-input = 1.
    
        MODIFY SCREEN.
       endif.
       endloop.
       endif.
    
    
    ENDMODULE.
    

    What I do in this coding is just to have the field ready for input in create and change mode (e.g. transaction VA01 and VA02). In display mode (e.g. transaction VA03) the field should not be ready for input.

That’s all the logic which is needed for the sales order itself. Since the field points to the append in table VBAK, the application logic will handle that values entered for the field on the screen and it will be saved/changed on the database.

Add the content of the enhancement field to the IDOC beeing sent to C4C

  1. My first idea to add the custom own field to the IDOC beeing send to C4C to create an IDOC extension for the respective IDOC, like I did in my parallel BLOGBLOGBLOG.But I soon figured out that this is not possible for the Sales Order IDOC, since this IDOC got generated from a BAPI. Due to this, the correct way to enhance the IDOC is to use the BAPI extensions. How to do this is described in detail in note 143580. Based on this note, as we deal with an enhancement on structure VBAK, the following structures need to be enhanced:
    1. VBAKKOZ (add your enhancement field as an append, as done in the begging for table VBAK)
    2. VBAKKOZX (add your enhancement field as append, but only as  character field length 1. This structure will control whether or not the field should be updated, it will only contain values ‘X’ or blank).
    3. BAPE_VBAK (add your enhancement field as an append)
    4. BAPE_VBAKX (add your enhancement field as append, but only as  character field length 1. This structure will control whether or not the field should be updated, it will only contain values ‘X’ or blank)

Through this enhancement, the value in the extension field will be automatically put in the IDOC. But these data have a special structure. SAP Note 143580 describes this as well with an example.

As an example, that’s how the IDOC content looks when I put the text DemoC4C in the text field:

This data is being sent to C4C. But in C4C, I only want the content of the field itself (e.g. DemoC4C without 000000036). The challenge is how to get these data in the right format for C4C. I did not find a BADI on ERP side with which I could cut the content. Maybe there is one, but I managed to solve this with an offset rule in the iFLOW in HCI. I will describe in a later step how we managed this complex offset rule. Before, I am going to describe the steps executed on C4C side.

Required steps on C4C and HCI side

  1. First step is to add this field in the sales order on C4C side. To do so, go to the Sales Orders Work center and open one sales order. In the menu choose ‘Adapt->Edit Master Layout’.
    1. Place the cursor where you want to add this field and choose ‘Add Field’. In the pop-up which opens, choose ‘New Field’ and create the field as required (see my screenshot on the data I used. Press Save.
    2. Now this field must be added to the service definition. Press the change properties symbol on this new field and choose Field Definition.
    3. Now this field must be added to the service definition. Press the change properties symbol on this new field and choose Field Definition.
    4. In the window which gets opened, choose Tab Services. The Service where this field should be added is CustomerOrderRepliacationIn. Press the button ‘Add field’ in the Action column. Then save the changes. Now this field is added to service.
    5. This new service definition should now be uploaded to HCI. To do so, you must download it from the communication scenario.The communication scenario from which to download is Sales Order Replication to SAP Business Suite, the service is Replicate Sales Order to SAP Business Suite. Please see this blog which desccribes how to do so https://blogs.sap.com/2013/12/12/guide-how-to-download-wsdl-and-api-documentation-of-a-business-object/
    6. Logon to your HCI account and choose package SAP Hybris Cloud for Customer Integration with SAP ERP.
    7. Click on Replicate Sales Order and Sales Quote from SAP Business Suite. Select Mapping and click on the Resource name. Within the Mapping on the right side you need to upload the WSDL downloaded in the previous step.Then change the Mapping to link field STRUCTURE and VALUEPART1 in segment E101BAPIPAREX with field ExtERPText.Then create a mapping expression, to extract the value entered in the field on ERP side from the special structure of this BAPI field.See the screenshot how mapping looks.

 

This mapping rule does the following:

If field „STRUCTURE“ in segment “E101BAPIPAREX” of the ERP IDoc contains the string “BAPE_VBAK” the extension field “ExtERPText” in C4C will be filled based on the following condition:

If field “VALUEPART1” has more than 10 characters, the first 10 characters are cut off and the remaining characters are mapped to the field “ExtERPText” in C4C.

If field “VALUEPART1” has 10 characters or less, an empty string is mapped to the field “ExtERPText” in C4C

  1. For the other direction Cloud for Customer to ERP also the changed WSDL definition must be downloaded from Cloud for Customer and uploaded to HCI.
  2. The field must be added as in the previous step here also in the outbound request Sales Order Request – General. See my screenshot on the fields added to the service.
  3. To download it, the respective Communication Arrangement is Sales Order Replication to SAP Business Suite.
  4. Select Mapping and click on the Resource name. Within the Mapping, on the left side upload the WSDL definition you downloaded previously from Cloud for Customer.
    1. For this direction, I did the Mapping without any additional rule. I just mapped the custom own field to VALUEPART1 of E1BPPAREX. Putting the data in a right format to be handled by the BAPI on ERP side I will do with an ERP BADI in the next step.

Implement a Mapping BADI on ERP side

  1. To get the data coming from C4C in the enhancment field in the correct format which can be handled by the ERP BAPI to create/change the sales order I implemented enhancement spot COD_SLS_SE_SPOT_SALESORDER.

That’s my coding for the mentioned enhancment spot:

METHOD if_cod_sls_se_salesorder_repl~adjust_import_data.
    DATA: ls_extension TYPE bapiparex.
    TYPES: BEGIN OF zfield,
             vbeln TYPE vbak-vbeln,
             info  TYPE vbak-zzc4cinfo,
           END OF zfield.

    TYPES: BEGIN OF zfieldx,
             vbeln TYPE vbak-vbeln,
             info  TYPE char1,
           END OF zfieldx.

    DATA: ls_zfield TYPE zfield.
    DATA: ls_zfieldx TYPE zfieldx.


    LOOP AT ct_order_extensions INTO ls_extension.
      IF ls_extension-structure EQ 'BAPE_VBAK' AND ls_extension-valuepart1 IS NOT INITIAL.
        ls_zfield-vbeln = iv_salesdocument.
        ls_zfield-info = ls_extension-valuepart1.
        CLEAR ls_extension-valuepart1 .
        ls_extension-valuepart1 = ls_zfield.

        MODIFY ct_order_extensions FROM ls_extension.
        CLEAR ls_extension-valuepart1.
        ls_zfieldx-vbeln = iv_salesdocument.
        ls_zfieldx-info = 'X'.
        ls_extension-structure = 'BAPE_VBAKX'.
        ls_extension-valuepart1 = ls_zfieldx.
        APPEND ls_extension TO ct_order_extensions.
        EXIT.

     ELSEIF ls_extension-structure EQ 'BAPE_VBAK' AND ls_extension-valuepart1 IS INITIAL.
        CLEAR ls_extension.
        MODIFY ct_order_extensions FROM ls_extension.
      ENDIF.
    ENDLOOP.


  ENDMETHOD.

This coding basically brings the value of the enhancement field in the format which is explained by the mentioned note 143580.

That’s it – with those steps you should be able to replicate custom own fields in the sales order bidirectional.



This post first appeared on Web Service Testing A Blackjack GUI And API, please read the originial post: here

Share the post

Cloud for Customer Integration with ERP – create and replicate an enhancement field in sales order

×

Subscribe to Web Service Testing A Blackjack Gui And Api

Get updates delivered right to your inbox!

Thank you for your subscription

×