04-21-2010 8:34 AM
Hi Experts,
I am displaying data using Statis ALV.
In my output, i have 20 columns in that i dont want to display empty field column (dont know which column comes empty for senerio).
If the whole column is empty then i need to delete that column from fieldcatlog.
Could you please help me if any one faced the same issue.
Regards
SK
04-21-2010 8:51 AM
check the final internal table values before populating the Field catalog.
If the internal table column doesn't contain values then pass
wa_fieldcat-no_out = 'X'.
Regards
Vinod
Edited by: Vinod Kumar on Apr 21, 2010 1:27 PM
04-21-2010 9:13 AM
Hi,
Well there would be a logical approach to it :-
1. Do a read on your internal table checking one by one which field contains all empty values (or shud say no values).
EG:- Table1-f1,f2,f3,f4,f5.
Out of this in the 1st instance the fields F4 and F5 dont contain any values, u can arrive at this concl by doin the following.
**- check the number of lines in internal table
DESCRIBE TABLE <table1> LINES <li_line>.
** check field by field which field contains empty entries
READ TABLE <table1> INTO <wa_1> WITH KEY F1 = SPACE.
<li_index> = SY-INDEX. "-- sy-index will contain the total number of entries found with matching criteria"
IF <li_index> = <li_line> . " this clause is a check to see if all the lines for column F1 are empty
APPEND 'F1' TO <table_exclude>.
ENDIF.
READ TABLE <table1> INTO <wa_1> WITH KEY F2 = SPACE.
<li_index> = SY-INDEX. "-- sy-index will contain the total number of entries found with matching criteria"
IF <li_index> = <li_line> . " this clause is a check to see if all the lines for column F1 are empty
APPEND 'F2' TO <table_exclude>.
ENDIF.
................................. (do this for all the fields)
** at the end of checking all the fields and appending the correponding field-names in table <TABLE_EXCL>.
PERFORM BUILD_CATALOG USING : 'F1' 'FIELD1' '40' 'L',
'F2' 'FIELD2' '40' 'L',
'F3 'FIELD3' '40' 'L',
'F4' 'FIELD4' '40' 'L',
'F5' 'FIELD5' '40' 'L'.
FORM BUILD_CATALOG USING PC_FNAME PC_FDESC PC_FLEN PC_FTYPE.
READ TABLE <table_excl> INTO <wa_excl> WITH KEY FIELD = PC_FNAME.
IF SY-SUBRC <> 0.
APPEND FIELDCATALOG.
ENDIF.
ENDFORM.
Hope this gives u an idea and helps..
-- Dedeepya C
04-21-2010 9:29 AM
hi
Read table itab with key field1 = space
transporting no fields.
if sy-subrc ne 0.
fldcat-fieldname = 'FIELD1'
append fldcat
endif.
Read table itab with key field2 = space
transporting no fields.
if sy-subrc ne 0.
fldcat-fieldname = 'FIELD2'
append fldcat.
endif.
05-13-2010 11:56 AM
07-12-2010 9:27 AM