博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
UI基础一:简单的BOL查询
阅读量:5278 次
发布时间:2019-06-14

本文共 10198 字,大约阅读时间需要 33 分钟。

利用标准的BOL编辑工具,添加BOL对象,重写查询方法,实现简答的BOL查询

1.SE11创建查询对象结构:

 

2.SE11创建查询结果对象:

 

3.SE24新建处理类:

重写查询结果方法:

METHOD IF_GENIL_APPL_INTLAY~GET_DYNAMIC_QUERY_RESULT.    TYPES:BEGIN OF TY_ADM,            GUID_H         TYPE CRMT_OBJECT_GUID, "销售订单            OBJECT_ID      TYPE CRMT_OBJECT_ID_DB,            OBJECT_ID_H    TYPE CRMT_OBJECT_ID_DB, "销售订单            ZZZTRACKRETURN TYPE ZTRACKRETURN, "销售订单-发回运单号            GUID_D         TYPE CRMT_OBJECT_GUID, "维修工单            OBJECT_ID_D    TYPE CRMT_OBJECT_ID_DB, "维修工单          END OF TY_ADM,          BEGIN OF TY_PARTNER,            GUID_HI    TYPE CRMT_OBJECT_GUID,            GUID_SET   TYPE CRMT_OBJECT_GUID,            PARTNER_NO TYPE CRMT_PARTNER_NO,            PARTNER    TYPE BU_PARTNER,            BU_SORT1   TYPE BU_SORT1,          END OF TY_PARTNER,          BEGIN OF TY_ITEM,            HEADER       TYPE CRMT_OBJECT_GUID, "销售订单            PRODUCT      TYPE CRMT_PRODUCT_GUID_DB,            ORDERED_PROD TYPE CRMT_ORDERED_PROD_DB,            NUMBER_INT   TYPE CRMT_ITEM_NO,            ITM_TYPE     TYPE CRMT_ITEM_TYPE_DB,            QUANTITY     TYPE CRMT_SCHEDLIN_QUAN,          END OF TY_ITEM,          BEGIN OF TY_RESU,            GUID_H         TYPE CRMT_OBJECT_GUID,            OBJECT_ID      TYPE CRMT_OBJECT_ID_DB,            CREATED_AT     TYPE COMT_CREATED_AT_USR,            ZZZMODENO      TYPE ZMODENO,            ZZCLIENT_TYPE  TYPE ZADTEL000056,            PO_NUMBER_SOLD TYPE CRMT_PO_NUMBER_SOLD,          END OF TY_RESU.    DATA: LT_SELECTION    TYPE AXTT_TABLES_SEL_PARAM,          LS_SELECTION    TYPE AXT_TABLES_SEL_PARAM,          RT_OBJECT_ID    TYPE RANGE OF CRMT_OBJECT_ID,          RS_OBJECT_ID    LIKE LINE OF RT_OBJECT_ID,          RT_ZZAFLD00001X TYPE RANGE OF ZADTEL00009Q,          RS_ZZAFLD00001X LIKE LINE OF RT_ZZAFLD00001X,          LV_DATE         TYPE ZADTEL00009Q,          RT_ZZAFLD00001Y TYPE RANGE OF ZADTEL00009U,          RS_ZZAFLD00001Y LIKE LINE OF RT_ZZAFLD00001Y,          LV_TIME         TYPE ZADTEL00009U,          LX_ROOT         TYPE REF TO CX_ROOT.              "#EC NEEDED    DATA:GT_ADM      TYPE TABLE OF TY_ADM,         VT_ADM      TYPE TABLE OF TY_ADM,         GW_ADM      LIKE LINE OF GT_ADM,         GT_PARTNER  TYPE TABLE OF TY_PARTNER,         LT_PARTNER  TYPE TABLE OF TY_PARTNER,         GW_PARTNER  LIKE LINE OF GT_PARTNER,         LS_PARTNER  LIKE LINE OF LT_PARTNER,         GV_PARTNER  TYPE BU_PARTNER_GUID,         GT_ITEM     TYPE TABLE OF TY_ITEM,         VT_ITEM     TYPE TABLE OF TY_ITEM,         GW_ITEM     LIKE LINE OF GT_ITEM,         GT_PRTEXT   TYPE TABLE OF COMM_PRSHTEXT,         GW_PRTEXT   LIKE LINE OF GT_PRTEXT,         GV_INDEX    TYPE I,         GT_PRICE    TYPE TABLE OF CNCCRMPRSAP032,         GW_PRICE    LIKE LINE OF GT_PRICE,         GV_TIMESTMP TYPE /SAPCND/TIMESTAMP_TO.. "    DATA LS_SELECTION_PARAS TYPE GENILT_SELECTION_PARAMETER.    DATA LT_WHERE_CONDITION TYPE CRMT_REPORT_DYN_SQL_LINE_TA.    DATA: LT_RESULT TYPE TABLE OF ZCRMS0031,          LT_RESU   TYPE TABLE OF TY_RESU,          LS_RESU   LIKE LINE OF LT_RESU,          GT_RESULT TYPE TABLE OF ZCRMS0031,          LS_RESULT TYPE          ZCRMS0031.    DATA: LV_MAXHIT     TYPE          INT4,          LV_NAME       TYPE THEAD-TDNAME,          LV_STR1       TYPE STRING,          LV_STR2       TYPE STRING,          LV_OBJECT_KEY TYPE          CRMT_BSP_OBJECTKEY,          LR_OBJECT     TYPE REF TO   IF_GENIL_CONT_ROOT_OBJECT.    DEFINE SET_RESULT.      LOOP AT GT_RESULT INTO LS_RESULT.         LR_OBJECT = IV_ROOT_LIST->ADD_OBJECT( IV_OBJECT_NAME = 'ZODRESULT'                                        IS_OBJECT_KEY = LS_RESULT-OBJECT_ID ).         LV_OBJECT_KEY = LS_RESULT-OBJECT_ID.         LR_OBJECT->SET_KEY( LV_OBJECT_KEY ).         LR_OBJECT->SET_ATTRIBUTES( LS_RESULT ).         CLEAR LS_RESULT.      ENDLOOP.    END-OF-DEFINITION .*    IF ZCL_CRM_BUFFER=>GT_RESULT IS NOT INITIAL.*      LT_RESULT = ZCL_CRM_BUFFER=>GT_RESULT .*      SET_RESULT.**      CLEAR ZCL_CRM_BUFFER=>GT_RESULT.*      EXIT.*    ENDIF.    LT_SELECTION = IT_SELECTION_PARAMETERS.*    SORT LT_SELECTION BY ATTR_NAME.    LOOP AT LT_SELECTION INTO LS_SELECTION.      CASE  LS_SELECTION-ATTR_NAME.        WHEN 'OBJECT_ID'.          MOVE-CORRESPONDING LS_SELECTION TO RS_OBJECT_ID.          INSERT RS_OBJECT_ID INTO TABLE RT_OBJECT_ID.        WHEN 'ZZAFLD00001X'.          MOVE-CORRESPONDING LS_SELECTION TO RS_ZZAFLD00001X.          INSERT RS_ZZAFLD00001X INTO TABLE RT_ZZAFLD00001X.        WHEN 'ZZAFLD00001Y'.          MOVE-CORRESPONDING LS_SELECTION TO RS_ZZAFLD00001Y.          INSERT RS_ZZAFLD00001Y INTO TABLE RT_ZZAFLD00001Y.      ENDCASE.    ENDLOOP.    LV_MAXHIT = IS_QUERY_PARAMETERS-MAX_HITS.    SELECT SINGLE PARTNER_GUID INTO GV_PARTNER      FROM BUT000 WHERE PARTNER = '0000200100'."'0000202525'.    "取到销售订单抬头信息    SELECT A~GUID      AS GUID_H           A~OBJECT_ID           A~PO_NUMBER_SOLD AS OBJECT_ID_H           A~ZZZTRACKRETURN      INTO CORRESPONDING FIELDS OF TABLE GT_ADM      FROM ZHSB_SALES_INDEX AS A      INNER JOIN CRMD_ORDERADM_I AS B      ON A~GUID = B~HEADER      WHERE A~OBJECT_ID IN RT_OBJECT_ID      AND   B~ZZAFLD00001X IN RT_ZZAFLD00001X      AND   B~ZZAFLD00001Y IN RT_ZZAFLD00001Y*      AND   B~ZZAFLD00001X <> LV_DATE      AND   A~PROCESS_TYPE = 'ZSO5'      AND   A~SALES_ORG    = 'O 50000231'."日期不为空    IF GT_ADM[] IS NOT INITIAL.      "合作伙伴过滤      SELECT A~GUID_HI"    TYPE CRMT_OBJECT_GUID,             A~GUID_SET"   TYPE CRMT_OBJECT_GUID,             B~PARTNER_NO" TYPE CRMT_PARTNER_NO,        INTO CORRESPONDING FIELDS OF TABLE GT_PARTNER        FROM CRMD_LINK AS A        INNER JOIN CRMD_PARTNER AS B        ON A~GUID_SET = B~GUID        AND B~PARTNER_NO = GV_PARTNER        FOR ALL ENTRIES IN GT_ADM        WHERE A~GUID_HI = GT_ADM-GUID_H        AND   A~OBJTYPE_SET = '07'.                         "付款方为202525      "取销售订单项目      SELECT A~HEADER"       TYPE CRMT_OBJECT_GUID, "销售订单             A~PRODUCT  "    TYPE CRMT_PRODUCT_GUID_DB,             A~ORDERED_PROD" TYPE CRMT_ORDERED_PROD_DB,             A~NUMBER_INT  " TYPE CRMT_ITEM_NO,             A~ITM_TYPE   "  TYPE CRMT_ITEM_TYPE_DB,             B~QUANTITY        INTO TABLE GT_ITEM        FROM CRMD_ORDERADM_I AS A        INNER JOIN CRMD_SCHEDLIN AS B        ON A~GUID = B~ITEM_GUID        AND B~EVENT_TYPE = 'ORDER'        FOR ALL ENTRIES IN GT_ADM        WHERE HEADER = GT_ADM-GUID_H.      "销售订单项目 物料文本      IF GT_ITEM[] IS NOT INITIAL.        VT_ITEM[] = GT_ITEM[].        SORT VT_ITEM BY PRODUCT.        DELETE ADJACENT DUPLICATES FROM VT_ITEM COMPARING PRODUCT.        SELECT * INTO TABLE GT_PRTEXT          FROM COMM_PRSHTEXT          FOR ALL ENTRIES IN VT_ITEM          WHERE PRODUCT_GUID = VT_ITEM-PRODUCT          AND   LANGU = 'J'.        CONCATENATE SY-DATUM SY-UZEIT INTO GV_TIMESTMP.        SELECT * INTO CORRESPONDING FIELDS OF TABLE GT_PRICE          FROM CNCCRMPRSAP032          FOR ALL ENTRIES IN VT_ITEM          WHERE PRODUCT     = VT_ITEM-PRODUCT          AND   SALES_ORG   = 'O 50000231'          AND   DIS_CHANNEL = '11'          AND   PRICE_GRP   IN ('11','12','03')          AND   KSCHL       = 'ZPR0'          AND   TIMESTAMP_TO >= GV_TIMESTMP          AND   TIMESTAMP_FROM < GV_TIMESTMP.      ENDIF.      "取维修工单抬头      VT_ADM[] = GT_ADM[].      DELETE VT_ADM WHERE OBJECT_ID_H IS INITIAL.      IF VT_ADM[] IS NOT INITIAL.        SELECT GUID AS GUID_H             OBJECT_ID             CREATED_AT             ZZZMODENO             ZZCLIENT_TYPE             PO_NUMBER_SOLD        INTO CORRESPONDING FIELDS OF TABLE LT_RESU        FROM ZHSB_ORDER_INDEX        FOR ALL ENTRIES IN VT_ADM        WHERE OBJECT_ID = VT_ADM-OBJECT_ID_H        AND   PROCESS_TYPE   = 'ZSV1'.      ENDIF.      CHECK LT_RESU[] IS NOT INITIAL.      IF LT_RESU[] IS NOT INITIAL.        SELECT A~GUID_HI"    TYPE CRMT_OBJECT_GUID,           A~GUID_SET"   TYPE CRMT_OBJECT_GUID,           B~PARTNER_NO" TYPE CRMT_PARTNER_NO,           C~PARTNER           C~BU_SORT1      INTO CORRESPONDING FIELDS OF TABLE LT_PARTNER      FROM CRMD_LINK AS A      INNER JOIN CRMD_PARTNER AS B      ON A~GUID_SET = B~GUID      AND B~PARTNER_FCT = 'ZHSI00SN'      INNER JOIN BUT000 AS C      ON B~PARTNER_NO = C~PARTNER_GUID      FOR ALL ENTRIES IN LT_RESU      WHERE A~GUID_HI = LT_RESU-GUID_H      AND   A~OBJTYPE_SET = '07'.      ENDIF.    ENDIF.    LOOP AT GT_ADM INTO GW_ADM.      READ TABLE GT_PARTNER INTO GW_PARTNER WITH KEY GUID_HI = GW_ADM-GUID_H."过滤条件      IF SY-SUBRC = 0.        READ TABLE LT_RESU INTO LS_RESU WITH KEY OBJECT_ID = GW_ADM-OBJECT_ID_H.        IF SY-SUBRC = 0.          MOVE-CORRESPONDING LS_RESU TO LS_RESULT.          READ TABLE LT_PARTNER INTO LS_PARTNER WITH KEY GUID_HI = LS_RESU-GUID_H.          IF SY-SUBRC = 0.            LS_RESULT-BU_SORT1 = LS_PARTNER-BU_SORT1.          ENDIF.          LOOP AT GT_ITEM INTO GW_ITEM WHERE HEADER = GW_ADM-GUID_H."销售订单项目            LS_RESULT-ZZZTRACKRETURN = GW_ADM-ZZZTRACKRETURN."跟踪单号*            LS_RESULT-PRODUCT = GW_ITEM-PRODUCT."产品GUID            LS_RESULT-ORDERED_PROD = GW_ITEM-ORDERED_PROD.            LS_RESULT-PRODUCT_ID = GW_ITEM-ORDERED_PROD.            LS_RESULT-QUANTITY = GW_ITEM-QUANTITY.            READ TABLE GT_PRTEXT INTO GW_PRTEXT WITH KEY PRODUCT_GUID = GW_ITEM-PRODUCT.            IF SY-SUBRC = 0.              LS_RESULT-SHORT_TEXT = GW_PRTEXT-SHORT_TEXT.            ENDIF.            LOOP AT GT_PRICE INTO GW_PRICE WHERE PRODUCT = GW_ITEM-PRODUCT.              CASE GW_PRICE-PRICE_GRP.                WHEN '03'."End User                  LS_RESULT-SUBTOTAL3 = GW_PRICE-KBETR.                WHEN '11'."Retailer                  LS_RESULT-SUBTOTAL1 = GW_PRICE-KBETR.                WHEN '12'."Distributor                  LS_RESULT-SUBTOTAL2 = GW_PRICE-KBETR.                WHEN OTHERS.              ENDCASE.            ENDLOOP.            APPEND LS_RESULT TO GT_RESULT.          ENDLOOP.        ENDIF.      ENDIF.    ENDLOOP.    SET_RESULT."添加结果  ENDMETHOD.

