ALV BLOCK SAMPLE REPORT

TYPE-POOLS: slis.

TABLES : ekko, ekpo.

DATA : BEGIN OF i_ekko OCCURS 0,
ebeln LIKE ekko-ebeln,
ernam LIKE ekko-ernam,
bsart LIKE ekko-bsart,
var1,
END OF i_ekko.

DATA : BEGIN OF i_ekpo OCCURS 0,
ebeln LIKE ekpo-ebeln,
ebelp LIKE ekpo-ebelp,
matnr LIKE ekpo-matnr,
aedat LIKE ekpo-aedat,
var2,
END OF i_ekpo.

DATA : BEGIN OF i_final OCCURS 0,
ebeln LIKE ekko-ebeln,
ernam LIKE ekko-ernam,
bsart LIKE ekko-bsart,
ebelp LIKE ekpo-ebelp,
matnr LIKE ekpo-matnr,
aedat LIKE ekpo-aedat,
END OF i_final.

SELECT-OPTIONS : S_EBELN FOR EKKO-EBELN.

DATA : fcat TYPE slis_t_fieldcat_alv, "FIELDCATALOG(TABLE)
fcat1 TYPE slis_t_fieldcat_alv, "FIELDCATALOG(TABLE)
cat TYPE slis_fieldcat_alv. "FIELDCATALOG(WORK AREA)


DATA : LAYOUT1 TYPE SLIS_LAYOUT_ALV, "LAYOUT 1
LAYOUT2 TYPE SLIS_LAYOUT_ALV, "LAYOUT 2

KEY TYPE SLIS_KEYINFO_ALV , "KEY INFORMATION
GT_EVENT1 TYPE SLIS_T_EVENT.

PERFORM GETTING_DATA.

PERFORM append_field.



CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
EXPORTING
i_callback_program = 'ZD_ALV_BLOCK_DISPLAY'.


CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
IS_LAYOUT = LAYOUT1
IT_FIELDCAT = FCAT
I_TABNAME = 'I_EKKO'
IT_EVENTS = GT_EVENT1
I_TEXT = 'HEADER BLOCK'
TABLES
T_OUTTAB = I_EKKO.

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
IS_LAYOUT = LAYOUT2
IT_FIELDCAT = FCAT1
I_TABNAME = 'I_EKPO'
IT_EVENTS = GT_EVENT1
I_TEXT = 'ITEMS BLOCK'
TABLES
T_OUTTAB = I_EKPO.

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'.

*&---------------------------------------------------------------------
*
*& Form GETTING_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text *----------------------------------------------------------------------* FORM GETTING_DATA . SELECT EBELN BSART ERNAM UP TO 100 ROWS INTO CORRESPONDING FIELDS OF TABLE I_EKKO FROM EKKO WHERE EBELN IN S_EBELN. SELECT EBELN EBELP MATNR AEDAT INTO CORRESPONDING FIELDS OF TABLE I_EKPO FROM EKPO FOR ALL ENTRIES IN I_EKKO WHERE EBELN = I_EKKO-EBELN . SORT I_EKKO BY EBELN. LOOP AT I_EKKO. READ TABLE I_EKPO WITH KEY EBELN = I_EKKO-EBELN. IF SY-SUBRC EQ 0. MOVE: I_EKKO-EBELN TO I_FINAL-EBELN, I_EKKO-BSART TO I_FINAL-BSART, I_EKKO-ERNAM TO I_FINAL-ERNAM, I_EKPO-EBELP TO I_FINAL-EBELP, I_EKPO-MATNR TO I_FINAL-MATNR, I_EKPO-AEDAT TO I_FINAL-AEDAT. APPEND I_FINAL. ENDIF. ENDLOOP. ENDFORM. " GETTING_DATA *&---------------------------------------------------------------------* *& Form APPEND_FIELD *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text
* <-- p2 text *----------------------------------------------------------------------* FORM append_field . CLEAR cat. cat-col_pos = 1. cat-fieldname = 'EBELN'. cat-tabname = 'I_EKKO'. cat-ref_fieldname = 'EBELN'. cat-ref_tabname = 'EKKO'. cat-key = 'X'. "define field as key APPEND cat TO fcat. CLEAR cat. cat-col_pos = 2. cat-fieldname = 'BSART'. cat-tabname = 'I_EKKO'. cat-ref_fieldname = 'BSART'. cat-ref_tabname = 'EKKO'. APPEND cat TO fcat. CLEAR cat. cat-col_pos = 3. cat-fieldname = 'ERNAM'. cat-tabname = 'I_EKKO'. cat-ref_fieldname = 'ERNAM'. cat-ref_tabname = 'EKKO'. APPEND cat TO fcat. CLEAR cat. cat-col_pos = 4. cat-fieldname = 'EBELP'. cat-tabname = 'I_EKPO'. cat-ref_fieldname = 'EBELP'. cat-ref_tabname = 'EKPO'. cat-key_SEL = 'X'. "define field as key APPEND cat TO fcat1. CLEAR cat. cat-col_pos = 5. cat-fieldname = 'MATNR'. cat-tabname = 'I_EKPO'. cat-ref_fieldname = 'MATNR'. cat-ref_tabname = 'EKPO'. APPEND cat TO fcat1. CLEAR cat. cat-col_pos = 6. cat-fieldname = 'AEDAT'. cat-tabname = 'I_EKPO'. cat-ref_fieldname = 'AEDAT'. cat-ref_tabname = 'EKPO'. APPEND cat TO fcat1. CLEAR cat. ENDFORM. " APPEND_FIELD RELATED POSTS


REPLACE COMMENTARY WITH ALV REPORT
SAMPLE CODE FOR DATA BASE ACCESSING FROM UNIX FILE
ALV SAMPLE CODE CONTACT RENUAL DETAILS

No comments :

Post a Comment