*&---------------------------------------------------------------------*
*& Report ZF_TEST4
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT Z_SALAH_SC07.
**********************************************************************
*REPORT DESCRIBE:1. 创建REPORT,要求从根据公司代码从透明表中去BSEG 和BKPF 中取数,
*同样要求使用 FOR ALL entries in 取数,然后进行ALV显示,ALV显示特殊要求,3个按钮,‘操作1’‘操作2’‘操作3’
*,点击操作1后只显示内表前50条数据,其他数据删除,刷新ALV输出,
*点击操作2,把内表中的公司代码,修改为0000.并添加备注“内表以修改”
*,点击操作3 使用二分查找法指定读取一条数据(数据可在程序里自定义在此不详细列出,)
*。如果查到 那就弹出这条数据的具体内容,如果没有查到那就报出消息‘请重新输入未查到!’。
*读取数据:公司代码,凭证编号 凭证日期。
*DEVELOPER:SALAH
*DEVELOP DATE:20190918
*MODIFY DATE:
*FUNCTION SPEC:
*KEY USER:
**********************************************************************
TYPE-POOLS:SLIS.
TABLES:MARA,MSEG,MKPF.
TYPES:BEGIN OF TYP_01,
MBLNR TYPE MSEG-MBLNR,
BUKRS TYPE MSEG-BUKRS,
CPUDT TYPE MKPF-CPUDT,
BEIZU TYPE CHAR20,
END OF TYP_01.
DATA GT_01 TYPE STANDARD TABLE OF TYP_01.
DATA GS_01 TYPE TYP_01.
DATA GT_02 TYPE STANDARD TABLE OF TYP_01.
DATA GS_02 TYPE TYP_01.
DATA GT_MSEG TYPE STANDARD TABLE OF TYP_01.
DATA GS_MSEG TYPE TYP_01.
DATA GT_MKPF TYPE STANDARD TABLE OF TYP_01.
DATA GS_MKPF TYPE TYP_01.
*PARAMETERS P_BUKRS TYPE CHAR04 .
DATA GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
DATA GS_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
DATA L_GRID TYPE REF TO CL_GUI_ALV_GRID.
DEFINE FIELDCAT.
CLEAR GS_FIELDCAT.
GS_FIELDCAT-COL_POS = &1.
GS_FIELDCAT-FIELDNAME = &2.
GS_FIELDCAT-SELTEXT_L = &3.
APPEND GS_FIELDCAT TO GT_FIELDCAT.
END-OF-DEFINITION.
START-OF-SELECTION.
* SELECT BUKRS
* FROM T001
* INTO TABLE @DATA(GS_BUKRS)
* WHERE BUKRS = @P_BUKRS.
* IF SY-SUBRC <> 0.
* MESSAGE '请重新输入' TYPE 'I' DISPLAY LIKE 'E'.
* EXIT.
* ENDIF.
SELECT MBLNR
BUKRS
FROM MSEG
INTO CORRESPONDING FIELDS OF TABLE GT_01.
*WHERE BUKRS EQ P_BUKRS.
IF GT_01 IS NOT INITIAL.
SELECT MBLNR
CPUDT
FROM MKPF
INTO CORRESPONDING FIELDS OF TABLE GT_MKPF
FOR ALL ENTRIES IN GT_01 WHERE MBLNR = GT_01-MBLNR .
ENDIF.
LOOP AT GT_01 INTO GS_01.
READ TABLE GT_MKPF INTO GS_MKPF WITH KEY MBLNR = GS_01-MBLNR .
GS_01-CPUDT = GS_MKPF-CPUDT.
MODIFY GT_01 FROM GS_01 .
ENDLOOP.
END-OF-SELECTION.
IF GT_01 IS NOT INITIAL.
PERFORM FRM_ALV_SHOW.
ELSE.
MESSAGE '无符合要求的数据' TYPE 'E'.
ENDIF.
INCLUDE Z_PHARAOH918.
来源:https://www.cnblogs.com/salah/p/11935425.html