<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Update &amp; upload the database table in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/update-upload-the-database-table/m-p/3442496#M826749</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jose&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for ur reply. I think by using this pop up FM i'll get a pop up to specify a path right?????????&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After using the Modify statement the database will be automatically get updated with my new values right????&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So now at the same time i dont want any duplicate entries also. That is if it is having already an entry then it should not enter that value to the ztable??? how to perform this???&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 09 Feb 2008 10:53:49 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-02-09T10:53:49Z</dc:date>
    <item>
      <title>Update &amp; upload the database table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/update-upload-the-database-table/m-p/3442485#M826738</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Nanda&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 Feb 2008 07:20:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/update-upload-the-database-table/m-p/3442485#M826738</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-09T07:20:22Z</dc:date>
    </item>
    <item>
      <title>Re: Update &amp; upload the database table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/update-upload-the-database-table/m-p/3442486#M826739</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can use GUI_UPLOAD data, once data in uploaded you will captured data into the internal table. If you want to filter out the duplicate entries, you can use below statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
sort itab by &amp;lt;fieldname&amp;gt;."Here you have to use all your four primary keys.

DELETE ADJACENT DUPLICATES FROM ITAB COMPARING &amp;lt;FIELDNAME&amp;gt;." Here you can use all the four fields.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Sriram Ponna.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 Feb 2008 07:40:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/update-upload-the-database-table/m-p/3442486#M826739</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-09T07:40:16Z</dc:date>
    </item>
    <item>
      <title>Re: Update &amp; upload the database table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/update-upload-the-database-table/m-p/3442487#M826740</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can i have a sample coding????&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And one more thing is i have to fetch the values from that ztable using primaryu key only&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 Feb 2008 07:41:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/update-upload-the-database-table/m-p/3442487#M826740</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-09T07:41:57Z</dc:date>
    </item>
    <item>
      <title>Re: Update &amp; upload the database table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/update-upload-the-database-table/m-p/3442488#M826741</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Create a report and in the report declare a internal table similar the structure of the ztable. &lt;/P&gt;&lt;P&gt;2. Now upload the flat file by GUI_UPLOAD functional module.&lt;/P&gt;&lt;P&gt;3. Split the string for each rows from the flat file and populate each field the internal table.&lt;/P&gt;&lt;P&gt;4. By Modify/update command update the internal table data to the stable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To upload a flat file : &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;    CALL FUNCTION 'GUI_UPLOAD'&lt;/P&gt;&lt;P&gt;      EXPORTING&lt;/P&gt;&lt;P&gt;        filename                = l_file&lt;/P&gt;&lt;P&gt;        filetype                = 'ASC'&lt;/P&gt;&lt;P&gt;      TABLES&lt;/P&gt;&lt;P&gt;        data_tab                = p_local_table&lt;/P&gt;&lt;P&gt;      EXCEPTIONS&lt;/P&gt;&lt;P&gt;        file_open_error         = 1&lt;/P&gt;&lt;P&gt;        file_read_error         = 2&lt;/P&gt;&lt;P&gt;        no_batch                = 3&lt;/P&gt;&lt;P&gt;        gui_refuse_filetransfer = 4&lt;/P&gt;&lt;P&gt;        invalid_type            = 5&lt;/P&gt;&lt;P&gt;        no_authority            = 6&lt;/P&gt;&lt;P&gt;        unknown_error           = 7&lt;/P&gt;&lt;P&gt;        bad_data_format         = 8&lt;/P&gt;&lt;P&gt;        header_not_allowed      = 9&lt;/P&gt;&lt;P&gt;        separator_not_allowed   = 10&lt;/P&gt;&lt;P&gt;        header_too_long         = 11&lt;/P&gt;&lt;P&gt;        unknown_dp_error        = 12&lt;/P&gt;&lt;P&gt;        access_denied           = 13&lt;/P&gt;&lt;P&gt;        dp_out_of_memory        = 14&lt;/P&gt;&lt;P&gt;        disk_full               = 15&lt;/P&gt;&lt;P&gt;        dp_timeout              = 16&lt;/P&gt;&lt;P&gt;        OTHERS                  = 17.&lt;/P&gt;&lt;P&gt;    IF sy-subrc  0.&lt;/P&gt;&lt;P&gt;      MESSAGE e002 WITH l_file.&lt;/P&gt;&lt;P&gt;    ENDIF.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To split each rows of flat file to internal table fields : &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: l_cnt TYPE i.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;  CLEAR: l_cnt, wa_local.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;  LOOP AT i_local INTO wa_local.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;    REFRESH i_split[].&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;    SPLIT wa_local AT c_tab INTO TABLE i_split.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;    CLEAR l_cnt.&lt;/P&gt;&lt;P&gt;    ADD 1 TO l_cnt.&lt;/P&gt;&lt;P&gt;    CLEAR wa_split.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;    LOOP AT i_split INTO wa_split.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;      IF g_file_flag = 'I'.&lt;/P&gt;&lt;P&gt;        ASSIGN COMPONENT l_cnt OF STRUCTURE wa_input TO &amp;lt;fs_field&amp;gt;.&lt;/P&gt;&lt;P&gt;      ELSEIF g_file_flag = 'A'.&lt;/P&gt;&lt;P&gt;        ASSIGN COMPONENT l_cnt OF STRUCTURE wa_asset TO &amp;lt;fs_field&amp;gt;.&lt;/P&gt;&lt;P&gt;      ELSEIF g_file_flag = 'C'.&lt;/P&gt;&lt;P&gt;        ASSIGN COMPONENT l_cnt OF STRUCTURE wa_cost TO &amp;lt;fs_field&amp;gt;.&lt;/P&gt;&lt;P&gt;      ELSEIF g_file_flag = 'D'.&lt;/P&gt;&lt;P&gt;        ASSIGN COMPONENT l_cnt OF STRUCTURE wa_depr TO &amp;lt;fs_field&amp;gt;.&lt;/P&gt;&lt;P&gt;      ENDIF.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;      CLEAR &amp;lt;fs_field&amp;gt;.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;      &amp;lt;fs_field&amp;gt; = wa_split-col.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;      ADD 1 TO l_cnt.&lt;/P&gt;&lt;P&gt;      CLEAR wa_split.&lt;/P&gt;&lt;P&gt;    ENDLOOP.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;    IF g_file_flag = 'I'.&lt;/P&gt;&lt;P&gt;      APPEND wa_input TO p_input_tab.&lt;/P&gt;&lt;P&gt;      CLEAR: wa_input .&lt;/P&gt;&lt;P&gt;    ELSEIF g_file_flag = 'A'.&lt;/P&gt;&lt;P&gt;      APPEND wa_asset TO p_asset_tab.&lt;/P&gt;&lt;P&gt;      CLEAR: wa_asset .&lt;/P&gt;&lt;P&gt;    ELSEIF g_file_flag = 'C'.&lt;/P&gt;&lt;P&gt;      APPEND wa_cost TO p_cost_tab.&lt;/P&gt;&lt;P&gt;      CLEAR: wa_cost .&lt;/P&gt;&lt;P&gt;    ELSEIF g_file_flag = 'D'.&lt;/P&gt;&lt;P&gt;      APPEND wa_depr TO p_depr_tab.&lt;/P&gt;&lt;P&gt;      CLEAR: wa_depr .&lt;/P&gt;&lt;P&gt;    ENDIF.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;    CLEAR: wa_local .&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;  ENDLOOP.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To modify ztable with internal table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    IF NOT lt_itab_modif IS INITIAL.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;EZ_ZMMS_PHYINV&lt;/P&gt;&lt;P&gt;      CALL FUNCTION 'ENQUEUE_EZ_lt_itab_modif'&lt;/P&gt;&lt;P&gt;        EXPORTING&lt;/P&gt;&lt;P&gt;          mode_itab = 'E'&lt;/P&gt;&lt;P&gt;          mandt            = sy-mandt&lt;/P&gt;&lt;P&gt;        EXCEPTIONS&lt;/P&gt;&lt;P&gt;          foreign_lock     = 1&lt;/P&gt;&lt;P&gt;          system_failure   = 2&lt;/P&gt;&lt;P&gt;          OTHERS           = 3.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;      IF sy-subrc EQ 0.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;        MODIFY zitab FROM TABLE lt_itab_modif.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;        CALL FUNCTION 'DEQUEUE_EZ_lt_itab_modif'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Pavan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 Feb 2008 07:43:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/update-upload-the-database-table/m-p/3442488#M826741</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-09T07:43:43Z</dc:date>
    </item>
    <item>
      <title>Re: Update &amp; upload the database table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/update-upload-the-database-table/m-p/3442489#M826742</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below is the sample code :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
                                                                                *&amp;amp;---------------------------------------------------------------------*
