Hi Haritha,
We can achieve this in couple of steps.
- Copy the Internal table into a temporary Internal table IT_TEMP.
- SORT IT_TEMP by RACCT.
- DELETE ADJACENT DUPLICATES from the temp table IT_TEMP comparing RACCT. By which you will get the Unique Account Numbers.
- Loop at IT_TEMP into LS_TEMP.
- READ TABLE IT_GLT0 INTO LS_GLT0_1 WITH KEY RACCT = LS_TEMP-RACT
- DRCRK = 'H'.
- READ TABLE IT_GLT0 INTO LS_GLT0_1 WITH KEY RACCT = LS_TEMP-RACT
- DRCRK = 'S'.
- IF LS_GLT0_1-HSLVT NE 0 AND LS_GLT0_2-HSLVT NE 0.
- APPEND LS_GLT0_1 TO IT_FINAL.
- APPEND LS_GLT0_2 TO IT_FINAL.
- ENDIF.
- CLEAR: LS_GLT0_1, LS_GLT0_2.
- READ TABLE IT_GLT0 INTO LS_GLT0_1 WITH KEY RACCT = LS_TEMP-RACT
- ENDLOOP.
Now you will get the required data into your final internal table IT_FINAL.
Please ask me if any future clarifications required.