Chinaunix首页 | 论坛 | 博客
  • 博客访问: 706099
  • 博文数量: 145
  • 博客积分: 3446
  • 博客等级: 中校
  • 技术积分: 1567
  • 用 户 组: 普通用户
  • 注册时间: 2006-08-30 13:58
文章分类

全部博文(145)

文章存档

2021年(1)

2020年(1)

2019年(1)

2018年(6)

2017年(1)

2016年(10)

2015年(12)

2014年(10)

2013年(15)

2012年(33)

2011年(21)

2010年(9)

2009年(18)

2008年(2)

2006年(5)

我的朋友

分类:

2011-05-16 23:13:39

*&---------------------------------------------------------------------*
*& Report  ZGEP_VCZX0020                                               *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*&                                                                     *
*&---------------------------------------------------------------------*
REPORT  zgep_vczx0020                           .
TABLES: z1crm_order_head ,z1crm_sales_org,but000,crmd_orderadm_h.
TYPE-POOLS: slis.
DATA: g_repid     LIKE sy-repid.
DATA: gt_fieldcat TYPE slis_t_fieldcat_alv .
DATA: gs_fieldcat TYPE slis_fieldcat_alv .
DATA: gs_layout   TYPE slis_layout_alv.
DATA: gs_variant  LIKE disvariant.
DATA: BEGIN OF itab OCCURS 0 .
        INCLUDE STRUCTURE z1crm_order_head .
DATA: text_org LIKE z1crm_sales_org-text_org.
DATA: sold_to_name LIKE but000-name_org1 .
DATA: ship_to_name LIKE but000-name_org1 .
DATA: line_color(4) TYPE c .
DATA: END OF itab .
DATA : guid_temp TYPE crmt_object_guid .
*DATA: itab1 LIKE TABLE OF itab .
DATA: return(1) .
DATA: answer(1) .
DATA: i_t_params  TYPE rsti_t_par .
DATA: i_s_params  TYPE rsparams .
DATA: dest LIKE rfcdes-rfcdest.
RANGES: r_order FOR z1crm_order_head-order_id .
RANGES: r_order1 FOR z1crm_order_head-order_id .
DATA: BEGIN OF order OCCURS 0 .
DATA: order_id LIKE z1crm_order_head-order_id .
DATA: END OF order .

SELECTION-SCREEN BEGIN OF BLOCK bk1 WITH FRAME TITLE text-001.
PARAMETER: mill LIKE z1crm_order_head-mill OBLIGATORY .       "工厂编号
SELECT-OPTIONS pro_type FOR z1crm_order_head-process_type .   "订单类型
SELECT-OPTIONS cdate    FOR z1crm_order_head-creat_date .   "订单类型
SELECT-OPTIONS statu    FOR z1crm_order_head-txt04_process .   "订单状态
*PARAMETERS: check_y RADIOBUTTON GROUP g1 DEFAULT 'X' .
*PARAMETERS: check_e RADIOBUTTON GROUP g1 .
PARAMETERS: error AS CHECKBOX .
SELECTION-SCREEN END OF BLOCK bk1.
START-OF-SELECTION.
*********获得主数据
  IF statu IS INITIAL .
    statu-sign     = 'I' .
    statu-option   = 'BT' .
    statu-low      = 'A110' .
    statu-high     = 'A140' .
    APPEND statu .
  ENDIF.
  REFRESH: itab ,r_order ,r_order1,order.
  SELECT * INTO TABLE itab
    FROM z1crm_order_head
    WHERE mill = mill
      AND txt04_process IN statu
      AND process_type IN pro_type
      AND creat_date IN cdate.
  SORT itab BY order_id .
  DELETE ADJACENT DUPLICATES FROM itab COMPARING order_id .
********找出已传输到R3的单子
  REFRESH: r_order .
  LOOP AT itab .
    r_order-sign = 'I' .
    r_order-option = 'EQ'.
    r_order-low = itab-order_id .
    APPEND r_order .CLEAR r_order .
  ENDLOOP .
  IF sy-mandt = '777'.
    dest = 'RFC_P01_666_GE'.
  ELSEIF sy-mandt = '162'.
    dest = 'D01_170_HQ'.
*    dest = 'PRO_666_HP'.
  ELSEIF sy-mandt = '137'.
    dest = 'RFC_RS1_666_HQ'.
  ENDIF .
  CALL FUNCTION 'ZGET_VBELN'
    DESTINATION dest
    TABLES
      order = r_order.
  LOOP AT r_order .
    DELETE itab WHERE order_id = r_order-low .
  ENDLOOP .
  IF r_order[] IS NOT INITIAL .
    UPDATE z1crm_order_head SET stat_process = 'E0022'
                                txt04_process = 'B010'
         WHERE order_id IN r_order
           AND txt04_process <> 'B020'.
  ENDIF.
*******找出有批次为空的单子
  IF error <> 'X'.
    REFRESH: r_order1,order .
    LOOP AT itab .
      r_order1-sign = 'I' .
      r_order1-option = 'EQ'.
      r_order1-low = itab-order_id .
      APPEND r_order1 .CLEAR r_order1 .
    ENDLOOP .
    SELECT order_id INTO TABLE order
      FROM z1crm_order_head
      WHERE mill = mill
        AND order_id IN r_order1
        AND ( matnr IN ('','000000000043300000',
                   '000000000053000000','000000000053300000')
             OR charg = '' OR txt04_process < 'A110') .
    LOOP AT order .
      DELETE itab WHERE order_id = order-order_id .
    ENDLOOP .
  ENDIF.
*********找出标准表里不存在的记录
  REFRESH: r_order1,order .
  LOOP AT itab .
    r_order1-sign = 'I' .
    r_order1-option = 'EQ'.
    r_order1-low = itab-order_id .
    APPEND r_order1 .CLEAR r_order1 .
  ENDLOOP .
  SELECT object_id INTO TABLE order
    FROM crmd_orderadm_h
    WHERE object_id IN r_order1 .
  LOOP AT itab .
    READ TABLE order WITH KEY order_id = itab-order_id .
    IF sy-subrc <> 0 .
      DELETE itab . CLEAR itab .
    ENDIF .
  ENDLOOP .
*********判断能否传输
*  IF check_y = 'X' .  "传输失败
  LOOP AT itab .
    CLEAR return .
    CALL FUNCTION 'Z1CRM_TRANSFER_CHECK'
      EXPORTING
        guid   = itab-head_guid
      IMPORTING
        return = return.
    IF return = 'E' .
      itab-line_color = 'C610'.
    ELSEIF return = 'T'.
      itab-line_color = 'C510'.
    ELSEIF return = 'F' .
      itab-line_color = 'C410'.
    ENDIF .
    MODIFY itab. CLEAR itab .
  ENDLOOP .
*  ENDIF .
*********************描述
  LOOP AT itab .
    SELECT SINGLE text_org INTO itab-text_org
      FROM z1crm_sales_org
      WHERE sales_group = itab-sales_group
        AND spras = '1'.
    SELECT SINGLE name_org1 INTO itab-sold_to_name
      FROM but000
      WHERE partner = itab-sold_to .
    SELECT SINGLE name_org1 INTO itab-ship_to_name
      FROM but000
      WHERE partner = itab-ship_to .
    MODIFY itab.CLEAR itab .
  ENDLOOP .
  SORT itab BY creat_date DESCENDING .
END-OF-SELECTION.
  gs_layout-zebra             = 'X'.
  gs_layout-cell_merge        = 'X'.
  gs_layout-colwidth_optimize = 'X'.
  gs_layout-info_fieldname = 'LINE_COLOR'.
  g_repid = sy-repid.
  gs_variant-report = sy-repid.
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
*      i_background_id    = 'ALV_BACKGROUND'
      i_callback_pf_status_set = 'MENU_SET'
      i_callback_user_command  = 'USER_COMMAND'
      i_callback_program = g_repid
      i_structure_name   = 'ZGEP_VCZX0020'
      is_layout          = gs_layout
*      i_save             = 'A'
*      is_variant         = gs_variant
*      it_fieldcat        = gt_fieldcat[]
    TABLES
      t_outtab           = itab.
*&--------------------------------------------------------------------*
*&      Form  menu_set
*&--------------------------------------------------------------------*
*       text
*---------------------------------------------------------------------*
*      -->RT_EXTAB   text
*---------------------------------------------------------------------*
FORM menu_set USING lt_extab TYPE slis_t_extab.
  DATA: ls_extab TYPE slis_extab.
  SET PF-STATUS '101'.   "定义屏幕状态,然后在里面定义自己的按钮
ENDFORM.                    "menu_set
*&--------------------------------------------------------------------*
*&      Form  execute_command
*&--------------------------------------------------------------------*
*       text
*---------------------------------------------------------------------*
*      -->R_UCOMM    text
*      -->RS_SELFIELDtext
*---------------------------------------------------------------------*
FORM user_command USING ucomm LIKE sy-ucomm
                  rs_selfield TYPE slis_selfield.
  CASE ucomm.
    WHEN '&IC1'.
      READ TABLE itab INDEX rs_selfield-tabindex .
      REFRESH : i_t_params . CLEAR: i_s_params .
      i_s_params-selname = 'IV_GUID' .
      i_s_params-kind = 'S' .
      i_s_params-sign = 'I' .
      i_s_params-option = 'EQ' .
      i_s_params-low = itab-head_guid .
      APPEND i_s_params TO i_t_params .
      SUBMIT crm_report_start AND RETURN WITH SELECTION-TABLE i_t_params.
    WHEN 'TRANSPORT'.
      CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
        EXPORTING
          textline1 = '您确认正确且继续吗?'
          titel     = '传输'
        IMPORTING
          answer    = answer.
      IF answer = 'J' .
        CALL FUNCTION 'Z1CRM_TRANSFER_2_R3_VC'
          STARTING NEW TASK 'task'
          EXPORTING
            guid = itab-head_guid
            sign = 'X'.
        MESSAGE 'OK!' TYPE 'I' .
      ENDIF.
  ENDCASE.
ENDFORM.                    "execute_command
阅读(801) | 评论(0) | 转发(0) |
0

上一篇:report

下一篇:sap crm bp

给主人留下些什么吧!~~