2008 Feb 26 9:14 AM
HI.
How can delete Internal table column if its Initial.
eg:I have one internal table its has 5. field1 ,field2,field3,field4 have values but field field5 have no value,that col is empty,
I want delete clo5( field5 ) from Internal table,Pls help me.
Regards.
Jay
HI.
How can delete Internal table column if its Initial.
eg:I have one internal table its has 5. field1 ,field2,field3,field4 have values but field field5 have no value,that col is empty,
I want delete clo5( field5 ) from Internal table,Pls help me.
Regards.
Jay
2008 Feb 26 9:21 AM
Hi Jay,
take 5 internal tables and send the data into them as follows.
itab1 - field1
itab2 - field2
itab3 - field3
itab4 - field4
itab5 - field5.
check the INITIALITY of these tables while printing the output.
2008 Feb 26 9:24 AM
Hi,
You use one more itab and use move corresponding and pass only the 4 fields not field5
or append it to new one
regards
Shiva
2008 Feb 26 9:32 AM
you cannot delete the column in an internal table. you need another table with 4 fields u want and assign this table to the table with 4 fields.
for initial you can check using this
loop at tab.
if tab-field5 is initial .
tab2-field1 = tab-field1
tab2-field2 = tab-field2
tab2-field3 = tab-field3
tab2-field4 = tab-field4
append tab2.
endif.
endloop.
<REMOVED BY MODERATOR>
varun
Edited by: Alvaro Tejada Galindo on Feb 26, 2008 12:29 PM
2008 Feb 26 9:35 AM
2008 Feb 26 9:54 AM
HI..
Sorry Eric for duplicate threads, am using this internal table to display ALV, End user saying its seems not good if it has empty column while display. Already I got answers like its not possible at runtime, but again aim trying people who faced same problem.
Regards.
Jay
2008 Feb 26 9:58 AM
removing a field from internal table, and not displaying a coloumn in ALV list are completely different things! If you don't want to display a coloumn in ALV list, all you have to do is to turn off the field in the ALV field catalouge:
fieldcat-no_out = 'X'.
and the coloumn won't be displayed
2008 Feb 26 10:15 AM
Hi Eric.
yes, Its fine ,before hide the particular column I need to check whether it has any value or empty ,I need hide only if its empty else I need to display that column.
Pls help me.
Jay
2008 Feb 26 9:41 AM
Try this , it will work
loop at itab.
if itab-field5 is initial .
itab2-field1 = itab-field1
itab2-field2 = itab-field2
itab2-field3 = itab-field3
itab2-field4 = itab-field4
append itab2.
else.
itab2-field1 = itab-field1
itab2-field2 = itab-field2
itab2-field3 = itab-field3
itab2-field4 = itab-field4
itab2-field5 = itab-field5
append itab2
endif.
endloop.
Regards,
Ajay
2008 Feb 26 9:44 AM
If you already know which field in the internal table doesn't have any value, you can define a different internal table with the fields that you desire, and then do a move-corresponding for the same.
2008 Feb 26 9:46 AM
Hi,
You can do this by moving the data to target internal table with required fields / you need to create the dynamic internal table.
if you have only 5 fields then you can do this with the below approach.
try to have the internal table columns like Fld1 FLd2 Fld3 Fld4 Fld5 , and make another internal table for the actual column names like below.
for example,
fld name
FLd1 Matnr
Fld2 ERSDA
Fld3 ERNAM
Fld4 LAEDA
Fld5 VPSTA
now consider fld3 is initial so now build the target table with fld1 , fld2 , fld4 , fld5.
but for output display you refer the above internal table for actual fields.
Hope this is clear.
Kind Regards,
2008 Feb 26 12:13 PM
Hye jay,
Consider your internal table is having 3 fields fld1 fld2 fld3.
Declare 3 characters of length 1 and initialize to 1.
Loop at itab into wa.
If wa-fld1 is not initial.
Clear fld1.
Endif.
If wa-fld2 is not initial.
Clear fld2.
Endif.
If wa-fld3 is not initial.
Clear fld3.
Endif.
If fld1 EQ space and fld2 EQ space fld3 EQ space.
Exit.
Endif.
Endloop.
No when you assign the colums to alv, add this statement.
if fld1 is intial.
fieldcat-no_out = 'X'.
endif.
like wise for all fields.
wa_fldcat-col_pos = 1.
wa_fldcat-fieldname = 'fld1'.
wa_fldcat-tabname = 'IT_PROJECT'.
wa_fldcat-seltext_l = field 1.
if fld1 is intial.
fieldcat-no_out = 'X'.
endif.
APPEND wa_fldcat TO it_fldcat.
CLEAR wa_fldcat.
may be this is helpful..
thanks,
Imran.
2008 Feb 26 5:32 PM
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |