<?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: table logic in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/table-logic/m-p/6655968#M1445590</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI Karan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;In PAI,

loop at itab.
chain.
field : itab-col1, itab-col2.
module validate on request.
module validate.
endchain.
module update_tc.
endloop.

in Program

module validate.
read table itab with key col1 = itab-col1  " This is newly entered Value in Table Control
              col2 = itab-col2. " This is newly entered Value in Table Control
if sy-subrc = 0.
message 'These values are already Entered' Type 'E'.
endif.
endmodule.
module update_tc.
describe table itab lines tc-lines.
if tc-current_line &amp;gt; tc-lines.
append itab. " You pass newly enterd Row into Internal table in the Program
else.
modify itab index tc-current_line. " Or Modify the Existing row in the Program Itab
endif.
"Here  you update the Values back to Program Internal Table
endmodule&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Cheerz&lt;/P&gt;&lt;P&gt;Ram&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 19 Mar 2010 12:51:27 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2010-03-19T12:51:27Z</dc:date>
    <item>
      <title>table logic</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/table-logic/m-p/6655962#M1445584</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have 2 columns for table controls &amp;lt;col1&amp;gt; &amp;lt;col2&amp;gt; for which i need to input values &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can have multiple same values for col1 and cols 2 seperately but not together , means both in combination shud form a unique key if not then need to display messgae&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;col1  col2&lt;/P&gt;&lt;P&gt;a       b&lt;/P&gt;&lt;P&gt;a       c&lt;/P&gt;&lt;P&gt;d       b&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;a      c&lt;/STRONG&gt;  -&lt;/P&gt;&lt;HR originaltext="---" /&gt;&lt;P&gt;&amp;gt; Not allowed (display msg when save is pressed in table control)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How to do it???&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Mar 2010 12:24:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/table-logic/m-p/6655962#M1445584</guid>
      <dc:creator>Karan_Chopra_</dc:creator>
      <dc:date>2010-03-19T12:24:23Z</dc:date>
    </item>
    <item>
      <title>Re: table logic</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/table-logic/m-p/6655963#M1445585</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try declaring your internal table with UNIQUE KEY.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Kiran&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Mar 2010 12:34:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/table-logic/m-p/6655963#M1445585</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-03-19T12:34:44Z</dc:date>
    </item>
    <item>
      <title>Re: table logic</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/table-logic/m-p/6655964#M1445586</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;but how does this help &lt;/P&gt;&lt;P&gt;is thr some logic for that&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Mar 2010 12:40:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/table-logic/m-p/6655964#M1445586</guid>
      <dc:creator>Karan_Chopra_</dc:creator>
      <dc:date>2010-03-19T12:40:40Z</dc:date>
    </item>
    <item>
      <title>Re: table logic</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/table-logic/m-p/6655965#M1445587</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;if you are validating it in a chain statement, then read the same internal table with the values 'a' and 'c'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;read itab with key f1 = 'a' f2 = 'b' transporting no fields.&lt;/P&gt;&lt;P&gt;if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;Then the value exists.&lt;/P&gt;&lt;P&gt;else.&lt;/P&gt;&lt;P&gt;valid.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Mar 2010 12:42:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/table-logic/m-p/6655965#M1445587</guid>
      <dc:creator>kesavadas_thekkillath</dc:creator>
      <dc:date>2010-03-19T12:42:01Z</dc:date>
    </item>
    <item>
      <title>Re: table logic</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/table-logic/m-p/6655966#M1445588</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;what kiran meant was to declare the internal table as sorted type with unique key ( your two fields).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Mar 2010 12:45:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/table-logic/m-p/6655966#M1445588</guid>
      <dc:creator>kesavadas_thekkillath</dc:creator>
      <dc:date>2010-03-19T12:45:00Z</dc:date>
    </item>
    <item>
      <title>Re: table logic</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/table-logic/m-p/6655967#M1445589</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I cannot expicilt provide values as it can be for many combination or i dont know before hand which values are repeated&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Mar 2010 12:46:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/table-logic/m-p/6655967#M1445589</guid>
      <dc:creator>Karan_Chopra_</dc:creator>
      <dc:date>2010-03-19T12:46:35Z</dc:date>
    </item>
    <item>
      <title>Re: table logic</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/table-logic/m-p/6655968#M1445590</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI Karan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;In PAI,

loop at itab.
chain.
field : itab-col1, itab-col2.
module validate on request.
module validate.
endchain.
module update_tc.
endloop.

in Program

module validate.
read table itab with key col1 = itab-col1  " This is newly entered Value in Table Control
              col2 = itab-col2. " This is newly entered Value in Table Control
