2009 Mar 23 1:41 PM
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.
2009 Mar 24 5:07 AM
Hi,
Try using this way:-
MODULE validate_data.
CASE sy-ucomm.
WHEN 'CHECK'.
IF WA_MARA-ZZSELECT = ' '.
MESSAGE E008. "Select a record
ENDIF.
IF WA_MARA-ZZSELECT = 'X'.
IF WA_MARA-MATNR IS INITIAL.
MESSAGE E006. "enter value using F4
ENDIF.
ELSE.
"take another internal table it_temp and same as it_mara
it_temp = it_mara.
SORT it_temp BY matnr.
DELETE ADJACENT DUPLICATES FROM it_temp COMPARING matnr.
IF sy-subrc = 0.
MESSAGE E005. " entry repeated
ELSE.
MESSAGE E009. " proper data
ENDIF.
ENDIF.
ENDCASE.
ENDMODULE.
Hope this helps you.
Regards,
Tarun
Edited by: Tarun Gambhir on Mar 24, 2009 10:39 AM
Hi,
Try using this way:-
MODULE validate_data.
CASE sy-ucomm.
WHEN 'CHECK'.
IF WA_MARA-ZZSELECT = ' '.
MESSAGE E008. "Select a record
ENDIF.
IF WA_MARA-ZZSELECT = 'X'.
IF WA_MARA-MATNR IS INITIAL.
MESSAGE E006. "enter value using F4
ENDIF.
ELSE.
"take another internal table it_temp and same as it_mara
it_temp = it_mara.
SORT it_temp BY matnr.
DELETE ADJACENT DUPLICATES FROM it_temp COMPARING matnr.
IF sy-subrc = 0.
MESSAGE E005. " entry repeated
ELSE.
MESSAGE E009. " proper data
ENDIF.
ENDIF.
ENDCASE.
ENDMODULE.
Hope this helps you.
Regards,
Tarun
Edited by: Tarun Gambhir on Mar 24, 2009 10:39 AM
2009 Mar 24 5:07 AM
Hi,
Try using this way:-
MODULE validate_data.
CASE sy-ucomm.
WHEN 'CHECK'.
IF WA_MARA-ZZSELECT = ' '.
MESSAGE E008. "Select a record
ENDIF.
IF WA_MARA-ZZSELECT = 'X'.
IF WA_MARA-MATNR IS INITIAL.
MESSAGE E006. "enter value using F4
ENDIF.
ELSE.
"take another internal table it_temp and same as it_mara
it_temp = it_mara.
SORT it_temp BY matnr.
DELETE ADJACENT DUPLICATES FROM it_temp COMPARING matnr.
IF sy-subrc = 0.
MESSAGE E005. " entry repeated
ELSE.
MESSAGE E009. " proper data
ENDIF.
ENDIF.
ENDCASE.
ENDMODULE.
Hope this helps you.
Regards,
Tarun
Edited by: Tarun Gambhir on Mar 24, 2009 10:39 AM
2009 Mar 24 6:24 AM
Hi Tarun,
I have tried implementing your code.
The problem i am facing is whatever selection i make, irrespective of that i get one fixed message - SELECT A RECORD.
I tried to debug the code..Even if i give two similar inputs and then select one the records and click on CHECK, then also i am having the same message- SELECT A RECORD.
I would appreciate your help.
2009 Mar 24 6:40 AM
Hi,
Use:-
PROCESS AFTER INPUT.
* MODULE user_coomand_8001.
LOOP WITH CONTROL tab_ctrl.
MODULE modify_data.
ENDLOOP.
MODULE validate_data.
In PAI,
MODULE modify_data.
MODIFY it_mara FROM wa_mara INDEX tab_ctrl-current_line.
"modify the contents into internal table from table control
ENDMODULE.
MODULE validate_data.
CASE sy-ucomm.
WHEN 'CHECK'.
REFRESH it_temp.
REFRESH it_temp1.
CLEAR it_temp.
CLEAR it_temp1.
"take another internal table it_temp and same as it_mara
it_temp = it_mara.
READ TABLE it_temp INTO wa_temp WITH KEY zzselect = 'X'.
IF sy-subrc ne 0.
MESSAGE E008. "Select a record
ELSE.
IF WA_MARA-MATNR IS INITIAL.
MESSAGE E006. "enter value using F4
ELSE.
"take another internal table it_temp1 and same as it_mara
it_temp1 = it_mara.
DELETE it_temp1 WHERE matnr = wa_temp-matnr.
IF sy-subrc = 0.
IF sy-dbcnt > 1.
MESSAGE E005. " entry repeated
ELSEIF sy-dbcnt = 1.
MESSAGE E009. " proper data
ENDIF.
ENDIF.
ENDIF.
ENDCASE.
ENDMODULE.
Hope this helps you.
Regards,
Tarun
2009 Mar 24 8:58 AM
Thanks a lot gentlemen for your help.
Tarun- Little changes in your logic have helped me to solve the problem.
Keep the good work on.
Regards.
2009 Mar 24 5:07 AM
HI ,
1. First Check for the Record is selected or not
2. Checkl for the matnr entered or not by checking for initial values.
3. If value is entered is repeated or not .
4. if every this is ok continue your process.
Copy the Old data to one internal table in PBO to check for the dulpicate entries
IF WA_MARA-ZZSELECT = 'X'.
IF WA_MARA-MATNR IS INITIAL.
MESSAGE E006. "Enter value using F4
ELSE.
READ TABLE I_MARA_OLD INTO WA_MARA1 WITH KEY MATNR = WA_MARA-MATNR.
IF SY-SUBRC = 0.
MESSAGE E005. " Entry repeated
ELSE.
APPEND WA_MARA1 TO I_MARA.
MESSAGE S009. " Proper data
ENDIF.
ENDIF.
ELSE.
MESSAGE E008. "Select a record first
ENDIF.
2009 Mar 24 6:25 AM
Hi Avinash,
I have tried implementing your code.
The problem i am facing is whatever selection i make, irrespective of that i get one fixed message - SELECT A RECORD.
I tried to debug the code..Even if i give two similar inputs and then select one the records and click on CHECK, then also i am having the same message- SELECT A RECORD.
I would appreciate your help.
2009 Mar 24 6:33 AM
HI,
Check wether you flag for the selected record is getting populated or not.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |