I am stuck with coding a SAP query..I am new to ABAP.
What I would like to achieve is a join between tables ESLL, EKPO, EKKO. Specifically these are the steps I would like to achieve:
- in the selection parameter every time I will enter the query I will give a different value for ESLL-EXTSRVNO;
- basing on that value the query automatically should select ESLL-PACKNO basing on ESLL-EXTSRVNO given;
- then the query should put ESLL-SUB_PACKNO equal to the ESLL-PACKNO values of the steps before;
- 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:
- EKPO-EBELN
- EKPO-EBELP
- EKPO-MATKL
- EKKO-BSART
- EKPO-PACKNO
Could you please help me?