2008 Nov 10 9:54 AM
Hi All
Iu2019m calling on FM and it returns tab ITAB1 (with fields user,data, tcode & etc.). I have another structure Itab2 (with fields sing, option, low & high). Now I want to check each row in Itab2 is in the Itab2 range or not. And finally I want to save in another Itab.
Suggest me in ABAP statements,
Regards,
Hi All
Iu2019m calling on FM and it returns tab ITAB1 (with fields user,data, tcode & etc.). I have another structure Itab2 (with fields sing, option, low & high). Now I want to check each row in Itab2 is in the Itab2 range or not. And finally I want to save in another Itab.
Suggest me in ABAP statements,
Regards,
2008 Nov 10 10:02 AM
Loop at itab1 .
Read table itab2 with key ( Comparing fields ).
If sy-subrc eq o.
Move what ever your require in the 3rd itab.
Append itab3.
clear itab3.
endif.
endloop.
2008 Nov 10 10:03 AM
Hi
declare a range r_range and pass the values of itab2 to r_range.
loop at itab1 into wa_itab1.
if wa_itab1-data in r_range .
els.
endif.
endloop.
regards,
Ramya
2008 Nov 10 12:11 PM
Hi Ramy,
Can you explain a little bit clearly. I hope this process will solve my problem.
Thkx
2008 Nov 10 10:03 AM
for example you can use:
LOOP AT ITAB1 INTO ... WHERE field IN itab2.
==> this value of field is in itab2
ENDLOOP.
2008 Nov 10 10:06 AM
Hi
data: itab3 like table of itab1 with header line.
loop at itab1.
read table itab2 with table key <condition>.
if sy-subrc = 0.
move itab1 to itab3.
endif .
enloop.Hope this logic will help ful
Regards
Srinivasu
Edited by: srinivasu bv on Nov 10, 2008 11:06 AM
2008 Nov 10 10:39 AM
Hi Srinivas,
Sorry for asking this question.
In ur replay, in Read stat I need to write some contion. But the confustion is Itab1 contains a field Tcode but Itab2 contain fields Low & High (as Tcode fields).
So, How can i write a condition at this case. Plz help me on this.
Thnks.
2008 Nov 10 10:43 AM
Hi Sandya
Give the Declerations of itab1 and itab2 internal tabels
then it is easy to understand your requiremnt
Regards
2008 Nov 10 10:52 AM
REPORT ZSRK_035 .
DATA : BEGIN OF ITAB1 OCCURS 0,
USER LIKE USR01-BNAME,
DATA(30),
TCODE LIKE TSTC-TCODE,
END OF ITAB1.
DATA : BEGIN OF ITAB2 OCCURS 0,
SIGN,
OPTION(2),
LOW LIKE TSTC-TCODE,
HIGH LIKE TSTC-TCODE,
END OF ITAB2.
ITAB2-SIGN = 'I'.
ITAB2-OPTION = 'BT'.
ITAB2-LOW = 'MM01'.
ITAB2-HIGH = 'MM03'.
APPEND ITAB2.
CLEAR ITAB2.
ITAB1-USER = SY-UNAME.
ITAB1-DATA = 'AAAAAAAAAAAA'.
ITAB1-TCODE = 'VA01'.
APPEND ITAB1.
CLEAR ITAB1.
ITAB1-USER = SY-UNAME.
ITAB1-DATA = 'BBBBBBBBBBBB'.
ITAB1-TCODE = 'MM02'.
APPEND ITAB1.
CLEAR ITAB1.
ITAB1-USER = SY-UNAME.
ITAB1-DATA = 'CCCCCCCCCCCCCCC'.
ITAB1-TCODE = 'MM01'.
APPEND ITAB1.
CLEAR ITAB1.
ITAB1-USER = SY-UNAME.
ITAB1-DATA = 'DDDDDDDDDDDDD'.
ITAB1-TCODE = 'VA02'.
APPEND ITAB1.
CLEAR ITAB1.
ITAB1-USER = SY-UNAME.
ITAB1-DATA = 'EEEEEEEEEEEE'.
ITAB1-TCODE = 'MM03'.
APPEND ITAB1.
CLEAR ITAB1.
LOOP AT ITAB1 WHERE TCODE IN ITAB2.
WRITE : / ITAB1-DATA.
ENDLOOP.
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |