<?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: Data integrity in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/data-integrity/m-p/783414#M39426</link>
    <description>&lt;P&gt;"Is there something similar in ABAP?"&lt;/P&gt;&lt;P&gt;No. As I said in my very first response "You have to program the constraints yourself".&lt;/P&gt;</description>
    <pubDate>Mon, 04 Feb 2019 15:08:05 GMT</pubDate>
    <dc:creator>matt</dc:creator>
    <dc:date>2019-02-04T15:08:05Z</dc:date>
    <item>
      <title>Data integrity</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/data-integrity/m-p/783402#M39414</link>
      <description>&lt;P&gt;&lt;/P&gt;
  &lt;P&gt;When defining a constraint in a database it affects all the options to enter/modify data. For example if I define a database foreign key, no matter how I try to insert/modify the data the foreign key will be checked. In opposite to it- When I define a foreign key in the application server (SE11) it is possible to enter data that conflicts the foreign key. For example if I update the data via the update clause in ABAP , the foreign key is not checked. The question is how the database constrains can be checked in ABAP (and how can I define it via SAP tools) or Is there another way to define constrains which will affect in all options&lt;/P&gt;
  &lt;P&gt;Thanks&lt;/P&gt;
  &lt;P&gt;Hagit&lt;/P&gt;</description>
      <pubDate>Tue, 29 Jan 2019 11:00:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/data-integrity/m-p/783402#M39414</guid>
      <dc:creator>hagit</dc:creator>
      <dc:date>2019-01-29T11:00:06Z</dc:date>
    </item>
    <item>
      <title>Re: Data integrity</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/data-integrity/m-p/783403#M39415</link>
      <description>&lt;P&gt;You have to program the constraints yourself. The foreign keys in SE11 applies to screen fields - not database operations as such. Referential integrity is the programmer's responsibility.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Jan 2019 15:21:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/data-integrity/m-p/783403#M39415</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2019-01-29T15:21:01Z</dc:date>
    </item>
    <item>
      <title>Re: Data integrity</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/data-integrity/m-p/783404#M39416</link>
      <description>&lt;P&gt;&lt;/P&gt;&lt;P&gt;Matthew Billingham,&lt;/P&gt;&lt;P&gt;Thanks for your answer.&lt;/P&gt;&lt;P&gt;So what you are saying is that – In SAP there isn’t any way to
define a constraint in one place, which will affect everywhere. When there is
more than one program, which input data to the same table, the programmer has
to rethink about the constraints&lt;/P&gt;&lt;P&gt;Is it like that?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Hagit&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jan 2019 06:57:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/data-integrity/m-p/783404#M39416</guid>
      <dc:creator>hagit</dc:creator>
      <dc:date>2019-01-30T06:57:46Z</dc:date>
    </item>
    <item>
      <title>Re: Data integrity</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/data-integrity/m-p/783405#M39417</link>
      <description>&lt;P&gt;Yes. But with good application design, you shouldn't have multiple places of update. For example, have a single class updating the database tables, and handling referential integrity. Multiple programs can call the class without there being any fear of ruining your db integrity. &lt;/P&gt;</description>
      <pubDate>Wed, 30 Jan 2019 11:04:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/data-integrity/m-p/783405#M39417</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2019-01-30T11:04:00Z</dc:date>
    </item>
    <item>
      <title>Re: Data integrity</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/data-integrity/m-p/783406#M39418</link>
      <description>&lt;P&gt;Please use the comment button, don't post text using "answer" which is reserved to solutions&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jan 2019 12:43:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/data-integrity/m-p/783406#M39418</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2019-01-30T12:43:48Z</dc:date>
    </item>
    <item>
      <title>Re: Data integrity</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/data-integrity/m-p/783407#M39419</link>
      <description>&lt;P&gt;Matthew
Billingham,&lt;/P&gt;&lt;P&gt;Thanks
for your answer.&lt;/P&gt;&lt;P&gt;What
do you mean “have a single class”? Is it different from a single function
module?&lt;/P&gt;&lt;P&gt;Could
you please give an example for writing the class and implementing it?&lt;/P&gt;&lt;P&gt;According to
your suggestion the programmer does not have to rethink about the constraints
but has to remember to use the class. (Or if it is another programmer he has to
find the class and use it). &lt;/P&gt;&lt;P&gt;Another
problem is that I cannot define a check constraint in the application server,
as I can in db (for ex. the value must be
grater then 5). Therefor the check must be in the program/class level. It will
not be checked if someone uses SM30 to update a table.&lt;/P&gt;&lt;P&gt;Thanks
in advance&lt;/P&gt;&lt;P&gt;Hagit&lt;/P&gt;</description>
      <pubDate>Sun, 03 Feb 2019 08:07:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/data-integrity/m-p/783407#M39419</guid>
      <dc:creator>hagit</dc:creator>
      <dc:date>2019-02-03T08:07:18Z</dc:date>
    </item>
    <item>
      <title>Re: Data integrity</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/data-integrity/m-p/783408#M39420</link>
      <description>&lt;P&gt;It's called "ABAP Objects". Object oriented programming for ABAP. It's been around since before 2000. Probably worth learning. Maybe you should buy a book. There's plenty.&lt;/P&gt;&lt;P&gt;The point is that you have one place, callable from any number of programs, that do your db update. &lt;/P&gt;&lt;P&gt;You might also like to examine the programming concepts of separation of concerns and layering. The book "The Pragmatic Programmer" is good in this respect.&lt;/P&gt;</description>
      <pubDate>Sun, 03 Feb 2019 08:37:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/data-integrity/m-p/783408#M39420</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2019-02-03T08:37:02Z</dc:date>
    </item>
    <item>
      <title>Re: Data integrity</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/data-integrity/m-p/783409#M39421</link>
      <description>&lt;P&gt;&lt;/P&gt;&lt;P&gt;According to
your suggestion the programmer does not have to rethink about the constraints
but has to remember to use the class. (Or if it is another programmer he has to
find the class and use it). &lt;/P&gt;&lt;P&gt;Another
problem is that I cannot define a check constraint in the application server,
as I can in db (for ex. the value must be
grater the 5). Therefor the check must be in the program/class level. It will
not be checked if someone uses SM30 to update a table.&lt;/P&gt;</description>
      <pubDate>Sun, 03 Feb 2019 09:18:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/data-integrity/m-p/783409#M39421</guid>
      <dc:creator>hagit</dc:creator>
      <dc:date>2019-02-03T09:18:22Z</dc:date>
    </item>
    <item>
      <title>Re: Data integrity</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/data-integrity/m-p/783410#M39422</link>
      <description>&lt;P&gt;SM30 handles constraints set by foreign keys automatically. Any other constraints you'll have to program using table events. These are very well documented, and there are blogs etc.&lt;/P&gt;</description>
      <pubDate>Sun, 03 Feb 2019 10:55:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/data-integrity/m-p/783410#M39422</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2019-02-03T10:55:48Z</dc:date>
    </item>
    <item>
      <title>Re: Data integrity</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/data-integrity/m-p/783411#M39423</link>
      <description>&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I understand
correctly then table events affect only sm30. If it is true then a programmer
has to deal with the constraints twice. Once when creating SM30. Second when
update the table via a program&lt;/P&gt;</description>
      <pubDate>Sun, 03 Feb 2019 15:53:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/data-integrity/m-p/783411#M39423</guid>
      <dc:creator>hagit</dc:creator>
      <dc:date>2019-02-03T15:53:38Z</dc:date>
    </item>
    <item>
      <title>Re: Data integrity</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/data-integrity/m-p/783412#M39424</link>
      <description>&lt;P&gt;In your program that does some kind of programmatic update of the table you do something like&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Call thing that checks constraints&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;In the event of SM30 you also have something like&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Call thing that checks&lt;/EM&gt;&lt;EM&gt; constraints&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;The &lt;EM&gt;thing&lt;/EM&gt; is where you check the constraints. So, yes, you call it twice, but you only write the constraint checker once. This is basic programming... never write code twice.&lt;/P&gt;</description>
      <pubDate>Sun, 03 Feb 2019 17:25:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/data-integrity/m-p/783412#M39424</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2019-02-03T17:25:43Z</dc:date>
    </item>
    <item>
      <title>Re: Data integrity</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/data-integrity/m-p/783413#M39425</link>
      <description>&lt;P&gt;&lt;/P&gt;&lt;P&gt;I agree with you “This is basic programming... never write
