<?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: Dynamic record deletion from database table in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-record-deletion-from-database-table/m-p/1607911#M272813</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey Rich...So sad to know it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you please suggest me some other alternative.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The requirement is that :&lt;/P&gt;&lt;P&gt;The main program calls a function module passing the internal table(tablename and field name)...like&lt;/P&gt;&lt;P&gt;TAB1  FIELD1&lt;/P&gt;&lt;P&gt;TAB1  FIELD2&lt;/P&gt;&lt;P&gt;TAB1  FIELD3&lt;/P&gt;&lt;P&gt;TAB2  FIELD1&lt;/P&gt;&lt;P&gt;TAB2  FIELD2&lt;/P&gt;&lt;P&gt;TAB3  FIELD1&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;along with the values in range tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The containt of internal table passed will not be the same for all the run of this program...so can not think of building static where clause.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Based on the fields passed the table records will be deleted comparing it with the values passed from the program to function module. The passed values are from selection screen, so will be different.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please give some clue...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanking you,&lt;/P&gt;&lt;P&gt;Surya&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 05 Oct 2006 19:28:01 GMT</pubDate>
    <dc:creator>surya_gupta3</dc:creator>
    <dc:date>2006-10-05T19:28:01Z</dc:date>
    <item>
      <title>Dynamic record deletion from database table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-record-deletion-from-database-table/m-p/1607908#M272810</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 need to delete selected records from database table(dynamic names). Table names are being passed from main program with some of their field names. The record to be deleted from the database table is being decided based on the fields passed for the table and their contains passed from the main program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is not possible to write dynamic where clause for DELETE statement directly.&lt;/P&gt;&lt;P&gt;So, I created a dynamic internal table and i am trying to fetch all records using SELECT statement(for which we can write dynamic where condition, something like...SELECT...WHERE (itab).  ) which need to be deleted in the iternal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Piece of code :&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="--------------" /&gt;&lt;P&gt;          CONCATENATE c_im v_tablefield1 INTO v_imprtfield1.&lt;/P&gt;&lt;P&gt;          CONCATENATE v_tablefield1 c_in v_imprtfield1&lt;/P&gt;&lt;P&gt;                   into s_condition separated by space.&lt;/P&gt;&lt;P&gt;          APPEND s_condition TO t_condition.&lt;/P&gt;&lt;P&gt;          PERFORM GET_DYNAMIC_ITAB USING s_flds_agtab-tabname&lt;/P&gt;&lt;P&gt;                                changing t_itab.&lt;/P&gt;&lt;P&gt;          ASSIGN t_itab-&amp;gt;* TO &amp;lt;itab&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Select the data (to be deleted) from the database table&lt;/P&gt;&lt;P&gt;           SELECT * FROM (s_flds_agtab-tabname) INTO TABLE &amp;lt;itab&amp;gt;&lt;/P&gt;&lt;P&gt;             WHERE (t_condition).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Delete the records from the table&lt;/P&gt;&lt;P&gt;           IF SY-SUBRC = 0.&lt;/P&gt;&lt;P&gt;             DELETE (s_flds_agtab-tabname) FROM TABLE &amp;lt;itab&amp;gt;.&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;Here t_condition is of standard table of WHERETXT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;t_condition at the run time before giving dump was:&lt;/P&gt;&lt;P&gt;SPART IN IM_SPART&lt;/P&gt;&lt;P&gt;AND KUNNR IN IM_KUNNR&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here IM_SPART is renge type of SPART and IM_KUNNR is renge of KUNNR.&lt;/P&gt;&lt;P&gt;I am getting a DUMP:&lt;/P&gt;&lt;P&gt;The WHERE condition has an unexpected format.&lt;/P&gt;&lt;P&gt;Error analysis                                                                                &lt;/P&gt;&lt;P&gt;The current ABAP/4 program attempted to execute an ABAP/4 Open SQL&lt;/P&gt;&lt;P&gt;statement containing a WHERE condition of the form WHERE (itab) or&lt;/P&gt;&lt;P&gt;WHERE ... AND (itab). The part of the WHERE condition specified at&lt;/P&gt;&lt;P&gt;runtime in the internal table itab contains the operator          &lt;/P&gt;&lt;P&gt;         IN (v1, ..., vn)                                         &lt;/P&gt;&lt;P&gt;in incomplete form.                                               &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How to correct the error&lt;/P&gt;&lt;P&gt;If the error occurred in a non-modified SAP program, you may be   &lt;/P&gt;&lt;P&gt;able to find a solution in the SAP note system.                   &lt;/P&gt;&lt;P&gt;If you have access to the note system yourself, use the following &lt;/P&gt;&lt;P&gt;search criteria:                                                  &lt;/P&gt;&lt;P&gt; "SAPSQL_IN_ILLEGAL_LIST"                                &lt;/P&gt;&lt;P&gt; "SAPLZSD_TAB_REFRESH " or "LZSD_TAB_REFRESHU01 "        &lt;/P&gt;&lt;P&gt; "Z_SD_REFRESH_AGTABLES"                                 &lt;/P&gt;&lt;P&gt;If you cannot solve the problem yourself, please send the&lt;/P&gt;&lt;P&gt;following documents to SAP:                              &lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="--------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to know whether "IN" operator is allowed in (itab) of WHERE clause. While testing I changed the "IN" to "=" specifying a suitable value there. It worked. So please let me know if i can give "IN" operator using renge table in the dynamic where clause.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanking you,&lt;/P&gt;&lt;P&gt;Surya&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Oct 2006 18:58:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-record-deletion-from-database-table/m-p/1607908#M272810</guid>
      <dc:creator>surya_gupta3</dc:creator>
      <dc:date>2006-10-05T18:58:33Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic record deletion from database table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-record-deletion-from-database-table/m-p/1607909#M272811</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Someone had this same exact problem last year or so,  If my memory serves me correctly,  we decided that you can not use the IN operator in a dynamic WHERE clause.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Oct 2006 19:03:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-record-deletion-from-database-table/m-p/1607909#M272811</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2006-10-05T19:03:58Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic record deletion from database table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-record-deletion-from-database-table/m-p/1607910#M272812</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi again,  so if you can not use the IN in a dynamic where clause you might be forced to dynamically build the entire select statement,  Here is a sample program which may give you some ideas, notice that we are writing the select statement code, putting it in another program and generating the subroutine at runtime, then call this routine.  I'm sure that this will help you see what you need to do.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

