Primary key allowing NULL values to be inserted And F4 check

Question:
Hi All,
I am developing a module pool in which i have a screen which takes inputs for Z table and inserts the row in Z table. The problem is that , evenif i dont enter one of the primary key field, it inserts row in table with that perticular field as NULL , though in table definition the checkbox (NOT NULL) is checked against that field.
2nd problem is,
IN my screen which inserts row in Z table, i have attached search help to input field Customer No, i.e Customer field is linked to KNA1-kunnr by search help. But my concern is that its possible that user dont select F4 and directly enters any value (by typing), which may not be existing in KNA1. How to avoid user typing any values...and just allow F4. Is it possible ?
Please help ASAP
Regards
Answer:
try this code for your screen....
* === Screen Flow Logic === *
PROCESS BEFORE OUTPUT.
MODULE STATUS_0100.
PROCESS AFTER INPUT.
FIELD: BUT000-PARTNER MODULE CHECK_FIELD_01.
MODULE USER_COMMAND_0100.
* attribute of field BUT000-PARTNER -> check "From dict."
* === Program Logic ==== *
*&---------------------------------------------------------------------*
*& Module CHECK_FIELD_01 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE CHECK_FIELD_01 INPUT.
SELECT SINGLE * FROM BUT000
WHERE PARTNER = BUT000-PARTNER.
IF SY-SUBRC <> 0.
MESSAGE E999(ZCS) WITH 'Invalid BP number'.
ENDIF.
ENDMODULE. " CHECK_FIELD_01 INPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0100 INPUT.
case okcode.
when 'EXIT'.
leave program.
endcase.
ENDMODULE. " USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS '0100'.
* SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_0100 OUTPUT
Answer:
Hi Violin,
Thanks for your code. I m using
FIELD : ztable-field MODULE check_field ON INPUT.
This works fine but i have to press 'ENTER' for the check to process. Is it not possible that the check is triggered even when i press TAB key.
I want that check should be triggered as soon as the value is changed and user moves to next field.
Thanks and Regards

More Articles:

Smartforms table template.?
How to change development class of an object?
coming back to same screen after button click.?
Locking in background job run?
selection screen help?
Uploading an Excel file using ABAP?