ERPClimb logoERPClimb

Code examples · Modern ABAP · Beginner

Material master: join MARA and MAKT to list materials with their description

The problem

A planner wants a short list of finished products with the material number, the description and the base unit.

How we solve it

  1. 1The two tablesMARA and MAKT
  2. 2Joinnumber and language
  3. 3Keep gapsleft outer join
  4. 4Printloop

The result

Five finished products with number, description and base unit.

SAP objects in play

Overview drawn by ERPClimb from this example. The steps are the same as in the code below.

1. The requirement

A planner wants a short list of finished products with the material number, the description and the base unit. The description is not stored with the material itself, so the program must find it in another table and show it in the language of the user.

2. How we design it

SAP separates the data of an object from its texts. MARA holds one row per material (type, unit, group). MAKT holds the descriptions, one row per material and language. To show them together we JOIN the two tables on the material number and add the language to the join condition, so we get exactly one description per material. Then we filter for finished products and print a few rows.

Why we decided it this way

  1. 1Inner join on the material numberThe material number is the key that both tables share. The join puts the description next to the material.
  2. 2The language in the join, not in the WHEREThe language belongs to the question 'which text row matches', so it sits in the ON condition.
  3. 3Material type FERT in the WHEREFERT stands for finished product. Filtering in the database means only matching rows travel to the program.

Before you start

  • A system with sample materials. Look at them first in transaction MM03 or in SE16N (tables MARA and MAKT).
  • ADT and a package such as $TMP.

3. The code, step by step

Step 1 of 4: Know the two tables

A runnable class and a clear idea of which field comes from which table.

ABAP · Class · ZCL_MATERIAL_LIST (frame)
" Class frame
CLASS zcl_material_list DEFINITION PUBLIC FINAL CREATE PUBLIC.
  PUBLIC SECTION.
    INTERFACES if_oo_adt_classrun.
ENDCLASS.

CLASS zcl_material_list IMPLEMENTATION.
  METHOD if_oo_adt_classrun~main.
Part by part (plain text)
  1. Class frame. The standard frame of a runnable class. Nothing about materials yet: the next step asks the database.

Open in the portal

The SAP objects named in this code are linked in the code above and listed here. Each opens its page in the SAP Library.

SAP tables

4. The final outcome

Five finished products with number, description and base unit.

What you should see

Example output (your system has other data): 5 materials read, 2 without a description in your language FG-100 Bicycle frame (ST) FG-101 Bicycle wheel (ST) FG-200 Helmet size M (ST)

Try it and check the result

  • Run with F9. The console shows up to five finished products.
  • Change 'FERT' to 'ROH' (raw material) and run again: you see raw materials instead.
  • Open MARA and MAKT in SE16N for one of the printed materials: the unit comes from MARA and the description from MAKT.
  • Compare the first line with the list: materials that appear only in the left outer join have no text in your logon language. Add the missing text in MM02 (Additional data > Descriptions) and run again.

Common mistakes

  • A material without a text in your language disappears from an inner join. Use LEFT OUTER JOIN if the material must still be listed.
  • Always include the language in the join. Without it the same material appears once per language.
  • MARA is large. Never select from it without a WHERE condition or UP TO n ROWS.

Keep learning

Checking status: Reviewed line by line against SAP documentation. Not executed on a live system. Reviewed 2026-11-25. Release: SAP S/4HANA or ECC system (for example an S/4HANA trial appliance from SAP Cloud Appliance Library). The ABAP trial images do not contain these tables. Not released for ABAP Cloud.

Original ERPClimb teaching code with illustrative names. Not taken from a customer system. Syntax can differ by release; check the references below and activate in a sandbox first. ERPClimb is independent of SAP SE.