Wednesday, November 30, 2016

send pdf file to ftp server

REPORT  zpdfsendtoftp.


DATA BEGIN OF t_vbak OCCURS 0,
         vbeln TYPE vbrk-vbeln,
         vkorg TYPE vbak-vkorg,
         vkbur TYPE vbak-vkbur,
       END OF t_vbak.

DATAfm_name TYPE rs38l_fnam,
            p_form  TYPE tdsfname   VALUE 'ZTEST1'.   "smartforms name

DATAcarr_id       TYPE sbook-carrid,
           cparam        TYPE ssfctrlop,
           outop         TYPE ssfcompop,
           tab_otf_data  TYPE ssfcrescl,
           pdf_tab       LIKE tline OCCURS WITH HEADER LINE,
           tab_otf_final TYPE itcoo OCCURS WITH HEADER LINE,
          file_size     TYPE i,
          bin_filesize  TYPE i,
          file_name     TYPE string,
         file_path     TYPE string,
         full_path     TYPE string.


PARAMETERS vbeln TYPE vbak-vbeln.   " input parameter

SELECT vbeln vkorg vkbur FROM vbak INTO TABLE t_vbak WHERE vbeln vbeln.

outop-tddest 'LP01'.
cparam-no_dialog 'X'.
cparam-preview space.
cparam-getotf 'X'.


CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
  EXPORTING
    formname           p_form
  IMPORTING
    fm_name            fm_name
  EXCEPTIONS
    no_form            1
    no_function_module 2
    OTHERS             3.

CALL FUNCTION fm_name
  EXPORTING
    control_parameters cparam
    output_options     outop
    user_settings      space
    vbeln              vbeln
  IMPORTING
*   DOCUMENT_OUTPUT_INFO       =
    job_output_info    tab_otf_data
  TABLES
    t_vbak             t_vbak.


tab_otf_final[] tab_otf_data-otfdata[].

CALL FUNCTION 'CONVERT_OTF'
  EXPORTING
    format                'PDF'
    max_linewidth         132
  IMPORTING
    bin_filesize          bin_filesize
  TABLES
    otf                   tab_otf_final
    lines                 pdf_tab
  EXCEPTIONS
    err_max_linewidth     1
    err_format            2
    err_conv_not_possible 3
    err_bad_otf           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.


