Download and upload ABAP database table to presentation server and R/3

Hi experts,
I want to download ABAP database table (Ztable) to presentation server and again want to upload this to another R/3 server but i dont want to use any transport request. is there any possible sollution for this.
Thanks in advance

Hi,
Look at this code hope this will help you to solve your problem
REPORT y_test_559.
Program for
1. Downloading Data of any DB table to a tab delimited ASCII file
2. Checking if a tab delimited ASCII file has the structure of a
   DB table and showing its contents
3. Uploading a tab delimited ASCII file to a DB table with the same
   structure
4. Showing the data of any DB table
======================================================================
======================================================================
DATA DECLARATIONS
======================================================================
TYPES : data_object  TYPE REF TO data.
DATA  : itab TYPE REF TO data .
TYPE-POOLS : slis .
DATA  : it_fieldcat TYPE STANDARD TABLE OF slis_fieldcat_alv
        WITH HEADER LINE .
DATA : it_fieldcatalog TYPE lvc_t_fcat .
DATA : wa_fieldcatalog TYPE lvc_s_fcat .
DATA : i_structure_name LIKE dd02l-tabname .
DATA : i_callback_program LIKE sy-repid .
DATA  : dyn_line TYPE data_object .
FIELD-SYMBOLS : <fs_itab> TYPE  STANDARD  TABLE .
DATA : table_name_is_valid TYPE c .
DATA : dynamic_it_instantiated TYPE c .
CONSTANTS buttonselected TYPE c VALUE 'X' .
======================================================================
SELECTION SCREEN DEFAULT
======================================================================
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 5(29) t_tabl.
PARAMETERS : tabl_nam LIKE rsrd1-tbma_val
             MATCHCODE OBJECT dd_dbtb_16 OBLIGATORY .
                               "Search for Database Tables is dd_dbtb_16
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 5(29) t_file.
PARAMETERS : file_nam LIKE rlgrap-filename .
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 5(29) t_down.
PARAMETERS : p_downld RADIOBUTTON GROUP grp1
             USER-COMMAND m_ucomm .
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 5(29) t_chkf.
PARAMETERS : p_chkfil RADIOBUTTON GROUP grp1 .
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 5(29) t_upld.
PARAMETERS : p_upload RADIOBUTTON GROUP grp1 .
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 5(29) t_show.
PARAMETERS : p_show_t RADIOBUTTON GROUP grp1 ."show table data
SELECTION-SCREEN END OF LINE.
======================================================================
AT SELECTION SCREEN OUTPUT
======================================================================
AT SELECTION-SCREEN OUTPUT .
  PERFORM check_filename .
======================================================================
AT SELECTION SCREEN ON VALUE REQUEST FOR FILENAME
======================================================================
AT SELECTION-SCREEN ON VALUE-REQUEST FOR file_nam .
  PERFORM f4_for_filename .
======================================================================
Initialization .
======================================================================
INITIALIZATION .
  t_tabl = 'Table Name' .
  t_file = 'File Name' .
  t_down = 'Download Table' .
  t_chkf = 'Check File to Upload' .
  t_upld = 'Upload File' .
  t_show = 'Show Table Contents' .
======================================================================
START OF SELECTION
======================================================================
START-OF-SELECTION .
  PERFORM check_table_name_is_valid .
======================================================================
END OF SELECTION
======================================================================
END-OF-SELECTION .
  IF table_name_is_valid EQ ' ' .
    MESSAGE i398(00) WITH 'INVALID TABLE NAME' .
  ELSE .
    PERFORM instantiate_dynamic_internal_t  .
    CHECK  dynamic_it_instantiated = 'X' .
    CASE buttonselected .
      WHEN p_downld .
        PERFORM select_and_download .
      WHEN p_chkfil .
        PERFORM check_file_to_upload .
      WHEN p_upload .
        PERFORM upload_from_file .
      WHEN p_show_t .
        PERFORM show_contents .
    ENDCASE .
  ENDIF .
*&      Form  CHECK_TABLE_NAME_IS_VALID
      text
-->  p1        text
<--  p2        text
FORM check_table_name_is_valid.
  DATA l_count TYPE i .
  TABLES dd02l .
  CLEAR table_name_is_valid .
  SELECT COUNT(*) INTO l_count FROM tadir
  WHERE  pgmid = 'R3TR'
  AND    object = 'TABL'
  AND    obj_name = tabl_nam .
  IF l_count EQ 1 .
    CLEAR dd02l .
    SELECT SINGLE * FROM dd02l WHERE tabname  = tabl_nam .
    IF sy-subrc EQ 0.
      IF dd02l-tabclass = 'TRANSP' .
        table_name_is_valid = 'X' .
      ENDIF .
    ENDIF.
  ENDIF .
ENDFORM.                    " CHECK_TABLE_NAME_IS_VALID
*&      Form  SELECT_AND_DOWNLOAD
      text
-->  p1        text
<--  p2        text
FORM select_and_download.
  CLEAR : <fs_itab> .
  SELECT * FROM (tabl_nam)
  INTO CORRESPONDING FIELDS OF TABLE <fs_itab>   .
  PERFORM check_filename.
  CALL FUNCTION 'WS_DOWNLOAD'
    EXPORTING
      filename                = file_nam
      filetype                = 'DAT'
    TABLES
      data_tab                = <fs_itab>
    EXCEPTIONS
      file_open_error         = 1
      file_write_error        = 2
      invalid_filesize        = 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 EQ 0.
    MESSAGE i398(00) WITH 'Table' tabl_nam
                          'successfully downloaded to '
                          file_nam .
  ENDIF.
ENDFORM.                    " SELECT_AND_DOWNLOAD
*&      Form  UPLOAD_FROM_FILE
      text
-->  p1        text
<--  p2        text
FORM upload_from_file.
  DATA : ans TYPE c .
  DATA : lines_of_itab TYPE i .
  DATA : l_subrc TYPE i .
  CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
    EXPORTING
      textline1 = 'Are you sure you wish to upload'
      textline2 = 'data from ASCII File to DB table '
      titel     = 'Confirmation of Data Upload'
    IMPORTING
      answer    = ans.
  IF ans = 'J' .
    PERFORM check_filename.
    CLEAR l_subrc .
    CALL FUNCTION 'WS_UPLOAD'
      EXPORTING
        filename                = file_nam
        filetype                = 'DAT'
      TABLES
        data_tab                = <fs_itab>
      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.
    l_subrc = l_subrc  + sy-subrc .
    IF sy-subrc EQ 0.
      DESCRIBE TABLE <fs_itab> LINES lines_of_itab .
      IF lines_of_itab GT 0 .
        DELETE (tabl_nam) FROM TABLE <fs_itab> .
        COMMIT WORK .
        INSERT (tabl_nam) FROM TABLE <fs_itab> .
        l_subrc = l_subrc  + sy-subrc .
      ENDIF .
    ENDIF.
    IF  l_subrc EQ 0  .
      MESSAGE i398(00) WITH lines_of_itab
                           'Record(s) inserted in table'
                            tabl_nam .
    ELSE .
      MESSAGE i398(00) WITH
                      'Errors occurred No Records inserted in table'
                       tabl_nam .
    ENDIF .
  ENDIF .
ENDFORM.                    " UPLOAD_FROM_FILE
*&      Form  F4_FOR_FILENAME
      text
-->  p1        text
<--  p2        text
FORM f4_for_filename.
  CALL FUNCTION 'WS_FILENAME_GET'
    EXPORTING
      def_path         = 'C:\'
      mask             = ',.,..'
      mode             = '0'
    IMPORTING
      filename         = file_nam
    EXCEPTIONS
      inv_winsys       = 1
      no_batch         = 2
      selection_cancel = 3
      selection_error  = 4
      OTHERS           = 5.
ENDFORM.                    " F4_FOR_FILENAME
*&      Form  CHECK_FILENAME
      text
-->  p1        text
<--  p2        text
FORM check_filename.
  IF file_nam IS INITIAL
  AND NOT ( tabl_nam IS INITIAL  )
  AND p_show_t NE buttonselected.
    CONCATENATE 'C:\' tabl_nam  '.TXT'  INTO file_nam.
  ENDIF .
