*&---------------------------------------------------------------------*
*& Program Name :ZTST_PPJLI001
*& Title :采购订单查询
*& Module Name :MM模块
*& Author :PPJLI
*& Create Date :11.07.2019 08:56:45
*& Program Type :Report Program
*& Requested by :开发项编号
*& Description :
*&------------------- -------------------------------------------------*
*& Modification LOG
*&
*& 日期 修改人 修改描述
*& ---- ---- ------ -----------
*&---------------------------------------------------------------------*
REPORT YTST_PPJLI001.
*&---------------------------------------------------------------------*
*& 数据定义及屏幕定义部分
*&---------------------------------------------------------------------*
INCLUDE YMMR1001_TOP.
*&---------------------------------------------------------------------*
*& 子程序定义部分
*&---------------------------------------------------------------------*
INCLUDE YMMR1001_FORM.
*START-OF-SELECTION 下面是获取数据 END-OF-DEFINITION 下面是显示数据
START-OF-SELECTION .
PERFORM FRM_MAIN.
END-OF-SELECTION.
*&---------------------------------------------------------------------*
*& Form FRM_MAIN
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_MAIN.
*数据定义
DATA: LT_ORDER TYPE TY_TAB_EKKO_EKPO.
PERFORM FRM_GET_DATA CHANGING LT_ORDER. "获取数据
PERFORM FRM_DISPLAY_DATA USING LT_ORDER. " 展示数据
ENDFORM.
*&---------------------------------------------------------------------*
*& 包含 ZMMR1001_TOP
*&---------------------------------------------------------------------*
TABLES: EKKO,EKPO.
TYPE-POOLS: SLIS.
*&---------------------------------------------------------------------*
*& 类型定义
*&---------------------------------------------------------------------*
TYPES: BEGIN OF TY_EKKO_EKPO,
BUKRS TYPE EKKO-BUKRS, "公司代码
LIFNR TYPE EKKO-LIFNR, "供应商
EKORG TYPE EKKO-EKORG, "采购组织
BSART TYPE EKKO-BSART, "采购凭证
WERKS TYPE EKPO-WERKS, "工厂
MATNR TYPE EKPO-MATNR, "物料号
LGORT TYPE EKPO-LGORT, "库存地点
END OF TY_EKKO_EKPO.
TYPES: TY_TAB_EKKO_EKPO TYPE STANDARD TABLE OF TY_EKKO_EKPO.
*&---------------------------------------------------------------------*
*& 屏幕定义
*&---------------------------------------------------------------------*
SELECTION-SCREEN:BEGIN OF BLOCK BL WITH FRAME TITLE TEXT-001.
PARAMETERS: P_WERKS TYPE EKPO-WERKS. "工厂
SELECT-OPTIONS: S_LIFNR FOR EKKO-LIFNR, "供应商
S_MATNR FOR EKPO-MATNR, "物料
S_EKORG FOR EKKO-EKORG. "采购组织
SELECTION-SCREEN:END OF BLOCK BL.
*&---------------------------------------------------------------------*
*& Include ZMMR1001_FORM
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form GET_DATA
*&---------------------------------------------------------------------*
* text 从数据库表中获取需要查询的字段
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
*数据查询
FORM FRM_GET_DATA CHANGING PT_ORDER TYPE TY_TAB_EKKO_EKPO.
SELECT
EKKO~BUKRS "公司代码
EKKO~LIFNR "供应商
EKKO~EKORG "采购组织
EKKO~BSART "采购凭证
EKPO~WERKS "工厂
EKPO~MATNR "物料号
EKPO~LGORT "库存地点
FROM EKKO
INNER JOIN EKPO
ON EKKO~EBELN = EKPO~EBELN
INTO CORRESPONDING FIELDS OF TABLE PT_ORDER
WHERE EKPO~WERKS = P_WERKS "工厂
AND EKKO~LIFNR IN S_LIFNR "供应商
AND EKPO~MATNR IN S_MATNR "物料号
AND EKKO~EKORG IN S_EKORG. "采购组织
ENDFORM.
**&---------------------------------------------------------------------*
**& Form DISPLAY_DATA
**&---------------------------------------------------------------------*
** text 对报表展示进行设计
**----------------------------------------------------------------------*
** --> p1 text
** <-- p2 text
**----------------------------------------------------------------------*
FORM FRM_DISPLAY_DATA USING PT_ORDER TYPE TY_TAB_EKKO_EKPO.
DATA: LWA_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
LWA_LAYOUT TYPE SLIS_LAYOUT_ALV,
LT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
"获取表头字LT_FIELDCAT段信息
PERFORM FRM_BUILD1_FIELDCAT CHANGING LT_FIELDCAT.
PERFORM FRM_PRINT_ALV TABLES PT_ORDER
CHANGING LWA_LAYOUT
LWA_FIELDCAT
LT_FIELDCAT.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form BUILD_FIELDCAT
*&---------------------------------------------------------------------*
* text : 定义ALV表头
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_BUILD1_FIELDCAT USING LT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
PERFORM FRM_GS_FIELDCAT TABLES LT_FIELDCAT USING: 'BUKRS' '公司代码',
'LIFNR' '供应商',
'EKORG' '采购组织',
'LGORT' '库存地点',
'BSART' '采购凭证',
'WERKS' '工厂',
'MATNR' '物料号'.
ENDFORM. " BUILD_FIELDCAT
*&---------------------------------------------------------------------*
*& Form ALV_GS_FIELDCAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_0103 text
* -->P_0104 text
*----------------------------------------------------------------------*
FORM FRM_GS_FIELDCAT TABLES P_LT_FIELDCAT
USING VALUE(P_0089)
VALUE(P_0090).
DATA: LWA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
LWA_FIELDCAT-FIELDNAME = P_0089. "字段名
LWA_FIELDCAT-SELTEXT_L = P_0090. "字段描述
APPEND LWA_FIELDCAT TO P_LT_FIELDCAT.
CLEAR LWA_FIELDCAT.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_PRINT_ALV
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* <--P_LT_ORDER text
*----------------------------------------------------------------------*
FORM FRM_PRINT_ALV TABLES PT_ORDER TYPE TY_TAB_EKKO_EKPO
USING P_LWA_LAYOUT TYPE SLIS_LAYOUT_ALV
P_LWA_FIELDCAT TYPE SLIS_FIELDCAT_ALV
P_LT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
* 定义样式子例程框
P_LWA_LAYOUT-ZEBRA = 'X' . "zebra表示隔行显示不同颜色
P_LWA_LAYOUT-COLWIDTH_OPTIMIZE = 'X'. "自动调整列宽
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID "当前程序
IS_LAYOUT = P_LWA_LAYOUT "表头样式
IT_FIELDCAT = p_LT_FIELDCAT "表头字段
TABLES
T_OUTTAB = PT_ORDER
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
ENDFORM.
* 在PERFORM调用的地方定义, 用传参数的形式 传到form 里使用
* 调用 changing... 实现 USING
* changing 要在USING 后面,, 所以用TABLES,
- 在PERFORM调用的地方定义, 用传参数的形式 传到form 里使用
- 调用 changing... 实现 USING
- changing 要在USING 后面,, 所以用TABLES,