4.编辑BOL类:

事务代码:GENIL_MODEL_EDITOR

输入组件:ZCRMOD 点击创建

点击查询结果对象,右键创建:

 

点击动态查询对象,右键新建:ZODSEARCH

 

实施类:ZCL_DOWNLOAD_ORDER_IL

 

5.SPRO新建组件集,添加组件到组件集

 

6.UI组件:

事务代码:BSP_WD_CMPWB

输入组件名称:ZPARTLIST创建,

运行时资源库,添加组件集

退出重新事务代码进入,右键视图,创建搜索页面。根据向导一直做完就可以了,然后配置页面,就OK了

转载于:https://www.cnblogs.com/sapSB/p/6823522.html

你可能感兴趣的文章
MySQL 字符编码问题详细解释
查看>>
寄Android开发Gradle你需要知道的知识
查看>>
css & input type & search icon
查看>>
C# 强制关闭当前程序进程(完全Kill掉不留痕迹)
查看>>
语音识别中的MFCC的提取原理和MATLAB实现
查看>>
0320-学习进度条
查看>>
MetaWeblog API Test
查看>>
移动、尺寸改变
查看>>
c# 文件笔记
查看>>
类和结构
查看>>
心得25--JDK新特性9-泛型1-加深介绍
查看>>
安装NVIDIA驱动时禁用自带nouveau驱动
查看>>
HDU-1255 覆盖的面积 (扫描线)
查看>>
Java 中 静态方法与非静态方法的区别
查看>>
Jenkins+ProGet+Windows Batch搭建全自动的内部包(NuGet)打包和推送及管理平台
查看>>
线程池的概念
查看>>
Java 序列化
查看>>
Java 时间处理实例
查看>>
Java 多线程编程
查看>>
Java 数组实例
查看>>