0

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?

Suncatcher
  • 10,355
  • 10
  • 52
  • 90
hammerman
  • 23
  • 1
  • 5
  • 1
    In this state, the question is way too broad to be answered here. It looks like you need serious training - which is not meant to be condescending, but probably really the best way to go for you. There are multiple severe issues in your attempt (missing WHERE condition for the first selection, excessive use of FAE, no joins, no apparent approach to output). – vwegert May 16 '16 at 18:20
  • Why aren't you using SQL joins? Are you new to SQL as well? – Jagger May 16 '16 at 19:17
  • Hi all, could you please correct me the code? I am have told that I am new to ABAP...I have just asked for help... – hammerman May 17 '16 at 07:49

1 Answers1

1

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

Francesco
  • 46
  • 1