"""""""""""" send pdf file to server """""""""""
DATA i_tab_converted_data  TYPE STANDARD TABLE OF char200 WITH HEADER LINE.

TYPES:
  BEGIN OF ty_ftp,
    zcountry  TYPE zftpi-zcountry,
    zuser     TYPE zftpi-zuser,
    zpasswd   TYPE zftpi-zpasswd,
    zhost     TYPE zftpi-zhost,
    zrfc_dest TYPE zftpi-zrfc_dest,
    zapp      TYPE zftpi-zapp,
    zftp      TYPE zftpi-zftp,
  END OF ty_ftp,
  BEGIN OF xml_line,
    data(256TYPE x,
  END OF xml_line.

DATAlt_xml_table      TYPE TABLE OF xml_line,
      l_xml_size        TYPE i,
      l_rc              TYPE i,
      lv_success        TYPE VALUE 1,
      l_element_package TYPE REF TO if_ixml_element,
      l_element_details TYPE REF TO if_ixml_element,
      l_value           TYPE string.


DATAresult   TYPE TABLE OF text WITH HEADER LINE,
      commands TYPE TABLE OF text WITH HEADER LINE.

DATATYPE likp-ablad.
DATAcountry TYPE char2.
DATA :rec                          TYPE xml_line."Adjust as per requirement/OS limits
DATA filepath(128)                TYPE c.

DATAw_hdl         TYPE i,
      c_key         TYPE VALUE 26101957,
      l_slen        TYPE i,
      command_index TYPE i.
DATA l_interface_key TYPE char30,
       l_filename      TYPE char200,
       l_content_type  TYPE char10,
       lv_command(200TYPE c.

DATAt_time  TYPE sy-uzeit,
      lv_move TYPE c,
      lv_pick TYPE c,
      lv_pack TYPE c.


DATA:  l_user(30TYPE VALUE 'ftptest123'"user name of ftp server
       l_pwd(30)  TYPE VALUE 'pass123'"password of ftp server

       l_host(64TYPE VALUE 'enter host'"ip address of FTP server
       l_dest     LIKE rfcdes-rfcdest VALUE 'SAPFTPA'"Background RFC destination

filepath '/home'.
OPEN DATASET filepath FOR OUTPUT IN BINARY MODE.
IF sy-subrc 0.
  LOOP AT lt_xml_table INTO rec.
    TRANSFER rec TO filepath.
  ENDLOOP.
ENDIF.
CLOSE DATASET filepath.

CONCATENATE '/' 'test' '.pdf' INTO l_filename.  " file name

CONCATENATE 'put' filepath l_filename INTO lv_command SEPARATED BY space.
*HTTP_SCRAMBLE: used to scramble the password provided in a format recognized by SAP.
SET EXTENDED CHECK OFF.
l_slen strlenl_pwd ).

CALL FUNCTION 'HTTP_SCRAMBLE'
  EXPORTING
    source      l_pwd
    sourcelen   l_slen
    key         c_key
  IMPORTING
    destination l_pwd.

* To Connect to the Server using FTP
CALL FUNCTION 'FTP_CONNECT'
  EXPORTING
    user            l_user
    password        l_pwd
    host            l_host
    rfc_destination l_dest
  IMPORTING
    handle          w_hdl
  EXCEPTIONS
    OTHERS          1.

IF sy-subrc <> 0.
  lv_success 0.
  EXIT.
ENDIF.


REFRESH commands.

*  ***connecting to the ftp server
CALL FUNCTION 'FTP_R3_TO_SERVER'
  EXPORTING
    handle        w_hdl
    fname         l_filename
    blob_length   bin_filesize
  TABLES
    blob          pdf_tab
  EXCEPTIONS
    tcpip_error   1
    command_error 2
    data_error    3
    OTHERS        4.

* To disconnect the FTP
CALL FUNCTION 'FTP_DISCONNECT'
  EXPORTING
    handle w_hdl.

*RFC_CONNECTION_CLOSE:This is used to disconnect the RFC connection between SAP and other system.

CALL FUNCTION 'RFC_CONNECTION_CLOSE'
  EXPORTING
    destination l_dest
  EXCEPTIONS
    OTHERS      1.


WRITE'pdf file send successfully'.

Wednesday, November 2, 2016

How to Color row in ALV report



REPORT  ZROWCOLOR.

TABLES:     vbak.

TYPE-poolsslis.                                 "ALV Declarations
TYPESBEGIN OF t_vbak,
  vbeln TYPE vbak-vbeln,
  erdat TYPE vbak-erdat,
  netwr TYPE vbak-netwr,
 CELLCOLOR TYPE LVC_T_SCOL,
END OF t_vbak.

DATAit_vbak TYPE STANDARD TABLE OF t_vbak INITIAL SIZE 0,
      wa_vbak TYPE t_vbak.

*ALV data declarations
DATAfieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,
      gd_tab_group TYPE slis_t_sp_group_alv,
      gd_layout    TYPE slis_layout_alv,
      gd_repid     LIKE sy-repid,
      gt_events     TYPE slis_t_event,
      gd_prntparams TYPE slis_print_alv.

START-OF-SELECTION.

PERFORM fill_data.
PERFORM build_fieldcatalog.
PERFORM build_layout.
PERFORM set_cell_colours.
PERFORM display_alv_report.

*&---------------------------------------------------------------------*
*&      Form  BUILD_FIELDCATALOG
*&---------------------------------------------------------------------*
*       Build Fieldcatalog for ALV Report
*----------------------------------------------------------------------*
FORM build_fieldcatalog.

  fieldcatalog-fieldname   'VBELN'.
  fieldcatalog-seltext_m   'Sales Order'.
  fieldcatalog-col_pos     0.
  fieldcatalog-outputlen   10.
  fieldcatalog-emphasize   'X'.
  fieldcatalog-KEY         'X'.
  APPEND fieldcatalog TO fieldcatalog.
  CLEAR  fieldcatalog.

  fieldcatalog-fieldname   'ERDAT'.
  fieldcatalog-seltext_m   'Created Date  '.
  fieldcatalog-col_pos     1.
  APPEND fieldcatalog TO fieldcatalog.
  CLEAR  fieldcatalog.

  fieldcatalog-fieldname   'NETWR'.
  fieldcatalog-seltext_m   'Document Value'.
  fieldcatalog-col_pos     2.
  APPEND fieldcatalog TO fieldcatalog.
  CLEAR  fieldcatalog.

ENDFORM.                    " BUILD_FIELDCATALOG

*&---------------------------------------------------------------------*
*&      Form  BUILD_LAYOUT
*&---------------------------------------------------------------------*
*       Build layout for ALV grid report
*----------------------------------------------------------------------*
FORM build_layout.
  gd_layout-no_input          'X'.
  gd_layout-colwidth_optimize 'X'.
  gd_layout-totals_text       'Totals'(201).
  gd_LAYOUT-coltab_fieldname 'CELLCOLOR'.  "CTAB_FNAME
ENDFORM.                    " BUILD_LAYOUT


*&---------------------------------------------------------------------*
*&      Form  DISPLAY_ALV_REPORT
*&---------------------------------------------------------------------*
*       Display report using ALV grid
*----------------------------------------------------------------------*
FORM display_alv_report.
  gd_repid sy-repid.
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
  EXPORTING
    i_callback_program      gd_repid
    i_callback_top_of_page   'TOP-OF-PAGE'  "see FORM
    is_layout               gd_layout
    it_fieldcat             fieldcatalog[]
    i_save                  'X'

  TABLES
    t_outtab                it_vbak
  EXCEPTIONS
    program_error           1
    OTHERS                  2.
  IF sy-subrc <> 0.

  ENDIF.
ENDFORM.                    " DISPLAY_ALV_REPORT

*&---------------------------------------------------------------------*
*&      Form  DATA_RETRIEVAL
*&---------------------------------------------------------------------*
*       Retrieve data form vbak table and populate itab it_vbak
*----------------------------------------------------------------------*
FORM fill_data.

  SELECT vbeln erdat netwr
  UP TO 10 ROWS
  FROM vbak
  INTO CORRESPONDING FIELDS OF TABLE it_vbak.
ENDFORM.                    " DATA_RETRIEVAL


*-------------------------------------------------------------------*
* Form  TOP-OF-PAGE                                                 *
*-------------------------------------------------------------------*
* ALV Report Header                                                 *
*-------------------------------------------------------------------*
FORM top-OF-PAGE.
*ALV Header declarations
  DATAt_header TYPE slis_t_listheader,
        wa_header TYPE slis_listheader,
        t_line LIKE wa_header-info,
        ld_lines TYPE I,
        ld_linesc(10TYPE C.

* Title
  wa_header-typ  'H'.
  wa_header-info 'Sales Order Report'.
  APPEND wa_header TO t_header.
  CLEAR wa_header.

* Date
  wa_header-typ  'S'.
  wa_header-KEY 'Date: '.
  CONCATENATE  sy-datum+6(2'.'
  sy-datum+4(2'.'
  sy-datum(4INTO wa_header-info.   "todays date
  APPEND wa_header TO t_header.
  CLEARwa_header.

* Total No. of Records Selected
  DESCRIBE TABLE it_vbak LINES ld_lines.
  ld_linesc ld_lines.
  CONCATENATE 'Total No. of Records Selected: ' ld_linesc
  INTO t_line SEPARATED BY space.
  wa_header-typ  'A'.
  wa_header-info t_line.
  APPEND wa_header TO t_header.
  CLEARwa_headert_line.

  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
  EXPORTING
    it_list_commentary t_header.
ENDFORM.                    "top-of-page


*&---------------------------------------------------------------------*
*&      Form  SET_CELL_COLOURS
*&---------------------------------------------------------------------*
*       Set colour of individual ALV cell, field
*----------------------------------------------------------------------*
FORM SET_CELL_COLOURS .
  DATAWA_CELLCOLOR TYPE LVC_S_SCOL.
  DATAld_index TYPE SY-TABIX.

  LOOP AT IT_VBAK INTO wa_vbak.
    LD_INDEX SY-TABIX.

    WA_CELLCOLOR-FNAME 'VBELN'.
    WA_CELLCOLOR-COLOR-COL sy-tabix.
    WA_CELLCOLOR-COLOR-INT '1'.  "1 = Intensified on, 0 = Intensified off
    WA_CELLCOLOR-COLOR-INV '0'.  "1 = text colour, 0 = background colour
    APPEND WA_CELLCOLOR TO wa_vbak-CELLCOLOR.
    MODIFY it_vbak FROM wa_vbak INDEX ld_index TRANSPORTING CELLCOLOR.

    IF wa_vbak-netwr GT 0.
      WA_CELLCOLOR-FNAME 'NETWR'.
      WA_CELLCOLOR-COLOR-COL 4.
      WA_CELLCOLOR-COLOR-INT '0'.
      WA_CELLCOLOR-COLOR-INV '0'.
      APPEND WA_CELLCOLOR TO wa_vbak-CELLCOLOR.
      MODIFY it_vbak FROM wa_vbak INDEX ld_index TRANSPORTING CELLCOLOR.
    ENDIF.


    WA_CELLCOLOR-FNAME 'ERDAT'.
    WA_CELLCOLOR-COLOR-COL 6.
    WA_CELLCOLOR-COLOR-INT '0'.
    WA_CELLCOLOR-COLOR-INV '1'.
    APPEND WA_CELLCOLOR TO wa_vbak-CELLCOLOR.
    MODIFY it_vbak FROM wa_vbak INDEX ld_index TRANSPORTING CELLCOLOR.
  ENDLOOP.

ENDFORM.


outputs:

Tuesday, August 16, 2016

GS1-128 barcode create/convert


For GS1-128 barcode converter--


1. need to create barcode label using t-code se73 . click on system barcode and create new barcode label which will be use on smartsyles to print barcode.
2. use below parameter for creating barcode label--
supported Bar code symboligies = code 128
barcode alignment = normal
put lenght and weight
code128 mode = N


""" code for SAMRTFORMS""""""

