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.
START-OF-SELECTION.
PERFORM GETTING_DATA.
PERFORM append_field.
CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-CPROG
IS_LAYOUT = LAYOUT1
IT_FIELDCAT = FCAT
* IT_EVENTS = GT_EVENT1
i_tabname_header = 'I_EKKO'
i_tabname_item = 'I_EKPO'
is_keyinfo = KEY
tables
t_outtab_header = I_EKKO
t_outtab_item = I_EKPO.
*&---------------------------------------------------------------------
*
*& 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 = 'X'. "define field as key APPEND cat TO fcat. CLEAR cat. cat-col_pos = 5. cat-fieldname = 'MATNR'. cat-tabname = 'I_EKPO'. cat-ref_fieldname = 'MATNR'. cat-ref_tabname = 'EKPO'. APPEND cat TO fcat. CLEAR cat. cat-col_pos = 6. cat-fieldname = 'AEDAT'. cat-tabname = 'I_EKPO'. cat-ref_fieldname = 'AEDAT'. cat-ref_tabname = 'EKPO'. APPEND cat TO fcat. CLEAR cat. layout1-expand_fieldname = 'VAR1'. layout1-lights_fieldname = '3'. layout1-lights_tabname = 'I_EKPO'. key-header01 = 'EBELN'. key-item01 = 'EBELN'. ENDFORM. " APPEND_FIELD
RELATED POSTS
ALV INTERACTIVE REPORT SAMPLE CODE
INTERACTIVE REPORT SAMPLE CODE 2
SAMPLE CODE FOR DATA BASE ACCESSING FROM UNIX FILE
ALV SAMPLE CODE CONTACT RENUAL DETAILS
SAP ABAP Blog Covers Dictionary,reports,OOPS,BDC,Scripts,Forms,EDI,ALE,IDoc,BAPI,BADI,MySAP,ERP,CRM,FICO,BIW and Interview Questions.
No comments :
Post a Comment