Skip to Content

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 execute the same steps for table VBAK. 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 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.
      loop at screen.
      if screen-name = 'VBAK-ZZC4CINFO'.
        screen-input = 1.

    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 blog.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. When working with the enhancement options of BAPIs, please consider also the BAPI programming guide and BAPI user guide.

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.

Outlook – more than one extension field in BAPIPAREX for the same database table

In case you have more than one extension field for the same table the values will be concatenated in fields VALUEPART1-VALUEPART4 in the BAPIPAREX structure. It will always be in the order of how the fields are appeneded to the database table and with the same length as the extension fields are definied.

So let’s take as example again sales order header table VBAK:

Besides our field ZZC4CINFO which has length 20, I add two more fields one ZDATE (length 8) and one ZABC (length 5) in this order.

I would put the following values to these fields


ZDATE: 08052018


With these data VALUEPART1 would be filled like this (assuming the order number is again 36):

VALUEPART1:  0000000036DEMO                08052018BLABLA

You have blanks between DEMO and the date, as the DEMO field is defined with a length of 20 characters and this used.

In case the extension fields length exceeds in total 240 characters, variable VALUEPART2 would be filled next.

For this more extension field scenario, you would then also need to enhance the Mapping logic in HCI (which is described for the one field scenario in a later step) to consider this.

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.
  2. 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 from SAP Business Suite, the service is Replicate Sales Order to SAP Business Suite. Please see this blog which desccribes how to do so
    1. Logon to your HCI account and choose package SAP Hybris Cloud for Customer Integration with SAP ERP.
    2. 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

Download WSDL for direction Cloud for Customer to ERP and upload to HCI
  1. 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.
  2. To download it, the respective Communication Arrangement is Sales Order Replication to SAP Business Suite.
  3. Logon to your HCI account and choose package SAP Hybris Cloud for Customer Integration with SAP ERP. Click on Create Sales Quote Follow Up Document in SAP Business Suite on navigate to the Mapping.
  4. 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 complex rule. I just mapped the custom own field to VALUEPART1 of E1BPPAREX (see screenshot). Additionally for field STRUCTURE and @SEGMENT of E1BPPAREX a constant has to be defined. The constant for STRUCTURE is ‘BAPE_VBAK’ and for @SEGEMENT is 1.  Putting the data then in a right format for the ERP sales order is then to be handled by a BAPI on ERP side. I will describe this in a 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.

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


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.









To report this post you need to login first.

1 Comment

You must be Logged on to comment or reply to a post.

Leave a Reply