1. in smartforms ->
need to copy below routines in the SAMRTFORMS -> FORM ROUTINES


*&---------------------------------------------------------------------*
*&      Form  STREAMLINE_BARCODE
*&---------------------------------------------------------------------*
* Convert the barcode string that is passed in, into a barcode that uses
* the best subsets (B or C) to make the smallest possible barcode. Subset
* C provides the most compact barcode, but will only handle numeric digits,
* subset B will handle Alpha Characters as well.
*----------------------------------------------------------------------*
form streamline_barcode using    pa_add_fnc1_to_start type c
                        changing pa_barcode_str.

*----------------------------------------------------------------------*
* CONSTANTS used by the CODE128 Barcodes in SMARTFORMS
*----------------------------------------------------------------------*
  constants:
    c_start_code_a(2)  type c value '>9',
    c_start_code_b(2)  type c value '>:',
    c_start_code_c(2)  type c value '>;',
    c_fnc1(2)          type c value '>8',
    c_switch_a_to_b(2) type c value '>6',
    c_switch_a_to_c(2) type c value '>5',
    c_switch_b_to_a(2) type c value '>7',
    c_switch_b_to_c(2) type c value '>5',
    c_switch_c_to_a(2) type c value '>7',
    c_switch_c_to_b(2) type c value '>6'.

