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 Query SQ01

Former Member
0 Kudos

Hello , In Abap Query Sq01, need to add 2 fields in the output (Goods Receipt (MSEG-WEMPF) and Name( ?) ) . These 2 fields taken from MIGO Transection. In the Query, there was 3 tables has been used previously EKKO,EKPO EKKN. How to  fetch the field WEMPF from MSEG, because we do not find relation of MSEG with all these 3 table. Thanks Sankil

2 REPLIES 2

Former Member
0 Kudos

Hi Sankil,

Instead of touching MSEG table, I would recommend you to use EKKO, EKPO and EKBE tables.

If EKBE-VGABE = '1' then it is goods receipt and if EKBE-VGABE = '2' then it is invoice receipt.

I will provide you a sample Query.

SELECT EBELN

            LOEKZ

            ERNAM

            LIFNR

            EKGRP

            BEDAT FROM EKKO INTO TABLE GT_EKKO

                  WHERE EBELN IN S_EBELN AND

                        LIFNR IN S_LIFNR AND

                        BEDAT IN S_BEDAT AND

                        LOEKZ EQ ' '.

   IF GT_EKKO IS NOT INITIAL.

     SELECT EBELN

            EBELP

            LOEKZ

            TXZ01

            WERKS

            MENGE

            MEINS

            BPRME

            NETPR

            NETWR

            BRTWR

            PSTYP FROM EKPO INTO TABLE GT_EKPO

                  FOR ALL ENTRIES IN GT_EKKO

                  WHERE EBELN = GT_EKKO-EBELN AND

                        LOEKZ EQ ' '.

     IF GT_EKPO IS NOT INITIAL.

       SELECT EBELN

              EBELP

              VGABE

              MENGE

              WRBTR

              SHKZG

              BLDAT FROM EKBE INTO TABLE GT_EKBE

                    FOR ALL ENTRIES IN GT_EKPO

                    WHERE EBELN = GT_EKPO-EBELN

                      AND EBELP = GT_EKPO-EBELP.

     ENDIF.

     SELECT LIFNR

            NAME1 FROM LFA1 INTO TABLE GT_LFA1

                  FOR ALL ENTRIES IN GT_EKKO

                  WHERE LIFNR = GT_EKKO-LIFNR.

   ENDIF.

raymond_giuseppi
Active Contributor
0 Kudos

Read first 191492 - Performance: Customer developments in MM/WM


2.Access to material documents

a) via the purchase order number
Incorrect:

    • SELECT FROM MSEG WHERE EBELN = … and EBELP = ...

Correct:

    • SELECT FROM EKBE WHERE EBELN = .. AND EBELP = ... AND VGABE IN (1,6,7,8,9).
    • SELECT FROM MSEG WHERE MBLNR = EKBE-BELNR AND MJAHR = EKBE-GJAHR AND ZEILE = EKBE-BUZEI.

Regards,

Raymond