cancel
Showing results for 
Search instead for 
Did you mean: 

Abap code to get data from table EKKO

MSadri
Participant
0 Kudos

Hi,

I am trying to check supplier purchasing history from table EKKO.

Unfortunately data is too huge to output in Excel or flat file. 

I am trying to write query in SQ02 to sort data in table EKKO according to its creation date and then select one row per supplier with latest PO date.

I am not quite familiar with ABAP so struggling to write the code.

Can someone please help or guide on this ?

SELECT LIFNR FROM EKKO
WHERE LIFNR EQ 'XXXX'.

In above statement its saying INTO is missing but I don't want to insert data I just want to modify selection criteria and output table.

Br,

Murtuza

Sandra_Rossi
Active Contributor
0 Kudos
I don't understand your question: with SELECT, you must store the read data into memory! So, you say that you are writing ABAP code in an infoset, but you don't say where in the infoset... If you have choosen to use a Data reading program as source, you must load the data into memory. Please clarify.
Sandra_Rossi
Active Contributor
0 Kudos
Even if you have modify the initial extracted data, you must load the data into memory. Please clarify what your question is.

Accepted Solutions (0)

Answers (2)

Answers (2)

lou_
Explorer
0 Kudos

Hello MSadri ,

I'm not sure if I understand clearly your need, but if the goal is to have a query with one row per supplier with his latest PO creation date you can do as follow:

First create your Infoset in SQ02 with table EKKO (like you seem already did).

Next, go to Extra/Code:

1.png

In this area put the following code:

field-symbols <output_table> type any table.

assign ('%G00[]') to <output_table>. " %G00[] represent the final alv

sort <output_table>
  descending by   " To get the latest date on top
  ('EKKO-LIFNR')  " Supplier's account number
  ('EKKO-AEDAT'). " Creation date

" Keep the first line (with latest PO creation based on previous sort) and
" delete all the duplicate line comparing supplier's account number
delete adjacent duplicates from <output_table>
  comparing ('EKKO-LIFNR').

I choose LIFNR and AEDAT but it can be any fields in EKKO table.

You must add this fields in the corresponding field group (SQ02), and you must check the fields for displaying it in you final view (SQ01), if you don't you will get a dump.

2.png3.png

Regards.

MSadri
Participant
0 Kudos

Hi Sandra,

Thanks for replying.

I am writing code inside infoset-- code section -- Free code.

I am just trying to filter selection programmatically as data is too huge to output. I am trying to write select statement in infoset to select only desired data. Goal is to sort table EKKO depending on creation date and then output lastest po date per supplier. So let's say one supplier has 1000 POs so only row with latest PO date is needed for that supplier.

I just felt writing query might help and I am not sure whether this type of requirement can be accommodated here.

Thank you.

Sandra_Rossi
Active Contributor
0 Kudos
Please don't post a solution. Instead, click on Show replies > Comment.