ITPub博客

首页 > Linux操作系统 > Linux操作系统 > ABAP开发程序的基本样式

ABAP开发程序的基本样式

原创 Linux操作系统 作者:chouer523 时间:2019-05-23 13:21:05 0 删除 编辑
这个是我写的第一个程式,所有现在都舍不得扔掉。整个报表的格式大概就是这样吧!很简单的程式!

*******************************************************
声明:原创文章--版权所有---转载请保留信息
MSN:
njchouer@hotmail.com
作者:chouer
********************************************************

************************************************************************
*********PROGRAM NAME:ZRMOO3
*********DESCRIPTION:Material master detail report
*********DATE/AUTHOR:2006.01.17 /Chouer
************************************************************************
************************************************************************
**M O D I F I C A T I O N L O G
************************************************************************
************************************************************************
**CHANGEDATE PROGRAMMER REQUEST DESCRIPTION
**======================================================================
************************************************************************
**************
REPORT ZRM003
NO STANDARD PAGE HEADING
LINE-SIZE 255
LINE-COUNT 64(1).
TABLES:MARC,
MAKT,
MARA.
DATA:BEGIN OF I_OUT OCCURS 100,
WERKS LIKE MARC-WERKS,
MATNR LIKE MARA-MATNR,
MAKTX LIKE MAKT-MAKTX,
ERSDA LIKE MARA-ERSDA,
ERNAM LIKE MARA-ERNAM,
MTART LIKE MARA-MTART,
MATKL LIKE MARA-MATKL,
MEINS LIKE MARA-MEINS,
AUSME LIKE MARC-AUSME,
XCHPF LIKE MARC-XCHPF,
DISMM LIKE MARC-DISMM,
PLIFZ LIKE MARC-PLIFZ,
WEBAZ LIKE MARC-WEBAZ,
MHDRZ LIKE MARA-MHDRZ,
MHDHB LIKE MARA-MHDHB,
LVORM LIKE MARC-LVORM,
END OF I_OUT.
DATA:BEGIN OF LEN,
MATNR TYPE I VALUE 18,
MAKTX TYPE I VALUE 40,
ERSDA TYPE I VALUE 8,
ERNAM TYPE I VALUE 8,
MTART TYPE I VALUE 6,
MATKL TYPE I VALUE 6,
MEINS TYPE I VALUE 5,
AUSME TYPE I VALUE 6,
XCHPF TYPE I VALUE 6,
DISMM TYPE I VALUE 4,
PLIFZ TYPE I VALUE 7,
WEBAZ TYPE I VALUE 8,
MHDRZ TYPE I VALUE 10,
MHDHB TYPE I VALUE 10,
END OF LEN.
DATA: pnEND TYPE I,
pxREPID LIKE SY-REPID.
************************************************************************
***SELECTION SCREEN
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-020.
PARAMETERS:
P_WERKS LIKE MARC-WERKS OBLIGATORY.
SELECT-OPTIONS S_MTART FOR MARA-MTART.
SELECT-OPTIONS S_MATKL FOR MARA-MATKL.
SELECT-OPTIONS S_MATNR FOR MARA-MATNR.
SELECT-OPTIONS S_ERSDA FOR MARA-ERSDA.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS:
C1_LVORM LIKE MARA-LVORM.
SELECTION-SCREEN COMMENT 3(60) TEXT-021 FOR FIELD C1_LVORM.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS:
C2_LVORM LIKE MARC-LVORM.
SELECTION-SCREEN COMMENT 3(60) TEXT-022 FOR FIELD C2_LVORM.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK B1.
************************************************************************
****INITIALIZATION
************************************************************************
INITIALIZATION.
************************************************************************
**START-OF-SELECTION
************************************************************************
START-OF-SELECTION.
PERFORM GET_DATA.
************************************************************************
**END-OF_SELECTION
************************************************************************
END-OF-SELECTION.
PERFORM WRITE_REPORT.
************************************************************************
**TOP OF PAGE
************************************************************************
TOP-OF-PAGE.
PERFORM WRITE_HEADER.
************************************************************************
**END OF PAGE
************************************************************************
END-OF-PAGE.
pnEND = SY-LINSZ - 112.
WRITE AT pnEND 'continue...'.
************************************************************************
**FORM GET_DATA
************************************************************************
FORM GET_DATA.
IF C1_LVORM <> 'X' AND C2_LVORM <> 'X'.
SELECT B~WERKS A~MATNR A~ERSDA A~ERNAM A~MTART A~MATKL A~MEINS
B~AUSME B~XCHPF B~DISMM B~PLIFZ B~WEBAZ A~MHDRZ A~MHDHB
INTO CORRESPONDING FIELDS OF TABLE I_OUT
FROM MARA AS A
LEFT OUTER JOIN MARC AS B ON A~MATNR = B~MATNR
WHERE A~MTART IN S_MTART
AND A~MATKL IN S_MATKL
AND A~MATNR IN S_MATNR
AND A~ERSDA IN S_ERSDA
ORDER BY A~MATNR.
ELSEIF C1_LVORM = 'X' AND C2_LVORM <> 'X'.
SELECT B~WERKS A~MATNR A~ERSDA A~ERNAM A~MTART A~MATKL A~MEINS
B~AUSME B~XCHPF B~DISMM B~PLIFZ B~WEBAZ A~MHDRZ A~MHDHB
INTO CORRESPONDING FIELDS OF TABLE I_OUT
FROM MARA AS A
LEFT OUTER JOIN MARC AS B ON A~MATNR = B~MATNR
WHERE A~LVORM <> 'X'
AND A~MTART IN S_MTART
AND A~MATKL IN S_MATKL
AND A~MATNR IN S_MATNR
AND A~ERSDA IN S_ERSDA
ORDER BY A~MATNR.
ELSEIF C2_LVORM = 'X' AND C1_LVORM <> 'X'.
SELECT B~WERKS A~MATNR A~ERSDA A~ERNAM A~MTART
A~MATKL A~MEINS B~AUSME B~XCHPF B~DISMM
B~PLIFZ B~WEBAZ A~MHDRZ A~MHDHB B~LVORM
INTO CORRESPONDING FIELDS OF TABLE I_OUT
FROM MARA AS A
LEFT OUTER JOIN MARC AS B ON A~MATNR = B~MATNR
WHERE A~MTART IN S_MTART
AND A~MATKL IN S_MATKL
AND A~MATNR IN S_MATNR
AND A~ERSDA IN S_ERSDA
ORDER BY A~MATNR.
DELETE I_OUT WHERE LVORM = 'X'.
ENDIF.
**GET THE PLANT
DELETE I_OUT WHERE WERKS <> P_WERKS.