ENDFORM.                    " CHECK_FILENAME
*&      Form  INSTANTIATE_DYNAMIC_INTERNAL_T
      text
-->  p1        text
<--  p2        text
FORM instantiate_dynamic_internal_t.
  CLEAR dynamic_it_instantiated .
-----> Step 1 - Finding Field Names and ALV GRID Fieldcatalog
  i_structure_name =  tabl_nam .
  CLEAR it_fieldcat[] .
  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
      i_structure_name       = i_structure_name
    CHANGING
      ct_fieldcat            = it_fieldcat[]
    EXCEPTIONS
      inconsistent_interface = 1
      program_error          = 2
      OTHERS                 = 3.
  IF sy-subrc EQ 0.
-----> Step 2 - Creating Field Catalog of the Object
                                              cl_alv_table_create
    LOOP AT it_fieldcat .
      CLEAR wa_fieldcatalog .
      MOVE-CORRESPONDING it_fieldcat TO  wa_fieldcatalog .
      wa_fieldcatalog-ref_field = it_fieldcat-fieldname .
      wa_fieldcatalog-ref_table = tabl_nam .
      APPEND  wa_fieldcatalog  TO it_fieldcatalog .
    ENDLOOP .
-----> Step 3 - Creating Internal Table Dynamicaly
    CALL METHOD cl_alv_table_create=>create_dynamic_table
      EXPORTING
        it_fieldcatalog = it_fieldcatalog
      IMPORTING
        ep_table        = itab.
    ASSIGN itab->* TO <fs_itab> .
    dynamic_it_instantiated = 'X' .
  ENDIF.
ENDFORM.                    " INSTANTIATE_DYNAMIC_INTERNAL_T
*&      Form  SHOW_CONTENTS
      text
-->  p1        text
<--  p2        text
FORM show_contents.
  CLEAR : <fs_itab> .
  SELECT * FROM (tabl_nam)
  INTO CORRESPONDING FIELDS OF TABLE <fs_itab>   .
  i_callback_program = sy-repid .
  CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
      i_callback_program = i_callback_program
      it_fieldcat        = it_fieldcat[]
    TABLES
      t_outtab           = <fs_itab>
    EXCEPTIONS
      program_error      = 1
      OTHERS             = 2.
ENDFORM.                    " SHOW_CONTENTS
*&      Form  CHECK_FILE_TO_UPLOAD
      text
-->  p1        text
<--  p2        text
FORM check_file_to_upload.
  PERFORM check_filename.
CLEAR l_subrc .
  CALL FUNCTION 'WS_UPLOAD'
    EXPORTING
      filename                = file_nam
      filetype                = 'DAT'
    TABLES
      data_tab                = <fs_itab>
    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.
l_subrc = l_subrc  + SY-SUBRC .
  IF sy-subrc EQ 0.
    i_callback_program = sy-repid .
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
      EXPORTING
        i_callback_program = i_callback_program
        it_fieldcat        = it_fieldcat[]
      TABLES
        t_outtab           = <fs_itab>
      EXCEPTIONS
        program_error      = 1
        OTHERS             = 2.
  ENDIF .
ENDFORM.                    " CHECK_FILE_TO_UPLOAD
Thanks,
Pramod