*&amp;amp; Report  ZCUSTOMER_MASTER_UPLOAD
*&amp;amp;
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;
*&amp;amp;
*&amp;amp;---------------------------------------------------------------------*

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 '&amp;amp;1' WITH P_PAR_1 INTO P_MESSAGE.
          IF SY-SUBRC &amp;lt;&amp;gt; 0.
            EXIT.
          ENDIF.
    ENDDO.
    DO.
          REPLACE '&amp;amp;2' WITH P_PAR_2 INTO P_MESSAGE.
          IF SY-SUBRC &amp;lt;&amp;gt; 0.
            EXIT.
          ENDIF.
    ENDDO.
    DO.
          REPLACE '&amp;amp;3' WITH P_PAR_3 INTO P_MESSAGE.
          IF SY-SUBRC &amp;lt;&amp;gt; 0.
            EXIT.
          ENDIF.
    ENDDO.
    DO.
          REPLACE '&amp;amp;4' WITH P_PAR_4 INTO P_MESSAGE.
          IF SY-SUBRC &amp;lt;&amp;gt; 0.
            EXIT.
          ENDIF.
    ENDDO.
* falls keine numerierten Parameter vorh., ersetzen wie gehabt
*----------------------------------------------------------------------*
          REPLACE '&amp;amp;' WITH P_PAR_1 INTO P_MESSAGE.
          CONDENSE P_MESSAGE.

          IF SY-SUBRC EQ 0.

            REPLACE '&amp;amp;' WITH P_PAR_2 INTO P_MESSAGE.
            CONDENSE P_MESSAGE.

                IF SY-SUBRC EQ 0.

                    REPLACE '&amp;amp;' WITH P_PAR_3 INTO P_MESSAGE.
                    CONDENSE P_MESSAGE.

                    IF SY-SUBRC EQ 0.
                      REPLACE '&amp;amp;' 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 &amp;lt;&amp;gt; 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 &amp;lt;&amp;gt; 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 &amp;lt;&amp;gt; 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.