* declare local variables
  data:
    input_str(80)   type c,
    output_str(80)  type c,
    mode            type c,
    ofs             type i,
    len             type i,
    restlen         type i,
    c2(2)           type c,
    c4(4)           type c,
    2digits         type c,
    4digits         type c.

* store the barcode string in a local variable for processing
  move pa_barcode_str to input_str.

************************
* determine the starting mode
************************

* work out the length of the string
  len = strlen( input_str ).

* initialise the offset to zero
  ofs = 0.

* initialise the remaining length of the string
  restlen = len - ofs.

* default the mode to B
  mode = 'B'.

* if the remaining length of the string is at least 4 characters then ...
  if restlen ge 4.
*   default the 4 Digits flag to false
    clear 4digits.

*   if the first 4 characters are all numeric digits then ...
    if input_str(4) co '1234567890'.
*     set the 4 digits flag to true
      4digits = 'X'.
    endif.

*   if the 4 digits flag is set then ...
    if 4digits = 'X'.
*     default the starting mode to C
      mode = 'C'.
    else.
*     default the starting mode to B
      mode = 'B'.
    endif.
  endif.

* depending on the starting mode
  case mode.
*   subset C
    when 'C'.
*     add the starting mode to the output string
      output_str = c_start_code_c.
*   subset B
    when 'B'.
*     add the starting mode to the output string
      output_str = c_start_code_b.
  endcase.

* if the flag is set to add an FNC1 character onto the start of the barcode then ...
  if pa_add_fnc1_to_start eq 'X'.
*   add an FNC1 character after the mode selection string
    concatenate output_str
                c_fnc1
                into output_str.
  endif.

************************
* process the string
************************

* while the character offset is less than the length of the string ...
  while ofs < len.
*   work out the remaining length of the string
    restlen = len - ofs.

*   if there is at least two characters remaining in the string
    if restlen ge 2.
*     grab the next two characters
      c2 = input_str+ofs(2).

*     if these are a BARCODE control string (Starts with a >) then ...
      if c2(1) = '>'.
*       copy the string into the output string
        concatenate output_str
                    c2
                    into output_str.

*       increment the offset by two characters
        add 2 to ofs.
      endif.
    endif.

*   work out the remaining length of the string
    restlen = len - ofs.

*   depending on the mode we are currently operating in
    case mode.
*     subset C
      when 'C'.
*       default the 2 Digits flag to false
        clear 2digits.

*       if there is at least 2 characters remaining in the string ...
        if restlen ge 2.
*         grab the next 2 characters from the string
          c2 = input_str+ofs(2).

*         if the 2 characters are all numeric digits then ...
          if c2 co '1234567890'.
*           set the 2 digits flag to true
            2digits = 'X'.
          endif.
        endif.

*       if the 2 digits flag is set then ...
        if 2digits = 'X'.
*         add the two digits into the output string
          concatenate output_str
                      c2
                      into output_str.

*         increment the offset by 2
          add 2 to ofs.
        else.
*         switch the mode to subset B
          concatenate output_str
                      c_switch_c_to_b
                      into output_str.
          mode = 'B'.
        endif.
*     subset B
      when 'B'.
*       default the 4 Digits flag to false
        clear 4digits.

*       if there is at least 4 characters remaining in the string ...
        if restlen ge 4.
*         grab the next 4 characters from the string
          c4 = input_str+ofs(4).

*         if the 4 characters are all numeric digits then ...
          if c4 co '1234567890'.
*           set the 4 digits flag to true
            4digits = 'X'.
          endif.
        endif.

*       if the 4 digits flag is set then ...
        if 4digits = 'X'.
*         switch the mode back to subset C and add the
*         data into the string
          concatenate output_str
                      c_switch_b_to_c
                      c4
                      into output_str.
          mode = 'C'.

*         increment the offset by 4
          add 4 to ofs.
        else.
*         if the next character is a BARCODE control string (Starts with a >) and
*         it is not the last character in the string then ...
          if input_str+ofs(1) = '>' and
            restlen >= 2.
*           do nothing
          else.
*           add the character into the output string
            concatenate output_str
                        input_str+ofs(1)
                        into output_str.

*           increment the offset by one
            add 1 to ofs.
          endif.
        endif.
    endcase.
  endwhile.

* update the barcode string
  move output_str to pa_barcode_str.

endform.                               " STREAMLINE_BARCODE






2.  write below code in the smartforms - > program lines

PERFORM streamline_barcode
USING 'X'
      CHANGING convert_to_gs1_128_barcode.


convert_to_gs1_128_barcode =  it is 20 to 25 digit barcode text.











Monday, May 16, 2016

xml tag checking using call transformation in ABAP (t-code: XSLT_TOOL)



Transforming data from xml tag to internal table with checking (whether the tag exits or not)

<tt:cond s-check="not-initial(ref('QUANTITY'))">
<Quantity tt:value-ref="QUANTITY"/>
</tt:cond>

<tt:cond s-check="initial(ref('QUANTITY'))">
<Quantity tt:value-ref="QUANTITY"/>
</tt:cond>


Transforming data from xml tag to internal table without checking-

 <Quantity tt:value-ref="QUANTITY"/>


Quantity  = xml tag
QUANTITY = internal table field

xml parsing T-code using Call Transformation


XML parsing using call transformation

CALL TRANSFORMATION t-code : XSLT_TOOL

  CALL TRANSFORMATION Z_TransformationName
          SOURCE XML xmlstr_src
          RESULT
          in_asn = it_table. (internal table)



go to link for details:  

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/2011fbe7-3285-2e10-b281-fec5ef0c225b?QuickLink=index&overridelayout=true&51552492473450

Thursday, April 21, 2016

what is abs, sign, floor, ceil, trunc and frac in abap






FunctionfuncReturn value
absAbsolute value of argument arg
signSign of argument arg: -1, if the value of arg is negative; 0, if the value of arg is 0; 1, if the value of arg is positive
ceilSmallest integer that is not less than the value of the argument arg is
floorLargest integer that is not greater than the value of the argument arg is
truncValue of the integer part of the argument arg
fracValue of the decimal places of the argument arg



