Move FMOIX/FMCOX structures into Internal Table

Alex picture Alex · Jun 20, 2012 · Viewed 25k times · Source

I am a newbie to ABAP (3 days experience) and I am currently on a task to write reports using ABAP code. It is like moving some data from a specific SAP database to a Business Intelligence staging area.

So the core difficulty is that some data on the SAP server is in the format of dictionary structures (FMOIX, FMCOX, etc.) and I need to move these data into internal tables during program runtime. I was told that OPENSQL would not work in this case.

If you still do not get what I mean, I can suggest several ways, actually given by my supervisor. First is to use GET event, say

GET FMOIX.
    IF FMOIX-zhdlt > From_dat and FMOIX-zhdlt < to_dat.
        Append FMOIX to itab.
    ENDIF.

The thing is that I am still not very clear about this GET event. Is it just a event handler thing, or can it loop through data records?

What I googled for more than two days give me something like

LOOP at FMOIX.
    MOVE FMOIX to itab.
ENDLOOP.

So what are the ways to move transactional structure like FMOIX into internal tables, say the internal table name is ITAB?

Your answer would be greatly appreciated. Though I have time, I am totally new. Thanks a lot.

Answer

Smigs picture Smigs · Jun 20, 2012

If your supervisor is suggesting that you use the GET event, it means that your program is (or should be) using a logical database - in this case probably FMF or FMF_BCS.

Doing GET FMOIX reads a set of fields defined in the logical database (as a node). Underneath your GET statement, you can use FMOIX as a structure, e.g. WRITE FMOIX-field1. The program will (implicitly, it's not explicity defined in the code like a LOOP...ENDLOOP is) loop through all the rows returned according to your selection criteria. You should be able to use MOVE-CORRESPONDING to move the contents of each row into a proper structure, and then APPEND that structure to your itab.

Quick link on GET in ABAPDocu

Note: this answer is a bit of a guess, since I've only used a logical database once, and the documentation is a little thin on the ground compared to the volumes out there about standard SELECTs and internal tables.