Google Search - Blog...........

ABAP - Simple ALV Interactive Report Program.

REPORT ZPURCHASE_ORDER.
*--type pools
TYPE-POOLS:SLIS.
*--internal tables for alv
DATA:
W_EBELN TYPE EKKO-EBELN,
W_PROG TYPE SY-REPID,
T_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
FS_FIELDCAT LIKE LINE OF T_FIELDCAT,
T_EVENTCAT TYPE SLIS_T_EVENT,
W_EVENTCAT LIKE LINE OF T_EVENTCAT.

DATA:
T_EKKO LIKE STANDARD TABLE OF EKKO,
FS_EKKO LIKE LINE OF T_EKKO.

DATA:T_EKPO LIKE STANDARD TABLE OF EKPO,
FS_EKPO LIKE LINE OF T_EKPO.

*---- SELECT-OPTIONS DECLARATION
SELECT-OPTIONS:S_EBELN FOR W_EBELN.

*----- START-OF-SELECTION
START-OF-SELECTION.
SELECT *
FROM EKKO
INTO TABLE T_EKKO
WHERE EBELN IN S_EBELN.

W_PROG = SY-REPID.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = W_PROG
I_CALLBACK_USER_COMMAND = 'PICK'
I_STRUCTURE_NAME = 'EKKO'
TABLES
T_OUTTAB = T_EKKO .

*&--------------------------------------------------------------------*
*& Form pick
*---------------------------------------------------------------------*
FORM PICK USING COMMAND LIKE SY-UCOMM
SELFIELD TYPE SLIS_SELFIELD.
READ TABLE T_EKKO INTO FS_EKKO INDEX SELFIELD-TABINDEX.

CASE COMMAND.
WHEN '&IC1'.
SELECT *
FROM EKPO
INTO TABLE T_EKPO
WHERE EBELN EQ FS_EKKO-EBELN.

W_PROG = SY-REPID.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_STRUCTURE_NAME = 'EKPO'
CHANGING
CT_FIELDCAT = T_FIELDCAT .


DELETE T_FIELDCAT WHERE FIELDNAME EQ 'EBELN'.
DELETE T_FIELDCAT WHERE FIELDNAME EQ 'BUKRS'.
DELETE T_FIELDCAT WHERE FIELDNAME EQ 'LGORT'.
DELETE T_FIELDCAT WHERE FIELDNAME EQ 'WERKS'.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = W_PROG
IT_FIELDCAT = T_FIELDCAT
IT_EVENTS = T_EVENTCAT
TABLES
T_OUTTAB = T_EKPO .

ENDCASE. " CASE COMMAND
ENDFORM. " FORM PICK

FORM T_EVENTCAT.
W_EVENTCAT-NAME = 'TOP_OF_PAGE'.
W_EVENTCAT-FORM = 'TOP'.
APPEND W_EVENTCAT TO T_EVENTCAT.
ENDFORM.

FORM TOP.
READ TABLE T_EKPO INTO FS_EKPO INDEX 1.
WRITE:/ 'Purchase Document Number'(001),30 FS_EKPO-EBELN,
/ 'Company Code'(002), 30 FS_EKPO-BUKRS,
/ 'Plant'(003), 30 FS_EKPO-WERKS,
/ 'Storage Location'(004),30 FS_EKPO-LGORT.
ENDFORM.


ALSO READ:

- Simple ALV Grid/List With Save Layout.

- Checkbox In ALV Program.

- ALV Header With Logo.

- Including Line After Subtotal In ALV Display.

..... Back To Index On ALV List/ Grid Display.

..... Back To MAIN INDEX.

No comments:

Post a Comment