Similar Messages

  • Access is not inserting, updating or deleting records in my database table on the server

    I am having a problem with an application I developed using Dreamweaver 8 and Access 2000 several years ago which is no longer working correctly. The problem is that Access is not inserting, updating or deleting records in my database table on the server but is reflected in changes to my Web site. I used the Dreamweaver server behaviors: insert record, update record and delete record to make the changes to my Access table on the server. My Access table on the server shows all of the records I inserted or updated in the past, but not any of the newly inserted on updated records.
    does any one have any ideas as to what my problem is?
    Jim

    No, that has nothing to do with your problem. Let's make sure I understand the symptoms.
    1) Your site is online at a remote host.
    2) You use a dynamic page in your online site to update a database record (insert, delete, or update)
    3) The update then appears correctly on your dynamic content page.
    4) You download the mdb and it appears to not have any of the upates you just made.
    Please correct any of these statements if they are wrong.
    If the above is correct, then you must be looking at a cached mdb, or the mdb you are looking at is in the wrong location. Do this: search your entire drive for copies of the mdb, including in the Windows temp directories which is likely where the cached copy is located. Delete any extra copies and download again.

  • How to Import/Export database tables from one server to other in oracle8i

    Hello friend,
    Please can any one tell me how to import/export groups of database tables from one server with oracle to another using VB.net. It would be nice if some one can provide some code of it.
    I am a software developer and I am in middle of a large project development, in which I need to export a large oracle database from one server to another efficiently.
    Its very urgent so please someone help me.

    At command prompt (source db)
    set ORACLE_SID=db_name
    exp system/password@db_name full=y buffer=104857600 file=(c:\file1.dmp, c:\file2.dmp....) log=c:\exp.log filesize=2000M
    Then ftp the export dump files (in binary) to the other server or copy to target server over the network.
    At command prompt (target db)
    set ORACLE_SID=db_name
    imp system/password@db_name full=y ignore=y buffer=104857600 file=(c:\file1.dmp, c:\file2.dmp....) log=c:\imp.log filesize=2000M
    If the path names of the datafiles are going to be different in the target server (as compared to the source), then precreate the tablespaces before import. Set buffer value accordingly.
    Message was edited by:
    FeNiCrC_Neil

  • Downloading an internal table to presentation server from WebUI

    Hi All,
    We have a requirement to download an internal table as a CSV file from CRM 7.0 WebUI to the presentation server. The file path is fixed, so the user need not choose the download location. The data to be downloaded is not part of any view on the WebUI and is being collected through code from several context nodes.
    We have looked at CL_BSP_UTILITY, which is not solving our purpose, as the prepared data stream gets over written by CRM 7.0 framework during execution.
    Any suggestions on how we can achieve the functionality?
    Regards,
    Mugdha

    Hi,
         If you need to provide download window via the browser, check out this wiki - [http://wiki.sdn.sap.com/wiki/pages/pointstab/viewpageversion.action?pageId=187336093&version=6] . If you want to directly write to the presentation server, you have th efollowing ways. If you submit a report in background, you have the option of using CL_GUI_FRONTEND_SERVICES. Otherwise you can check out using a combination of javascript and activex objects ( [http://www.codingforums.com/showthread.php?t=136906] ).
    Regards,
    Arun Prakash

  • Query in abap database tables

    hello Experts,
       Is there any System table to get the Year.For Example to get the Month we can use T247 database table like this any system table to get year.
    thanks
    regards,
    Ashok.

    Sorry can you explain what do you mean to get year ??
    The below would give you the year.
    Year = Sy-datum(4).
    If you wish to convert it into words you can use SPELL_WORD and make sure to use currency with zero decimails..in that case it would return two thousand six in words.

  • Uploading into database table from text file using tab (GUI_UPLOAD)

    i have small doubt
    i have 3 fiels in text file using tab as separator
    i need to update into database table 'ZABPSP_01'
    from 's.txt' located in local disk.
    My code is below.
    Please let me know the correction.
    Awaiting for ur response.
    Thanks in advance
    REPORT  ZABPSPPRG_02.
    TABLES: LFA1,MARA,KNA1,ZABPSP_01.
    DATA:  begin of itab occurs 0,
    IKUNNR type zabpsp_01-kunnr,
    IMATNR type zabpsp_01-matnr,
    IADRNR type zabpsp_01-adrnr.
    DATA:END OF ITAB.
    DATA: FILENAME1 TYPE STRING.
    FILENAME1 = 'C:/s.txt'.
    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        FILENAME                      = FILENAME1
      FILETYPE                      = 'ASC'
       HAS_FIELD_SEPARATOR           = 'X'
      HEADER_LENGTH                 = 0
      READ_BY_LINE                  = 'X'
      DAT_MODE                      = ' '
      CODEPAGE                      = ' '
      IGNORE_CERR                   = ABAP_TRUE
      REPLACEMENT                   = '#'
      CHECK_BOM                     = ' '
      VIRUS_SCAN_PROFILE            =
      NO_AUTH_CHECK                 = ' '
    IMPORTING
      FILELENGTH                    =
      HEADER                        =
      TABLES
        DATA_TAB                     = itab.
    EXCEPTIONS
      FILE_OPEN_ERROR               = 1
      FILE_READ_ERROR               = 2
      NO_BATCH                      = 3
      GUI_REFUSE_FILETRANSFER       = 4
      INVALID_TYPE                  = 5
      NO_AUTHORITY                  = 6
      UNKNOWN_ERROR                 = 7
      BAD_DATA_FORMAT               = 8
      HEADER_NOT_ALLOWED            = 9
      SEPARATOR_NOT_ALLOWED         = 10
      HEADER_TOO_LONG               = 11
      UNKNOWN_DP_ERROR              = 12
      ACCESS_DENIED                 = 13
      DP_OUT_OF_MEMORY              = 14
      DISK_FULL                     = 15
      DP_TIMEOUT                    = 16
      OTHERS                        = 17
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    IF sy-subrc EQ 0.
    zabpsp_01-kunnr = ITAB-IKUNNR.
    zabpsp_01-matnr = ITAB-IMATNR.
    zabpsp_01-adrnr = ITAB-IADRNR.
    WRITE : / ' UPLOAD SUCCESS ' .
    ENDIF.
    \[subject changed, don't write everything in upper case!\]
    Edited by: Jan Stallkamp on Aug 6, 2008 2:39 PM

    Hi,
    After upload modify the code like below. Also change the file name as some one suggested already. If u are still facing problems then check in debug mode what is happening after FM call.
    CALL GUI_UPLOAD FM.
    IF sy-subrc EQ 0
    IF NOT itab[] IS INITIAL.
    MODIFY ZABPSP_01 FROM TABLE itab.
    WRITE : / ' UPLOAD SUCCESS ' .
    ELSE.
    WRITE 'No data in file'.
    ENDIF.
    ELSE.
    WRITE 'Upload failure'.
    ENDIF.
    Thanks,
    Vinod.

  • ABAP Database Table error

    Hi Gurus,
    While creating the database table it giving the error that SAP System has status 'not modifiable'.
    Pls help us.
    Regards
    Sachin Patil
    Moderator message: please search for available information before asking.
    Edited by: Thomas Zloch on Dec 1, 2010 5:23 PM

    Hi,
    When u creating the field for standard table u must use the APPEND STRUCTURE using that option we can create fields for that table.
    STEP1:GOTA DB TABLE
    STEP2:FIND THE APPENDSTURCTURE OPTION ON APPLICATION TOOLBAR.
    STEP3:CREATE ONE STRUCTURE START WITH 'ZSTR'.
    STEP4:ADD YOUR FIELDS INTO THAT STRUCTURE.
    STEP5:ACTIVATE THAT STRUCTURE.
    regards,
    MURALII

  • How to transfer database tables from sql server 2000 to oracle 10g

    Hi,
    I have a database and tables in sql server 2000. I have to transfer those data to Oracle 10g. I have installed Oracle warehouse Builder ETL Tool. Using this how can i transfer data. Any help is vary helpful for me.
    Thanks in advance.

    you have to do it using ODBC HS.
    1. Configure ODBC connection through gateway.
    2. Create a initxxx.ora file with HS config.
    restart gateway listener services
    3. on target o/s add entries to your tnsnames.ora
    4. On your target o/s create a db link
    restart listener on target
    cheeck this out.Non-Oracle connection through HS issue
    Edited by: Darthvader-647181 on Jan 29, 2009 2:02 AM

  • Csv file uploading for database table creation

    Hi there,
    I'm in the process of making an application that will be able to upload a csv file and create a table based on the same file. As of now, I have managed to make my application upload a csv file into the database. My problem now is to transfer the data in the csv into a table. If there is a function that can do this, please let me know. But as of now, I have tried all that I can but in vain. I would appreciate any assistance rendered as to how I can go about this.
    Kind regards,
    Lusuntha

    hai Lusuntha ,
    Go to search forum and type "upload within html db".here u will find the required information ,as well as the code.go for each topic in the search result.

  • Update & upload the database table

    Hi
    I have a small issue. In which i have to Upload the data from a flat file based on primary key its a  customised table in which there are 4 primary keys. Based on this the customer numbers should be updated and on emore thing is the data should not be repeated. In the selection screen i'll provide a path based on this path it will upload all the data in the flat file
    Regards
    Nanda

    Hi,
    Below is the sample code :
    *& Report  ZCUSTOMER_MASTER_UPLOAD
    REPORT  ZCUSTOMER_MASTER_UPLOAD
           no standard page heading line-size 255.
    *include bdcrecx1.
    TABLES : T100.      "Company Codes
    *        Internal table declaration                                    *
    DATA : begin of it_customer  occurs 0,        "Internal table for creating customer
                  INDEX(4),    "Index
                  KUNNR(16),    "Customer No
                  BUKRS(4),     "Company code
                  VKORG(4),     "Sales Organization
                  VTWEG(2),     "Distribution Channel
                  SPART(2),     "Division
                  KTOKD(4),     "Account group
                  ANRED(30),    "Title
                  NAME1(35),    "Name1
                  SORTL(10),    "Search field
                  NAME2(35),    "Name2
                  NAME3(35),    "Name3
                  NAME4(35),    "Name4
                  STRAS(35),    "House and street
                  STREET2(35),
                  PFACH(10),    "PO box
                  ORT01(35),    "City
                  PSTLZ(10),    "Postal code
                  ORT02(35),    "District
                  PFORT(35),    "PO Box city
                  PSTL2(10),    "Postal code
                  LAND1(3),     "Country Key
                  REGIO(3),     "Region
                  SPRAS(2),     "Language key
                  TELX1(30),    "Telex number
                  TELF1(16),    "First telephone number
                  TELFX(30),    "Fax number
                  TELF2(16),    "Second telephone number
                  TELTX(30),    "Second telex number
                  KNURL(132),   "URL
                  STCEG(20),    "VAT Registration number
                  AKONT(10),    "Recon Account
                  ZUAWA(4),     "Sort key
                  ZTERM(4),     "Terms of payment key
                  ZWELS(10),    "List of payment methods to be considered
                  BZIRK(6),     "Sales district
    *              AWAHR(3),     "Order probability
                  VKBUR(4),     "Sales office
                  VKGRP(3),     "Sales group
                  KDGRP(2),     "Customer group
                  WAERS(5),     "Currency
                  KALKS(1),     "Pricing procedure assigned to this customer
                  VERSG(1),     "Customer statistics group
                  LPRIO(2),     "Delivery Priority
                  VWERK(4),     "Delivering Plant
    *              ANTLF(1)  VALUE 9,  "Maximum partial deliveries allowed
                  INCO1(3),     "Inco terms1
                  INCO2(28),     "Inco terms2
                  ZTERM_01(4),  "Terms of payment key
                  KTGRD(2),     "Account assignment group
                  TAXKD_01(1),  "Tax classification1
                  TAXKD_02(1),  "Tax classification2
                  er_message(100),
           end of it_customer.
    data : begin of it_customer_ext occurs 0,      "Internal table for extending customer
                  KUNNR(16),    "Customer No
                  VKORG(4),     "Sales Organization
                  VTWEG(2),     "Distribution channel
                  SPART(2),     "Division
                  KTOKD(4),     "Account group
                  BZIRK(6),     "Sales district
                  VKBUR(4),     "Sales office
                  VKGRP(3),     "Sales group
                  KDGRP(2),     "Customer group
                  WAERS(5),     "Currency
                  KALKS(1),     "Pricing procedure assigned to this customer
                  VERSG(1),     "Customer statistics group
                  LPRIO(2),     "Delivery priority
                  VWERK(4),     "Delivery plant
                  INCO1(3),     "Incoterms (part 1)
                  INCO2(28),    "Incoterms (part 2)
                  ZTERM(4),     "Terms of payment key
                  KTGRD(2),     "Account assignment group for this customer
                  TAXKD_01(1),  "Tax classification1
                  TAXKD_02(1),  "Tax classification2
            end of it_customer_ext.
    * Internal table to get the error data                                 *
    DATA : it_error like it_customer occurs 0 with header line.
    DATA : BDCDATA like BDCDATA occurs 0 with header line.
    DATA : i_msgtab like bdcmsgcoll occurs 0 with header line.
    * Internal table to find the error from the legacy data                *
    DATA : begin of it_erfind occurs 0,
                  INDEX(10),        "Index for error file
                  kunnr(16),
                  er_message(100),  "For Error Message
            end of it_erfind.
    * Variables declaration                                                *
    DATA : g_message(200),
           time(10),
           date(10)  ,
           v_error_filename like RLGRAP-FILENAME.
           date      = sy-datum.
           time      = sy-uzeit.
    *        Initialization
    initialization.
    * Generating Error file name with date and time.
      perform make_file_name.
    *        Selection Screen                                              *
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    parameter: p_file like IBIPPARMS-PATH obligatory.
    SELECTION-SCREEN SKIP.
    SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE text-005.
                    parameters    : pm_crt radiobutton group g1 default 'X',
                                    pm_ext radiobutton group g1.
    SELECTION-SCREEN END OF BLOCK B2.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 1(30)  text-003.
    SELECTION-SCREEN COMMENT 33(79) text-004.
    SELECTION-SCREEN end OF LINE.
    SELECTION-SCREEN:END OF BLOCK B1.
    at selection-screen ON VALUE-REQUEST FOR p_file .
          perform get_filename.
    * Start of selection
    start-of-selection.
            perform upload_data.
            if pm_crt = 'X'.       "If Customer creation is selected
                perform fill_data_create.
            elseif pm_ext = 'X'.   "If Customer extension is selected
                perform fill_data_extension.
            endif.
    end-of-selection.
    FORM fill_data_create.
            loop at it_customer.
                        perform bdc_dynpro      using 'SAPMF02D' '0100'.
                        perform bdc_field       using 'BDC_CURSOR'
                                                      'RF02D-KTOKD'.
                        perform bdc_field       using 'BDC_OKCODE'
                                                      '/00'.
                        perform bdc_field       using 'RF02D-KUNNR'
                                                      it_customer-KUNNR.
                        perform bdc_field       using 'RF02D-BUKRS'
                                                      it_customer-BUKRS.
                        perform bdc_field       using 'RF02D-VKORG'
                                                      it_customer-VKORG.
                        perform bdc_field       using 'RF02D-VTWEG'
                                                      it_customer-VTWEG.
                        perform bdc_field       using 'RF02D-SPART'
                                                      it_customer-SPART.
                        perform bdc_field       using 'RF02D-KTOKD'
                                                      it_customer-KTOKD.
                         perform bdc_dynpro      using 'SAPMF02D' '0110'.
                        perform bdc_field       using 'BDC_CURSOR'
                                                      'KNA1-KNURL'.
                        perform bdc_field       using 'BDC_OKCODE'
                                                      '=VW'.
                        perform bdc_field       using 'KNA1-ANRED'
                                                      it_customer-ANRED.
                        perform bdc_field       using 'KNA1-NAME1'
                                                      it_customer-NAME1.
                        perform bdc_field       using 'KNA1-SORTL'
                                                      it_customer-SORTL.
                        perform bdc_field       using 'KNA1-NAME2'
                                                      it_customer-NAME2.
                        perform bdc_field       using 'KNA1-NAME3'
                                                      it_customer-NAME3.
                        perform bdc_field       using 'KNA1-NAME4'
                                                      it_customer-NAME4.
                        perform bdc_field       using 'KNA1-STRAS'
                                                      it_customer-STRAS.
                        perform bdc_field       using 'KNA1-STREET2'
                                                      it_customer-STREET2.
                        perform bdc_field       using 'KNA1-PFACH'
                                                      it_customer-PFACH.
                        perform bdc_field       using 'KNA1-ORT01'
                                                      it_customer-ORT01.
                        perform bdc_field       using 'KNA1-PSTLZ'
                                                      it_customer-PSTLZ.
                        perform bdc_field       using 'KNA1-ORT02'
                                                      it_customer-ORT02.
                        perform bdc_field       using 'KNA1-PFORT'
                                                      it_customer-PFORT.
                        perform bdc_field       using 'KNA1-PSTL2'
                                                      it_customer-PSTL2.
                        perform bdc_field       using 'KNA1-LAND1'
                                                      it_customer-LAND1.
                        perform bdc_field       using 'KNA1-REGIO'
                                                      it_customer-REGIO.
                        perform bdc_field       using 'KNA1-SPRAS'
                                                      it_customer-SPRAS.
                        perform bdc_field       using 'KNA1-TELX1'
                                                      it_customer-TELX1.
                        perform bdc_field       using 'KNA1-TELF1'
                                                      it_customer-TELF1.
                        perform bdc_field       using 'KNA1-TELFX'
                                                      it_customer-TELFX.
                        perform bdc_field       using 'KNA1-TELF2'
                                                      it_customer-TELF2.
                        perform bdc_field       using 'KNA1-TELTX'
                                                      it_customer-TELTX.
                        perform bdc_field       using 'KNA1-KNURL'
                                                      it_customer-KNURL.
                        if it_customer-KTOKD = 'Z002' or
                           it_customer-KTOKD = 'Z003' or
                           it_customer-KTOKD = 'Z004' or
                           it_customer-KTOKD = 'Z005' or
                           it_customer-KTOKD = 'Z006' or
                           it_customer-KTOKD = 'Z007'.
                           perform customer_001.
                        elseif it_customer-KTOKD = 'Z011'.
                           perform customer_002.
                        else.
                           perform customer_003.
                        endif.
                        perform bdc_transaction tables i_msgtab using 'XD01' 'A' 'L' .
    *        To fetch the error message from the standard error table
                    select  single * from T100 where SPRSL = 'E'
                                               and ARBGB = SY-MSGID
                                               and MSGNR = SY-MSGNO.
                                               G_MESSAGE = T100-TEXT.
    *        subroutine to change the error message for every document number
                    perform REPLACE_PARAMETERS  using SY-MSGV1
                                                      SY-MSGV2
                                                      SY-MSGV3
                                                      SY-MSGV4
                                            changing  G_MESSAGE.
                     write: / 'System variables:'.
                     skip.
                     write: / '        Sy-msgty:', SY-MSGTY.
                     write: / '        Sy-msgid:', SY-MSGID.
                     write: / '        Sy-msgno:', SY-MSGNO.
                     write: / '        Sy-msgv1:', SY-MSGV1.
                     write: / '        Sy-msgv2:', SY-MSGV2.
                     write: / '        Sy-msgv3:', SY-MSGV3.
                     write: / '        Sy-msgv4:', SY-MSGV4.
                     skip.
                     write: / 'Message:'.
                     skip.
                     write: / SY-MSGTY, G_MESSAGE.
    *        To find out the error in the legacy data if there is anything and pass
    *        the document no with error message to the seperate internal table
    *        called it_erfind
                    if sy-msgty = 'E'.
                          it_erfind-index = it_customer-index.
                          it_erfind-er_message = G_MESSAGE.
                          append it_erfind.
                    endif.
    *        Finally we are segregating the error and downloading the error data.
                  at last.
    *        To segregate the error
                           perform segregate_error.
    *        To download the error from it_error internal table with err mesg
                           perform error_download.
                           perform display_message.
                  endat.
            endloop.
            clear it_customer.
    ENDFORM.
    FORM fill_data_extension.
        loop at it_customer_ext.
                perform bdc_dynpro      using 'SAPMF02D' '0107'.
                perform bdc_field       using 'BDC_CURSOR'
                                              'RF02D-KTOKD'.
                perform bdc_field       using 'BDC_OKCODE'
                                              '/00'.
                perform bdc_field       using 'RF02D-KUNNR'
                                              it_customer_ext-KUNNR.
                perform bdc_field       using 'RF02D-VKORG'
                                              it_customer_ext-VKORG.
                perform bdc_field       using 'RF02D-VTWEG'
                                              it_customer_ext-VTWEG.
                perform bdc_field       using 'RF02D-SPART'
                                              it_customer_ext-SPART.
                perform bdc_field       using 'RF02D-KTOKD'
                                              it_customer_ext-KTOKD.
                if it_customer_ext-KTOKD = 'Z002' or
                   it_customer_ext-KTOKD = 'Z003' or
                   it_customer_ext-KTOKD = 'Z004' or
                   it_customer_ext-KTOKD = 'Z005' or
                   it_customer_ext-KTOKD = 'Z006' or
                   it_customer_ext-KTOKD = 'Z007' or
                   it_customer_ext-KTOKD = 'Z011'.
                           perform customer_extension_001.
                else.
                           perform customer_extension_002.
                endif.
                perform bdc_transaction tables i_msgtab using 'VD01' 'N' 'L' .
    *        To fetch the error message from the standard error table
                    select  single * from T100 where SPRSL = 'E'
                                               and ARBGB = SY-MSGID
                                               and MSGNR = SY-MSGNO.
                                               G_MESSAGE = T100-TEXT.
    *        subroutine to change the error message for every document number
                    perform REPLACE_PARAMETERS  using SY-MSGV1
                                                      SY-MSGV2
                                                      SY-MSGV3
                                                      SY-MSGV4
                                            changing  G_MESSAGE.
                     write: / 'System variables:'.
                     skip.
                     write: / '        Sy-msgty:', SY-MSGTY.
                     write: / '        Sy-msgid:', SY-MSGID.
                     write: / '        Sy-msgno:', SY-MSGNO.
                     write: / '        Sy-msgv1:', SY-MSGV1.
                     write: / '        Sy-msgv2:', SY-MSGV2.
                     write: / '        Sy-msgv3:', SY-MSGV3.
                     write: / '        Sy-msgv4:', SY-MSGV4.
                     skip.
                     write: / 'Message:'.
                     skip.
                     write: / SY-MSGTY, G_MESSAGE.
    *        To find out the error in the legacy data if there is anything and pass
    *        the document no with error message to the seperate internal table
    *        called it_erfind
                    if sy-msgty = 'E'.
                           it_erfind-kunnr = it_customer_ext-kunnr.
                           it_erfind-er_message = G_MESSAGE.
                           append it_erfind.
                    endif.
    *        Finally we are segregating the error and downloading the error data.
                  at last.
    *        To segregate the error
                           perform segregate_error.
    *        To download the error from it_error internal table with err mesg
                           perform error_download.
                           perform display_message.
                  endat.
            endloop.
            clear it_customer_ext.
    ENDFORM.
    *This subroutine is used to fill the data for the Account groups
    *Z002,Z003,Z004,Z005,Z006 AND Z007
    FORM customer_001.
              perform bdc_dynpro      using 'SAPMF02D' '0120'.
              perform bdc_field       using 'BDC_CURSOR'
                                            'KNA1-TXJCD'.
              perform bdc_field       using 'BDC_OKCODE'
                                            '=VW'.
              perform bdc_dynpro      using 'SAPMF02D' '0360'.
              perform bdc_field       using 'BDC_CURSOR'
                                            'KNVK-NAMEV(01)'.
              perform bdc_field       using 'BDC_OKCODE'
                                            '=VW'.
              perform bdc_dynpro      using 'SAPMF02D' '0310'.
              perform bdc_field       using 'BDC_CURSOR'
                                            'KNVV-VERSG'.
              perform bdc_field       using 'BDC_OKCODE'
                                            '=VW'.
              perform bdc_field       using 'KNVV-BZIRK'
                                            it_customer-BZIRK.
              perform bdc_field       using 'KNVV-VKBUR'
                                            it_customer-VKBUR.
              perform bdc_field       using 'KNVV-VKGRP'
                                            it_customer-VKGRP.
              perform bdc_field       using 'KNVV-VERSG'
                                            it_customer-VERSG.
              perform bdc_dynpro      using 'SAPMF02D' '0324'.
              perform bdc_field       using 'BDC_CURSOR'
                                            'KNVP-PARVW(01)'.
              perform bdc_field       using 'BDC_OKCODE'
                                            '=UPDA'.
    *          perform bdc_transaction using 'XD01'.
    ENDFORM.
    *This subroutine is used to fill the data for the Account group Z011
    FORM customer_002.
              perform bdc_dynpro      using 'SAPMF02D' '0120'.
              perform bdc_field       using 'BDC_CURSOR'
                                            'KNA1-LIFNR'.
              perform bdc_field       using 'BDC_OKCODE'
                                            '=VW'.
              perform bdc_dynpro      using 'SAPMF02D' '0125'.
              perform bdc_field       using 'BDC_CURSOR'
                                            'KNA1-NIELS'.
              perform bdc_field       using 'BDC_OKCODE'
                                            '=VW'.
              perform bdc_dynpro      using 'SAPMF02D' '0130'.
              perform bdc_field       using 'BDC_CURSOR'
                                            'KNBK-BANKS(01)'.
              perform bdc_field       using 'BDC_OKCODE'
                                            '=VW'.
              perform bdc_dynpro      using 'SAPMF02D' '0340'.
              perform bdc_field       using 'BDC_CURSOR'
                                            'RF02D-KUNNR'.
              perform bdc_field       using 'BDC_OKCODE'
                                            '=VW'.
              perform bdc_dynpro      using 'SAPMF02D' '0370'.
              perform bdc_field       using 'BDC_CURSOR'
                                            'RF02D-KUNNR'.
              perform bdc_field       using 'BDC_OKCODE'
                                            '=VW'.
              perform bdc_field       using 'KNA1-CIVVE'
                                            'X'.
              perform bdc_dynpro      using 'SAPMF02D' '0360'.
              perform bdc_field       using 'BDC_CURSOR'
                                            'KNVK-NAMEV(01)'.
              perform bdc_field       using 'BDC_OKCODE'
                                            '=VW'.
              perform bdc_dynpro      using 'SAPMF02D' '0310'.
              perform bdc_field       using 'BDC_CURSOR'
                                            'KNVV-VERSG'.
              perform bdc_field       using 'BDC_OKCODE'
                                            '=VW'.
              perform bdc_field       using 'KNVV-BZIRK'
                                            it_customer-BZIRK.
              perform bdc_field       using 'KNVV-VERSG'
                                            it_customer-VERSG.
              perform bdc_dynpro      using 'SAPMF02D' '0324'.
              perform bdc_field       using 'BDC_CURSOR'
                                            'KNVP-PARVW(01)'.
              perform bdc_field       using 'BDC_OKCODE'
                                            '=UPDA'.
    ENDFORM.
    *This subroutine is used to fill the data for the Account groups
    *Z020,Z021,Z022,Z023,Z200,Z201.
    FORM customer_003.
                        perform bdc_dynpro      using 'SAPMF02D' '0120'.
                        perform bdc_field       using 'BDC_CURSOR'
                                                      'KNA1-STCEG'.
                        perform bdc_field       using 'BDC_OKCODE'
                                                      '=VW'.
                        perform bdc_field       using 'KNA1-STCEG'
                                                      it_customer-STCEG.
                        perform bdc_dynpro      using 'SAPMF02D' '0125'.
                        perform bdc_field       using 'BDC_CURSOR'
                                                      'KNA1-NIELS'.
                        perform bdc_field       using 'BDC_OKCODE'
                                                      '=VW'.
                        perform bdc_dynpro      using 'SAPMF02D' '0130'.
                        perform bdc_field       using 'BDC_CURSOR'
                                                      'KNBK-BANKS(01)'.
                        perform bdc_field       using 'BDC_OKCODE'
                                                      '=VW'.
                        perform bdc_dynpro      using 'SAPMF02D' '0340'.
                        perform bdc_field       using 'BDC_CURSOR'
                                                      'RF02D-KUNNR'.
                        perform bdc_field       using 'BDC_OKCODE'
                                                      '=VW'.
                        perform bdc_dynpro      using 'SAPMF02D' '0370'.
                        perform bdc_field       using 'BDC_CURSOR'
                                                      'RF02D-KUNNR'.
                        perform bdc_field       using 'BDC_OKCODE'
                                                      '=VW'.
                        perform bdc_field       using 'KNA1-CIVVE'
                                                      'X'.
                        perform bdc_dynpro      using 'SAPMF02D' '0360'.
                        perform bdc_field       using 'BDC_CURSOR'
                                                      'KNVK-NAMEV(01)'.
                        perform bdc_field       using 'BDC_OKCODE'
                                                      '=VW'.
                        perform bdc_dynpro      using 'SAPMF02D' '0210'.
                        perform bdc_field       using 'BDC_CURSOR'
                                                      'KNB1-KNRZE'.
                        perform bdc_field       using 'BDC_OKCODE'
                                                      '=VW'.
                        perform bdc_field       using 'KNB1-AKONT'
                                                      it_customer-AKONT.
                        perform bdc_field       using 'KNB1-ZUAWA'
                                                      it_customer-ZUAWA.
                        perform bdc_dynpro      using 'SAPMF02D' '0215'.
                        perform bdc_field       using 'BDC_CURSOR'
                                                      'KNB1-ZWELS'.
                        perform bdc_field       using 'BDC_OKCODE'
                                                      '=VW'.
                        perform bdc_field       using 'KNB1-ZTERM'
                                                      it_customer-ZTERM.
                        perform bdc_field       using 'KNB1-ZWELS'
                                                      it_customer-ZWELS.
                        perform bdc_dynpro      using 'SAPMF02D' '0220'.
                        perform bdc_field       using 'BDC_CURSOR'
                                                      'KNB5-MAHNA'.
                        perform bdc_field       using 'BDC_OKCODE'
                                                      '=VW'.
                        perform bdc_dynpro      using 'SAPMF02D' '0230'.
                        perform bdc_field       using 'BDC_CURSOR'
                                                      'KNB1-VRSNR'.
                        perform bdc_field       using 'BDC_OKCODE'
                                                      '=VW'.
                        perform bdc_dynpro      using 'SAPMF02D' '0610'.
                        perform bdc_field       using 'BDC_OKCODE'
                                                      '=VW'.
                        perform bdc_field       using 'BDC_CURSOR'
                                                      'RF02D-KUNNR'.
                        perform bdc_dynpro      using 'SAPMF02D' '0310'.
                        perform bdc_field       using 'BDC_CURSOR'
                                                      'KNVV-VERSG'.
                        perform bdc_field       using 'BDC_OKCODE'
                                                      '=VW'.
                        perform bdc_field       using 'KNVV-BZIRK'
                                                      it_customer-BZIRK.
    *                    perform bdc_field       using 'KNVV-AWAHR'
    *                                                  it_customer-AWAHR.
                        perform bdc_field       using 'KNVV-VKBUR'
                                                      it_customer-VKBUR.
                        perform bdc_field       using 'KNVV-VKGRP'
                                                      it_customer-VKGRP.
                        perform bdc_field       using 'KNVV-KDGRP'
                                                      it_customer-KDGRP.
                        perform bdc_field       using 'KNVV-WAERS'
                                                      it_customer-WAERS.
                        perform bdc_field       using 'KNVV-KALKS'
                                                      it_customer-KALKS.
                        perform bdc_field       using 'KNVV-VERSG'
                                                      it_customer-VERSG.
                        perform bdc_dynpro      using 'SAPMF02D' '0315'.
                        perform bdc_field       using 'BDC_CURSOR'
                                                      'KNVV-VWERK'.
                        perform bdc_field       using 'BDC_OKCODE'
                                                      '=VW'.
                        perform bdc_field       using 'KNVV-LPRIO'
                                                      it_customer-LPRIO.
    *                    perform bdc_field       using 'KNVV-KZAZU'
    *                                                  'X'.
                        perform bdc_field       using 'KNVV-VWERK'
                                                      it_customer-VWERK.
    *                    perform bdc_field       using 'KNVV-ANTLF'
    *                                                  it_customer-ANTLF.
                        perform bdc_dynpro      using 'SAPMF02D' '0320'.
                        perform bdc_field       using 'BDC_CURSOR'
                                                      'KNVV-KTGRD'.
                        perform bdc_field       using 'BDC_OKCODE'
                                                      '=VW'.
                        perform bdc_field       using 'KNVV-INCO1'
                                                      it_customer-INCO1.
                        perform bdc_field       using 'KNVV-INCO2'
                                                      it_customer-INCO2.
                        perform bdc_field       using 'KNVV-ZTERM'
                                                      it_customer-ZTERM_01.
                        perform bdc_field       using 'KNVV-KTGRD'
                                                      it_customer-KTGRD.
                        perform bdc_dynpro      using 'SAPMF02D' '1350'.
                        perform bdc_field       using 'BDC_CURSOR'
                                                      'KNVI-TAXKD(02)'.
                        perform bdc_field       using 'BDC_OKCODE'
                                                      '=VW'.
                        perform bdc_field       using 'KNVI-TAXKD(01)'
                                                      it_customer-TAXKD_01.
                        perform bdc_field       using 'KNVI-TAXKD(02)'
                                                      it_customer-TAXKD_02.
                        perform bdc_dynpro      using 'SAPMF02D' '0324'.
                        perform bdc_field       using 'BDC_CURSOR'
                                                      'KNVP-PARVW(01)'.
                        perform bdc_field       using 'BDC_OKCODE'
                                                      '=UPDA'.
    *                   perform bdc_transaction using 'XD01'.
    ENDFORM.
    FORM customer_extension_001.
              perform bdc_dynpro      using 'SAPMF02D' '0310'.
              perform bdc_field       using 'BDC_CURSOR'
                                            'KNVV-VERSG'.
              perform bdc_field       using 'BDC_OKCODE'
                                            '=VW'.
              perform bdc_field       using 'KNVV-BZIRK'
                                            it_customer_ext-BZIRK.
              if not it_customer_ext-KTOKD = 'Z011'.
                    perform bdc_field       using 'KNVV-VKBUR'
                                                  it_customer_ext-VKBUR.
                    perform bdc_field       using 'KNVV-VKGRP'
                                                  it_customer_ext-VKGRP.
              endif.
                    perform bdc_field       using 'KNVV-VERSG'
                                                  it_customer_ext-VERSG.
              perform bdc_dynpro      using 'SAPMF02D' '0324'.
              perform bdc_field       using 'BDC_CURSOR'
                                            'KNVP-PARVW(01)'.
              perform bdc_field       using 'BDC_OKCODE'
                                            '=UPDA'.
    ENDFORM.
    FORM customer_extension_002.
                perform bdc_dynpro      using 'SAPMF02D' '0310'.
                perform bdc_field       using 'BDC_CURSOR'
                                              'KNVV-VERSG'.
                perform bdc_field       using 'BDC_OKCODE'
                                              '=VW'.
                perform bdc_field       using 'KNVV-BZIRK'
                                              it_customer_ext-BZIRK.
    *            perform bdc_field       using 'KNVV-AWAHR'
    *                                          '100'.
                perform bdc_field       using 'KNVV-VKBUR'
                                              it_customer_ext-VKBUR.
                perform bdc_field       using 'KNVV-VKGRP'
                                              it_customer_ext-VKGRP.
                perform bdc_field       using 'KNVV-KDGRP'
                                              it_customer_ext-KDGRP.
                perform bdc_field       using 'KNVV-WAERS'
                                              it_customer_ext-WAERS.
                perform bdc_field       using 'KNVV-KALKS'
                                              it_customer_ext-KALKS.
                perform bdc_field       using 'KNVV-VERSG'
                                              it_customer_ext-VERSG.
                perform bdc_dynpro      using 'SAPMF02D' '0315'.
                perform bdc_field       using 'BDC_CURSOR'
                                              'KNVV-VWERK'.
                perform bdc_field       using 'BDC_OKCODE'
                                              '=VW'.
                perform bdc_field       using 'KNVV-LPRIO'
                                              it_customer_ext-LPRIO.
    *            perform bdc_field       using 'KNVV-KZAZU'
    *                                          'X'.
                perform bdc_field       using 'KNVV-VWERK'
                                              it_customer_ext-VWERK.
    *            perform bdc_field       using 'KNVV-ANTLF'
    *                                          '9'.
                perform bdc_dynpro      using 'SAPMF02D' '0320'.
                perform bdc_field       using 'BDC_CURSOR'
                                              'KNVV-KTGRD'.
                perform bdc_field       using 'BDC_OKCODE'
                                              '=VW'.
                perform bdc_field       using 'KNVV-INCO1'
                                              it_customer_ext-INCO1.
                perform bdc_field       using 'KNVV-INCO2'
                                              it_customer_ext-INCO2.
                perform bdc_field       using 'KNVV-ZTERM'
                                              it_customer_ext-ZTERM.
                perform bdc_field       using 'KNVV-KTGRD'
                                              it_customer_ext-KTGRD.
                perform bdc_dynpro      using 'SAPMF02D' '1350'.
                perform bdc_field       using 'BDC_CURSOR'
                                              'RF02D-KUNNR'.
                perform bdc_field       using 'BDC_OKCODE'
                                              '=VW'.
                perform bdc_dynpro      using 'SAPMF02D' '0324'.
                perform bdc_field       using 'BDC_CURSOR'
                                              'KNVP-PARVW(01)'.
                perform bdc_field       using 'BDC_OKCODE'
                                              '=UPDA'.
    ENDFORM.
    *Subrotine to replace the parameters
        FORM REPLACE_PARAMETERS USING P_PAR_1 P_PAR_2 P_PAR_3
                                      P_PAR_4 CHANGING P_MESSAGE.
    * erst mal pruefen, ob numerierte Parameter verwendet wurden
        DO.
              REPLACE '&1' WITH P_PAR_1 INTO P_MESSAGE.
              IF SY-SUBRC <> 0.
                EXIT.
              ENDIF.
        ENDDO.
        DO.
              REPLACE '&2' WITH P_PAR_2 INTO P_MESSAGE.
              IF SY-SUBRC <> 0.
                EXIT.
              ENDIF.
        ENDDO.
        DO.
              REPLACE '&3' WITH P_PAR_3 INTO P_MESSAGE.
              IF SY-SUBRC <> 0.
                EXIT.
              ENDIF.
        ENDDO.
        DO.
              REPLACE '&4' WITH P_PAR_4 INTO P_MESSAGE.
              IF SY-SUBRC <> 0.
                EXIT.
              ENDIF.
        ENDDO.
    * falls keine numerierten Parameter vorh., ersetzen wie gehabt
              REPLACE '&' WITH P_PAR_1 INTO P_MESSAGE.
              CONDENSE P_MESSAGE.
              IF SY-SUBRC EQ 0.
                REPLACE '&' WITH P_PAR_2 INTO P_MESSAGE.
                CONDENSE P_MESSAGE.
                    IF SY-SUBRC EQ 0.
                        REPLACE '&' WITH P_PAR_3 INTO P_MESSAGE.
                        CONDENSE P_MESSAGE.
                        IF SY-SUBRC EQ 0.
                          REPLACE '&' WITH P_PAR_4 INTO P_MESSAGE.
                          CONDENSE P_MESSAGE.
                        ENDIF.
                    ENDIF.
              ENDIF.
    ENDFORM.
    *Subroutine to segregate the error data from the legacy data
              FORM segregate_error.
                loop at it_erfind.
                     if pm_crt = 'X'.
                             loop at it_customer where index = it_erfind-index.
                                   move-corresponding it_customer to it_error.
                                   it_error-er_message = it_erfind-er_message.
                                   append it_error.
                             endloop.
                     elseif pm_ext = 'X'.
                             loop at it_customer_ext where kunnr = it_erfind-kunnr.
                                   move-corresponding it_customer_ext to it_error.
                                   it_error-er_message = it_erfind-er_message.
                                   append it_error.
                             endloop.
                     endif.
                endloop.
              ENDFORM.
    *Subroutine to download the error data from the it_error table.
          FORM error_download.
              if it_error[] is not initial.
                  call function 'WS_DOWNLOAD'
                       exporting
                          CODEPAGE = 'IBM'
                          FILENAME = v_error_filename
                          FILETYPE = 'DAT'
                  tables
                          DATA_TAB = IT_ERROR.
              endif.
          ENDFORM.
    *        Start new screen                                              *
          FORM BDC_DYNPRO USING PROGRAM DYNPRO.
                CLEAR BDCDATA.
                BDCDATA-PROGRAM  = PROGRAM.
                BDCDATA-DYNPRO   = DYNPRO.
                BDCDATA-DYNBEGIN = 'X'.
                APPEND BDCDATA.
          ENDFORM.
    *        Insert field                                                  *
          FORM BDC_FIELD USING FNAM FVAL.
    *          IF FVAL <> NODATA.
               CLEAR BDCDATA.
               BDCDATA-FNAM = FNAM.
               BDCDATA-FVAL = FVAL.
               APPEND BDCDATA.
    *          ENDIF.
          ENDFORM.
          FORM bdc_transaction tables MESSTAB USING  TCODE CTUMODE CUPDATE .
                  CALL TRANSACTION TCODE USING BDCDATA
                                        MODE   CTUMODE
                                        UPDATE CUPDATE
                                        MESSAGES INTO MESSTAB.
                  REFRESH BDCDATA.
                  clear   BDCDATA.
           ENDFORM.                    " bdc_transaction
    * Uploading data file to internal table.                           *
           FORM upload_data.
               if pm_crt = 'X'.
                      CALL FUNCTION 'WS_UPLOAD'
                          EXPORTING
                             FILENAME                      = p_file
    *                         CODEPAGE                      = 'IBM '
                             FILETYPE                      = 'DAT'
                          TABLES
                              DATA_TAB                      = it_customer
                          EXCEPTIONS
                             CONVERSION_ERROR              = 1
                             INVALID_TABLE_WIDTH           = 2
                             INVALID_TYPE                  = 3
                             NO_BATCH                      = 4
                             UNKNOWN_ERROR                 = 5
                             GUI_REFUSE_FILETRANSFER       = 6
                             OTHERS                        = 7.
                      IF SY-SUBRC <> 0.
                         MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
                      ENDIF.
              elseif pm_ext = 'X'.
                          CALL FUNCTION 'WS_UPLOAD'
                          EXPORTING
                             FILENAME                      = p_file
    *                         CODEPAGE                      = 'IBM '
                             FILETYPE                      = 'DAT'
                          TABLES
                              DATA_TAB                      = it_customer_ext
                          EXCEPTIONS
                             CONVERSION_ERROR              = 1
                             INVALID_TABLE_WIDTH           = 2
                             INVALID_TYPE                  = 3
                             NO_BATCH                      = 4
                             UNKNOWN_ERROR                 = 5
                             GUI_REFUSE_FILETRANSFER       = 6
                             OTHERS                        = 7.
                      IF SY-SUBRC <> 0.
                         MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
                      ENDIF.
              endif.
    {size:13}Here you can use sort and delete statement to delete the duplicate entries.{size}
          ENDFORM.
    *&      Form  display_message
    FORM display_message .
        if it_error[] is initial.
           message i019(zmsg).   "Success
        else.
           message e020(zmsg).   "Failed
        endif.
    ENDFORM.                    " display_message
    *&      Form  get_filename
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM get_filename .
        CALL FUNCTION 'F4_FILENAME'
         EXPORTING
           PROGRAM_NAME        = SYST-CPROG
           DYNPRO_NUMBER       = SYST-DYNNR
    *       FIELD_NAME          = p_file
         IMPORTING
           FILE_NAME           = p_file .
         if sy-subrc NE 0  .
            write : / 'Enter File Name'.
         endif.
    ENDFORM.                    " get_filename
    *&      Form  make_file_name
    FORM make_file_name .
           write sy-datum to date  MM/DD/YYYY.
           write sy-uzeit to time  USING EDIT MASK ' __ __ __'.
           concatenate Text-002 date time '.txt'
                  into v_error_filename.
    ENDFORM.                    " make_file_name
    Thanks,
    Sriram Ponna.

  • Download internal table to presentation server in UTF-8 format

    Hello everyone.
    We are trying to use function module GUI_DOWNLOAD to download data from internal table to a text file (filetype ASCII). The defualt encoding for the text file is ANSI but we need to download it with the encoding UTF-8.
    We have already used codepage 4110 but that did not solve the problem.
    We are using SAP ECC 5.0 system.
    Can anyone please provide us with a solution? We need to solve this as early as possible.

    Hi Saurav.
    Try this
    1.Go to SAP GUI Logon
    2. Change your icon logon on Tabstrib "Code Page" at "Upload/Download"  to encod whatever language
    do you want.
    Hope it helps.
    Sayan.

  • Download SAP data to Excel file in Presentation server

    Hi gurus,
    I need to download SAP data to excel file. for that im using SAP_CONVERT_TO_XLS_FORMAT   function module. I have to download with column header and also date should be in YYMMDD format. Im changing the format in ITAB but when populating to excel leading zero's were removed.(EX. 12102007 is converted to 071012 and it was populated as 71012). can someone explain how to use this function module or give someother solution for this....And if possible explain the parameters of the function module SAP_CONVERT_TO_XLS_FORMAT. Is there any function module for converting date as required format?
    Thanks,
    Amal

    Hi Amal...
    The Problem you are facing is because of Display properties of Microsoft Excel itself. I believe this can not be solver with in SAP. Instead I would suggest you to go for a .csv format. which can also be viewed in Excel.
    In any case if you get to find a different solution for this, I would appriciate if you can share it with me :).
    Santosh

  • Upload to file in the presentation server

    Hi Guyz,
    I got a report, which would download output into a .txt file using function module "download", but one field is not getting downloaded into that.
    how to check that? plz let me know..
    thanks a lot..
    venu.

    I guess its the last field in your structure you didn´t get. Right ? Then maybe you exceeded a hardcoded length of about 1000 or 1200 bytes in the FM.
    Hope that helps.

  • File Upload and Download From Presentation server

    I have a requirement to provide a selection option to user to upload a big file from presentation server.
    Not sure whther we can a upload the entire file at one short from presentation server. PLease provide some sample code to upload a huge file from presentation server and downlaod a file to presentation server.

    Hi,
    Try this code for download----
    TABLES:
      kna1.                                " General Data in Customer Master
    TYPES:
      BEGIN OF type_s_kna1,
        kunnr TYPE kna1-kunnr,             " Customer Number
        adrnr TYPE kna1-adrnr,             " Address
        anred TYPE kna1-anred,             " Title
        erdat TYPE kna1-erdat,             " Date on which record created
        ernam TYPE kna1-ernam,             " Name of Person who Created the
                                           " Object
    END OF type_s_kna1.
    DATA:
      fs_kna1 TYPE type_s_kna1.
    DATA:
        t_kna1 LIKE
      STANDARD TABLE
            OF fs_kna1.
    " Select-options----
    SELECT-OPTIONS:
      s_kunnr FOR kna1-kunnr.              " Customer Number
    AT SELECTION-SCREEN ON s_kunnr.
      SELECT kunnr                         " Customer number
        FROM kna1
        INTO s_kunnr UP TO 1 ROWS.
      ENDSELECT.
      IF sy-subrc NE 0.
        MESSAGE 'No such customer exists' TYPE 'S'.
      ENDIF.                               " IF SY-SUBRC NE 0
    START-OF-SELECTION.
      PERFORM customer_selection.
    FORM customer_selection .
      SELECT kunnr                         " Customer Number
             adrnr                         " Address
             anred                         " Title
             erdat                         " Date of record creation
             ernam                         " Person who created object
        FROM kna1
        INTO TABLE t_kna1
       WHERE kunnr IN s_kunnr.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
        BIN_FILESIZE                  =
          filename                      = 'C:\TEMP\CUSTOMER.TXT'
        FILETYPE                      = 'ASC'
         write_field_separator         = 'X'
        HEADER                        = '00'
        WRITE_LF                      = 'X'
         col_select                    = 'X'
         col_select_mask               = 'XXXXX'
        IGNORE_CERR                   = ABAP_TRUE
        REPLACEMENT                   = '#'
      IMPORTING
        FILELENGTH                    =
        TABLES
          data_tab                      = t_kna1
       EXCEPTIONS
               dataprovider_exception        = 20
         control_flush_error           = 21
         OTHERS                        = 22
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.                               " IF SY-SUBRC NE 0
    ENDFORM.                               " FORM CUSTOMER_SELECTION.
    for upload----
    " Table declarations----
    TABLES:
      bkpf.                                " Accounting Document Header
    TYPES:
      BEGIN OF type_s_bkpf,
        bukrs TYPE bkpf-bukrs,             " Company code
        belnr TYPE bkpf-belnr,             " Accounting Document Number
        gjahr TYPE bkpf-gjahr,             " Fiscal Year
        blart TYPE bkpf-blart,             " Document type
        bldat TYPE bkpf-bldat,             " Document Date in Document
      END OF type_s_bkpf.
    DATA:
      fs_bkpf TYPE type_s_bkpf.
    DATA:
      fname(10) TYPE c VALUE 'ACCOUNTING'  .
    DATA:
        t_bkpf LIKE
      STANDARD TABLE
            OF fs_bkpf.
    *" Select-options----
    SELECT-OPTIONS:
      s_bukrs FOR bkpf-bukrs,              " Company code
      s_gjahr FOR bkpf-gjahr.              " Fiscal year
    OPEN DATASET fname FOR OUTPUT IN BINARY MODE .
    PERFORM account_selection.
    LOOP AT t_bkpf INTO fs_bkpf.
      TRANSFER fs_bkpf TO fname.
    ENDLOOP.                               " LOOP T_BKPF
    CLOSE DATASET fname.
    FORM account_selection .
      SELECT bukrs                         " Company code
             belnr                         " Accounting document number
             gjahr                         " Fiscal year
             blart                         " Document year
             bldat                         " Document date
        FROM bkpf
        INTO TABLE t_bkpf
       WHERE bukrs IN s_bukrs
         AND gjahr IN s_gjahr.
    ENDFORM.                               " FORM ACCOUNT_SELECTION
    also try
    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        filename                      = 'C:\TEMP\CUSTOMER.TXT'
      FILETYPE                      = 'ASC'
       has_field_separator           = 'X'
      HEADER_LENGTH                 = 0
      READ_BY_LINE                  = 'X'
      IGNORE_CERR                   = ABAP_TRUE
      REPLACEMENT                   = '#'
    IMPORTING
      FILELENGTH                    =
      HEADER                        =
      TABLES
        data_tab                      = t_kna1
    EXCEPTIONS
          disk_full                     = 15
       dp_timeout                    = 16
       OTHERS                        = 17
    IF sy-subrc EQ 0.
      PERFORM customer_display.
    ELSE.
      MESSAGE 'No customer file exists'(006) TYPE 'S'.
    ENDIF.                                 " IF SU-SUBRC EQ 0
    Regards,
    jaya
    Edited by: Jayapradha Neeli on May 28, 2009 11:38 AM

  • Download or upload a scripts..

    hi,
    can any body tell me, How can we copy a script from one server to another ?
    or can we download or upload a SAP Script from local server ...?

    Hi Meenakshi,
    Hope the example below gives you a clear picture.
    Login to Client (512)
    Goto SE38 or SA38 and execute the abap program: RSTXSCRP
    Mode : EXPORT
    Login to Client (500)
    Goto SE38 or SA38 and execute the abap program: RSTXSCRP
    Mode : IMPORT
    or
    Login to Client (500)
    Goto SE71 - Click Utilities - Copy from client
    Cheers,
    Suvendu

Maybe you are looking for

  • Not able to copy files to HD even when plenty of space

    Hello, please help! I need to work out how to transfer something back to my HD from an external HD. I temporarily transferred my APerture library (129 GB) to my external hd to create space while I tidied up my Itunes library, which is now tidy, whic

  • 30EA1: Mac version will not disconnect from database

    Hello, I was trying the EA1 version on my mac this morning and although I opened a couple of connections to different databases fine, when i did right click / disconnect it seemed to carry on being connected. I didn't run any queries in that database

  • SAP WM over MM

    Dear all, How will i convince a client for question like . Why do we need SAP WM system,rather than just using SAP MM ? From a business perceptive what should be my convincing answer to the client ?

  • Windows 7 Partition Unusable After OS X Yosemite Upgrade

    Hello All, I have an Early 2013 15" MBPR, and I just recently upgraded to OS X 10.10. (I made a time machine backup right before). However, it seems that my Windows 7 partition is not bootable anymore using "alt" on boot, and it also isn't showing up

  • Run function on component load / focus

    hi I want to run a function every time a component is opened / focused upon. at the moment I am running the function with the "creationComplete" property which works fine, although it only runs when the component is first created, whereas I want to r