Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

field validation in table maintenance generator and input value grey out.

Former Member
0 Kudos

i have created ztable with 3 fields as em_no,em_no and addrnumber.

first two fields are custom fields but the third custom field need to validate the standard table adrc contains the value of the field addrnumber.

i need the query of field validation query which we write in create entry events in table maintenance generator and also if we give wrong value for addrnumber in sm30 maintain table, the input field need not to be grey out for next entry...

please help.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

But the requirement is without using checktable i have to validate the field.

i know using events in table maintenance we can do that.

But i need the code to write in form...endform.

and also if i give wrong value in sm30 for that validation field,it need to be active for giving another input..

but its showing grey for me and i am giving all input field values again..

13 REPLIES 13

Former Member
0 Kudos

Why not set the Check table relationship for the AddrNumber?[http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ea77446011d189700000e8322d00/frameset.htm]

Former Member
0 Kudos

Hi,

Insted of writing method in table mentainace generator,better you maintain forign key realationship with table ADRC with your custom table field .

If u want to maintan forign key realation both domain of the fields in both table shold me same,after creating table maintanance generator it will accept the values only those are existed in standerd table ADRC.

Thanks.

Harsh_Bansal
Contributor
0 Kudos

Hi,

You can make use of Table Events to achieve your requirement.

Regards,

Harsh Bansal

Former Member
0 Kudos

But the requirement is without using checktable i have to validate the field.

i know using events in table maintenance we can do that.

But i need the code to write in form...endform.

and also if i give wrong value in sm30 for that validation field,it need to be active for giving another input..

but its showing grey for me and i am giving all input field values again..

0 Kudos

Hi,

create method -


>before saving data.....write the logic between the method

go to utilities->table maintanance ,,,after creating generator ---go to envirnment->modification->events.

create event -.>.as zsave select event type 1(before saving data to table) write code in include....

consider data for field3 is 10 .

lv_new = ztbr(table name)-field3.

select field3 from ADRC(ZTABLE) into wa_new (TYPE ZTABLE) where field3 = lv_new.

if sy-subrc = 0.

working fine

else.

message i888(sabapdocu) with 'data invalid'.

endform.

This will help u...

Thank u.........

0 Kudos

I entered this code on create entry event.

FORM VALIDATE.

TYPES: BEGIN OF ST_A,

ADDRNUMBER TYPE ADRC-ADDRNUMBER,

END OF ST_A.

DATA: IT_ADDRNUMBER TYPE TABLE OF ST_A WITH HEADER LINE,

WA_ADDRNUMBER TYPE ST_A.

SELECT SINGLE ADDRNUMBER FROM ADRC INTO CORRESPONDING FIELDS OF WA_ADDRNUMBER WHERE ADDRNUMBER = ZINAATR_EM-ADDRNUMBER.

IF SY-SUBRC <> 0.

VIM_ABORT_SAVING = 'X'.

MESSAGE E000(ZADDRNO) DISPLAY LIKE 'S'.

ENDIF.

ENDFORM.

the above code works fine..

but when i give wrong input..all the input fields got greyed(inactive)

i want to enter the value again without resetting or clicking back button.

please help..

0 Kudos

Hi,

You can try by giving warning message instead of error.

Regards,

Harsh Bansal

0 Kudos

Hi,

MESSAGE E000(ZADDRNO) DISPLAY LIKE 'S'.

insted of his error message give status message...........bcz error msg will stop executing further but status message will show the status ,then allow user to interact...

i.e give message s000(zaddrno) display like 's'.(message shold be status type ) or use THis

MESSAGE ID 'ZDM_MESSAGE_GENERIC' TYPE 'S' NUMBER 001 DISPLAY LIKE 'E'.

thanks...........

Edited by: lingaraj.ad on Feb 22, 2012 11:39 AM

0 Kudos

IF I USE 'S' MESSAGE,it saves the value even though if i give wrong input.

need reply..

0 Kudos

hi,

you used this????

MESSAGE ID 'ZDM_MESSAGE_GENERIC' TYPE 'S' NUMBER 001 DISPLAY LIKE 'E'.

this will show the error message but in status type ,it will stop current transaction,,,

if you getting the error after using this try something different

MESSAGE ID lc_msg_id TYPE 'E'

number 001 DISPLAY LIKE 'S'.

try this .....

revert back abt progress....

0 Kudos

Hi,

I tries with this code -


FORM validate_matnr.

DATA: l_matnr TYPE mara-matnr.
  SELECT SINGLE matnr
    FROM mara
    INTO l_matnr
    WHERE matnr EQ ztestevent-matnr.

  IF sy-subrc EQ 0.
    MESSAGE 'ERROR' TYPE 'E' DISPLAY LIKE 'S'.
  ENDIF.

ENDFORM.

I had the matnr field open for entry.

Regards,

Harsh Bansal

Former Member
0 Kudos

Hi,

After you generate the Table Maintenance, a Screen will be generated. In the CHAIN...END-CHAIN of that Screen, add this field in the event PAI. This will make it active for i/p.

BR

Neelesh

Former Member
0 Kudos

HI,

Every maintenance generator has screen and you need to write MODULE in PAI of the screen where you can validate the data in your field like shown below.

PROCESS AFTER INPUT.

FIELD <Your SCreen field name> MODULE <any name>.

In your module, write code based on your requirment like screen has company code as one column, validate its entry from T001 table and give error message. There is one issue with EVENTS used in table maintenance generator that if someone re-generates the screen then your cod ein EVENTS will be gone. Be careful while re-generation of function group.

Regards,

Shailendra