cancel
Showing results for 
Search instead for 
Did you mean: 

How to delete multiple empty lines in item assignment block in WebUI

Former Member
0 Kudos

Hi Experts,

   When i am reading 'BTAdminI' context node data, I am getting empty lines along with data. I can able to delete only one empty lines when its executing second empty line its failing in loop. Can you suggest me how can i delete multiple empty lines. I am using below code.

DATA: lr_entity1           TYPE REF TO cl_crm_bol_entity,

        lr_current          TYPE REF TO if_bol_bo_property_access,

        lr_iterator         TYPE REF TO if_bol_bo_col_iterator,

        lv_strukname        TYPE strukname,

        dref                TYPE REF TO data,

        lv_thtmlb_tableview TYPE REF TO cl_thtmlb_table_view,

        lr_cn               TYPE REF TO cl_bsp_wd_context_node_tv,

        cr_mixed_node_tv    TYPE REF TO cl_bsp_wd_mixed_node.

    FIELD-SYMBOLS: <fs_line_structure> TYPE data.

    lr_iterator = me->typed_context->btadmini->collection_wrapper->get_iterator( ).

    TRY.

        lr_current = lr_iterator->get_first( ).

      CATCH cx_root.

    ENDTRY.

    WHILE lr_current IS BOUND.

      lr_entity1 ?= lr_current.

      CHECK lr_entity1 IS BOUND.

      lr_entity1->get_attr_struct_name( RECEIVING rv_result = lv_strukname ).

      IF lv_strukname IS NOT INITIAL.

        CREATE DATA dref TYPE (lv_strukname).

        ASSIGN dref->* TO <fs_line_structure>.

        IF <fs_line_structure> IS ASSIGNED.

          lr_current->get_properties( IMPORTING es_attributes = <fs_line_structure> ).

          IF <fs_line_structure> IS INITIAL.

            me->typed_context->btadmini->collection_wrapper->remove( lr_current ).

            EXIT.

          ENDIF.

        ENDIF.

      ENDIF.

      TRY.

          lr_current = lr_iterator->get_next( ).

        CATCH cx_root.

      ENDTRY.

    ENDWHILE.

Accepted Solutions (1)

Accepted Solutions (1)

dharmakasi
Active Contributor
0 Kudos

Hi Nitish,

I just curious to know why would you use EXIT statement after deleting first empty line?

System will not continue the loop after deleting the first empty line.

Regards,

Dharmakasi.

kumar5
Active Contributor
0 Kudos

Good catch @dharmakasi. I missed this one while looking into the code.:)

And Nitish as suggested by Dharmakasi you should not use Exit after deleting  the first empty row. It will get you out of the loop after deleting the first empty row.

Thanks

Kumar Gaurav. 

Former Member
0 Kudos

Hi Dharmakasi,

   Thanks for your reply. Actually in code, i have commented that 'EXIT' statement. I forgot to update while copying the code.

Thanks & Regards,

Nitish

dharmakasi
Active Contributor
0 Kudos

Hi Nitish,

Ok cool..:)

Is your issue got fixed or still persisting?

Best Regards,
Dharmakasi.

Former Member
0 Kudos

Hi Dharmakasi,

  My issue not yet solved. Still searching for solution.

Thanks & Regards,

Nitish

dharmakasi
Active Contributor
0 Kudos

Hi Nitish,

Try below code instead of your code,

Data:

lt_empty_lines  TYPE TABLE OF REF TO cl_crm_bol_entity,

lr_entity TYPE REF TO cl_crm_bol_entity.


After getting collection from BTadmini use the below code.

    

lr_iterator ?= lr_coll->get_iterator( ).


    lr_entity ?= lr_iterator->get_first( ).

   
WHILE lr_entity IS BOUND.

     
IF lr_entity->is_send_active( ) EQ abap_false.

       
APPEND lr_entity TO lt_empty_lines.

     
ENDIF.

      lr_entity ?= lr_iterator
->get_next( ).

   
ENDWHILE.

   
LOOP AT lt_empty_lines INTO lr_entity.

      typed_context
->btadmini->collection_wrapper->remove( lr_entity ).

      lr_entity
->delete( ).

   
ENDLOOP.

Best Regards,
Dharmakasi.

Former Member
0 Kudos

Hi Dharmakasi,

   My issue has been solved. Thanks a lot.

Thanks & Regards,

Nitish

Answers (1)

Answers (1)

kumar5
Active Contributor
0 Kudos

Hi ,

Use below statement before endwhile:

UNASSIGN <fs_line_structure>.

ENDWHILE.

Thanks

Kumar Gaurav

Former Member
0 Kudos

Hi Gaurav,

  Thanks a lot for your quick reply. I tried with above statement but, its not working.

Ex. 3 records and 3 empty lines. Total 6 entries in 'BTAdminI' context node. its deleting only first 2 empty rows.

Thanks & Regards,

Nitish.