Skip to Content
author's profile photo Former Member
Former Member

ABAP report - Check Po items Material group

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Posted on Aug 13, 2009 at 05:36 PM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 13, 2009 at 06:21 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.