code twice.”&lt;/P&gt;&lt;P&gt;My aim is not just writing the checker code once, but also
to call the checker once. I am new is ABAP and SAP. I used to program in
ORACLE. There it is possible to define the check as a constraint in the db . This
way you write the checker code once and do not have to call the checker at all.
No matter how data is inserted/modified, the data will be checked by the
constraint. Is there something similar in ABAP?&lt;/P&gt;</description>
      <pubDate>Mon, 04 Feb 2019 15:05:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/data-integrity/m-p/783413#M39425</guid>
      <dc:creator>hagit</dc:creator>
      <dc:date>2019-02-04T15:05:32Z</dc:date>
    </item>
    <item>
      <title>Re: Data integrity</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/data-integrity/m-p/783414#M39426</link>
      <description>&lt;P&gt;"Is there something similar in ABAP?"&lt;/P&gt;&lt;P&gt;No. As I said in my very first response "You have to program the constraints yourself".&lt;/P&gt;</description>
      <pubDate>Mon, 04 Feb 2019 15:08:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/data-integrity/m-p/783414#M39426</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2019-02-04T15:08:05Z</dc:date>
    </item>
    <item>
      <title>Re: Data integrity</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/data-integrity/m-p/783415#M39427</link>
      <description>&lt;P&gt;So I just want to add some information if you going to program path:&lt;/P&gt;&lt;P&gt;1. in selection screen, you could add VALUE CHECK statement to parameter and it will be checked against foreign key.&lt;/P&gt;&lt;P&gt;2. in dynpro there is a checkbox to do the same..&lt;/P&gt;&lt;P&gt;3. in coding you may try class CL_HRBAS_FOREIGN_KEY_CHECK, or fm: DDUT_INPUT_CHECK.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;U&gt;&lt;/U&gt;&lt;SUB&gt;&lt;/SUB&gt;&lt;SUP&gt;&lt;/SUP&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;U&gt;&lt;/U&gt;&lt;SUB&gt;&lt;/SUB&gt;&lt;SUP&gt;&lt;/SUP&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Feb 2019 02:30:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/data-integrity/m-p/783415#M39427</guid>
      <dc:creator>DoanManhQuynh</dc:creator>
      <dc:date>2019-02-05T02:30:23Z</dc:date>
    </item>
    <item>
      <title>Re: Data integrity</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/data-integrity/m-p/783416#M39428</link>
      <description>&lt;P&gt;I used CL_HRBAS_FOREIGN_KEY_CHECK.
But it does not catch the case when foreign key rule is not fulfilled.&lt;/P&gt;&lt;P&gt;Maybe some of the
parameters are not sent properly ?&lt;/P&gt;&lt;P&gt;Could you help ?&lt;/P&gt;&lt;P&gt;SPAN {
font-family: "Courier New";
font-size: 10pt;
color: #000000;
background: #FFFFFF;
}
.L0S31 {
font-style: italic;
color: #808080;
}
.L0S32 {
color: #3399FF;
}
.L0S33 {
color: #4DA619;
}
.L0S52 {
color: #0000FF;
}
.L0S55 {
color: #800080;
}
.L0S70 {
color: #808080;
}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;REPORT ZTRY_CHK_FK.&lt;BR /&gt;
&lt;BR /&gt;
data: lt_ztry_detailed TYPE TABLE OF ztry_detailed&lt;BR /&gt;
 ,ls_detailed like line of lt_ztry_detailed&lt;BR /&gt;
 ,lr_fk_chk TYPE REF TO CL_HRBAS_FOREIGN_KEY_CHECK&lt;BR /&gt;
 ,l_excluded_fields TYPE hrbas_fieldlist_tab&lt;BR /&gt;
 ,lv_ignore_initial_fields TYPE boole_d&lt;BR /&gt;
 ,l_message_handler TYPE HRBAS_MSG_HANDLER_IF_REF&lt;BR /&gt;
 , l_message_handler_cls TYPE REF TO cl_hrbas_message_list&lt;BR /&gt;
 , lv_ok TYPE boole_d&lt;BR /&gt;
 .&lt;BR /&gt;
ls_detailed-bnk1 = 1 .&lt;BR /&gt;
ls_detailed-bnk2 = 2 .&lt;BR /&gt;
ls_detailed-bnk3 = 3 .&lt;BR /&gt;
ls_detailed-key1 = 55 .&lt;BR /&gt;
&lt;BR /&gt;
refresh l_excluded_fields.&lt;BR /&gt;
lv_ignore_initial_fields = abap_true. "abap_false. "@@????&lt;BR /&gt;
&lt;BR /&gt;
CREATE OBJECT lr_fk_chk.&lt;BR /&gt;
create OBJECT l_message_handler_cls.&lt;BR /&gt;
l_message_handler ?= l_message_handler_cls.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
TRY.&lt;BR /&gt;
CALL METHOD lr_fk_chk-&amp;gt;check_structure&lt;BR /&gt;
 EXPORTING&lt;BR /&gt;
 structure = ls_detailed&lt;BR /&gt;
 excluded_fields = l_excluded_fields&lt;BR /&gt;
 ignore_initial_fields = lv_ignore_initial_fields&lt;BR /&gt;
 message_handler = l_message_handler&lt;BR /&gt;
 IMPORTING&lt;BR /&gt;
 is_ok = lv_ok&lt;BR /&gt;
 .&lt;BR /&gt;
 CATCH cx_hrbas_violated_assertion .&lt;BR /&gt;
 message 'err' TYPE 'i'.&lt;BR /&gt;
