ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 批导bdc(模板)

批导bdc(模板)

原创 Linux操作系统 作者:hzq2010 时间:2011-04-06 09:37:22 0 删除 编辑
  SPAN { font-family: "Courier New"; font-size: 10pt; color: #000000; background: #FFFFFF; } .L1S31 { font-style. italic; color: #808080; } .L1S32 { color: #3399FF; } .L1S33 { color: #4DA619; } .L1S52 { color: #0000FF; } REPORT zbmm_mm02_profit MESSAGE-ID 00.
*----------------------------------------------------------------------*
*                              DATA DEFINE                             *
*----------------------------------------------------------------------*
CONSTANTS: cns_mask(30)  TYPE c VALUE ',*.xls,*.xls,*.txt,*.txt',
           cns_lfile(03TYPE c VALUE 'c:\',
           cns_dat(03)   TYPE c VALUE 'DAT',
           cns_x(01)     TYPE c VALUE 'X'.
DATA: bdctab LIKE bdcdata OCCURS 0 WITH HEADER LINE.
DATA: bdcdata2 LIKE bdcdata OCCURS 0 WITH HEADER LINE.
DATABEGIN OF i_message OCCURS 0.
        INCLUDE STRUCTURE bdcmsgcoll.
DATAEND OF i_message.
DATA: gv_remark1(122TYPE c,
      gv_remark2(122TYPE c.
DATA  gv_tt TYPE i.
DATA  lwk_repid LIKE sy-repid.
DATABEGIN OF gi_message OCCURS 0,
       matnr LIKE mara-matnr,
       werks LIKE marc-werks,
       prctr LIKE marc-prctr,
       msgtyp TYPE bdcmsgcoll-msgtyp,"消息类型
       remark(122TYPE c,           "消息描述
       color(4TYPE c,
       cbox(1TYPE c,
     END OF gi_message.
DATA:  count1 TYPE p,
       count2 TYPE p.
TYPE-POOLS slis.
DATA: i_fcat TYPE lvc_t_fcat,
      w_fcat TYPE lvc_s_fcat,
      w_layo TYPE lvc_s_layo,
      i_fcat1 TYPE lvc_t_fcat,
      w_fcat1 TYPE lvc_s_fcat,
      w_layo1 TYPE lvc_s_layo,
      i_excluding  TYPE slis_t_extab,
      gs_sort TYPE lvc_s_sort,
      gt_sort TYPE lvc_t_sort,
      gs_event TYPE slis_alv_event,
      gt_events TYPE slis_t_event,
      gv_txt TYPE slis_t_listheader,
      gv_title TYPE lvc_title.
DATA:BEGIN OF gi_load OCCURS 0,
       matnr LIKE mara-matnr,
       werks LIKE marc-werks,
       prctr LIKE marc-prctr,
       cbox(1TYPE c,
      END OF gi_load.
DATABEGIN OF gi_list OCCURS 0.
        INCLUDE STRUCTURE alsmex_tabline.
DATAEND OF gi_list.
DATA:gv_row TYPE i,
     gv_col TYPE i,
     gv_lct TYPE i,
     gv_lctt(8TYPE c,
     gv_mtart LIKE mara-mtart.
*----------------------------------------------------------------------*
*                           SELECTION-SCREEN                           *
*----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME TITLE text-001.
PARAMETERS:    p_lfile LIKE rlgrap-filename OBLIGATORY LOWER CASE,
               p_mode  LIKE ctu_params-dismode OBLIGATORY DEFAULT 'N'.
SELECTION-SCREEN END OF BLOCK block1.
*----------------------------------------------------------------------*
*                            INITIALIZATION                            *
*----------------------------------------------------------------------*
INITIALIZATION.
  lwk_repid = sy-repid.
*----------------------------------------------------------------------*
*                AT SELECTION-SCREEN ON VALUE-REQUEST                  *
*----------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_lfile.
  PERFORM frm_value_request USING p_lfile cns_lfile
                             CHANGING p_lfile.
*----------------------------------------------------------------------*
*                           START-OF-SELECTION                         *
*----------------------------------------------------------------------*
START-OF-SELECTION.

  PERFORM frm_load_file_input USING p_lfile.
  PERFORM frm_alv_list.
*&---------------------------------------------------------------------*
*&      Form  frm_alv_list
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM frm_alv_list.

  PERFORM frm_fieldcat_build.

  w_layo-zebra = 'X'.
  w_layo-cwidth_opt = 'X'.
  DESCRIBE TABLE gi_load LINES gv_lct.

  gv_lctt = gv_lct.

  CONDENSE gv_lctt NO-GAPS.

  CONCATENATE '记录条目:' gv_lctt '条' space space space space  '请检查批导的原始数据是否正确!!' INTO gv_title SEPARATED BY space.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
    EXPORTING
      i_callback_program       = lwk_repid
      i_callback_pf_status_set = 'SET_STATUS'
      i_callback_user_command  = 'FRM_UCOMM'
      is_layout_lvc            = w_layo
      it_fieldcat_lvc          = i_fcat
      i_bypassing_buffer       = 'X'
      i_default                = 'X'
      i_save                   = ''
      i_grid_title             = gv_title
    TABLES
      t_outtab                 = gi_load[]
    EXCEPTIONS
      program_error            = 1
      OTHERS                   = 2.

ENDFORM.                    "frm_alv_list
*&---------------------------------------------------------------------*
*&      Form  FRM_FIELDCAT_BUILD
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM frm_fieldcat_build.

  CLEAR w_fcat.
  w_fcat-fieldname = 'MATNR'.
  w_fcat-coltext = '物料编码'.
  w_fcat-outputlen = 18.
  w_fcat-hotspot = 'X'.
  w_fcat-just = 'C'.
  APPEND w_fcat TO i_fcat.

  CLEAR w_fcat.
  w_fcat-fieldname = 'WERKS'.
  w_fcat-coltext = '工厂'.
  w_fcat-outputlen = 4.
  w_fcat-just = 'C'.
  APPEND w_fcat TO i_fcat.

  CLEAR w_fcat.
  w_fcat-fieldname = 'PRCTR'.
  w_fcat-coltext = '利润中心'.
  w_fcat-outputlen = 8.
  w_fcat-just = 'C'.
  APPEND w_fcat TO i_fcat.

ENDFORM.                    "FRM_FIELDCAT_BUILD
*&---------------------------------------------------------------------*
*&      Form  frm_bdc_mm02
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM frm_bdc_mm02.

  CLEAR:bdctab,bdcdata2[],bdcdata2,gv_mtart.

  SELECT SINGLE mtart
  INTO gv_mtart
  FROM mara
  WHERE matnr = gi_load-matnr.

  IF sy-subrc <> 0.
    CLEAR gv_mtart.
  ENDIF.

  CALL FUNCTION 'MATERIAL_BTCI_SELECTION_NEW'
    EXPORTING
      material                  = gi_load-matnr
      selection                 = 'L'
      tcode                     = 'MM02'
    TABLES
      btci_d0070                = bdcdata2
    EXCEPTIONS
      material_not_found        = 1
      material_number_missing   = 2
      material_type_missing     = 3
      material_type_not_found   = 4
      no_active_dynpro_selected = 5
      no_authority              = 6
      OTHERS                    = 7.

  IF sy-subrc = 0.

    PERFORM bdc_dynpro      USING 'SAPLMGMM' '0060'.
    PERFORM bdc_field       USING 'BDC_CURSOR'
                                  'RMMG1-MATNR'.
    PERFORM bdc_field       USING 'BDC_OKCODE'
                                  '/00'.
    PERFORM bdc_field       USING 'RMMG1-MATNR'
                                  gi_load-matnr.
    PERFORM bdc_dynpro      USING 'SAPLMGMM' '0070'.

    READ TABLE bdcdata2 WITH KEY fval = 'X'.
    IF sy-subrc = 0.
      IF sy-tabix > 17.
        PERFORM bdc_field       USING 'BDC_CURSOR'
                                'MSICHTAUSW-DYTXT(01)'.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                      '=P+'.
        PERFORM bdc_dynpro      USING 'SAPLMGMM' '0070'.
        bdcdata2-fnam+17(2) = bdcdata2-fnam+17(2) - 17 + 1.
        IF bdcdata2-fnam+18(1) = space.
          bdcdata2-fnam+18(1) = bdcdata2-fnam+17(1).
          bdcdata2-fnam+17(1) = '0'.
        ENDIF.
        APPEND bdcdata2 TO bdctab.
      ELSE.
        bdcdata2-fnam+17(2) = bdcdata2-fnam+17(2) + 1.
        APPEND bdcdata2 TO bdctab.
      ENDIF.
    ENDIF.

    PERFORM bdc_field       USING 'BDC_OKCODE'
                                  '=ENTR'.
    PERFORM bdc_dynpro      USING 'SAPLMGMM' '0080'.
    PERFORM bdc_field       USING 'BDC_CURSOR'
                                  'RMMG1-WERKS'.
    PERFORM bdc_field       USING 'BDC_OKCODE'
                                  '=ENTR'.
    PERFORM bdc_field       USING 'RMMG1-WERKS'
                                  gi_load-werks.
    PERFORM bdc_dynpro      USING 'SAPLMGMM' '4000'.
    PERFORM bdc_field       USING 'BDC_OKCODE'
                                  '/00'.
    PERFORM bdc_field       USING 'BDC_CURSOR'
                                  'MARC-PRCTR'.
    PERFORM bdc_field       USING 'MARC-PRCTR'
                                  gi_load-prctr.
    PERFORM bdc_dynpro      USING 'SAPLSPO1' '0300'.
    PERFORM bdc_field       USING 'BDC_OKCODE'
                                  '=YES'.
    CALL TRANSACTION  'MM02' USING bdctab
                              MODE p_mode
                              MESSAGES INTO i_message.
  ELSEIF sy-subrc = 1.

    CLEAR:i_message,i_message[].
    i_message-msgtyp = 'E'.
    i_message-msgid = '00'.
    i_message-msgnr = '208'.
    i_message-msgv1 = '物料不存在!!'.
    APPEND i_message.
    CLEAR i_message.

  ELSEIF sy-subrc = 2.

    CLEAR:i_message,i_message[].
    i_message-msgtyp = 'E'.
    i_message-msgid = '00'.
    i_message-msgnr = '208'.
    i_message-msgv1 = '物料号丢失!!'.
    APPEND i_message.
    CLEAR i_message.

  ELSEIF sy-subrc = 3.

    CLEAR:i_message,i_message[].
    i_message-msgtyp = 'E'.
    i_message-msgid = '00'.
    i_message-msgnr = '208'.
    i_message-msgv1 = '物料类型丢失!!'.
    APPEND i_message.
    CLEAR i_message.

  ELSEIF sy-subrc = 4.

    CLEAR:i_message,i_message[].
    i_message-msgtyp = 'E'.
    i_message-msgid = '00'.
    i_message-msgnr = '208'.
    i_message-msgv1 = '物料类型不存在!!'.
    APPEND i_message.
    CLEAR i_message.

  ELSEIF sy-subrc = 5.

    CLEAR:i_message,i_message[].
    i_message-msgtyp = 'E'.
    i_message-msgid = '00'.
    i_message-msgnr = '208'.
    i_message-msgv1 = '成本视图不存在!!'.
    APPEND i_message.
    CLEAR i_message.

  ELSEIF sy-subrc = 6.

    CLEAR:i_message,i_message[].
    i_message-msgtyp = 'E'.
    i_message-msgid = '00'.
    i_message-msgnr = '208'.
    i_message-msgv1 = '没有相应的权限!!'.
    APPEND i_message.
    CLEAR i_message.

  ELSE.

    CLEAR:i_message,i_message[].
    i_message-msgtyp = 'E'.
    i_message-msgid = '00'.
    i_message-msgnr = '208'.
    i_message-msgv1 = '系统错误!!'.
    APPEND i_message.
    CLEAR i_message.

  ENDIF.

ENDFORM.                    "frm_bdc_mm02
*----------------------------------------------------------------------*
*                        FORM FRM_VALUE_REQUEST                        *
*----------------------------------------------------------------------*
FORM frm_value_request USING  pr_lfile LIKE rlgrap-filename
                              cns_path
                              CHANGING pe_lfile LIKE rlgrap-filename.

  DATA: l_finname(128TYPE c,
        l_name(128TYPE c.

  CALL FUNCTION 'WS_FILENAME_GET'
    EXPORTING
      def_filename     = l_finname
      def_path         = cns_path
      mask             = cns_mask
      mode             = 'O'
      title            = '请选择要上载的文件'
    IMPORTING
      filename         = l_name
    EXCEPTIONS
      inv_winsys       = 1
      no_batch         = 2
      selection_cancel = 3
      selection_error  = 4
      OTHERS           = 5.
  IF sy-subrc = 0.
    pe_lfile = l_name.
  ENDIF .
ENDFORM.                    "frm_value_request
*----------------------------------------------------------------------*
*                       FORM FRM_LOAD_FILE_INPUT                       *
*----------------------------------------------------------------------*
FORM frm_load_file_input USING p_lfile.

  CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
    EXPORTING
      filename    = p_lfile  "要取数据的EXCEL文件
      i_begin_col = 1
      i_begin_row = 1
      i_end_col   = 3
      i_end_row   = 65535
    TABLES
      intern      = gi_list.

  IF gi_list[] IS INITIAL.
    MESSAGE i208(00WITH text-not.
    STOP.
  ELSE.
    SORT gi_list BY row col.
    LOOP AT gi_list.
      gv_row = gi_list-row.
      gv_col = gi_list-col.
      CASE gv_col.
        WHEN 1.
          gi_load-matnr  = gi_list-value.
        WHEN 2.
          gi_load-werks  = gi_list-value.
        WHEN 3.
          gi_load-prctr  = gi_list-value.
      ENDCASE.
      AT END OF row.
        APPEND gi_load.
        CLEAR gi_load.
      ENDAT.
      CLEAR gi_list.
    ENDLOOP.

    IF gi_load[] IS INITIAL.
      MESSAGE i208(00WITH text-not.
      STOP.
    ENDIF.
  ENDIF.

ENDFORM.                    "frm_load_file_input
*----------------------------------------------------------------------*
*                        FORM BDC_DYNPRO_START                         *
*----------------------------------------------------------------------*
FORM bdc_dynpro USING p_g_program_1
                      p_g_screen.
  CLEAR bdctab.
  bdctab-program  = p_g_program_1.
  bdctab-dynpro   = p_g_screen.
  bdctab-dynbegin = 'X'.
  APPEND bdctab.

ENDFORM.                    "bdc_dynpro
*----------------------------------------------------------------------*
*                              FORM BDC_FIELD                          *
*----------------------------------------------------------------------*
FORM bdc_field USING f_name
                     f_value.

  CLEAR bdctab.
  bdctab-fnam = f_name.
  bdctab-fval = f_value.
  APPEND bdctab.

ENDFORM.                    "bdc_field
*&---------------------------------------------------------------------*
*&      Form  set_status
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->RT_EXTAB   text
*----------------------------------------------------------------------*
FORM set_status USING rt_extab TYPE slis_t_extab .          "#EC *
  SET PF-STATUS 'STANDARD_FULLSCREEN'.
ENDFORM.                    "set_status
*&---------------------------------------------------------------------*
*&      Form  frm_ucomm
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->R_UCOMM      text
*      -->RS_SELFIELD  text
*----------------------------------------------------------------------*
FORM frm_ucomm USING r_ucomm     LIKE sy-ucomm
                     rs_selfield TYPE slis_selfield.

  DATA: gs_kvbuk TYPE kvbuk,
        gv_check(1TYPE c,
        gv_linecnt TYPE i,
        gv_cnt(10TYPE n,
        gv_lines TYPE i,
        gv_percent TYPE i.

  CASE r_ucomm.
    WHEN '&IC1'.
      IF rs_selfield-fieldname = 'MATNR'.
        READ TABLE gi_load INDEX rs_selfield-tabindex.
        IF sy-subrc = 0.
          SET PARAMETER ID 'MAT' FIELD gi_load-matnr.
          SET PARAMETER ID 'WRK' FIELD gi_load-werks.
          SET PARAMETER ID 'MXX' FIELD 'G'.
          CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.
        ENDIF.
      ENDIF.
    WHEN 'RUN'.

      CALL FUNCTION 'POPUP_TO_CONFIRM_WITH_MESSAGE'
        EXPORTING
          diagnosetext1 = text-m01
          textline1     = text-m02
          titel         = text-m03
        IMPORTING
          answer        = gv_check.

      IF gv_check = 'J'.

        CLEAR:gi_message[],i_fcat1[],w_layo1,gv_txt,gt_events[],gs_event,i_excluding[],count1,count2.

        DESCRIBE TABLE gi_load LINES gv_lines.

        gv_lines = 100 / gv_lines .

        LOOP AT gi_load.

          PERFORM frm_bdc_mm02.

          CLEAR gv_remark1.
          CLEAR gv_remark2.
          LOOP AT i_message .
            IF i_message-msgtyp <> 'W'.
              CALL FUNCTION 'MESSAGE_TEXT_BUILD'
                EXPORTING
                  msgid               = i_message-msgid
                  msgnr               = i_message-msgnr
                  msgv1               = i_message-msgv1
                  msgv2               = i_message-msgv2
                  msgv3               = i_message-msgv3
                  msgv4               = i_message-msgv4
                IMPORTING
                  message_text_output = gv_remark1.
              CONCATENATE gv_remark1 gv_remark2 INTO gv_remark2 SEPARATED BY space.
            ENDIF.
          ENDLOOP.

          CLEAR gv_tt.
          DESCRIBE TABLE i_message LINES gv_tt.
          READ TABLE i_message INDEX gv_tt.

          MOVE:
          gi_load-matnr  TO gi_message-matnr,
          gi_load-werks  TO gi_message-werks,
          gi_load-prctr  TO gi_message-prctr,
          i_message-msgtyp TO gi_message-msgtyp,
          gv_remark2 TO gi_message-remark.
          APPEND gi_message.
          CLEAR gi_message.

          CLEAR i_message.
          REFRESH i_message.
          REFRESH bdctab.

          gv_percent = gv_lines + gv_percent.
          IF gv_percent > 100.
            gv_percent = 100.
          ENDIF.
          PERFORM schedule USING ' ' gv_percent.

        ENDLOOP.

        DO.
          IF gv_percent = 100.
            EXIT.
          ENDIF.
          DO 100000 TIMES.
            CLEAR gv_lines.
          ENDDO.
          gv_percent = gv_percent + 1.
          PERFORM schedule USING ' ' gv_percent.
        ENDDO.

        LOOP AT gi_message.
          IF gi_message-msgtyp = 'S' OR gi_message-msgtyp = 'I'.
            count1 = count1 + 1.
            gi_message-color = 'C500'.
          ELSEIF gi_message-msgtyp = 'E' .
            count2 = count2 + 1.
            gi_message-color = 'C600'.
          ENDIF.
          MODIFY gi_message TRANSPORTING color.
          CLEAR gi_message.
        ENDLOOP.

        w_layo1-cwidth_opt = 'X'.
        w_layo1-box_fname = 'CBOX'.
        w_layo1-info_fname = 'COLOR'.

        PERFORM frm_sub_fieldcat_build.
        PERFORM frm_build_comment USING gv_txt.
        PERFORM frm_get_event.

        CLEAR i_excluding[].
        APPEND '&OUP' TO i_excluding.
        APPEND '&ODN' TO i_excluding.
        APPEND '&ILT' TO i_excluding.
        APPEND '&ILD' TO i_excluding.
        APPEND '&VEXCEL' TO i_excluding.
        APPEND '&AQW' TO i_excluding.
        APPEND '%SL' TO i_excluding.
        APPEND '%ALL' TO i_excluding.
        APPEND '%SAL' TO i_excluding.
        APPEND '%OL0' TO i_excluding.

        CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
          EXPORTING
            i_callback_program      = lwk_repid
            i_callback_user_command = 'FRM_UCOMM_S'
            it_fieldcat_lvc         = i_fcat1[]
            i_default               = 'X'
            i_save                  = ''
            is_layout_lvc           = w_layo1
            i_screen_start_column   = 10
            i_screen_start_line     = 5
            i_screen_end_column     = 90
            i_screen_end_line       = 25
            it_events               = gt_events[]
            it_excluding            = i_excluding[]
          TABLES
            t_outtab                = gi_message[]
          EXCEPTIONS
            program_error           = 1
            OTHERS                  = 2.
      ELSE.
        IF gv_check = 'N'.
          MESSAGE s001(00WITH '用户' sy-uname '终止当前操作!!'.
        ELSE.
          MESSAGE s001(00WITH '用户' sy-uname '取消当前操作!!'.
        ENDIF.
      ENDIF.
    WHEN OTHERS.
  ENDCASE.

ENDFORM.                    "frm_ucomm
*&---------------------------------------------------------------------*
*&      Form  frm_sub_fieldcat_build
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM frm_sub_fieldcat_build.

  CLEAR w_fcat1.
  w_fcat1-fieldname = 'MSGTYP'.
  w_fcat1-coltext = '消息类型'.
  w_fcat1-outputlen = 8.
  w_fcat1-just = 'C'.
  APPEND w_fcat1 TO i_fcat1.

  CLEAR w_fcat1.
  w_fcat1-fieldname = 'REMARK'.
  w_fcat1-coltext = '消息文本'.
  w_fcat1-outputlen = 122.
  w_fcat1-just = 'L'.
  APPEND w_fcat1 TO i_fcat1.

  CLEAR w_fcat1.
  w_fcat1-fieldname = 'MATNR'.
  w_fcat1-coltext = '物料编码'.
  w_fcat1-outputlen = 18.
  w_fcat1-hotspot = 'X'.
  w_fcat1-just = 'C'.
  APPEND w_fcat1 TO i_fcat1.

  CLEAR w_fcat1.
  w_fcat1-fieldname = 'WERKS'.
  w_fcat1-coltext = '工厂'.
  w_fcat1-outputlen = 4.
  w_fcat1-just = 'C'.
  APPEND w_fcat1 TO i_fcat1.

  CLEAR w_fcat1.
  w_fcat1-fieldname = 'PRCTR'.
  w_fcat1-coltext = '利润中心'.
  w_fcat1-outputlen = 8.
  w_fcat1-just = 'C'.
  APPEND w_fcat1 TO i_fcat1.

ENDFORM.                    "frm_SUB_fieldcat_build
*----------------------------------------------------------------------*
*                          FORM FRM_GET_EVENT                          *
*----------------------------------------------------------------------*
FORM frm_get_event.
  gs_event-name = slis_ev_top_of_page.
  gs_event-form = 'FRM_TOP_OF_PAGE'.
  APPEND gs_event TO gt_events.
ENDFORM.                    "frm_get_event
*----------------------------------------------------------------------*
*                         FORM TOP_OF_PAGE                             *
*----------------------------------------------------------------------*
FORM frm_top_of_page.
  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
      it_list_commentary = gv_txt.
ENDFORM.                    "frm_top_of_page
*----------------------------------------------------------------------*
*                                                                      *
*----------------------------------------------------------------------*
FORM frm_build_comment USING gv_heading TYPE slis_t_listheader.

  DATA hline TYPE slis_listheader.

  CLEAR: hline.
  hline-typ = 'S'.
  hline-key = '成功条目:'.
  hline-info = count1.
  APPEND hline TO gv_heading.

  CLEAR hline.
  hline-typ = 'S'.
  hline-key = '失败条目:'.
  hline-info = count2.
  APPEND hline TO gv_heading.
  CLEAR hline.

  APPEND hline TO gv_heading.
  CLEAR hline.

ENDFORM.                    "frm_build_comment
*&---------------------------------------------------------------------*
*&      Form  schedule
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->C_MESSAGE  text
*      -->I_PERCENT  text
*----------------------------------------------------------------------*
FORM schedule USING c_message TYPE c i_percent TYPE i.

  DATA: c_sche(204).

  IF i_percent <= 0 OR i_percent > 100 .
    c_sche = '百分比错误!!!'.
  ELSE.
    DATA: c_percent(4),
    c_block(3TYPE c VALUE '■',
    i_blocklen TYPE i,
    i_count TYPE i,
    i_col TYPE i,
    i_len TYPE i,
    i_temp TYPE i VALUE 0,
    i_mod TYPE i.
    i_blocklen = STRLEN( c_block ).
    c_percent = i_percent.
    CONDENSE c_percent.
    c_percent+3(1) = '%'.
    c_sche = c_percent.
    i_count = i_percent / 4.
    DO i_count TIMES.
      i_col = ( i_temp * i_blocklen ) + 4.
      c_sche+i_col(i_blocklen) = c_block.
      i_temp = i_temp + 1.
    ENDDO.
    i_len = STRLEN( c_message ).
    i_mod = i_len MOD 2.
    IF i_mod = 1.
      i_len = i_len + 1.
    ENDIF.
    IF i_len > 0.
      c_sche+4(i_len) = c_message.
    ENDIF.
    i_len = STRLEN( c_sche ).
  ENDIF.
  CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
    EXPORTING
      percentage = 0
      text       = c_sche
    EXCEPTIONS
      OTHERS     = 1.

ENDFORM" SCHEDULE
*&---------------------------------------------------------------------*
*&      Form  frm_ucomm_S
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->R_UCOMM      text
*      -->RS_SELFIELD  text
*----------------------------------------------------------------------*
FORM frm_ucomm_s USING r_ucomm     LIKE sy-ucomm
                       rs_selfield TYPE slis_selfield.

  CASE r_ucomm.
    WHEN '&IC1'.
      IF rs_selfield-fieldname = 'MATNR'.
        READ TABLE gi_message INDEX rs_selfield-tabindex.
        IF sy-subrc = 0.
          SET PARAMETER ID 'MAT' FIELD gi_message-matnr.
          SET PARAMETER ID 'WRK' FIELD gi_message-werks.
          SET PARAMETER ID 'MXX' FIELD 'G'.
          CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.
        ENDIF.
      ENDIF.
    WHEN OTHERS.
  ENDCASE.

ENDFORM.                    "frm_ucomm_S

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

下一篇: 自定义权限对象
请登录后发表评论 登录
全部评论

注册时间:2010-03-11

  • 博文量
    196
  • 访问量
    171609