cancel
Showing results for 
Search instead for 
Did you mean: 

Data extract from MARA, MARC with Procurment type -

0 Kudos

Dear SAP Experts,

I have a requirement to have a data extract fro belwo requirment. It would be great if you can help me how can I get it as I am not able to think much on this.

We need an extract of FERT-Materials with procurement type F which having Total shelf life maintained (You can . These FERT material should be with procurement type F in all plants i.e should not have been extended to any plant with procurement type E. I have tried with Making Query with table joinn MARA, MARC and different other options but cant get the desired results.

I will be very thankful if you can let me know how can I make this extract.

Regards,

Rohit

FredericGirod
Active Contributor

Lets read little bit about JOIN in SQL statement

https://pawelwiejkut.dev/posts/sql-on-join-conditions/

Accepted Solutions (0)

Answers (1)

Answers (1)

raju_alankar
Participant
0 Kudos

To extract the FERT materials with procurement type F that have a total shelf life maintained, you can use the following steps:

  1. Join Tables: You can join the Material Master (MARA) table with the Material Plant (MARC) table and the Material Valuation (MBEW) table.

  2. Filter Criteria: In the MARA table, filter for the procurement type F. In the MARC table, filter for the total shelf life maintained. In the MBEW table, filter for procurement type F in all plants, ensuring that the material is not extended to any plant with procurement type E.

  3. Extract Data: You can extract the relevant data, such as the material number, material description, total shelf life, procurement type, and plant, into an Excel or other desired format.

REPORT z_fert_materials.

TABLES: mara, marc, mbew.

DATA: lt_mara TYPE TABLE OF mara,
      lt_marc TYPE TABLE OF marc,
      lt_mbew TYPE TABLE OF mbew.

SELECT-OPTIONS: so_matnr FOR mara-matnr,
                 so_werks FOR marc-werks.

SELECT *
FROM mara
INTO TABLE lt_mara
WHERE ekgrp = 'F'.

SELECT *
FROM marc
INTO TABLE lt_marc
WHERE vstel IS NOT INITIAL.

SELECT *
FROM mbew
INTO TABLE lt_mbew
WHERE ekgrp = 'F'.

LOOP AT lt_mara.

  LOOP AT lt_marc.

    IF lt_marc-matnr = lt_mara-matnr.

      LOOP AT lt_mbew.

        IF lt_mbew-matnr = lt_mara-matnr AND lt_mbew-werks = lt_marc-werks.

          WRITE:/ lt_mara-matnr, lt_mara-maktx, lt_marc-vstel, lt_mara-ekgrp.
          BREAK.

        ENDIF.

      ENDLOOP.

    ENDIF.

  ENDLOOP.

ENDLOOP.