Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

ABAP report - Check Po items Material group

Former Member
0 Kudos

Hi All,

I would like in my abap report to check efficiently each line item in the Purchase order and make sure each line item should have the same material group.

Any ideas appreciated.

Meghna

3 REPLIES 3

former_member215870
Participant
0 Kudos

You can gather all the PO items from the table EKPO into a STANDARD TABLE like the the EKPO. For each line of the table LT_EKPO you will searching into the MARA (MARA-MATNR = EKPO-MATNR) and you will collect the MARA-MATKL into an internal table that will have only one field, the Material Group. At the end you will check how many lines has the internal table. Becouse you wil you the COLLECT instead of APPEND, if the PO has only one Material Group then this table should have only one line.

Check the following code (it has been written by hard)

With Regards

George

-


TABLES: MARA, EKPO.

TYPES: BEGIN OF TY_GROUP,

MATKL LIKE MARA-MATKL,

END OF TY_GROUP.

DATA: lt_group TYPE STANDARD TABLE OF TY_GROUP,

wa_group LIKE LINE OF lt_group.

DATA: lt_ekpo LIKE EKPO occurs 0,

wa_ekpo LIKE LINE OF lt_ekpo,

lines_count TYPE I.

SELECT * FROM EKPO INTO TABLE lt_ekpo

WHERE EBELN = p_ebeln.

SORT lt_ekpo.

LOOP AT lt_ekpo INTO wa_ekpo.

CLEAR MARA.

SELECT SINGLE * FROM MARA

WHERE MATNR = wa_ekpo-matnr.

WA_GROUP-MATKL = MARA-MATKL.

COLLECT wa_group INTO lt_group.

CLEAR wa_group.

ENDLOOP.

DESCRIBE TABLE lt_group LINES lines_count.

IF lines_count > 1.

  • DO SOMETHING.

ENDIF.

0 Kudos

Thanks.This is the best answer..

Meghna

Former Member
0 Kudos

Hi maghana

There is a small modification in Michale code

TABLES: MARA, EKPO.

TYPES: BEGIN OF TY_GROUP,

matnr like mara-matnr,

MATKL LIKE MARA-MATKL,

END OF TY_GROUP.

DATA: lt_group TYPE STANDARD TABLE OF TY_GROUP,

wa_group LIKE LINE OF lt_group.

DATA: lt_ekpo LIKE EKPO occurs 0,

wa_ekpo LIKE LINE OF lt_ekpo,

lines_count TYPE I.

SELECT * FROM EKPO INTO TABLE lt_ekpo

WHERE EBELN = p_ebeln.

SORT lt_ekpo.

LOOP AT lt_ekpo INTO wa_ekpo.

CLEAR MARA.

SELECT SINGLE * FROM MARA

WHERE MATNR = wa_ekpo-matnr.

WA_GROUP-matnr = MARA-matnr.

WA_GROUP-MATKL = MARA-MATKL.

COLLECT wa_group INTO lt_group.

CLEAR wa_group.

ENDLOOP.

DESCRIBE TABLE lt_group LINES lines_count.

IF lines_count > 1.

  • DO SOMETHING.

ENDIF.

then it will not add any duplicates