ABAP程式示例

mmccking發表於2007-07-29
SAP ABAP 互動報表 滑鼠手形 顏色字型[@more@]

REPORT ZRL003.
TABLES: EKKO.
**---Initial table ekko
TYPES: BEGIN OF STR_EKKO,
EBELN LIKE EKKO-EBELN,
BUKRS LIKE EKKO-BUKRS,
EKGRP LIKE EKKO-EKGRP,
END OF STR_EKKO.
DATA: WA_EKKO TYPE STR_EKKO,
IT_EKKO TYPE TABLE OF STR_EKKO.

**---Initial table ekpo
TYPES: BEGIN OF STR_EKPO,
EBELN LIKE EKPO-EBELN,
NETPR LIKE EKPO-NETPR,
END OF STR_EKPO.
DATA: WA_EKPO TYPE STR_EKPO,
IT_EKPO TYPE TABLE OF STR_EKPO.

**---selection screen
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETERS:P_BUKRS LIKE EKKO-BUKRS OBLIGATORY DEFAULT '1000'.
SELECT-OPTIONS: S_EKGRP FOR EKKO-EKGRP.
SELECTION-SCREEN END OF BLOCK B1.

**---Start-of-selection
PERFORM GET_DATA.

**---End-of-selection
PERFORM DISPLAY_HEADER.
PERFORM DISPLAY_DATA.

**---at line-selection
AT LINE-SELECTION.
CHECK NOT WA_EKKO-EBELN IS INITIAL.
PERFORM SELECT_DATA.
PERFORM GET_MYDATA.

*&---------------------------------------------------------------------*
*& Form get_data
*&---------------------------------------------------------------------*
* Get data from database
*----------------------------------------------------------------------*
FORM GET_DATA .
SELECT EBELN BUKRS EKGRP
INTO CORRESPONDING FIELDS OF TABLE IT_EKKO
FROM EKKO
WHERE BUKRS = P_BUKRS
AND EKGRP IN S_EKGRP.
ENDFORM. " get_data
*&---------------------------------------------------------------------*
*& Form display_data
*&---------------------------------------------------------------------*
* Display data
*----------------------------------------------------------------------*
FORM DISPLAY_DATA .
LOOP AT IT_EKKO INTO WA_EKKO.
**滑鼠變成手型
FORMAT HOTSPOT ON.
**格式化字型
FORMAT COLOR COL_KEY INTENSIFIED ON.
WRITE: AT /5 WA_EKKO-EBELN.
FORMAT RESET.
WRITE: AT 16 WA_EKKO-BUKRS,
21 WA_EKKO-EKGRP.
**Hide資料
HIDE: WA_EKKO-EBELN.

ENDLOOP.
ENDFORM. " display_data
*&---------------------------------------------------------------------*
*& Form display_header
*&---------------------------------------------------------------------*
* Display header
*----------------------------------------------------------------------*
FORM DISPLAY_HEADER .
WRITE: AT /5 '採購憑證號',
16 '工廠',
21 '採購組'.

ENDFORM. " display_header
*&---------------------------------------------------------------------*
*& Form select_data
*&---------------------------------------------------------------------*
* Select Data from database
*----------------------------------------------------------------------*
FORM SELECT_DATA .
SELECT EBELN NETPR
INTO CORRESPONDING FIELDS OF TABLE IT_EKPO
FROM EKPO
WHERE EBELN = WA_EKKO-EBELN.
ENDFORM. " select_data
*&---------------------------------------------------------------------*
*& Form get_mydata
*&---------------------------------------------------------------------*
* Display ekpo data
*----------------------------------------------------------------------*
FORM GET_MYDATA .
***---Write header
WRITE: AT /5 '採購憑證號',
AT 16 '採購憑證中的淨價格'.

LOOP AT IT_EKPO INTO WA_EKPO.
WRITE: AT /5 WA_EKPO-EBELN.
WRITE: AT 16 WA_EKPO-NETPR.
ENDLOOP.

ENDFORM. " get_mydata

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/8356764/viewspace-929062/,如需轉載,請註明出處,否則將追究法律責任。

相關文章