Application Development 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: 

delete blank value columns from internal table in abap

Former Member
0 Kudos

Dear All,

   I have an excel sheet and i want to upload excel sheet data into internal table. Whenever i do this my internal table display blank value column also.

I want to delete that particular column which value is blank.

Regards

Sanchita

9 REPLIES 9

kesavadas_thekkillath
Active Contributor
0 Kudos

You cannot delete a blank column of internal table. You an either create a dynamic internal based on the filled columns.

The easiest thing is to delete the columns in excel and update it properly

0 Kudos

Hi,

already provided the possible/easiest solution.

But, I wonder why do u need to delete the empty columns ? Also, are this columns are always empty?

Regards,

Jake

Former Member
0 Kudos

Hi,

If you want to delete the empty row from the internal table,you can use the delete statement like below:

loop at itab.

if itab is initial.

delete itab

endif.

endloop.

Hope it serves useful.

Former Member
0 Kudos

hi,

i have to upload infotype 585 data into pa30. and in excel sheet i have some fields which value is blank

i.e. in some rows SBS01 SBD01 or SBS01 SBD01 nd so on..... fields values are zero. whe we uploas that excel sheet it will store all the rows into table. Bt when we check into pa30, when any code comes zero it is not store further columns .

what can i do for this problem?

Regards

0 Kudos

Hi,

    After Excel upload into internal table use DELETE statement.

DELETE i_itab WHERE sbs01 = '  '

                       AND      sbd01 = ' '.

check on additional option of DELETE statement.

Thanks & Regards

Bala Krishna

0 Kudos

thanks bala krishna,

But it will not helpfull.

Because when i write your statement it delete entire row. I dont want to delete entire row.

My query is whenever it find the blank column of any row it skip that column and proceed another columns of that row. but what happen whenever it find the blank field it will not fill the entire row data into tcode pa30.

thanks

0 Kudos

Hi,    

   Try the below code. pass the uploaded internal table in place of i_itab. The below code will check for blank column, if it is blank, it will populate a horizontal tab in that place and it should not consider  as blank.

If  cl_abap_char_utilities=>horizontal_tab does not work try  cl_abap_char_utilities=>cr_lf , even if this not work, give ASCII space( combination of ALT key + 255) which is equal to space.

c_tab  TYPE c VALUE cl_abap_char_utilities=>horizontal_tab.

or

c_tab  TYPE c VALUE cl_abap_char_utilities=>cr_lf

or

c_tab  TYPE c VALUE '    ' ( ALT + 255).

.

   PERFORM build_xls_data  CHANGING i_itab[].

*&---------------------------------------------------------------------*
*&      Form  build_xls_data
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_FS       text
*----------------------------------------------------------------------*
FORM build_xls_data  CHANGING    p_fs     TYPE ANY TABLE.


  CONSTANTS:
      c_tab  TYPE c VALUE cl_abap_char_utilities=>horizontal_tab.


  DATA: lv_line     TYPE REF TO data.
  FIELD-SYMBOLS: <ft> TYPE ANY TABLE,
                 <fs> TYPE any,
                 <fl> TYPE any.

  ASSIGN p_fs TO <ft>.

  CREATE DATA lv_line LIKE LINE OF p_fs.

  ASSIGN lv_line->* TO <fl>.

  IF NOT p_fs[] IS INITIAL .

    LOOP AT <ft> INTO <fl>.

      DO.
        ASSIGN COMPONENT sy-index OF STRUCTURE <fl> TO <fs>.
        IF sy-subrc <> 0.
          EXIT.
        ENDIF.
        IF <fs> IS INITIAL.
* If field is blank it will add this tab to that field
          WRITE c_tab TO <fs> .
        ENDIF.

      ENDDO.

    ENDLOOP.

  ENDIF.

ENDFORM.                    " BUILD_XLS_DATA

Thanks & Regards

Bala Krishna

Clemenss
Active Contributor
0 Kudos

Hi suchipant,

it depends who you display the table. If you use ALV then just mark empty columns as no_out or technical.

Loop at the table once, for each row check all unpopulated fields. Delete field that is populated from the list of unpopulated fields. With each row, the list of unpopulated fields (initially all fields) gets smaller so that it runs faster. If no unpopulated fields are left, exit the loop. Mark unpopulated fields technical or no_out in field catalog. Using SALV use SET_TECHNICAL or SET_DISPLAY method of columns object.

Sorry, no code as it looks ugly in new SCN

Regards

Clemens

Private_Member_49934
Contributor
0 Kudos

What are you doing with the data of the excel after uploading to internal table? Don't delete the cloumns. Rather don't use them in your program. Why do you want to bring more complexity by creating dynamic tables and putting logic just to check which cloumn is empty for all rows.

If you are displaying it then you can use the field catalog wisely to display only not blank columns .