Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Delete Empty ALV static fieldcatlog

Former Member
0 Likes
730

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

5 REPLIES 5
Read only

Former Member
0 Likes
696

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

Read only

Former Member
0 Likes
696

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

Read only

former_member418469
Participant
0 Likes
696

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.

Read only

Former Member
0 Likes
696

Solved

Read only

Former Member
0 Likes
696

hi Basha,

how did you solve it. thanks