ITPub博客

首页 > Linux操作系统 > Linux操作系统 > ZR_BDC_I0001程序

ZR_BDC_I0001程序

原创 Linux操作系统 作者:ytfsrs2008 时间:2009-02-14 09:25:53 0 删除 编辑
**INCLUDE ZR_BDC_I0001 .

TABLES:  t100.
DATA: bdcdata LIKE bdcdata    OCCURS 0 WITH HEADER LINE,
      messtab LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE.

*---------------------------------------------------------------------*
*       FORM. bdc_dynpro                                               *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
*  -->  PROGRAM                                                       *
*  -->  DYNPRO                                                        *
*---------------------------------------------------------------------*
FORM. bdc_dynpro USING program dynpro.
  CLEAR bdcdata.
  bdcdata-program  = program.
  bdcdata-dynpro   = dynpro.
  bdcdata-dynbegin = 'X'.
  APPEND bdcdata.
ENDFORM.

*---------------------------------------------------------------------*
*       FORM. bdc_field                                                *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
*  -->  FNAM                                                          *
*  -->  FVAL                                                          *
*---------------------------------------------------------------------*
FORM. bdc_field USING fnam fval.

  CLEAR bdcdata.

  bdcdata-fnam = fnam.
  bdcdata-fval = fval.
  APPEND bdcdata.
ENDFORM.
*---------------------------------------------------------------------*
*       FORM. bdc_field_combine                                        *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
*  -->  FNAM                                                          *
*  -->  FNAM_I                                                        *
*  -->  FVAL                                                          *
*  -->  FVAL_I                                                        *
*---------------------------------------------------------------------*
FORM. bdc_field_combine USING fnam fnam_i fval fval_i.

  DATA: l_fnam(132) TYPE c.
  DATA: l_fval(132) TYPE c.
  l_fnam = fnam.
  l_fval = fval.

  IF fnam_i <> '00'.
    CONDENSE l_fnam NO-GAPS.
    CONCATENATE l_fnam '(' fnam_i ')' INTO l_fnam.
  ENDIF.
  IF fval_i <> '00'.
    CONDENSE l_fval NO-GAPS.
    CONCATENATE l_fval '(' fval_i ')' INTO l_fval.
  ENDIF.

  PERFORM. bdc_field USING l_fnam l_fval.

ENDFORM.

*---------------------------------------------------------------------*
*       FORM. clear_data                                               *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM. clear_data.
  CLEAR:   bdcdata,messtab.
  REFRESH: bdcdata,messtab.
ENDFORM.

*---------------------------------------------------------------------*
*       FORM. message_out                                              *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM. message_out.
  DATA: l_mstring(480).
  LOOP AT messtab.
    SELECT SINGLE * FROM t100 WHERE sprsl = messtab-msgspra
                              AND   arbgb = messtab-msgid
                              AND   msgnr = messtab-msgnr.
    IF sy-subrc = 0.
      l_mstring = t100-text.
      IF l_mstring CS '&1'.
        REPLACE '&1' WITH messtab-msgv1 INTO l_mstring.
        REPLACE '&2' WITH messtab-msgv2 INTO l_mstring.
        REPLACE '&3' WITH messtab-msgv3 INTO l_mstring.
        REPLACE '&4' WITH messtab-msgv4 INTO l_mstring.
      ELSE.
        REPLACE '&' WITH messtab-msgv1 INTO l_mstring.
        REPLACE '&' WITH messtab-msgv2 INTO l_mstring.
        REPLACE '&' WITH messtab-msgv3 INTO l_mstring.
        REPLACE '&' WITH messtab-msgv4 INTO l_mstring.
      ENDIF.
      CONDENSE l_mstring.
      WRITE: / messtab-msgtyp, l_mstring(250).
    ELSE.
      WRITE: / messtab.
    ENDIF.
  ENDLOOP.
ENDFORM.

*---------------------------------------------------------------------*
*       FORM. upload_data                                              *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
*  -->  IT_MATERIAL                                                   *
*  -->  PC_FPATH                                                      *
*---------------------------------------------------------------------*
FORM. upload_data TABLES it_material
                 USING  pc_fpath.
  CALL FUNCTION 'WS_UPLOAD'
    EXPORTING
*     CODEPAGE                      = ' '
      filename                      = pc_fpath
      filetype                      = 'DAT'
*     HEADLEN                       = ' '
*     LINE_EXIT                     = ' '
*     TRUNCLEN                      = ' '
*     USER_FORM                     = ' '
*     USER_PROG                     = ' '
*     DAT_D_FORMAT                  = ' '
*   IMPORTING
*     FILELENGTH                    =
    TABLES
      data_tab                      = it_material
    EXCEPTIONS
      conversion_error              = 1
      file_open_error               = 2
      file_read_error               = 3
      invalid_type                  = 4
      no_batch                      = 5
      unknown_error                 = 6
      invalid_table_width           = 7
      gui_refuse_filetransfer       = 8
      customer_error                = 9
      OTHERS                        = 10
             .
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

ENDFORM.                    " upload_data

*---------------------------------------------------------------------*
*       FORM. get_filepath                                             *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
*  -->  P_PC_FPATH                                                    *
*---------------------------------------------------------------------*
FORM. get_filepath CHANGING p_pc_fpath LIKE rterm-file.
  CALL FUNCTION 'WS_FILENAME_GET'
    EXPORTING
      def_filename           = 'TEST.TXT'
      def_path               = 'C:\'
      mask                   = ',*.TXT,*.TXT.'
      mode                   = 'O'
      title                  = 'Get File Name'
    IMPORTING
      filename               = p_pc_fpath
*     RC                     =
    EXCEPTIONS
      inv_winsys             = 1
      no_batch               = 2
      selection_cancel       = 3
      selection_error        = 4
      OTHERS                 = 5
            .
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

ENDFORM.                    " GET_FILEPATH

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

请登录后发表评论 登录
全部评论

注册时间:2008-10-31

  • 博文量
    52
  • 访问量
    50337