‎2011 Feb 15 9:11 AM
Dear all,
Am creating Table Control without wizard. In that i am looping the values, that is, Once if i entered 5 digit values means, 12345-08... the values should be stored in z-table like this 12345,12346,12347,12348 . That is 5-8 it as to update in z table. for this i createdloop at itab and inside that i written a code to count the value and all. and also its clearly updating the value in ztable too. now i want to know, if once again i entered the same value means, like 12345-08.. it as to show error messge.I dont know how to set the condition with error message inside the single loop .... Its all comes under module pool program.
Thanks,
Santhosh.R
‎2011 Feb 15 11:34 AM
If i understood your doubt, here goes the answer.
LOOP AT itab INTO wa_itab. " This is your loop
l_tabix = sy-tabix. "l_tabix receives the line of the loop
READ TABLE itab WITH KEY itab = wa_itab. "itab is the same tab of your loop
IF sy-subrc EQ 0 AND l_tabix NE sy-tabix. "Here the sy tabix have the value of the read table.
* Here you do your error treatment.
ENDIF.
ENDLOOP.
Explanation: When you are looping your internal table, you use a READ TABLE to see the already recorded registers. If the read table finds one register (sy-subrc EQ 0) and the this register is not the one of the current line (l_tabix NE sy-tabix). It means you have a duplicated register.
Maybe there is someway easier to do this, but this is what i thought now.
I hope this was your doubt hehe.
Thales Schmidt
‎2011 Feb 15 11:54 AM
Hi,
What i will do is...if its a z table i will creaate one more field like "Combination Key". For each record of 12345,12346,12347,12348 i will store 12345-08 against it . So that its easy to do such manipulations.
It can be also done through looping logic but lots of effort is needed.
‎2011 Feb 15 12:14 PM
hi,
as only the last digit(5-8) will change, write a select statement on Z table write a where condition as below.
select matnr from ztab into itab where (matnr like 1234*)
then looping through the table itab will not take much time and if duplicates ar efoung while looping, raise message.
Regards,
KIshore