LOOP AT I_OUT.
**GET THE DESCRIPTION FROM TABLE(MAKT)
SELECT SINGLE MAKTX
INTO I_OUT-MAKTX FROM MAKT
WHERE MATNR = I_OUT-MATNR
AND SPRAS = SY-LANGU.
MODIFY I_OUT.
ENDLOOP.
ENDFORM.

************************************************************************
**FORM WRITE_HEADER
************************************************************************
FORM WRITE_HEADER.
WRITE: 50 'Checking report for Material Master'.
SKIP.
WRITE:'Plant:',P_WERKS.
SKIP.
WRITE:
at /(LEN-MATNR) 'Material' ,
at (LEN-MAKTX) 'Description',
at (LEN-ERSDA) 'Creation',
at (LEN-ERNAM) 'Created',
at (LEN-MTART) text-023,
at (LEN-MATKL) text-024,
at (LEN-MEINS) 'Base' ,
at (LEN-AUSME) 'Issue',
at (LEN-XCHPF) 'Batch',
at (LEN-DISMM) 'MRP',
at (LEN-PLIFZ) 'Deliv' RIGHT-JUSTIFIED,
at (LEN-WEBAZ) 'GR proc' RIGHT-JUSTIFIED,
at (LEN-MHDRZ) 'Min.rem' RIGHT-JUSTIFIED,
at (LEN-MHDHB) 'Total' RIGHT-JUSTIFIED.
WRITE:
at /(LEN-MATNR) '',
at (LEN-MAKTX) '',
at (LEN-ERSDA) 'Date',
at (LEN-ERNAM) 'by',
at (LEN-MTART) 'Type',
at (LEN-MATKL) 'Group',
at (LEN-MEINS) 'UoM' ,
at (LEN-AUSME) 'Unit',
at (LEN-XCHPF) 'Mgt',
at (LEN-DISMM) 'Type',
at (LEN-PLIFZ) 'Time',
at (LEN-WEBAZ) 'Time',
at 135(LEN-MHDRZ) 'shelf life',
at (LEN-MHDHB) 'Shelf life'.
ULINE.
ENDFORM.
************************************************************************
**FORM WRITE_REPORT
************************************************************************
FORM WRITE_REPORT.
SORT I_OUT BY MATNR.
LOOP AT I_OUT.
WRITE: at /(LEN-MATNR) I_OUT-MATNR(18),
at (LEN-MAKTX) I_OUT-MAKTX(40),
at (LEN-ERSDA) I_OUT-ERSDA,
at (LEN-ERNAM) I_OUT-ERNAM(12),
at (LEN-MTART) I_OUT-MTART,
at (LEN-MATKL) I_OUT-MATKL,
at (LEN-MEINS) I_OUT-MEINS,
at (LEN-AUSME) I_OUT-AUSME,
at (LEN-XCHPF) I_OUT-XCHPF,
at (LEN-DISMM) I_OUT-DISMM,
at (LEN-PLIFZ) I_OUT-PLIFZ,
at (LEN-WEBAZ) I_OUT-WEBAZ,
at (LEN-MHDRZ) I_OUT-MHDRZ,
at (LEN-MHDHB) I_OUT-MHDHB.
ENDLOOP.
ENDFORM.

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/332542/viewspace-53514/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-03-28

  • 博文量
    74
  • 访问量
    47832