06-24-2009 12:07 PM
hello experts,
i have 2 internal tables. Both have identical structures except that the second internal table holds only the status of data that is present in first.
e.g- if there is some data in third cell(field) of first row in first table, then the in the same cell of second tab, there must be X or nothing otherwise.
so i have to loop at itab 1 and then each cell of it..
Regards,
Sumit Nene
06-24-2009 12:57 PM
TRY SOMETHING LIKE FOLLOWING.
DATA LV_COUNT TYPE I.
FIELD-SYMBOLS: <ITAB1_FIELD>,
<ITAB2_FIELD>.
LOOP AT IT1 INTO WA1.
READ TABLE IT2 INTO WA2 INDEX SY-TABIX.
CLEAR LV_COUNT.
DO.
LV_COUNT = LV_COUNT + 1.
ASSIGN COMPONENT LV_COUNT OF STRUCTURE WA1 TO <ITAB1_FIELD>.
IF SY-SUBRC NE '0'.
EXIT.
ENDIF.
ASSIGN COMPONENT LV_COUNT OF STRUCTURE WA2 TO <ITAB2_FIELD>.
IF <ITAB1_FIELD> IS NOT INITIAL.
<ITAB2_FIELD> = 'X'.
ENDIF.
ENDDO.
MODIFY ITAB2 FROM WA2.
ENDLOOP.
06-24-2009 12:12 PM
Hi ,
You have to loop at itab 1 and same time you have to read the second table itab2.
If you clearly specify . I can try giving you the exact code.
Regards,
Ranjitha
06-24-2009 12:20 PM
@ranjitha
what im planning to do is..
loop at it1 into wa1.
read table it2 into wa2 index sy-tabix.
if wa1-f1 is not initial.
wa2-f1 = 'X'.
endif.
if wa1-f2 is not initial.
wa2-f2 = 'X'.
endif.
if wa1-f3 is not initial.
wa2-f3 = 'X'.
endif.
.....
..
.till all the fields are done.
modify it2 from wa2.
endloop.
but i dont want those if conditions as i have many fields in it1.
Regards,
Sumit
06-24-2009 12:42 PM
Hi,
Check at one shot for all the fields whether the fields are intial like
if wa1-f1 is not initial and wa1-f2 is not initial.....
wa2-f2 = 'X'.
endif.
if you ar checking all the fields then you can check
if wa1 is not intial.
wa2-f2 = 'X'.
endif.
And one more thing if you are looping at first table then you cannot modify the second table.
loop at second table and check the if condition.
Regards,
Ranjitha
06-24-2009 12:50 PM
Hi,
Check at one shot for all the fields whether the fields are intial like
if wa1-f1 is not initial and wa1-f2 is not initial.....
wa2-f2 = 'X'.
endif.
if you ar checking all the fields then you can check
if wa1 is not intial.
wa2-f2 = 'X'.
endif.
And one more thing if you are looping at first table then you cannot modify the second table.
loop at second table and check the if condition.
Regards,
Ranjitha
Hi Ranjitha,
i dont think i could use "and" condition here. I have to check all the fields individually.
as far as the modify statement is concerned, i will make it append. thats not an issue.
Edited by: Sumit Nene on Jun 24, 2009 1:50 PM
06-24-2009 12:57 PM
TRY SOMETHING LIKE FOLLOWING.
DATA LV_COUNT TYPE I.
FIELD-SYMBOLS: <ITAB1_FIELD>,
<ITAB2_FIELD>.
LOOP AT IT1 INTO WA1.
READ TABLE IT2 INTO WA2 INDEX SY-TABIX.
CLEAR LV_COUNT.
DO.
LV_COUNT = LV_COUNT + 1.
ASSIGN COMPONENT LV_COUNT OF STRUCTURE WA1 TO <ITAB1_FIELD>.
IF SY-SUBRC NE '0'.
EXIT.
ENDIF.
ASSIGN COMPONENT LV_COUNT OF STRUCTURE WA2 TO <ITAB2_FIELD>.
IF <ITAB1_FIELD> IS NOT INITIAL.
<ITAB2_FIELD> = 'X'.
ENDIF.
ENDDO.
MODIFY ITAB2 FROM WA2.
ENDLOOP.
06-25-2009 6:57 AM