Skip to Content
0
Former Member
Mar 23, 2009 at 01:41 PM

Unable to perform validation properly

36 Views

Hi All,

Please help me out. I am having a scenario in a dialog prog where i have a screen in which a table control is there.1st coloum is a check box (screen name is WA_MARA-ZZSELECT), 2nd coloum is MATNR where a F4 help is used for Input.As the Input is given using F4 help, value of corresponding MATKL should come in coloum 3.

For validation one needs to select a record/records by marking the check box and click on a push button- CHECK.

Now i need to validate the input as follows:

1) if a user doesnt select any record and clicks on CHECK, he should get a msg saying "Select a record first".

2) If a user doesnt give any input and select a record and click CHECK, he should get a msg saying "enter value using F4."

3)If a user enters two same MATNR as input by F4 and then select any one of the records and click on CHECK he should get a msg- "Entry repeated".

4) If none of the above happens then he should get a msg - "Proper Data".

The code i have developed (though not working perfectly) is:

  • For Validation

CASE OK_CODE.

WHEN 'CHECK'.

IF WA_MARA-ZZSELECT = ' '.

MESSAGE E008. "Select a record first

ENDIF.

IF WA_MARA-ZZSELECT = 'X'.

IF WA_MARA-MATNR IS INITIAL.

MESSAGE E006. "Enter value using F4

ELSE.

READ TABLE I_MARA INTO WA_MARA WITH KEY WA_MARA-MATNR.

IF SY-SUBRC = 0.

MESSAGE E005. " Entry repeated

ELSE.

MESSAGE E009. " Proper data

ENDIF.

ENDIF.

ENDIF.

ENDCASE.

Please guys help me with the correct logic.