if sy-subrc = 0.
message 'These values are already Entered' Type 'E'.
endif.
endmodule.
module update_tc.
describe table itab lines tc-lines.
if tc-current_line &amp;gt; tc-lines.
append itab. " You pass newly enterd Row into Internal table in the Program
else.
modify itab index tc-current_line. " Or Modify the Existing row in the Program Itab
endif.
"Here  you update the Values back to Program Internal Table
endmodule&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Cheerz&lt;/P&gt;&lt;P&gt;Ram&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Mar 2010 12:51:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/table-logic/m-p/6655968#M1445590</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-03-19T12:51:27Z</dc:date>
    </item>
    <item>
      <title>Re: table logic</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/table-logic/m-p/6655969#M1445591</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You no need to provide the values explicitly, that was just a logic.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Mar 2010 12:54:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/table-logic/m-p/6655969#M1445591</guid>
      <dc:creator>kesavadas_thekkillath</dc:creator>
      <dc:date>2010-03-19T12:54:25Z</dc:date>
    </item>
    <item>
      <title>Re: table logic</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/table-logic/m-p/6655970#M1445592</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;requirement is pretty tricky .. &lt;/P&gt;&lt;P&gt;Im substituting ur column to field f1 and f2. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
report zvij57.
data: begin of itab occurs 0,
         f1(10) type c,
         f2(10) type c,
         end of itab.

*populate itab for say db
itab-f1 = 'a'. itab-f2 = 'b'. append itab.
itab-f1 = 'a'. itab-f2 = 'c'. append itab.
itab-f1 = 'd'. itab-f2 = 'c'. append itab.
itab-f1 = 'a'. itab-f2 = 'c'. append itab.
itab-f1 = 'd'. itab-f2 = 'c'. append itab.


sort itab by f1 f2.


data : lv_flag type c,
lv_cnt type i,
lv_val(10) type c.

loop at itab  .
  at new f1.
    lv_flag = 'X'.
  ENDAT.
  if lv_flag eq 'X'.
    lv_val = itab-f2.
    lv_flag = ''.
  endif.

  if lv_val = itab-f2.
    add 1 to lv_cnt .
  else.
    lv_val = itab-f2.
  endif.

  if lv_cnt ge 2.
    write :/ 'duplicate entry for', itab-f1 ,itab-f2.
  endif.
  at end of f1.
    clear : lv_flag, lv_val, lv_cnt.
  endat.

endloop.


&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Execute this and check if this meets your requirement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Br, &lt;/P&gt;&lt;P&gt;Vijay.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Mar 2010 12:59:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/table-logic/m-p/6655970#M1445592</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-03-19T12:59:45Z</dc:date>
    </item>
    <item>
      <title>Re: table logic</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/table-logic/m-p/6655971#M1445593</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i have to refine further this logic and now it looks fine to me . &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
REPORT  Zvij57.

data: begin of itab occurs 0,
         f1(10) type c,
         f2(10) type c,
         f3 type i,
         end of itab.

*populate itab for say db

itab-f1 = 'a'.  itab-f2 = 'e'. append itab.
itab-f1 = 'a'. itab-f2 = 'b'. append itab.
itab-f1 = 'a'. itab-f2 = 'c'. append itab.
itab-f1 = 'd'. itab-f2 = 'c'. append itab.
itab-f1 = 'a'. itab-f2 = 'c'. append itab.
itab-f1 = 'd'. itab-f2 = 'c'. append itab.
itab-f1 = 'a'. itab-f2 = 'd'. append itab.
itab-f1 = 'b'. itab-f2 = 'c'. append itab.
itab-f1 = 'a'. itab-f2 = 'g'. append itab.



sort itab by f1 f2.


data : lv_flag type c,
lv_cnt type i,
lv_val(10) type c.

loop at itab.
write :/ itab-f1 , 15 itab-f2.
endloop.

skip 10 .
write :/ sy-uline(30).

loop at itab  .
  at new f2.
    lv_flag = 'X'.
  ENDAT.
  if lv_flag eq 'X'.

    lv_val = itab-f2.
    lv_flag = ''.
  endif.
  if lv_val = itab-f2.
    add 1 to lv_cnt .
  endif.
  itab-f3 = lv_cnt.
  modify itab index sy-tabix.
  if lv_cnt eq 2.
    write :/ 'duplicate entry for', itab-f1 ,itab-f2, itab-f3.
  endif.
  at end of f2.
    clear : lv_cnt.
  endat.
endloop.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;occurance 2 should throw an error message before the save in the PAI . any occurance of 2 will stop the entry into DB .. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Br, &lt;/P&gt;&lt;P&gt;Vijay.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Mar 2010 13:31:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/table-logic/m-p/6655971#M1445593</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-03-19T13:31:50Z</dc:date>
    </item>
  </channel>
</rss>

