Fetch rows on joined ESLL, EKPO, EKKO from selection screen input

2.8k views Asked by At

What I would like to achieve is a join between tables ESLL, EKPO, EKKO via SAP Query. Specifically these are the steps I would like to achieve:

  1. in the selection parameter every time I will enter the query I will give a different value for ESLL-EXTSRVNO;
  2. based on that value the query automatically should select ESLL-PACKNO based on ESLL-EXTSRVNO given;
  3. then the query should put ESLL-SUB_PACKNO equal to the ESLL-PACKNO values of the steps before;
  4. then the query should put the new ESLL-PACKNO values equal to EKPO-PACKNO and retrieve the following fields: EKPO-EBELN, EKPO-EBELP, EKPO-MATKL.

I have already written some code inside the infoset, but I do not know how to fix it. In the "data" section I have written:

DATA: it_esll TYPE TABLE OF esll.
DATA: it_esll2 TYPE TABLE OF esll.
DATA: it_ekpo TYPE TABLE OF ekpo.

In the "start-of-selection" section I have written:

 SELECT packno
  FROM esll
  INTO TABLE it_esll.
IF sy-subrc EQ 0.
SELECT packno  FROM esll
  into TABLE it_esll2
  for ALL ENTRIES IN it_esll
  where sub_packno EQ it_esll-packno.
IF sy-subrc EQ 0.
  SELECT ebeln ebelp bukrs werks matkl menge netpr peinh
       FROM ekpo
       into TABLE it_ekpo
        for ALL ENTRIES IN it_esll2
       WHERE packno   EQ it_esll2-packno.
endif.
endif.

And, in order to display all the information I want, I have put the following joins: ESLL-PACKNO --> EKPO-PACKNO --> EKPO-EBELN --> EKKO-EBELN

At then end I would like to display these information:

  1. EKPO-EBELN
  2. EKPO-EBELP
  3. EKPO-MATKL
  4. EKKO-BSART
  5. EKPO-PACKNO

Could you please help me?

1

There are 1 answers

0
Francesco On BEST ANSWER

One option could be to use Alias table in your infoset, something like this:

  • First table: ESLL;
  • Second table ZESLL (Alias on ESLL) with join ZESLL-PACKNO = ESLL-SUB_PACKNO;
  • Third table: EKPO with join on EKPO-PACKNO = ZESLL-PACKNO;
  • Fourth table: EKKO with join on EBELN;

So you can avoid ABAP

Infoset Join