*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  display_message
*&amp;amp;---------------------------------------------------------------------*
FORM display_message .
    if it_error[] is initial.
       message i019(zmsg).   "Success
    else.
       message e020(zmsg).   "Failed
    endif.
ENDFORM.                    " display_message

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  get_filename
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  --&amp;gt;  p1        text
*  &amp;lt;--  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

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  make_file_name
*&amp;amp;---------------------------------------------------------------------*
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

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Sriram Ponna.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 Feb 2008 07:46:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/update-upload-the-database-table/m-p/3442489#M826742</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-09T07:46:49Z</dc:date>
    </item>
    <item>
      <title>Re: Update &amp; upload the database table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/update-upload-the-database-table/m-p/3442490#M826743</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I dont want any BDC to upload just a simple report which fetches the data based on primary key so plz give me any simple coding &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Nanda&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 Feb 2008 07:49:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/update-upload-the-database-table/m-p/3442490#M826743</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-09T07:49:29Z</dc:date>
    </item>
    <item>
      <title>Re: Update &amp; upload the database table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/update-upload-the-database-table/m-p/3442491#M826744</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;any reply plz&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 Feb 2008 09:42:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/update-upload-the-database-table/m-p/3442491#M826744</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-09T09:42:27Z</dc:date>
    </item>
    <item>
      <title>Re: Update &amp; upload the database table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/update-upload-the-database-table/m-p/3442492#M826745</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do one thing. First upload the data into your internal table and from there update it to your ztable after updating u can use &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;delete adjacent duplicates comparing ..... &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Pavan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 Feb 2008 10:33:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/update-upload-the-database-table/m-p/3442492#M826745</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-09T10:33:06Z</dc:date>
    </item>
    <item>
      <title>Re: Update &amp; upload the database table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/update-upload-the-database-table/m-p/3442493#M826746</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In ur text file u want to upload put all the data like below...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;1	2	3	4	hi
1	2	3	5	hello
2	3	4	5	welcome&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;1) one record per line&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;2) columns are seperated by tabs....&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;data : begin of itab occurs 0,
       field1 type p,
       field2 type p,
       field3 type P,
       field4 type p,
       desc   type char10,
       end   of itab.

