ITPub博客

首页 > Linux操作系统 > Linux操作系统 > bdc

bdc

原创 Linux操作系统 作者:hzq2010 时间:2011-04-29 13:14:38 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; } 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,
       bismt LIKE mara-bismt,
       spart LIKE mara-spart,
       prdha LIKE mara-prdha,
       brgew(17TYPE c,
       ntgew(17TYPE c,
       gewei LIKE mara-gewei,
       wrkst LIKE mara-wrkst,
       zeinr LIKE mara-zeinr,
       zeiar LIKE mara-zeiar,
       zeivr LIKE mara-zeivr,
       blatt LIKE mara-blatt,
       anszn LIKE mara-aeszn,
       zeifo LIKE mara-zeifo,
       blanz LIKE mara-blanz,
       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,
       bismt LIKE mara-bismt,
       spart LIKE mara-spart,
       prdha LIKE mara-prdha,
       brgew(17TYPE c,
       ntgew(17TYPE c,
       gewei LIKE mara-gewei,
       wrkst LIKE mara-wrkst,
       zeinr LIKE mara-zeinr,
       zeiar LIKE mara-zeiar,
       zeivr LIKE mara-zeivr,
       blatt LIKE mara-blatt,
       aeszn LIKE mara-aeszn,
       zeifo LIKE mara-zeifo,
       blanz LIKE mara-blanz,
       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.
SELECTION-SCREEN BEGIN OF BLOCK block2 WITH FRAME TITLE text-002.
SELECTION-SCREENBEGIN OF LINE ,
                    PUSHBUTTON 33(40) but USER-COMMAND dwn,
                END OF LINE.
SELECTION-SCREEN END OF BLOCK block2.
*----------------------------------------------------------------------*
*                            INITIALIZATION                            *
*----------------------------------------------------------------------*
INITIALIZATION.
  lwk_repid = sy-repid.
INITIALIZATION.
  MOVE '@15@批导模板下载  ' TO but.
*----------------------------------------------------------------------*
*                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.
at selection-screen.
  case sy-ucomm.
    when 'DWN' .
      submit zebc_bdc_template_upload and return with p_srtf = sy-repid
                                                with r_1 ='X'
                                                with r_2 = space.
  endcase.
*----------------------------------------------------------------------*
*                           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 i_fcat[].

  CLEAR w_fcat.w_fcat-fieldname = 'MATNR'. w_fcat-coltext = '物料号'.w_fcat-ref_field = 'MATNR'.w_fcat-ref_table = 'MARA'.APPEND w_fcat TO i_fcat.
  CLEAR w_fcat.w_fcat-fieldname = 'BISMT'. w_fcat-coltext = '旧物料号'APPEND w_fcat TO i_fcat.
  CLEAR w_fcat.w_fcat-fieldname = 'SPART'. w_fcat-coltext = '产品组'APPEND w_fcat TO i_fcat.
  CLEAR w_fcat.w_fcat-fieldname = 'PRDHA'. w_fcat-coltext = '产品层次'APPEND w_fcat TO i_fcat.
  CLEAR w_fcat.w_fcat-fieldname = 'BRGEW'. w_fcat-coltext = '毛重'APPEND w_fcat TO i_fcat.
  CLEAR w_fcat.w_fcat-fieldname = 'NTGEW'. w_fcat-coltext = '净重'APPEND w_fcat TO i_fcat.
  CLEAR w_fcat.w_fcat-fieldname = 'GEWEI'. w_fcat-coltext = '重量单位'APPEND w_fcat TO i_fcat.
  CLEAR w_fcat.w_fcat-fieldname = 'WRKST'. w_fcat-coltext = '基本物料'APPEND w_fcat TO i_fcat.
  CLEAR w_fcat.w_fcat-fieldname = 'ZEINR'. w_fcat-coltext = '凭证'APPEND w_fcat TO i_fcat.
  CLEAR w_fcat.w_fcat-fieldname = 'ZEIAR'. w_fcat-coltext = '凭证类型'APPEND w_fcat TO i_fcat.
  CLEAR w_fcat.w_fcat-fieldname = 'ZEIVR'. w_fcat-coltext = '凭证版本'APPEND w_fcat TO i_fcat.
  CLEAR w_fcat.w_fcat-fieldname = 'BLATT'. w_fcat-coltext = '页号'APPEND w_fcat TO i_fcat.
  CLEAR w_fcat.w_fcat-fieldname = 'AESZN'. w_fcat-coltext = '文档变更号'APPEND w_fcat TO i_fcat.
  CLEAR w_fcat.w_fcat-fieldname = 'ZEIFO'. w_fcat-coltext = '页面大小'APPEND w_fcat TO i_fcat.
  CLEAR w_fcat.w_fcat-fieldname = 'BLANZ'. w_fcat-coltext = '页数'APPEND w_fcat TO i_fcat.

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

  CLEAR:bdctab,bdcdata2[],bdcdata2.

  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.
*break-point.
  CALL FUNCTION 'MATERIAL_BTCI_SELECTION_NEW'
    EXPORTING
      material                  = gi_load-matnr
      selection                 = 'K'
      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'.

    DELETE bdcdata2 WHERE fval <> 'X'.

    READ TABLE bdcdata2 INDEX 1.
    IF sy-subrc = 0.
      IF bdcdata2-fnam+17(2) > 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.
        IF bdcdata2-fnam+18(1) = space.
          bdcdata2-fnam+18(1) = bdcdata2-fnam+17(1).
          bdcdata2-fnam+17(1) = '0'.
        ENDIF.
      ENDIF.
      APPEND bdcdata2 TO bdctab.
    ENDIF.

    PERFORM bdc_field       USING 'BDC_OKCODE'
                                  '=ENTR'.

    PERFORM bdc_dynpro      USING 'SAPLMGMM' '4004'.
    PERFORM bdc_field       USING 'BDC_OKCODE'
                                  '=SP02'.
    PERFORM bdc_field       USING 'MARA-BISMT'
                                  gi_load-bismt.
    PERFORM bdc_field       USING 'MARA-SPART'
                                  gi_load-spart.
    PERFORM bdc_field       USING 'MARA-PRDHA'
                                  gi_load-prdha.
    PERFORM bdc_field       USING 'MARA-BRGEW'
                                  gi_load-brgew.
    PERFORM bdc_field       USING 'MARA-NTGEW'
                                  gi_load-ntgew.
    PERFORM bdc_field       USING 'MARA-GEWEI'
                                  gi_load-gewei.


    PERFORM bdc_dynpro      USING 'SAPLMGMM' '4004'.
    PERFORM bdc_field       USING 'BDC_OKCODE'
                                  '=BU'.
    PERFORM bdc_field       USING 'MARA-WRKST'
                                  gi_load-wrkst.
    PERFORM bdc_field       USING 'MARA-ZEINR'
                                  gi_load-zeinr.
    PERFORM bdc_field       USING 'MARA-ZEIAR'
                                  gi_load-zeiar.
    PERFORM bdc_field       USING 'MARA-ZEIVR'
                                  gi_load-zeivr.
    PERFORM bdc_field       USING 'MARA-BLATT'
                                  gi_load-blatt.
    PERFORM bdc_field       USING 'MARA-AESZN'
                                  gi_load-aeszn.
    PERFORM bdc_field       USING 'MARA-ZEIFO'
                                  gi_load-zeifo.
    PERFORM bdc_field       USING 'MARA-BLANZ'
                                  gi_load-blanz.

    CALL TRANSACTION  'MM02' USING bdctab
                             MODE p_mode
                             UPDATE 'S'
                             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.

  CLEAR:gi_load,gi_load[].

  CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
    EXPORTING
      filename    = p_lfile  "要取数据的EXCEL文件
      i_begin_col = 1
      i_begin_row = 2
      i_end_col   = 15
      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-bismt  = gi_list-value.
        WHEN 3.
          gi_load-spart  = gi_list-value.
        WHEN 4.
          gi_load-prdha  = gi_list-value.
        WHEN 5.
          gi_load-brgew  = gi_list-value.
        WHEN 6.
          gi_load-ntgew  = gi_list-value.
        WHEN 7.
          gi_load-gewei  = gi_list-value.
        WHEN 8.
          gi_load-wrkst  = gi_list-value.
        WHEN 9.
          gi_load-zeinr  = gi_list-value.
        WHEN 10.
          gi_load-zeiar  = gi_list-value.
        WHEN 11.
          gi_load-zeivr  = gi_list-value.
        WHEN 12.
          gi_load-blatt  = gi_list-value.
        WHEN 13.
          gi_load-aeszn  = gi_list-value.
        WHEN 14.
          gi_load-zeifo  = gi_list-value.
        WHEN 15.
          gi_load-blanz  = 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,
        gv_per(8TYPE p DECIMALS 4,
        gv_sum(8TYPE p DECIMALS 4.

  CASE r_ucomm.

    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,gv_sum,gv_per.

        DESCRIBE TABLE gi_load LINES gv_lines.

        gv_per = 100 / gv_lines .

        LOOP AT gi_load.
          PERFORM frm_bdc_mm02.

          DELETE i_message WHERE msgtyp = 'W'.

          CLEAR gv_remark1.
          CLEAR gv_remark2.
          LOOP AT i_message .
            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.
          ENDLOOP.

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

          MOVE-CORRESPONDING gi_load TO gi_message.
          MOVE: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_sum = gv_sum + gv_per.

          gv_percent = TRUNC( gv_sum ).

          IF gv_percent > 100.
            gv_percent = 100.
          ENDIF.
          PERFORM schedule USING '处理中..' gv_percent.

        ENDLOOP.

        DO.
          IF gv_percent = 100.
            EXIT.
          ENDIF.
          WAIT UP TO 1 SECONDS.
          gv_percent = gv_percent + 1.
          IF gv_percent > 100.
            gv_percent = 100.
            PERFORM schedule USING '完成中..' gv_percent.
          ELSE.
            PERFORM schedule USING '处理中..' gv_percent.
          ENDIF.
        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
            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 i_fcat1[].

  CLEAR w_fcat1.w_fcat1-fieldname = 'MSGTYP'.w_fcat1-coltext = '消息类型'.APPEND w_fcat1 TO i_fcat1.
  CLEAR w_fcat1.w_fcat1-fieldname = 'REMARK'.w_fcat1-coltext = '消息文本'.APPEND w_fcat1 TO i_fcat1.
  CLEAR w_fcat1.w_fcat1-fieldname = 'MATNR'. w_fcat1-coltext = '物料号'.w_fcat1-ref_field = 'MATNR'.w_fcat1-ref_table = 'MARA'.APPEND w_fcat1 TO i_fcat1.
  CLEAR w_fcat1.w_fcat1-fieldname = 'BISMT'. w_fcat1-coltext = '旧物料号'APPEND w_fcat1 TO i_fcat1.
  CLEAR w_fcat1.w_fcat1-fieldname = 'SPART'. w_fcat1-coltext = '产品组'APPEND w_fcat1 TO i_fcat1.
  CLEAR w_fcat1.w_fcat1-fieldname = 'PRDHA'. w_fcat1-coltext = '产品层次'APPEND w_fcat1 TO i_fcat1.
  CLEAR w_fcat1.w_fcat1-fieldname = 'BRGEW'. w_fcat1-coltext = '毛重'APPEND w_fcat1 TO i_fcat1.
  CLEAR w_fcat1.w_fcat1-fieldname = 'NTGEW'. w_fcat1-coltext = '净重'APPEND w_fcat1 TO i_fcat1.
  CLEAR w_fcat1.w_fcat1-fieldname = 'GEWEI'. w_fcat1-coltext = '重量单位'APPEND w_fcat1 TO i_fcat1.
  CLEAR w_fcat1.w_fcat1-fieldname = 'WRKST'. w_fcat1-coltext = '基本物料'APPEND w_fcat1 TO i_fcat1.
  CLEAR w_fcat1.w_fcat1-fieldname = 'ZEINR'. w_fcat1-coltext = '凭证'APPEND w_fcat1 TO i_fcat1.
  CLEAR w_fcat1.w_fcat1-fieldname = 'ZEIAR'. w_fcat1-coltext = '凭证类型'APPEND w_fcat1 TO i_fcat1.
  CLEAR w_fcat1.w_fcat1-fieldname = 'ZEIVR'. w_fcat1-coltext = '凭证版本'APPEND w_fcat1 TO i_fcat1.
  CLEAR w_fcat1.w_fcat1-fieldname = 'BLATT'. w_fcat1-coltext = '页号'APPEND w_fcat1 TO i_fcat1.
  CLEAR w_fcat1.w_fcat1-fieldname = 'AESZN'. w_fcat1-coltext = '文档变更号'APPEND w_fcat1 TO i_fcat1.
  CLEAR w_fcat1.w_fcat1-fieldname = 'ZEIFO'. w_fcat1-coltext = '页面大小'APPEND w_fcat1 TO i_fcat1.
  CLEAR w_fcat1.w_fcat1-fieldname = 'BLANZ'. w_fcat1-coltext = '页数'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

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

上一篇: 动态内表
下一篇: alv00
请登录后发表评论 登录
全部评论

注册时间:2010-03-11

  • 博文量
    196
  • 访问量
    168015