2005 Jul 05 7:56 AM
Hi Folks,
iam having 3 records in my first itab( T_FINAL) with fields
material no, descrip , mat type and group.
and 16 records in second itab(T_MVKE ) with fields
mat no , distri.chanel and division
now I want to fetch the records from T_MVKE by comparing the records in
T_FINAL .my requirement is to check the given mat no. in sales org.2000,2100. if yes then i have to consider 2000 only, if it is in only 2100 then consider 2100 only . is it is in 2000 only then consider 2100 only
my code is
LOOP AT T_FINAL.
READ TABLE T_MVKE WITH KEY MATNR = T_FINAL-MATNR.
IF SY-SUBRC = 0.
ON CHANGE OF T_MVKE-MATNR OR T_MVKE-VKORG.
IF T_MVKE-VKORG = '2000' and SY-TABIX > 1.
CONCATENATE '2000' 'TS' P_WERKS T_FINAL-MATNR INTO KEY.
ELSEIF T_MVKE-VKORG = '2000' AND SY-TABIX = 1.
CONCATENATE '2000' 'TS' P_WERKS T_FINAL-MATNR INTO KEY.
ELSE.
CONCATENATE '2100' 'TS' P_WERKS T_FINAL-MATNR INTO KEY.
ENDIF.
this logic fails ,. could tell me how to compare values in single itab?
Thanks
neha
2005 Jul 05 8:18 AM
Hi ,
if i've understand you correctly , try that:
LOOP AT t_final.
AT NEW matnr.
CLEAR: v_2000, v_2100.
*1) 2000
READ TABLE t_mvke WITH KEY matnr = t_final-matnr
vkorg = 2000.
IF sy-subrc = 0.
v_2000 = 'X'.
ENDIF.
*2) 2100
READ TABLE t_mvke WITH KEY matnr = t_final-matnr
vkorg = 2100.
IF sy-subrc = 0.
v_2100 = 'X'.
ENDIF.
*compare
IF v_2000 = 'X' AND v_2100 = 'X'.
*read 2000 only
ELSEIF v_2000 = ' ' AND v_2100 = ' '.
*nothing found
ELSE.
*all other combinations
*read 2100 only
ENDIF.
ENDAT.
ENDLOOP.
regards Andreas
2005 Jul 05 8:01 AM
Hi,
Sort t_mvke.
loop at t_final.
read table t_mvke with key matnr = t_final-matnr.
check sy-subrc = 0. "Assuming at least one record for mat
CONCATENATE t_mvke-vkorg 'TS' P_WERKS T_FINAL-MATNR INTO KEY.
endloop.
cheers,
2005 Jul 05 8:18 AM
Hi ,
if i've understand you correctly , try that:
LOOP AT t_final.
AT NEW matnr.
CLEAR: v_2000, v_2100.
*1) 2000
READ TABLE t_mvke WITH KEY matnr = t_final-matnr
vkorg = 2000.
IF sy-subrc = 0.
v_2000 = 'X'.
ENDIF.
*2) 2100
READ TABLE t_mvke WITH KEY matnr = t_final-matnr
vkorg = 2100.
IF sy-subrc = 0.
v_2100 = 'X'.
ENDIF.
*compare
IF v_2000 = 'X' AND v_2100 = 'X'.
*read 2000 only
ELSEIF v_2000 = ' ' AND v_2100 = ' '.
*nothing found
ELSE.
*all other combinations
*read 2100 only
ENDIF.
ENDAT.
ENDLOOP.
regards Andreas
2005 Jul 05 8:57 AM
Hi Andreas Mann ,
thanks for ur help, my program working properly with your logic.
regrds
srini
2005 Jul 05 11:05 AM
Hi srini,
that's fine that i could help you
So please say
'Thanks the SDN way'. Click on the yellow star, and award suitable points.
Check out this weblog:
/people/mark.finnern/blog/2004/08/10/spread-the-love
thanks
Andreas
2005 Jul 05 11:52 AM
Hi Srinivas,
The response that Andreas has given deserves 10 points, because it has solved your problem. I have done it for this time. But from the next time around, please do make a habit of rewarding as many points as the answers deserve.
Regards,
Anand Mandalika.
2005 Jul 05 1:41 PM
Thank you Anand,
have you actually received my mail from 03/may/2005 ?
regards Andreas