Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7190674
  • 博文数量: 655
  • 博客积分: 10264
  • 博客等级: 上将
  • 技术积分: 8278
  • 用 户 组: 普通用户
  • 注册时间: 2007-06-04 17:47
个人简介

ABAP顾问

文章分类

全部博文(655)

文章存档

2017年(2)

2014年(8)

2013年(3)

2012年(2)

2011年(18)

2010年(102)

2009年(137)

2008年(274)

2007年(134)

分类:

2007-06-06 12:04:23

 
*&---------------------------------------------------------------------*
*& 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.
 
 
 
 
几个FTP例程:
RSFTP001
RSFTP002
RSFTP003
RSFTP004
RSFTP005
RSFTP006
RSFTP007
RSFTP008
RSFTP009
RSFTP011
阅读(10125) | 评论(10) | 转发(0) |
0

上一篇:WHO IS USING THIS TCODE

下一篇:CDHDR_CDPOS

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

chinaunix网友2009-09-09 20:13:10

老白 能把加密那个地方解释一下不?

chinaunix网友2009-02-23 16:28:49

老白这家伙从来如此,只写代码,不带说明。 现在更过分,只给截图,连代码都没了。