2008 Dec 18 11:20 AM
Hello,
In my Internal table few rows have null values and I want to delete them.
How can I do this....I am using specific Sturctures, based on them I had created
Internal tables
ex : In Itable 1st row has only 000000, it is null and I want to delete that entire row.
for ex : types : begin of ty_abc,
123 type q,
456 type p,
end of ty_abc.
data : t_abc type standard table of ty_abc.
This is my code.
LOOP AT T_PRCTSC INTO WA_PRCTSC.
WA_FINAL-GUID_PRCTSC = WA_PRCTSC-GUID_PRCTSC.
WA_FINAL-GUID_PR = WA_PRCTSC-GUID_PR.
WA_FINAL-STCTS = WA_PRCTSC-STCTS.
WA_FINAL-GUID_CTSNUMC = WA_PRCTSC-GUID_CTSNUMC.
READ TABLE T_CTSNUMC INTO WA_CTSNUMC WITH KEY GUID_CTSNUMC = WA_PRCTSC-GUID_CTSNUMC.
IF SY-SUBRC = 0.
WA_FINAL-GUID_MOBJ = WA_CTSNUMC-GUID_MOBJ.
WA_FINAL-CCNGN = WA_CTSNUMC-CCNGN.
ENDIF.
READ TABLE T_PRGEN INTO WA_PRGEN WITH KEY GUID_PR = WA_PRCTSC-GUID_PR.
IF SY-SUBRC = 0.
WA_FINAL-GUID_PRGEN = WA_PRGEN-GUID_PRGEN.
WA_FINAL-ATTR20A = WA_PRGEN-ATTR20A.
WA_FINAL-ATTR05A = WA_PRGEN-ATTR05A.
WA_FINAL-ATTR10A = WA_PRGEN-ATTR10A.
WA_FINAL-ATTR05B = WA_PRGEN-ATTR05B.
ENDIF.
READ TABLE T_PNTPR INTO WA_PNTPR WITH KEY GUID_PR = WA_PRCTSC-GUID_PR.
IF SY-SUBRC = 0.
WA_FINAL-PRVSY = WA_PNTPR-PRVSY.
WA_FINAL-GRVSY = WA_PNTPR-GRVSY.
ENDIF.
READ TABLE T_PR INTO WA_PR WITH KEY GUID_PR = WA_PRCTSC-GUID_PR.
IF SY-SUBRC = 0.
WA_FINAL-CRTSP = WA_PR-CRTSP.
WA_FINAL-CHTSP = WA_PR-CHTSP.
ENDIF.
READ TABLE T_PRT INTO WA_PRT WITH KEY GUID_PR = WA_PRCTSC-GUID_PR.
IF SY-SUBRC = 0.
WA_FINAL-PRTXT = WA_PRT-PRTXT.
ENDIF.
*&----
**Since the report will display all the classifications **
based on the SubID's. We are removing the records where **
subid is initial **
*&----
*IF WA_FINAL-ATTR20A IS INITIAL. but itable still*
CLEAR : WA_FINAL.
CLEAR T_FINAL[].
ENDIF.
APPEND WA_FINAL TO T_FINAL.
CLEAR WA_FINAL.
ENDLOOP.
Any suggestions will be apprecaited...
Regards,
Kittu
2008 Dec 18 11:22 AM
simply:
DELETE itab WHERE ... EQ '000000'.this will delete the lines from the internal table where the condition is true. of coure the condition could be more complicated.
Hello,
In my Internal table few rows have null values and I want to delete them.
How can I do this....I am using specific Sturctures, based on them I had created
Internal tables
ex : In Itable 1st row has only 000000, it is null and I want to delete that entire row.
for ex : types : begin of ty_abc,
123 type q,
456 type p,
end of ty_abc.
data : t_abc type standard table of ty_abc.
This is my code.
LOOP AT T_PRCTSC INTO WA_PRCTSC.
WA_FINAL-GUID_PRCTSC = WA_PRCTSC-GUID_PRCTSC.
WA_FINAL-GUID_PR = WA_PRCTSC-GUID_PR.
WA_FINAL-STCTS = WA_PRCTSC-STCTS.
WA_FINAL-GUID_CTSNUMC = WA_PRCTSC-GUID_CTSNUMC.
READ TABLE T_CTSNUMC INTO WA_CTSNUMC WITH KEY GUID_CTSNUMC = WA_PRCTSC-GUID_CTSNUMC.
IF SY-SUBRC = 0.
WA_FINAL-GUID_MOBJ = WA_CTSNUMC-GUID_MOBJ.
WA_FINAL-CCNGN = WA_CTSNUMC-CCNGN.
ENDIF.
READ TABLE T_PRGEN INTO WA_PRGEN WITH KEY GUID_PR = WA_PRCTSC-GUID_PR.
IF SY-SUBRC = 0.
WA_FINAL-GUID_PRGEN = WA_PRGEN-GUID_PRGEN.
WA_FINAL-ATTR20A = WA_PRGEN-ATTR20A.
WA_FINAL-ATTR05A = WA_PRGEN-ATTR05A.
WA_FINAL-ATTR10A = WA_PRGEN-ATTR10A.
WA_FINAL-ATTR05B = WA_PRGEN-ATTR05B.
ENDIF.
READ TABLE T_PNTPR INTO WA_PNTPR WITH KEY GUID_PR = WA_PRCTSC-GUID_PR.
IF SY-SUBRC = 0.
WA_FINAL-PRVSY = WA_PNTPR-PRVSY.
WA_FINAL-GRVSY = WA_PNTPR-GRVSY.
ENDIF.
READ TABLE T_PR INTO WA_PR WITH KEY GUID_PR = WA_PRCTSC-GUID_PR.
IF SY-SUBRC = 0.
WA_FINAL-CRTSP = WA_PR-CRTSP.
WA_FINAL-CHTSP = WA_PR-CHTSP.
ENDIF.
READ TABLE T_PRT INTO WA_PRT WITH KEY GUID_PR = WA_PRCTSC-GUID_PR.
IF SY-SUBRC = 0.
WA_FINAL-PRTXT = WA_PRT-PRTXT.
ENDIF.
*&----
**Since the report will display all the classifications **
based on the SubID's. We are removing the records where **
subid is initial **
*&----
*IF WA_FINAL-ATTR20A IS INITIAL. but itable still*
CLEAR : WA_FINAL.
CLEAR T_FINAL[].
ENDIF.
APPEND WA_FINAL TO T_FINAL.
CLEAR WA_FINAL.
ENDLOOP.
Any suggestions will be apprecaited...
Regards,
Kittu
2008 Dec 18 11:22 AM
simply:
DELETE itab WHERE ... EQ '000000'.this will delete the lines from the internal table where the condition is true. of coure the condition could be more complicated.
2008 Dec 18 11:26 AM
HI,
Once you find the where values are gettting cleared write Continue...it will continue with next record in the loop.
*&----
**Since the report will display all the classifications **
based on the SubID's. We are removing the records where **
subid is initial **
*&----
& -->Here it will make values null in Itable
IF WA_FINAL-ATTR20A IS INITIAL. but itable still
CLEAR : WA_FINAL.
CONTINUE. Continue's to next loop. Doesn't append the data t_final
ENDIF.
2008 Dec 18 11:27 AM
Hello KIttu,
Modify your code to :
IF WA_FINAL-ATTR20A IS INITIAL.
CLEAR : WA_FINAL.
* CLEAR T_FINAL[].
ELSE.
APPEND WA_FINAL TO T_FINAL.
CLEAR WA_FINAL.
ENDIF.
* APPEND WA_FINAL TO T_FINAL.
* CLEAR WA_FINAL.
It will not populate the rows at all. No need to delete the empty rows.
BR,
Suhas
2008 Dec 18 11:55 AM
2008 Dec 18 11:59 AM
HI KITTU,
Use DELETE ADJUSTANT DUPLICATES COMPARING FIELDS<F1,>
Regards,
Flavya
2008 Dec 18 12:02 PM
sort itab by field1.
DELETE ADJUSTANT DUPLICATES COMPARING FIELD1.
and anyhow one row will remain and that will be first row .
delete itab index 1.
Kiran
2008 Dec 22 9:36 AM
Hello,
Thank you for your response!
The information porovided was helpful.
Have a great day!
Regards,
Kittu