report zrich_0003 .

tables: kna1.

types: t_source(72).

data: routine(32) value 'DYNAMIC_SELECT',
             program(8),
             message(128),
             line type i.

data: isource type table of t_source,
            xsource type t_source.

ranges:
        r_kunnr for kna1-kunnr.

data: ikna1 type table of kna1.
data: xkna1 type kna1.


r_kunnr-sign = 'I'.
r_kunnr-option = 'EQ'.
r_kunnr-low    = '0001000500'.
append r_kunnr.

xsource = 'REPORT ZTEMP.'.
insert xsource  into isource index 1.
xsource = 'FORM dynamic_select'.
insert xsource  into isource index 2.
xsource = 'Tables r_kunnr ikna1.'.
append xsource to isource.
xsource = 'select * into table ikna1 from kna1'.
append xsource to isource.
xsource = 'where kunnr in r_kunnr.'.
append xsource to isource.
xsource = 'ENDFORM.'.
append xsource to isource.

generate subroutine pool isource name program
                         message message
                         line line.
if sy-subrc = 0.
  perform (routine) in program (program) tables r_kunnr
                                                ikna1.
else.
  write:/ message.
endif.

loop at ikna1 into xkna1.
  write:/ xkna1-kunnr.
endloop.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Oct 2006 19:22:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-record-deletion-from-database-table/m-p/1607910#M272812</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2006-10-05T19:22:00Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic record deletion from database table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-record-deletion-from-database-table/m-p/1607911#M272813</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey Rich...So sad to know it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you please suggest me some other alternative.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The requirement is that :&lt;/P&gt;&lt;P&gt;The main program calls a function module passing the internal table(tablename and field name)...like&lt;/P&gt;&lt;P&gt;TAB1  FIELD1&lt;/P&gt;&lt;P&gt;TAB1  FIELD2&lt;/P&gt;&lt;P&gt;TAB1  FIELD3&lt;/P&gt;&lt;P&gt;TAB2  FIELD1&lt;/P&gt;&lt;P&gt;TAB2  FIELD2&lt;/P&gt;&lt;P&gt;TAB3  FIELD1&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;along with the values in range tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The containt of internal table passed will not be the same for all the run of this program...so can not think of building static where clause.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Based on the fields passed the table records will be deleted comparing it with the values passed from the program to function module. The passed values are from selection screen, so will be different.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please give some clue...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanking you,&lt;/P&gt;&lt;P&gt;Surya&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Oct 2006 19:28:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-record-deletion-from-database-table/m-p/1607911#M272813</guid>
      <dc:creator>surya_gupta3</dc:creator>
      <dc:date>2006-10-05T19:28:01Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic record deletion from database table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-record-deletion-from-database-table/m-p/1607912#M272814</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Amazing....&lt;/P&gt;&lt;P&gt;Thanks Rich.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you please help me once more. How can i reward points in this site. I mean the steps.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Oct 2006 19:32:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-record-deletion-from-database-table/m-p/1607912#M272814</guid>
      <dc:creator>surya_gupta3</dc:creator>
      <dc:date>2006-10-05T19:32:57Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic record deletion from database table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-record-deletion-from-database-table/m-p/1607913#M272815</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You should see radiobuttons next to the answers given, here is where you will select to reward points.  If the answers are helpful, mark yellow or green, if the answer solved your problem, mark as blue star.  Marking as a blue star, says "this question has been answered and it solves my problem",  when others are searching for answers in the forums, they can clearly see where the resolutions are.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Oct 2006 19:36:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-record-deletion-from-database-table/m-p/1607913#M272815</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2006-10-05T19:36:48Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic record deletion from database table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-record-deletion-from-database-table/m-p/1607914#M272816</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Of course, now that I'm thinking about, no need to do any select, just simply build your DELETE statement in the generated FORM and call the FORM.  Right?  &lt;SPAN __jive_emoticon_name="wink"&gt;&lt;/SPAN&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;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Oct 2006 19:45:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-record-deletion-from-database-table/m-p/1607914#M272816</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2006-10-05T19:45:08Z</dc:date>
    </item>
  </channel>
</rss>

