<?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: Open sql insert not working in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/open-sql-insert-not-working/m-p/5034548#M1170948</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;U can create a BDC program for trx KA01 or try to use the BAPI BAPI_COSTELEM_CREATEMULTIPLE&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Max&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 12 Jan 2009 11:57:00 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-01-12T11:57:00Z</dc:date>
    <item>
      <title>Open sql insert not working</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/open-sql-insert-not-working/m-p/5034542#M1170942</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello SdNers,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was trying to insert records into table CSKA Cost Elements (Data Dependent on Chart of Accounts).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have an excel file with 45 records.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am able to upload to records from the file and display it on the list processing screens.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is not getting inserted to DB table...CSKA.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

data : begin of t_ks06 occurs 0,
       KOKRS type KOKRS,      " Controlling area
       KSTAR type KSTAR,      " Cost element
       DATAB type DATAB,      " Valid from date
       DATBI type DATBI,      " Valid to  date
       KTEXT type KTEXT,      " Name
       LTEXT type LTEXT,      " Description
       KATYP type KATYP,      " Cost element cat
       KOSTL type KOSTL,      " Cost center
       end of t_ks06.

data : wa like line of t_ks06.

data : it_excel type alsmex_tabline occurs 0 with header line.

selection-screen begin of block b1 with frame title text-001.
parameter: f_name type rlgrap-filename default 'C:\Documents and Settings\Administrator\Desktop\Project_data\Cost_element_KS06.xls'.
parameter : p_begcol type i default 1 no-display,
            p_begrow type i default 2 no-display,
            p_endcol type i default 8 no-display,
            p_endrow type i default 46 no-display.

selection-screen end of block b1.

at selection-screen on value-request for f_name.
perform f_get_file using f_name.

start-of-selection.
perform f_xls_itab using f_name changing it_excel.
perform f_move_data.
perform f_insert_db.
perform f_display_data.

form f_get_file  using    p_file_nam.

call function 'KD_GET_FILENAME_ON_F4'
 exporting
   program_name        = syst-repid
   dynpro_number       = syst-dynnr
*   FIELD_NAME          = ' '
*   STATIC              = ' '
*   MASK                = ' '
  changing
    file_name           = f_name
 exceptions
   mask_too_long       = 1
   others              = 2.
endform.                    " f_get_file

form f_xls_itab  using    p_file_nam changing p_it_excel.

call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
  exporting
    filename                      = f_name
    i_begin_col                   = p_begcol
    i_begin_row                   = p_begrow
    i_end_col                     = p_endcol
    i_end_row                     = p_endrow
  tables
    intern                        = it_excel
 exceptions
   inconsistent_parameters       = 1
   upload_ole                    = 2
   others                        = 3.
endform.                    " f_xls_itab

form f_move_data.

data : lv_index type i.
field-symbols &amp;lt;fs&amp;gt;.

* Sorting the internal table
sort it_excel by row col.
clear it_excel.

loop at it_excel.
  move it_excel-col to lv_index.
* Assigning each record to the internal table row.
  assign component lv_index of structure wa to &amp;lt;fs&amp;gt;.

* Assigning the field value to a field symbol
  move it_excel-value to &amp;lt;fs&amp;gt;.

  at end of row.
  append wa to t_ks06.
*   flg_mv = 1.
  clear wa.
  endat.

endloop.
endform.                    " f_move_data

form f_display_data.

  write:/1 sy-uline(140).
  write:/1 sy-vline,  'Cont area',        " Controlling area
         16 sy-vline, 'Cost ele',         " Cost element
         31 sy-vline, 'Valid from',       " Valid from  date
         46 sy-vline, 'Valid to '  ,      " Valid to date
         61 sy-vline, 'Name',             "Cost element cat
         76 sy-vline, 'Description',      " Cost center
         101 sy-vline,  'Cost ele cat',   " Cost element cat
         126 sy-vline, 'Cost center',     " Cost center
         140 sy-vline.
 write:/1 sy-uline(140).

skip 1.
clear wa.
loop at t_ks06 into wa.

  write:/2 sy-uline(139).
  write:/2  sy-vline,  wa-KOKRS,      " Controlling area
         16 sy-vline, wa-KSTAR,      " Cost element
         31 sy-vline, wa-DATAB,      " Valid from date
         46 sy-vline, wa-DATBI,      " Valid to date
         61 sy-vline, wa-KTEXT,      " Name
         76 sy-vline, wa-LTEXT,      " Description
         101 sy-vline, wa-KATYP,     " Cost element cat
         120 sy-vline, wa-KOSTL,     " Cost center
         140 sy-vline.
endloop.