ENDTRY.&lt;BR /&gt;
&lt;BR /&gt;
*MODIFY ztry_detailed from ls_detailed.&lt;BR /&gt;
*insert into table ztry_detailed @@@@@@@@@@@@&lt;BR /&gt;
&lt;BR /&gt;
ls_detailed-key1 = 2 .&lt;BR /&gt;
try.&lt;BR /&gt;
CALL METHOD lr_fk_chk-&amp;gt;check_structure&lt;BR /&gt;
 EXPORTING&lt;BR /&gt;
 structure = ls_detailed&lt;BR /&gt;
 excluded_fields = l_excluded_fields&lt;BR /&gt;
 ignore_initial_fields = lv_ignore_initial_fields&lt;BR /&gt;
 message_handler = l_message_handler&lt;BR /&gt;
 IMPORTING&lt;BR /&gt;
 is_ok = lv_ok&lt;BR /&gt;
.&lt;BR /&gt;
 CATCH cx_hrbas_violated_assertion .&lt;BR /&gt;
 message 'err' TYPE 'i'.&lt;BR /&gt;
ENDTRY.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 11 Feb 2019 12:59:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/data-integrity/m-p/783416#M39428</guid>
      <dc:creator>hagit</dc:creator>
      <dc:date>2019-02-11T12:59:32Z</dc:date>
    </item>
    <item>
      <title>Re: Data integrity</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/data-integrity/m-p/783417#M39429</link>
      <description>&lt;P&gt;your code is working fine but you have to check the return of lv_ok instead of exception. that class is designed for HR so exception also for HR, you cant get violation there.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;U&gt;&lt;/U&gt;&lt;SUB&gt;&lt;/SUB&gt;&lt;SUP&gt;&lt;/SUP&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2019 03:03:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/data-integrity/m-p/783417#M39429</guid>
      <dc:creator>DoanManhQuynh</dc:creator>
      <dc:date>2019-02-12T03:03:04Z</dc:date>
    </item>
    <item>
      <title>Re: Data integrity</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/data-integrity/m-p/783418#M39430</link>
      <description>&lt;P&gt;lv_ok is empty in both cases. It is empty when the foreign key rule is ok
and also when it is not&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2019 12:25:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/data-integrity/m-p/783418#M39430</guid>
      <dc:creator>hagit</dc:creator>
      <dc:date>2019-02-12T12:25:20Z</dc:date>
    </item>
    <item>
      <title>Re: Data integrity</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/data-integrity/m-p/783419#M39431</link>
      <description>&lt;P&gt;it shouldnt be, I checked with sflight table and it work fine, X if correct and space if incorrect...what about function module i gave you.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Feb 2019 04:31:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/data-integrity/m-p/783419#M39431</guid>
      <dc:creator>DoanManhQuynh</dc:creator>
      <dc:date>2019-02-13T04:31:36Z</dc:date>
    </item>
    <item>
      <title>Re: Data integrity</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/data-integrity/m-p/783420#M39432</link>
      <description>&lt;P&gt;I think that it's not recommended to do a generic check because of the performance. Moreover this class is not released by SAP, so it could be changed or even retired, it may have undesired effects, etc.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Feb 2019 06:25:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/data-integrity/m-p/783420#M39432</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2019-02-13T06:25:04Z</dc:date>
    </item>
    <item>
      <title>Re: Data integrity</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/data-integrity/m-p/783421#M39433</link>
      <description>&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you so much for your help.&lt;/P&gt;&lt;P&gt;You are right. This code works. (My mistake was in the data- I thought that a key existed in the master table but it did not).&lt;/P&gt;&lt;P&gt;The issue is not just checking the FK but also other constrains.&lt;BR /&gt;According to my test it seems that  check_structure method(in class CL_HRBAS_FOREIGN_KEY_CHECK) does not check if a value is in the range , which is defined in ‘value range’ of the domain. Is it so or something is wrong with my code? For example : &lt;BR /&gt;  In a domain I declare value range of 1 , 11 .&lt;BR /&gt;  I use this domain for a table’s field&lt;BR /&gt;  When checking the value 8 for this field via check_structure, lv_ok is X, even though  8 is not included in the above range&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/274748-nkpof.png" /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Feb 2019 09:09:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/data-integrity/m-p/783421#M39433</guid>
      <dc:creator>hagit</dc:creator>
      <dc:date>2019-02-13T09:09:47Z</dc:date>
    </item>
  </channel>
</rss>