DATA TYPE DECIMALS 2.
DATA TYPE DECIMALS VALUE '-3.55'.
ABS).  WRITE:  'ABS: 'n.
SIGN)WRITE'SIGN: 'n.
CEIL)WRITE'CEIL: 'n.
FLOOR)WRITE'FLOOR:'n.
TRUNC)WRITE'TRUNC:'n.
FRAC)WRITE'FRAC: 'n.

output: 

ABS:               3.55
SIGN:              1.00-
CEIL:              3.00-
FLOOR:          4.00-
TRUNC:          3.00-
FRAC:             0.55-



Sunday, April 3, 2016

Convert csv file and send to ftp server

DATAIT_FTP TYPE STANDARD TABLE OF ZFTPSERVERLIST ,
      WA_FTP 
TYPE ZFTPSERVERLIST,
      L_SLEN 
TYPE I,
      LV_USER
(30TYPE C,
      LV_PWD
(30TYPE C,
      C_KEY 
TYPE I VALUE 26101957.

DATATO_FILE TYPE CHAR300.
DATAMI_HANDLE TYPE I.
DATAitab1  TYPE truxs_t_text_data.

PERFORM CONVERT_TO_CSV.
PERFORM SERVER_CONN.
PERFORM R3_FTP USING TO_FILE.

FORM convert_to_csv .

  
CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'
  
EXPORTING
    i_field_seperator    
','
    I_LINE_HEADER        
'X'
  
TABLES
    i_tab_sap_data       
ITAB[] " final file
    
"FIELDNAMES           = T_DESC  " for header file
  
CHANGING
    i_tab_converted_data 
itab1[]
  
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.

ENDFORM.

FORM r3_ftp  USING    p_to_file.
  
""""" SEND FILE TO SERVER""""""
  
CALL FUNCTION 'FTP_R3_TO_SERVER'
  
EXPORTING
    HANDLE         
MI_HANDLE
    FNAME          
TO_FILE          "file path of destination system
    CHARACTER_MODE 
'X'
  
TABLES
    
TEXT           itab1
  
EXCEPTIONS
    TCPIP_ERROR    
1
    COMMAND_ERROR  
2
    DATA_ERROR     
3
    
OTHERS         4.

  
IF sy-subrc <> 0.
    
WRITE 'FILE NOT SEND'.
  
ELSE.
    
WRITE 'FILE SEND'.
  
ENDIF.

ENDFORM.

FORM server_conn .

  
SELECT FROM ZFTPSERVERLIST CLIENT SPECIFIED
  
INTO CORRESPONDING FIELDS OF TABLE IT_FTP
  
WHERE MANDT SY-MANDT
  
AND   ZCOUNTRY 'BD'.

  
CLEAR WA_FTP.
  
READ TABLE IT_FTP INTO WA_FTP INDEX 1.

*----CONNECTING TO FTP SERVER.
  
PERFORM FTP_CONNECT USING WA_FTP-ZUSER WA_FTP-ZPASSWD WA_FTP-ZHOST.

*----CHECKING SUCCESSFUL FTP CONNECTION
  
CHECK SY-SUBRC 0.
  
CLEARTO_FILE.
  
" FILE NAME CREATIONN
  
CONCATENATE WA_FTP-zapp 'test' '_' DATE '.csv' INTO TO_FILE.

ENDFORM.


FORM ftp_connect  USING   LV_USER LV_PWD LV_HOST.

  L_SLEN 
STRLENLV_PWD ).

  
CALL FUNCTION 'HTTP_SCRAMBLE'
  
EXPORTING
    SOURCE      
LV_PWD
    SOURCELEN   
L_SLEN
    
KEY         C_KEY
  
IMPORTING
    DESTINATION 
LV_PWD.

  
CALL FUNCTION 'FTP_CONNECT'
  
EXPORTING
    USER            
LV_USER "Your SAP-UNIX FTP user name (case sensitive)
    PASSWORD        
LV_PWD  "Your SAP-UNIX server host name (case sensitive)
    HOST            
LV_HOST
    RFC_DESTINATION 
'SAPFTPA'
  
IMPORTING
    HANDLE          
MI_HANDLE
  
EXCEPTIONS
    NOT_CONNECTED   
1
    
OTHERS          2.

ENDFORM.

Drop Down lists in the selection parameters

PROGRAM ztest.   TYPE-POOLS : vrm.   DATA : name TYPE vrm_id,        list TYPE vrm_values,        value LIKE LINE OF list. ...