Developer ToolsFree generatorPDF, Excel, Word exportSAP S/4HANA

SAP Configurable Material Selection ABAP Generator

Consultants constantly need to know which materials are configurable, in which plants. This generator creates a plain ABAP report based on MARA and MARC that lists configurable materials, and a second snippet that links to sales order items carrying a configuration.

Fill in

Customer namespace name for the report.

KMAT is the standard type for configurable materials.

Generated code
Download:

Report

REPORT ZVC_CONF_MATERIALS.

TYPES: BEGIN OF ty_conf,
         matnr TYPE mara-matnr,
         mtart TYPE mara-mtart,
         werks TYPE marc-werks,
         kzkfg TYPE marc-kzkfg,
       END OF ty_conf.

DATA: lt_conf TYPE STANDARD TABLE OF ty_conf,
      ls_conf TYPE ty_conf.

PARAMETERS: p_werks TYPE marc-werks DEFAULT '1000',
            p_mtart TYPE mara-mtart DEFAULT 'KMAT'.

START-OF-SELECTION.

  SELECT mara~matnr mara~mtart marc~werks marc~kzkfg
    FROM mara
    INNER JOIN marc ON marc~matnr = mara~matnr
    INTO TABLE lt_conf UP TO 500 ROWS
    WHERE marc~werks = p_werks
      AND mara~mtart = p_mtart
      AND marc~kzkfg = 'X'.

  IF sy-subrc <> 0.
    WRITE: / 'No configurable materials found.'.
    RETURN.
  ENDIF.

  LOOP AT lt_conf INTO ls_conf.
    WRITE: / ls_conf-matnr, ls_conf-mtart, ls_conf-werks.
  ENDLOOP.

  WRITE: / 'Count:', lines( lt_conf ).

Optional: link to sales order items

* VBAP-CUOBJ holds the configuration (internal object number) of the item.
* Use it to find sales order items that carry a configuration.
SELECT vbeln posnr matnr cuobj
  FROM vbap
  INTO TABLE @DATA(lt_items)
  UP TO 500 ROWS
  WHERE werks = @p_werks
    AND cuobj <> 0.

Verify field names and that MARC-KZKFG (configurable material indicator) exists in your release. Table access in S/4HANA may be affected by custom code checks. The inline declarations in the second block need ABAP 7.40 or later with the @ escape style, so do not mix it with the first block's older style without checking your syntax mode. Test in a sandbox client first.

ABAP report review

Optional review of custom reports against released APIs and S/4HANA custom code checks.

Optional. The tool and every export work without this. No spam.

How to use it

Enter a report name in your customer namespace, the plant, the material type (KMAT is the standard type for configurable materials) and a maximum number of rows. Copy the result into SE38, activate it, and run with a plant. Review the output and adapt the field list for your needs.

  • Use a customer namespace such as Z or Y
  • Keep UP TO ROWS in place when testing
  • Extend the select with MAKT for descriptions

What the code reads

MARA holds general material data including the material type, while MARC holds plant data. The indicator KZKFG in MARC marks a material as configurable in that plant. A join between the two gives the list. The second snippet reads sales order items from VBAP, where the field CUOBJ holds the internal object number of the configuration, which is non-zero for configured items.

Extending the report

To see the characteristic values of a configuration you would read the configuration data through the standard function modules or classes rather than selecting from tables yourself. For a broader inventory you can add the BOM usage and routing assignments, or join to the class assignment. In S/4HANA, check the relevant CDS views and released APIs before reading tables directly in new development.

Common mistakes

Selecting without a plant filter is slow on large systems, and joining on a missing key causes duplicates. Make sure the report is authorized with an authority check if you roll it out to users, and avoid putting such a report into a productive client without review.

  • No plant restriction
  • Missing authority checks
  • Reading VC data from tables instead of released APIs

Frequently Asked Questions

What does KZKFG mean?

KZKFG in table MARC is the indicator that marks a material as configurable at plant level. A value of X means variant configuration is allowed for that material in that plant.

Which material type is used for configurable materials?

KMAT is the standard material type for configurable materials, though many companies use FERT or a custom type with the configurable flag. Change the parameter to match your system.

Is it safe to select directly from MARA and MARC?

It is fine for a reporting utility in a sandbox. For production use and S/4HANA custom code, prefer released CDS views or APIs and add authority checks.

How do I read the characteristic values of an item?

Use the standard configuration interfaces rather than the underlying tables. The CUOBJ link identifies the configuration, but the values are stored in a structure that is best read through supported function modules or APIs.

Netray can help build and review custom reports like this and connect them to a natural language layer over your ERP data.