Skip to Content
Technical Articles
Author's profile photo Vincent Zhu

SAP S/4HANA Cloud, public edition, ABAP Environment Case 6: BOM Batch Extraction

This is a detailed step-by-step technical guide document to introduce a Developer Extensibility case followed by this blog.


1. Case Background:

There are some customers who require to see the BOM all level data, and they would also request to download the BOM all level data in batch. We do have standard App “Display BOM level by level” which can see/download the BOM all level data for single material. But there is no such app can view the same data for multiple materials.


standard App Display BOM level by level can only view the data for single Material


With developer extensibility, we have built a custom app which allow to select multiple materials, and view/download all nodes level data for the selected materials.


BOM Batch Extraction


2. Backend Service Development:

2.1 Create Data Definition

Create new data definition: Z_BOM_BATCH_EXTRACTION



2.2 Create Query Implementation Class

Create the class ZCL_BOM_DISPLAY. The class contains the detailed logic for data query.



METHOD get_bom_hierarchy.

*get BOM Link and BOM hierarchy based on condition
    SELECT *
    FROM I_BOMComponentWithKeyDate( p_keydate = @rp_keydate ) AS Bom
    JOIN I_MaterialBOMLink AS Bomlink
      ON Bom~BillOfMaterialCategory = Bomlink~BillOfMaterialCategory
     AND Bom~BillOfMaterialVariant = Bomlink~BillOfMaterialVariant
     AND Bom~BillOfMaterial = Bomlink~BillOfMaterial
    WHERE Bomlink~BillOfMaterialCategory = 'M'
    AND Bomlink~BillOfMaterialVariant = '01'
    AND Bomlink~Material IN @rt_material
    AND Bomlink~Plant IN @rt_plant
    INTO TABLE @DATA(lt_BOMlist).

    IF sy-subrc = 0.
      rv_resp = abap_true.
      CLEAR pt_materialhierarchy.
    LOOP AT lt_BOMlist ASSIGNING FIELD-SYMBOL(<lfs_bomlist>).
      MOVE-CORRESPONDING <lfs_bomlist>-bomlink TO ps_response.
      MOVE-CORRESPONDING <lfs_bomlist>-bom TO ps_response.

      "Get product descrption saperatelly since CDS view does not have it.
      SELECT SINGLE ProductName FROM I_producttext
      WHERE Product = @ps_response-material AND Language = @sy-langu INTO @ps_response-materialDesc.

      APPEND ps_response TO pt_response.
      CLEAR ps_response.

      ps_material-sign = 'I'.
      ps_material-option = 'EQ'.
      ps_material-low = <lfs_bomlist>-bom-BillOfMaterialComponent.
      APPEND ps_material TO pt_materialhierarchy.
      CLEAR ps_material.



2.3 Create Service Definition and Service Binding

Create Service Definition


Create Service Binding


And we can preview the service like below:


3. Frontend App Development

First, Configure the destination on BTP.

Then, open the SAP Business Application Studio service:


Choose List Report Page template from Application Generator:


Deploy the app to SAP S/4HANA cloud system:


Copy Launchpad App Description Item Name to IAM App:


With the new app, we can not only select multiple materials to view the BOM nodes level data, but also can download the data into Excel file.



More Information on SAP S/4HANA Cloud, Public Edition:

  • SAP S/4HANA Cloud, public edition, release info here
  • Latest SAP S/4HANA Cloud, public edition, release blog posts here and previous release highlights here
  • Product videos on our SAP S/4HANA Cloud, public edition and SAP S/4HANA YouTube playlist
  • SAP S/4HANA PSCC Digital Enablement Wheel here
  • Early Release Webinar Series here
  • Inside SAP S/4HANA Podcast here
  • openSAP Microlearnings for SAP S/4HANA here
  • Best practices for SAP S/4HANA Cloud, public edition, here
  • SAP S/4HANA Cloud, public edition, Community: here
  • Feature Scope Description here
  • What’s New here
  • Help Portal Product Page here
  • SAP S/4HANA Cloud ABAP Environment Community here

Follow us via @SAP and #S4HANA or follow Vincent Zhu

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Claudio Mendes
      Claudio Mendes

      Thanks for this blog.

      Can you, please, add the code for the TYPE z_bom_display used on the class, and can you please add the rest of code for the class ZCL_BOM_DISPLAY?

      Author's profile photo Vincent Zhu
      Vincent Zhu
      Blog Post Author
      define custom entity Z_BOM_DISPLAY
       with parameters 
      //    @Environment.systemField: #SYSTEM_DATE
      //    @UI.lineItem :[{label:'Material',position:10,importance: #HIGH }]
           P_KeyDate : vdm_v_key_date
          @UI.lineItem :[{label:'Material',position:10,importance: #HIGH }]
          @UI.selectionField: [{ position: 20 }]
      //    @Consumption.valueHelpDefinition: [{ entity: {name:'I_ProductStdVH' ,element: 'Product' } }]
          @Consumption.valueHelpDefinition: [{ entity: {name:'I_ProductPlantStdVH' ,element: 'Product' } }]    
          @Consumption.valueHelpDefinition: [{additionalBinding: [{ element: 'Plant', localElement: 'Plant' }]}]  
          @Consumption.filter:{mandatory: true}
        key Material                     : matnr;
          @UI.lineItem :[{label:'Plant', position:90, importance: #HIGH }]
          @UI.selectionField: [{ position: 10 }]
          @Consumption.valueHelpDefinition: [{ entity: {name:'I_PlantStdVH' ,element: 'Plant' } }] 
          @Consumption.filter:{mandatory: true}
      //    @Consumption.defaultValue: '1310'  
        key Plant                        : werks_d; 
          @UI.hidden: true    
        key BillOfMaterialCategory      : abap.char(1);       
      //    @UI.selectionField: [{ position: 50 }]       
          @UI.hidden: true                         
        key Billofmaterial               : abap.char(8);
      //    @UI.selectionField: [{ position: 60 }]       
          @UI.hidden: true  
        key Billofmaterialvariant        : abap.char(2);     
          @UI.hidden: true  
        key Billofmaterialitemnodenumber : abap.numc(8);
        @UI.lineItem :[{label:'MaterialDesc',position:20,importance: #HIGH  }]
        MaterialDesc                 : abap.char(40); 
        @UI.lineItem :[{label:'ValidityStartdate',position:100,importance: #HIGH  }]
        Validitystartdate            : abap.dats;
        @UI.lineItem :[{label:'ValidityEnddate',position:110,importance: #HIGH }]
        Validityenddate              : abap.dats;
        @UI.lineItem :[{label:'Component',position:50,importance: #HIGH  }]
        Billofmaterialcomponent      : matnr;
        @UI.lineItem :[{label:'ComponentDesc',position:60,importance: #HIGH  }]
      //  BillofmaterialcomponentDesc  : abap.char(40);  
        ComponentDescription      : abap.char(40);    
        @UI.lineItem :[{label:'ItemCategory',position:30,importance: #HIGH  }]
        Billofmaterialitemcategory   : abap.char(1);
        @UI.lineItem :[{label:'ItemNumber ',position:40,importance: #HIGH  }]
        Billofmaterialitemnumber     : abap.char(4);
        @UI.lineItem :[{label:'ItemUnit',position:80,importance: #HIGH  }]
      //  @Semantics.unitOfMeasure
        Billofmaterialitemunit       : meins;
      //  Billofmaterialitemunit       : abap.unit(3);  
        @UI.lineItem :[{label:'ItemQuantity',position:70,importance: #HIGH  }]
      //  @Semantics.quantity.unitOfMeasure : 'billofmaterialitemunit'
        Billofmaterialitemquantity   : abap.numc(13); 
      //   Billofmaterialitemquantity   : abap.quan(13,3); 
          @UI.hidden: true  
        Identifierbomitem            : abap.char(8);
      Author's profile photo Claudio Mendes
      Claudio Mendes

      Thanks Vincent.

      Can you please, also share the full code of the class ZCL_BOM_DISPLAY?