Quantcast
Channel: SCN : Unanswered Discussions - ABAP Development
Viewing all articles
Browse latest Browse all 8768

Report linking MARA to PIRs to Source Lists

$
0
0

I have a requirement to build an ABAP report linking four tables (MARA, EINE & EINA, EORD)

 

The goal of the report is to left join the Purchase Info Data (EINA & EINE) to the Material Master table (MARA) - this will show all the Materials which do not have a PIR

 

Once this has been established I want to link the Purchase Info Data to EORD (source list table) to highlight the materials which do not have a source list.

 

 

The way im trying to do this is by having 2 subroutines in my code:

  • read_values (step1)
  • prepare_output (step 2)

 

Step 1: Select all the data from the material master (MARA) and link the Purchase Info Data

 

Step 2: Loop through the existing code and add in the selected fields from the EORD table if there is a match

 

My code is below...

 

My question would be what is the best way to select and populate the EORD data in my grid. Is it efficient to loop through the internal table and add in the data line by line?

 

Any help would be greatly appreciated.

 

Thanks

 

 

REPORT  ZPIR_SOURCELIST.

 

 

 

 

*&---------------------------------------------------------------------*

*&      Data Declarations

*&---------------------------------------------------------------------*

TABLES : zvpir, " View with EINE & ENIA (Purchase Info Records)

         mara,  " Material Master

         eord.  " Purchasing Source List

 

 

 

 

DATA: BEGIN OF wa_pir_data,

 

 

          matnr  LIKE mara-matnr,    " Material

          infnr  LIKE eina-infnr,    " Purchase Info Record

          matkl  LIKE eina-matkl,    " Material Group

          lifnr  LIKE eina-lifnr,    " Vendor

          ekorg  LIKE eine-ekorg,    " Purchasing Org

          erdat  LIKE eina-erdat,    " Valid from

          ernam  LIKE eina-ernam,    " Created by

          urzzt  LIKE eina-urzzt,    " Re-order point

          werks  LIKE eine-werks,    " Plant

          loekz  LIKE eine-loekz,    " Deletion flag

          abskz  LIKE eine-abskz,    " Rejection indicator

          netpr  LIKE eine-netpr,    " Net price

          peinh  LIKE eine-peinh,    " Price Unit

          prdat  LIKE eine-prdat,    " Valid to

          flifn  LIKE eord-flifn,    " Fixed vendor

          autet  LIKE eord-autet,    " MRP

          vdatu  LIKE eord-vdatu,    " Valid from (eord)

          bdatu  LIKE eord-bdatu,    " Valid to (eord)

          test   LIKE eord-ernam.    " Test EORD

 

 

DATA: END OF wa_pir_data.

 

 

DATA it_pir_data LIKE TABLE OF wa_pir_data.

*DATA: it_pir_data TYPE STANDARD TABLE OF it_pir_data1.

 

 

 

 

DATA date TYPE d.

 

 

date = sy-datum.

 

 

 

 

 

 

*&---------------------------------------------------------------------*

*&      SELECTION CRITERIA

*&---------------------------------------------------------------------*

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.

 

 

SELECT-OPTIONS:

   s_ekorg FOR wa_pir_data-ekorg,              " Purchasing Org

   s_werks FOR wa_pir_data-werks,              " Plant

   s_abskz FOR wa_pir_data-abskz,              " Rejection Indicator

   s_loekz FOR wa_pir_data-loekz,              " Deletion Flag

   s_infnr FOR wa_pir_data-lifnr,              " Purchase Info Record

   s_matnr FOR wa_pir_data-matnr,              " Material

   s_lifnr FOR wa_pir_data-lifnr,              " Vendor

   s_erdat FOR wa_pir_data-erdat,              " Valid from

   s_ernam FOR wa_pir_data-ernam.              " Created by

 

 

SELECTION-SCREEN END OF BLOCK b1.

 

 

 

 

*&---------------------------------------------------------------------*

*&      INITIALIZATION

*&---------------------------------------------------------------------*

 

 

INITIALIZATION.

 

 

*&---------------------------------------------------------------------*

*&      START OF SELECTION

*&---------------------------------------------------------------------*

 

 

START-OF-SELECTION.

 

 

  PERFORM read_values.

 

 

  PERFORM prepare_output.

 

 

*&---------------------------------------------------------------------*

*&      END OF SELECTION

*&---------------------------------------------------------------------*

END-OF-SELECTION.

 

 

  PERFORM write_alv.

 

 

*&---------------------------------------------------------------------*

*&      Form  READ_VALUES

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

 

 

FORM read_values.

 

 

  SELECT mara~matnr  zvpir~infnr  zvpir~matkl  zvpir~lifnr  zvpir~erdat

         zvpir~ernam  zvpir~urzzt  zvpir~werks  zvpir~loekz  zvpir~abskz

         zvpir~netpr  zvpir~peinh  zvpir~prdat  zvpir~ekorg

  FROM mara LEFT JOIN zvpir ON zvpir~matnr EQ mara~matnr

    INTO CORRESPONDING FIELDS OF TABLE it_pir_data

    WHERE mara~matnr IN s_matnr.

 

 

 

 

 

 

ENDFORM.                    "READ_VALUES.

 

 

 

 

*&---------------------------------------------------------------------*

*&      Form  PREPARE_OUTPUT

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

 

 

FORM prepare_output.

 

 

  LOOP AT it_pir_data INTO wa_pir_data.

 

 

 

 

    SELECT SINGLE eord~flifn eord~autet eord~vdatu  eord~bdatu  eord~ernam

       FROM eord LEFT JOIN zvpir ON ( eord~matnr EQ zvpir~matnr )

    INTO (wa_pir_data-flifn, wa_pir_data-autet, wa_pir_data-vdatu,

          wa_pir_data-bdatu, wa_pir_data-test)

    WHERE eord~matnr EQ wa_pir_data-matnr

     AND eord~werks EQ wa_pir_data-werks.

 

 

 

 

  ENDLOOP.

 

 

ENDFORM.                    " PREPARE_OUTPUT


Viewing all articles
Browse latest Browse all 8768

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>