CALL FUNCTION 'GUI_UPLOAD'
  EXPORTING
    filename                      = 'C:\a.txt' "path and file name important
    FILETYPE                      = 'ASC'
    HAS_FIELD_SEPARATOR           = 'X'
  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 &amp;lt;&amp;gt; 0.
 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

loop at itab.
write : / itab-field1,itab-field2,itab-field3,itab-field4,itab-desc.
endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;jose.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 Feb 2008 10:35:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/update-upload-the-database-table/m-p/3442493#M826746</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-09T10:35:33Z</dc:date>
    </item>
    <item>
      <title>Re: Update &amp; upload the database table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/update-upload-the-database-table/m-p/3442494#M826747</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jose&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Plz clear some of my doubts. I have to specify the path through my selection screen. So how to declare that selection screen??&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;By using this GUI_UPLOAD can i get the data into my Ztable??&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Nanda&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 Feb 2008 10:40:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/update-upload-the-database-table/m-p/3442494#M826747</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-09T10:40:02Z</dc:date>
    </item>
    <item>
      <title>Re: Update &amp; upload the database table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/update-upload-the-database-table/m-p/3442495#M826748</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;change the above code like dis.........&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;data : begin of itab occurs 0,
       field1 type p,
       field2 type p,
       field3 type P,
       field4 type p,
       desc   type char10,
       end   of itab.

data: filepath_g(100),
      filepath        type string.

CALL FUNCTION 'AL_POPUP_FOR_LOCAL_PATH'
  EXPORTING
    DOC_TYPE         = 'txt'
  IMPORTING
    FILERETURN       = filepath_g
          .

filepath = filepath_g.

CALL FUNCTION 'GUI_UPLOAD'
  EXPORTING
    filename                      = filepath
    FILETYPE                      = 'ASC'
    HAS_FIELD_SEPARATOR           = 'X'
  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 &amp;lt;&amp;gt; 0.
 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

loop at itab.
write : / itab-field1,itab-field2,itab-field3,itab-field4,itab-desc.
endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;now u hav all the data in itab.........use modify syntax to update ur ztable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;jose&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 Feb 2008 10:49:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/update-upload-the-database-table/m-p/3442495#M826748</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-09T10:49:21Z</dc:date>
    </item>
    <item>
      <title>Re: Update &amp; upload the database table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/update-upload-the-database-table/m-p/3442496#M826749</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jose&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for ur reply. I think by using this pop up FM i'll get a pop up to specify a path right?????????&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After using the Modify statement the database will be automatically get updated with my new values right????&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So now at the same time i dont want any duplicate entries also. That is if it is having already an entry then it should not enter that value to the ztable??? how to perform this???&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 Feb 2008 10:53:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/update-upload-the-database-table/m-p/3442496#M826749</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-09T10:53:49Z</dc:date>
    </item>
    <item>
      <title>Re: Update &amp; upload the database table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/update-upload-the-database-table/m-p/3442497#M826750</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;ya..........&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For updating ur database table u can use one of the foll 3 commands&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) &lt;STRONG&gt;insert&lt;/STRONG&gt; to create a new entry in DBtable&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2) &lt;STRONG&gt;update&lt;/STRONG&gt; to edit existing entries (if there is no entry with the specified key it ll do nothing)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3) &lt;STRONG&gt;modify&lt;/STRONG&gt; to edit existing entries (if there is no entry with the specified key it ll create a new record)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Seems that first option (insert) ll be aplicable for u....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;note : if ur using insert and if a record already exists with the same key....it dumps............&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA itab1 LIKE itab OCCURS 0.  " deleting the duplicate records

SELECT  *
  FROM  ztable
  INTO  itab1
  FOR   ALL ENTRIES IN itab
  WHERE field1 = itab-field1
  AND   field2 = itab-field2
  AND   field3 = itab-field3
  AND   field4 = itab-field4.

  LOOP AT itab.
    READ TABLE itab1 WITH KEY field1 = itab-field1
                              field2 = itab-field2
                              field3 = itab-field3
                              field4 = itab-field4.
    IF sy-subrc IS INITIAL.
      DELETE itab.
    ENDIF.
  ENDLOOP.

  INSERT ztable FROM TABLE itab. "updating&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;jose.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 Feb 2008 11:23:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/update-upload-the-database-table/m-p/3442497#M826750</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-09T11:23:27Z</dc:date>
    </item>
  </channel>
</rss>

