2008 Feb 20 12:47 PM
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 20 12:49 PM
hi Jay,
it is not fully clear for me, but if you want to modify the definition of the internal table (i.e. the internal table would have only 4 coloumns), that is not possible during runtime.
hope this helps
ec
2008 Feb 20 12:50 PM
Hi Jay,
You actually cannot "delete" an internal table column, rather you delete the internal table row.
To delete an internal table column, would mean removing the column from the internal table declaration.
If you mean deleting the internal table row if one of the columns viz. field5 is blank, then code the following:
DELETE itab WHERE field5 IS INITIAL.
This will delete all records from internal table itab where the field5 (column) values are initial.
Cheers,
Aditya
2008 Feb 20 12:51 PM
Hi,
what u do is first declare a new structure with the fileds (4) u want and then write like this.
loop at itab_old.
itab_new-f1 = itab_old-f1.
itab_new-f2 = itab_old-f2.
itab_new-f3 = itab_old-f3.
itab_new-f4 = itab_old-f4.
append itab_new.
endloop.
<REMOVED BY MODERATOR>
Edited by: Alvaro Tejada Galindo on Feb 26, 2008 12:30 PM
2008 Feb 20 12:59 PM
Jay,
Try using the static method CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE to create a dynamic table
Eg:
CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
EXPORTING
IT_FIELDCATALOG = it_fieldcat
IMPORTING
EP_TABLE = dy_tbl.
<REMOVED BY MODERATOR>
Thanks,
Balaji
Edited by: Alvaro Tejada Galindo on Feb 26, 2008 12:31 PM
2008 Mar 14 5:49 AM
hi,can u answer my question tht how to delete column from ALV.....
2008 Mar 14 5:53 AM
Hi,
If you mean removing the column from ALV display, change the field catalog that is
being passed.
Pass NO_OUT = 'X'. By doing this, it will be available for selection in the "Change Layout", but will not be displayed initially.
Hope this helps.
Thanks,
Balaji
2008 Mar 14 10:53 AM
Hi Rajan,
I HAVE WRITTEN CODE FOR YOU...IT IS VERY INTERESTING...RUN AND SEE...YOU CAN DEBUG IT AND TEST FOR DIFFERENT SCENARIOS ALSO...
COPY PASTE AND RUN...
Reward points if useful...
&----
*& Report ZSS_TEST_TP *
*& *
&----
*& *
*& *
&----
REPORT zss_test_tp.
TYPE-POOLS: slis. " For ALV List
TYPES : BEGIN OF ty_bkpf,
bukrs TYPE bkpf-bukrs,
belnr TYPE bkpf-belnr,
gjahr TYPE bkpf-gjahr,
bvorg TYPE bkpf-bvorg.
TYPES : END OF ty_bkpf.
DATA : it_bkpf TYPE TABLE OF ty_bkpf,
wa_bkpf TYPE ty_bkpf.
TYPES : BEGIN OF ty_field,
column TYPE char50,
desc(50) TYPE c,
END OF ty_field.
DATA : it_field TYPE TABLE OF ty_field,
wa_field TYPE ty_field.
DATA : it_field1 TYPE TABLE OF ty_field.
DATA : w_ne TYPE c,
w_tabix TYPE sy-tabix.
DATA: ls_fieldcat TYPE slis_fieldcat_alv,
gf_pos TYPE i,
gt_fieldcat TYPE slis_t_fieldcat_alv,
g_repid LIKE sy-repid.
DATA: ls_event TYPE slis_alv_event,
lt_events TYPE slis_t_event,
gt_events TYPE slis_t_event,
g_variant LIKE disvariant,
g_user_command TYPE slis_formname VALUE 'USER_COMMAND'.
CONSTANTS:
gc_formname_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE'.
----
FIELD-SYMBOLS *
----
FIELD-SYMBOLS: <fs_table> TYPE table,
<fs_any> TYPE ANY,
<fs_wa> TYPE ANY.
PERFORM collect_columns.
PERFORM get_data.
PERFORM check_empty_columns.
IF it_field IS NOT INITIAL.
PERFORM fill_fieldcat.
PERFORM eventtab_build.
PERFORM call_alv.
ELSE.
MESSAGE s000(zenil_sd) DISPLAY LIKE 'E' WITH 'NO ENTRIES FOUND'.
LEAVE LIST-PROCESSING.
ENDIF.
----
Top Of Page
----
FORM top_of_page.
WRITE : 'SACHIN PROGRAM'.
ENDFORM. "top_of_page
&----
*& Form COLLECT_COLUMNS
&----
text
----
--> p1 text
<-- p2 text
----
FORM collect_columns .
wa_field-column = 'BUKRS'.
wa_field-desc = 'COMPANY CODE'.
APPEND wa_field TO it_field .
wa_field-column = 'BELNR'.
wa_field-desc = 'DOCUMENT NO'.
APPEND wa_field TO it_field .
wa_field-column = 'GJAHR'.
wa_field-desc = 'FISCAL YEAR'.
APPEND wa_field TO it_field .
wa_field-column = 'BVORG'.
wa_field-desc = 'BVORG'.
APPEND wa_field TO it_field .
ENDFORM. " COLLECT_COLUMNS
&----
*& Form get_data
&----
text
----
--> p1 text
<-- p2 text
----
FORM get_data .
SELECT * FROM bkpf
INTO CORRESPONDING FIELDS OF TABLE it_bkpf
WHERE bukrs = '2000'
AND belnr = '1120000001'
AND gjahr = '2007'.
ENDFORM. " get_data
&----
*& Form check_empty_columns
&----
text
----
--> p1 text
<-- p2 text
----
FORM check_empty_columns .
LOOP AT it_field INTO wa_field.
ASSIGN wa_field-column TO <fs_any>.
w_tabix = w_tabix + 1.
LOOP AT it_bkpf INTO wa_bkpf. "WHERE <fs_any> IS NOT INITIAL.
ASSIGN COMPONENT w_tabix OF STRUCTURE wa_bkpf TO <fs_wa>.
IF <fs_wa> IS NOT INITIAL.
w_ne = 'X'.
ENDIF.
ENDLOOP.
IF w_ne <> 'X'.
DELETE it_field.
ELSE.
CLEAR w_ne.
APPEND wa_field TO it_field1.
CONTINUE.
ENDIF.
ENDLOOP.
ENDFORM. " check_empty_columns
&----
*& Form fill_fieldcat
&----
text
----
--> p1 text
<-- p2 text
----
FORM fill_fieldcat .
LOOP AT it_field1 INTO wa_field.
CLEAR ls_fieldcat.
gf_pos = gf_pos + 1.
ls_fieldcat-col_pos = gf_pos.
ls_fieldcat-fieldname = wa_field-column.
ls_fieldcat-ref_fieldname = wa_field-column.
ls_fieldcat-ref_tabname = 'IT_BKPF'.
ls_fieldcat-seltext_s = wa_field-desc.
ls_fieldcat-seltext_m = wa_field-desc.
ls_fieldcat-seltext_l = wa_field-desc.
ls_fieldcat-reptext_ddic = wa_field-desc.
APPEND ls_fieldcat TO gt_fieldcat.
ENDLOOP.
ENDFORM. " fill_fieldcat
&----
*& Form eventtab_build
&----
text
----
--> p1 text
<-- p2 text
----
FORM eventtab_build .
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = lt_events.
READ TABLE lt_events WITH KEY name = slis_ev_top_of_page
INTO ls_event.
IF sy-subrc = 0.
MOVE gc_formname_top_of_page TO ls_event-form.
APPEND ls_event TO lt_events.
ENDIF.
ENDFORM. " eventtab_build
&----
*& Form call_alv
&----
text
----
--> p1 text
<-- p2 text
----
FORM call_alv .
g_repid = sy-cprog.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = g_repid
it_fieldcat = gt_fieldcat[]
it_events = gt_events[]
i_callback_user_command = g_user_command
i_save = 'A'
is_variant = g_variant
TABLES
t_outtab = it_bkpf.
ENDFORM. " call_alv
Edited by: Sachin Sawant on Mar 14, 2008 11:56 AM
2008 Mar 14 9:08 AM
Hi Jay,
Create a work area (WA) similar to the itab then read one row from itab into WA and check individual components of the wa if it is INITIAL.
now you can filterout field1 ,field2,field3,field4 as NON INITIAL.
Use RTTC of RTTI functionality for creaztion of the eork area WA-2 for the above four fields.
and from WA-2 you can create an itab.
I have not tested this before posting. Hope its helpful.
Regds,
Gaurav
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |