2018 Oct 04 5:00 PM
Hi everyone,
I have a internal table having 17 records
I need to delete two rows based on two field column values
For example:
Condition is , If movement type-bwart is 102 and its document number-belnr is initial, it shud check 101 movement type and if its document number is also initial.
It should delete both the line items from the internal table.How could we achieve this?
Hi everyone,
I have a internal table having 17 records
I need to delete two rows based on two field column values
For example:
Condition is , If movement type-bwart is 102 and its document number-belnr is initial, it shud check 101 movement type and if its document number is also initial.
It should delete both the line items from the internal table.How could we achieve this?
2018 Oct 04 5:18 PM
Hi,
I modified- check this:
Loop at it_tab into data(ls_tab1) where bwart = 102 and belnr = ' '.
Lv_tabix1 = sy-tabix.
Read it_tab into data(ls_tab2) with key 101 and belnr = space..
if sy-subrc is initial.
lv_tabix2 = sy-tabix.
Delete it_tab index index lv_tabix1. " delete 102
Delete it_tab index index lv_tabix2. " delete 101
endif.
Endloop.
Thanks,
Mohan
2018 Oct 04 5:27 PM
Hi Mohan,
That is not my requirement.
I need to check first movement type 102 and it's document number , if it's inital and then I should check 101 and it's document number.
If both document number is initial , I will delete both the rows
2018 Oct 04 6:05 PM
* Syntax may be wrong, please rewrite yourself...
LOOP AT ITAB ASSIGNING <FS> WHERE BWART = '102'
AND BELNR IS INITIAL.
READ TABLE ITAB TRANSPORTING NO FIELDS WITH KEY BWART = '101'
BELNR = ' '.
IF SY-SUBRC EQ 0.
FLAG = 'X'.
ENDIF.
ENDLOOP.
IF FLAG EQ ABAP_TRUE.
DELETE ITAB WHERE BWART = '102' AND '101'.
ENDIF.
2018 Oct 05 1:11 AM
SORT: <internal_table> BY <primary_key>.
READ TABLE <internal_table> INTO <work_area1> WITH KEY BWART = '102'
BELNR = space
BINARY SEARCH.
IF sy-subrc EQ 0.
READ TABLE <internal_table> INTO <work_area2> WITH KEY BWART = '101'
BELNR = space
BINARY SEARCH.
IF sy-subrc EQ 0.
DELETE <work_area1> FROM <internal_table>.
DELETE <work_area2> FROM <internal_table>.
ENDIF.
ENDIF.
2018 Oct 05 3:11 AM
I think there are alot of solution for this, just add one of mine 🙂
LOOP AT itab INTO wa group by ( vbeln = wa-vbeln ) ASSIGNING <fs_grp_key>.
IF <fs_grp_key>-vbeln IS INITIAL.
LOOP AT GROUP <fs_grp_key> INTO wa2.
IF wa2-bwart = '102' AND line_exist( <fs_grp_key>[ bwart = '101' ] ).
ELSE.
it_final = VALUE #( BASE ( it_final ) ( wa2 ) ).
ENDIF.
ENDLOOP.
ELSE.
it_final = VALUE #( BASE ( it_final ) FOR m in GROUP <fs_grp_key> ( m ) ).
ENDIF.
ENDLOOP.
2018 Oct 18 12:13 PM
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |