Hi,
I don't have test data but I think the following code will give you an idea, try to fill in the FM "READ_TEXT" below with your own parameter (check with table STXH).
REPORT ZTEST.
TYPES: BEGIN OF TY_RESULT,
EBELN TYPE EKKO-EBELN,
WAERS TYPE EKKO-WAERS,
EBELP TYPE EKPO-EBELP,
TXZ01 TYPE EKPO-TXZ01,
MENGE TYPE EKPO-MENGE,
NETPR TYPE EKPO-NETPR,
NETWR TYPE EKPO-NETWR,
ITEM_TEXT TYPE CHAR100,
END OF TY_RESULT.
DATA: GT_EKPO TYPE STANDARD TABLE OF EKPO,
GS_EKPO TYPE EKPO,
GT_EKKO TYPE STANDARD TABLE OF EKKO,
GS_EKKO TYPE EKKO,
GT_RESULT TYPE STANDARD TABLE OF TY_RESULT,
GS_RESULT TYPE TY_RESULT,
LV_TAB_IND TYPE SY-TABIX,
GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
GS_FIELDCAT TYPE LINE OF SLIS_T_FIELDCAT_ALV,
GV_NAME TYPE CHAR70,
GS_TLINE TYPE TLINE,
GT_TLINE TYPE STANDARD TABLE OF TLINE.
SELECT-OPTIONS: SO_EBELN FOR GS_EKKO-EBELN,
SO_WAERS FOR GS_EKKO-WAERS.
START-OF-SELECTION.
PERFORM SELECTION.
PERFORM BUILD_FIELDCAT.
PERFORM DISPLAY.
*&---------------------------------------------------------------------*
*& Form SELECTION
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM SELECTION.
SELECT EBELN WAERS FROM EKKO INTO CORRESPONDING FIELDS OF TABLE GT_EKKO
WHERE EBELN IN SO_EBELN
AND WAERS IN SO_WAERS.
IF GT_EKKO[] IS NOT INITIAL.
SELECT EBELN EBELP TXZ01 MENGE NETPR NETWR FROM EKPO INTO CORRESPONDING FIELDS OF TABLE GT_EKPO
FOR ALL ENTRIES IN GT_EKKO
WHERE EBELN EQ GT_EKKO-EBELN.
SORT GT_EKPO BY EBELN.
ENDIF.
LOOP AT GT_EKKO INTO GS_EKKO.
CLEAR GS_RESULT.
CLEAR LV_TAB_IND.
MOVE-CORRESPONDING GS_EKKO TO GS_RESULT.
READ TABLE GT_EKPO TRANSPORTING NO FIELDS WITH KEY EBELN = GS_EKKO-EBELN BINARY SEARCH.
IF SY-SUBRC EQ 0.
LV_TAB_IND = SY-TABIX.
LOOP AT GT_EKPO INTO GS_EKPO FROM LV_TAB_IND.
IF GS_EKKO-EBELN NE GS_EKPO-EBELN.
EXIT.
ENDIF.
MOVE-CORRESPONDING GS_EKPO TO GS_RESULT.
CONCATENATE GS_RESULT-EBELN GS_RESULT-EBELP INTO GV_NAME.
CONDENSE GV_NAME NO-GAPS.
CALL FUNCTION 'READ_TEXT'
EXPORTING
CLIENT = SY-MANDT
ID = 'F01'
LANGUAGE = SY-LANGU
NAME = GV_NAME
OBJECT = 'TEXT'
TABLES
LINES = GT_TLINE
EXCEPTIONS
NOT_FOUND = 1.
LOOP AT GT_TLINE INTO GS_TLINE.
IF SY-TABIX EQ 1.
GS_RESULT-ITEM_TEXT = GS_TLINE-TDLINE.
ELSE.
CONCATENATE GS_RESULT-ITEM_TEXT GS_TLINE-TDLINE INTO GS_RESULT-ITEM_TEXT.
ENDIF.
ENDLOOP.
APPEND GS_RESULT TO GT_RESULT.
ENDLOOP.
ENDIF.
ENDLOOP.
ENDFORM. "SELECTION
*&---------------------------------------------------------------------*
*& Form BUILD_FIELDCAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM BUILD_FIELDCAT.
CLEAR GS_FIELDCAT.
GS_FIELDCAT-COL_POS = 1.
GS_FIELDCAT-TABNAME = 'GT_RESULT'.
GS_FIELDCAT-FIELDNAME = 'EBELN'.
GS_FIELDCAT-SELTEXT_L = 'Purchasing Document Number'.
APPEND GS_FIELDCAT TO GT_FIELDCAT.
CLEAR GS_FIELDCAT.
GS_FIELDCAT-COL_POS = 2.
GS_FIELDCAT-TABNAME = 'GT_RESULT'.
GS_FIELDCAT-FIELDNAME = 'WAERS'.
GS_FIELDCAT-SELTEXT_L = 'Currency Key'.
APPEND GS_FIELDCAT TO GT_FIELDCAT.
CLEAR GS_FIELDCAT.
GS_FIELDCAT-COL_POS = 3.
GS_FIELDCAT-TABNAME = 'GT_RESULT'.
GS_FIELDCAT-FIELDNAME = 'EBELP'.
GS_FIELDCAT-SELTEXT_L = 'Item No'.
APPEND GS_FIELDCAT TO GT_FIELDCAT.
CLEAR GS_FIELDCAT.
GS_FIELDCAT-COL_POS = 4.
GS_FIELDCAT-TABNAME = 'GT_RESULT'.
GS_FIELDCAT-FIELDNAME = 'TXZ01'.
GS_FIELDCAT-SELTEXT_L = 'Short Text'.
APPEND GS_FIELDCAT TO GT_FIELDCAT.
CLEAR GS_FIELDCAT.
GS_FIELDCAT-COL_POS = 5.
GS_FIELDCAT-TABNAME = 'GT_RESULT'.
GS_FIELDCAT-FIELDNAME = 'MENGE'.
GS_FIELDCAT-SELTEXT_L = 'Purchase Order Quantity'.
APPEND GS_FIELDCAT TO GT_FIELDCAT.
CLEAR GS_FIELDCAT.
GS_FIELDCAT-COL_POS = 6.
GS_FIELDCAT-TABNAME = 'GT_RESULT'.
GS_FIELDCAT-FIELDNAME = 'NETPR'.
GS_FIELDCAT-SELTEXT_L = 'Net Price'.
APPEND GS_FIELDCAT TO GT_FIELDCAT.
CLEAR GS_FIELDCAT.
GS_FIELDCAT-COL_POS = 7.
GS_FIELDCAT-TABNAME = 'GT_RESULT'.
GS_FIELDCAT-FIELDNAME = 'NETWR'.
GS_FIELDCAT-SELTEXT_L = 'Net Order Value'.
APPEND GS_FIELDCAT TO GT_FIELDCAT.
CLEAR GS_FIELDCAT.
GS_FIELDCAT-COL_POS = 8.
GS_FIELDCAT-TABNAME = 'GT_RESULT'.
GS_FIELDCAT-FIELDNAME = 'ITEM_TEXT'.
GS_FIELDCAT-SELTEXT_L = 'Item Text'.
APPEND GS_FIELDCAT TO GT_FIELDCAT.
ENDFORM. "BUILD_FIELDCAT
*&---------------------------------------------------------------------*
*& Form DISPLAY
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM DISPLAY.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IT_FIELDCAT = GT_FIELDCAT[]
TABLES
T_OUTTAB = GT_RESULT
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. "DISPLAY
Thanks.
Regards,
Keng Haw