Chinaunix首页 | 论坛 | 博客
  • 博客访问: 685426
  • 博文数量: 194
  • 博客积分: 7067
  • 博客等级: 少将
  • 技术积分: 2008
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-09 14:48
个人简介

我很好

文章分类

全部博文(194)

文章存档

2019年(1)

2018年(1)

2017年(3)

2015年(2)

2012年(2)

2011年(1)

2010年(27)

2009年(15)

2008年(142)

分类: WINDOWS

2008-04-23 09:52:51

*&---------------------------------------------------------------------*
*& Report  Z_BARRY_FTP                                                 *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*&---------------------------------------------------------------------*
REPORT  Z_BARRY_FTP   .
TYPE-POOLS truxs.
DATA: BEGIN OF btab OCCURS 10 ,
        date TYPE d ,
        cdc(10) TYPE c,
        mat LIKE mard-matnr ,
        dj(3) TYPE c ,
        xx TYPE i ,
      END OF btab .
DATA: BEGIN OF ctab OCCURS 10 ,
        date TYPE d ,
        cdc(10) TYPE c,
        mat LIKE mard-matnr ,
        dj(3) TYPE c ,
        xx(5) TYPE c ,
      END OF ctab .
DATA: mi_key TYPE i VALUE 26101957,
      mi_handle TYPE i,
      slen TYPE i .
DATA: csvtab TYPE truxs_t_text_data  .
DATA : filename(128) .
CONCATENATE 'Csv' sy-datum sy-uzeit  '.csv' INTO filename .
PARAMETERS: suser(30) TYPE c LOWER CASE DEFAULT 'user01',
            spwd(30)  TYPE c LOWER CASE DEFAULT 'aaaaaa' ,
            shost(64) TYPE c LOWER CASE DEFAULT '192.168.1.54' .
AT SELECTION-SCREEN OUTPUT.
  LOOP AT SCREEN.
    IF screen-name = 'SPWD' .
      screen-invisible = '1'.
      MODIFY SCREEN.
    ENDIF.
  ENDLOOP.
 
END-OF-SELECTION .
  slen = STRLEN( spwd ).
  btab-date = '20050223'.
  btab-cdc = 'HDC1CDC'.
  btab-mat = '1BP2181BCN1A0'.
  btab-dj = '1'.
  btab-xx = '14' .
  APPEND btab .
  btab-date = '20040513'.
  btab-cdc = 'HDC1CDC'.
  btab-mat = '1BP2181BCN1A0'.
  btab-dj = '1'.
  btab-xx = '265' .
  APPEND btab .
  btab-date = '20050205'.
  btab-cdc = 'HDC1CDC'.
  btab-mat = '1BP2181BCN1A0'.
  btab-dj = '1'.
  btab-xx = '4' .
  APPEND btab .

  LOOP AT btab .
    MOVE-CORRESPONDING btab TO ctab .
    APPEND ctab .
  ENDLOOP .
  CALL FUNCTION 'SAP_CONVERT_TO_CSV_FORMAT'
    TABLES
      i_tab_sap_data       = ctab
    CHANGING
      i_tab_converted_data = csvtab
    EXCEPTIONS
      conversion_failed    = 1
      OTHERS               = 2.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
           WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

*  CALL 'AB_RFC_X_SCRAMBLE_STRING'
*  ID 'SOURCE' FIELD spwd
*  ID 'KEY' FIELD mi_key
*  ID 'SCR' FIELD 'X'
*  ID 'DESTINATION' FIELD spwd
*  ID 'DSTLEN' FIELD slen.
  CALL FUNCTION 'HTTP_SCRAMBLE'
    EXPORTING
      SOURCE      = spwd
      sourcelen   = slen
      key         = mi_key
    IMPORTING
      destination = spwd.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
           WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
  CALL FUNCTION 'FTP_CONNECT'
    EXPORTING
      user            = suser
      password        = spwd
      host            = shost
      rfc_destination = 'SAPFTP' "SAPFTPA
    IMPORTING
      handle          = mi_handle
    EXCEPTIONS
      not_connected   = 1
      OTHERS          = 2.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
           WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
  CHECK sy-subrc = 0.
  CALL FUNCTION 'FTP_R3_TO_SERVER'
    EXPORTING
      handle         = mi_handle
      fname          = filename
      character_mode = 'X'
    TABLES
      text           = csvtab.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
           WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
  CALL FUNCTION 'FTP_DISCONNECT'
    EXPORTING
      handle = mi_handle
    EXCEPTIONS
      OTHERS = 1.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
           WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
阅读(579) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~