‎2015 Feb 04 7:36 PM
Hi Experts,
I have a table A in which a field z_field is having Entry/Check on table B. So if I update table A in SM30 I can see that it is checking table B for field Z_field so if I enter anything that is not available in B it would throw error.
How can we achieve the same when we are uploading data through a program using modify statement.
thanks
Rahul.
‎2015 Feb 04 7:50 PM
Select by fkey in B table and if not exist, adapt your code.
Hope it helps.
‎2015 Feb 04 8:03 PM
I wanted it without code.. with code of course I can do that.
Thanks & regards,
Rahul
‎2015 Feb 04 8:10 PM
‎2015 Feb 04 8:35 PM
No way as far as I know.
If you insert value by value then in screen fields, google check table and value table.
From Abap, unlike for instance MS Sql there is no auto check when inserting. Thats what frustrated me for a while, but Sap wanted to work on most Databases so here You go.
You can manipulate DB directly, constraint, but I would not do that for such trivial thing...or ever.
2 lines of code, 1 select and IF
I recommend get data in Alv, test mode, flag wrong inserts etc.
Without code, use Winshuttle.
‎2015 Feb 05 7:55 AM
You could use a generic check tool which was developed in HR : method CHECK_STRUCTURE of class CL_HRBAS_FOREIGN_KEY_CHECK.
ls_structure-mtart = '????'. " wrong value
CREATE OBJECT: lr_key_check, lr_message_handler.
TRY.
lr_key_check->check_structure(
EXPORTING
structure = ls_structure
excluded_fields = lt_excluded_fields
ignore_initial_fields = lv_ignore_initial_fields
message_handler = lr_message_handler
IMPORTING
is_ok = is_ok ).
CATCH cx_hrbas_violated_assertion.
ENDTRY.
Regards,
Raymond