endform.                    " f_display_data

form f_insert_db .

if t_ks06[] is initial.
  write:/ 'No records fetched from file' color 3.
else.
  clear wa.
  loop at t_ks06 into wa.
  insert into CSKA values wa.
  endloop.
*    if sy-dbcnt ge 1.
*    perform f_display_data.
*    endif.
endif.

endform.                    " f_insert_db
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Help highly appreciated and would be rewarded.&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;Ranjith N&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Jan 2009 11:33:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/open-sql-insert-not-working/m-p/5034542#M1170942</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-12T11:33:13Z</dc:date>
    </item>
    <item>
      <title>Re: Open sql insert not working</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/open-sql-insert-not-working/m-p/5034543#M1170943</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;The code should be:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;INSERT CSKA FROM WA.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But WA has to be defined as CSKA.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyway y should use a BDC program or use BAPI or another std fm in order to upload the CSKA&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Max&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Jan 2009 11:38:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/open-sql-insert-not-working/m-p/5034543#M1170943</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-12T11:38:55Z</dc:date>
    </item>
    <item>
      <title>Re: Open sql insert not working</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/open-sql-insert-not-working/m-p/5034544#M1170944</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;Try this way&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;insert into CSKA FROM wa.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Jan 2009 11:39:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/open-sql-insert-not-working/m-p/5034544#M1170944</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-12T11:39:31Z</dc:date>
    </item>
    <item>
      <title>Re: Open sql insert not working</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/open-sql-insert-not-working/m-p/5034545#M1170945</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Has anyone ever mentioned to you that it is usually a bad idea to do direct updates on SAP tables?  The preferred option, which I think you should consider, is to find a SAP standard method of doing this - either a BADI or in the last resort a BDC on the update transaction.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Jan 2009 11:40:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/open-sql-insert-not-working/m-p/5034545#M1170945</guid>
      <dc:creator>christine_evans</dc:creator>
      <dc:date>2009-01-12T11:40:50Z</dc:date>
    </item>
    <item>
      <title>Re: Open sql insert not working</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/open-sql-insert-not-working/m-p/5034546#M1170946</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Max,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your reply as you said can you help me or guide me with the same.&lt;/P&gt;&lt;P&gt;Eg : FM or BAPI.&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;Ranjith N&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Jan 2009 11:42:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/open-sql-insert-not-working/m-p/5034546#M1170946</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-12T11:42:06Z</dc:date>
    </item>
    <item>
      <title>Re: Open sql insert not working</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/open-sql-insert-not-working/m-p/5034547#M1170947</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;Instead of move statements, you can use insert statements.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check out this link.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_nw70/helpdata/en/fc/eb3a6d358411d1829f0000e829fbfe/frameset.htm" target="test_blank"&gt;http://help.sap.com/saphelp_nw70/helpdata/en/fc/eb3a6d358411d1829f0000e829fbfe/frameset.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Deepthi.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Jan 2009 11:44:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/open-sql-insert-not-working/m-p/5034547#M1170947</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-12T11:44:27Z</dc:date>
    </item>
    <item>
      <title>Re: Open sql insert not working</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/open-sql-insert-not-working/m-p/5034548#M1170948</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;U can create a BDC program for trx KA01 or try to use the BAPI BAPI_COSTELEM_CREATEMULTIPLE&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Max&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Jan 2009 11:57:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/open-sql-insert-not-working/m-p/5034548#M1170948</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-12T11:57:00Z</dc:date>
    </item>
    <item>
      <title>Re: Open sql insert not working</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/open-sql-insert-not-working/m-p/5034549#M1170949</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Ranjinth,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To insert the record into data base table. you need to create a work area type of data base table.&lt;/P&gt;&lt;P&gt;because for insert purpose we need the all the field in header or in work area for inserting the new record into data base table. it doesn't mean that you need to use old the field that is avaible in data base table.&lt;/P&gt;&lt;P&gt;you can use only those field that you need in your program with primary key.Because primary key is mandatory to enter for inserting new record.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you can try this..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;wa_wrk1 type CSKA.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;to insert record.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;INSERT CSKA FROM wa_work1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hope it will help you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;Arun Kayal.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Jan 2009 12:12:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/open-sql-insert-not-working/m-p/5034549#M1170949</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-12T12:12:51Z</dc:date>
    </item>
    <item>
      <title>Re: Open sql insert not working</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/open-sql-insert-not-working/m-p/5034550#M1170950</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;ANSWERED&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Jan 2009 07:35:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/open-sql-insert-not-working/m-p/5034550#M1170950</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-13T07:35:13Z</dc:date>
    </item>
  </channel>
</rss>

