ABAP中文示例2

mmccking發表於2007-07-29
ABAP中文示例[@more@]

*&---------------------------------------------------------------------*
*& Report Z_TEST03
*&
*&---------------------------------------------------------------------*
*&Author : chenyanjun
*&
*&---------------------------------------------------------------------*

REPORT Z_TEST03 NO STANDARD PAGE HEADING.
*----------------定義工廠表所需資訊-----------------*
DATA: BEGIN OF IT_T001W OCCURS 0,
WERKS LIKE T001W-WERKS ,
NAME1 LIKE T001W-NAME1 ,
PFACH LIKE T001W-PFACH ,
END OF IT_T001W.
*---------------定義總庫存額資訊------------------------*
DATA: BEGIN OF IT_S032 OCCURS 0,
WBWBEST LIKE S032-WBWBEST,
WERKS LIKE S032-WERKS,
END OF IT_S032.
*--------------------定義結果資料資訊-----------------------------*
DATA: BEGIN OF IT_RESULT OCCURS 0,
NAME1 LIKE T001W-NAME1,
PFACH LIKE T001W-PFACH,
WBWBEST LIKE S032-WBWBEST,
END OF IT_RESULT.

DATA PWBWBEST TYPE P DECIMALS 3.

SELECT-OPTIONS S_WERKS FOR IT_T001W-WERKS.
*--------------------輸出面眉HEADING-------------------*
TOP-OF-PAGE.
PERFORM FRM_HEAD_OUTPUT .
*------------------START-OF-SELECTION-------------*
START-OF-SELECTION.
PERFORM FRM_GETDATA.
PERFORM FRM_PROCESS.
*------------------END-OF-SELECTION---------------*
END-OF-SELECTION.
PERFORM FRM_OUTPUT.
*&---------------------------------------------------------------------*
*& Form FRM_HEAD_OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --&gt p1 text
* *----------------------------------------------------------------------*
FORM FRM_HEAD_OUTPUT .
ULINE.
WRITE: '|' , (30) '電廠' CENTERED,'|', (25) '裝機容量(kwh)' CENTERED,'|',
(28) '庫存資金(萬元)' CENTERED, '|' , (28) '庫存資金佔用額(萬元/kwh)' CENTERED , '|'.
ULINE /.
ENDFORM. " FRM_HEAD_OUTPUT
*&---------------------------------------------------------------------*
*& Form FRM_GETDATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --&gt p1 text
* *----------------------------------------------------------------------*
FORM FRM_GETDATA .

SELECT * FROM T001W
INTO CORRESPONDING FIELDS OF TABLE IT_T001W
WHERE FABKL EQ 'ZT'.

SELECT * FROM S032
INTO CORRESPONDING FIELDS OF TABLE IT_S032
WHERE WERKS IN S_WERKS.
ENDFORM. " FRM_GETDATA
*&---------------------------------------------------------------------*
*& Form FRM_PROCESS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --&gt p1 text
* *----------------------------------------------------------------------*
FORM FRM_PROCESS .
LOOP AT IT_S032.
CLEAR IT_RESULT.
READ TABLE IT_T001W WITH KEY
WERKS = IT_S032-WERKS.
IT_RESULT-NAME1 = IT_T001W-NAME1.
IT_RESULT-PFACH = IT_T001W-PFACH * 10000.
IT_RESULT-WBWBEST = IT_S032-WBWBEST / 10000.
* IT_RESULT-PWBWBEST = IT_RESULT-WBWBEST / IT_RESULT-PFACH.
COLLECT IT_RESULT.
ENDLOOP.
ENDFORM. " FRM_PROCESS
*&---------------------------------------------------------------------*
*& Form FRM_OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --&gt p1 text
* *----------------------------------------------------------------------*
FORM FRM_OUTPUT .
LOOP AT IT_RESULT.
PWBWBEST = IT_RESULT-WBWBEST * 10000 / IT_RESULT-PFACH.
WRITE: '|', (30) IT_RESULT-NAME1 , '|' , (25) IT_RESULT-PFACH CENTERED , '|' ,
(28) IT_RESULT-WBWBEST, '|', (28) PWBWBEST , '|'.
ULINE /.
ENDLOOP.
ENDFORM. " FRM_OUTPUT

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

相關文章