Hi Chao,
Instead of using the above complicated INNER JOIN code just divide it into select statements for different tables one by one e.g. AUFK, AFKO, AFPO, CRHD & MARA.
While you select from one table use those retrieved entries to filter data from the next select statement using "FOR ALL ENTRIES in....".
For example:
SELECT AUFNR
AUART
AUTYP
REFNR
ERNAM
ERDAT
AENAM
AEDAT
FROM aufk
into table it_aufk
where ...............(some condition - if any)
If sy-subrc is initial.
SELECT AUFNR
GLTRP
GSTRP
FTRMS
FROM afko
into table it_afko
FOR ALL ENTRIES IN it_aufk
WHERE aufnr = it_aufk-aufnr.
Endif.
This will improve your performance and simplify the code rather than using INNER JOIN.
Hope this helps.
Regards,
Arnab