2013 Jun 12 9:12 AM
I'm fairly new to ABAP and i'm trying to delete entries from the internal table that don't contain certain value/s.
Below is a code that worked for me:
LOOP AT BASIS.
IF pa_WKZS = 'X' AND BASIS-ARBPL NE '2056'
DELETE BASIS.
ENDIF.
ENDLOOP.
If pa_WKZS is checked at selection I want it to only show ARBPL with value = 2056.
but how would I do the same for another checkbox that should only show 2301 2302 2303 for example. tried with strings but didn't have any luck. or am i approaching this from the wrong angle?
any help is appreciated!
2013 Jun 12 10:18 AM
Try below logic.
data: table1 type standard table of basis,
table2 type standard table of basis,
table3 type standard table of basis,
table4 type standard table of basis.
table1 = BASIS.
table2 = BASIS.
table3 = BASIS.
table4 = BASIS.
refresh basis.
if cb1 = 'X'.
DELETE table1 where ARBPL NE '2056'.
endif.
if cb2 = 'X'.
DELETE table2 where ARBPL NE '2031'.
endif.
if cb3 = 'X'.
DELETE table3 where ARBPL NE '2032'.
endif.
if cb4 = 'X'.
DELETE table4 where ARBPL NE '2033'.
endif.
append lines of table1 to basis.
append lines of table2 to basis.
append lines of table3 to basis.
append lines of table4 to basis.
Try below logic.
data: table1 type standard table of basis,
table2 type standard table of basis,
table3 type standard table of basis,
table4 type standard table of basis.
table1 = BASIS.
table2 = BASIS.
table3 = BASIS.
table4 = BASIS.
refresh basis.
if cb1 = 'X'.
DELETE table1 where ARBPL NE '2056'.
endif.
if cb2 = 'X'.
DELETE table2 where ARBPL NE '2031'.
endif.
if cb3 = 'X'.
DELETE table3 where ARBPL NE '2032'.
endif.
if cb4 = 'X'.
DELETE table4 where ARBPL NE '2033'.
endif.
append lines of table1 to basis.
append lines of table2 to basis.
append lines of table3 to basis.
append lines of table4 to basis.
2013 Jun 12 9:30 AM
Hey,
Your question is not too clear. Please explain in detail about 'another checkbox functionality'.
what i understood from your problem is that you want to restrict data on the basis of pa_WKZS and BASIS-ARBPL
for selection screen field, you can restrict the values by
AT SELECTION-SCREEN ON pa_WKZS .
** Here write a perform to restrict the values.
Or you can do the direct deletion by
IF pa_WKZS = 'X'.
DELETE BASIS where BASIS-ARBPL NE '2056'.
ENDIF.
(though NE should not be used for comparision, as it affects the performance)
2013 Jun 12 9:36 AM
Hi Aaron Karger,
Just try this instead of your code.
IF pa_wkzs = 'X' .
delete basis where ARBPL <> '2056' .
endif.
regards,
Madhumahesh.
2013 Jun 12 9:37 AM
2013 Jun 12 9:43 AM
Hi,
Try like this
LOOP AT BASIS.
IF pa_WKZS = 'X' .
DELETE BASIS WHERE BASIS-ARBPL NE '2056'.
ENDIF.
IF pa_WKZS_2 = 'X' .
DELETE BASIS WHERE BASIS-ARBPL NE '2301'
AND BASIS-ARBPL NE '2302'
AND BASIS-ARBPL NE '2303'.
ENDIF.
ENDLOOP.
2013 Jun 12 9:44 AM
2013 Jun 12 9:44 AM
HI Aaron,
do the following code,
if pa_wkzs = 'X
if pa_wkzs2 = 'X'
get data from basis where arbpl in r_arbpl. (define ranges for arbpl values.)
else.
get data from basis relating to first checkbox.
else.
get data from basis relating to second checkbox.
endif.'
2013 Jun 12 9:45 AM
Hi Aaron
Try the below code...
if pa_wkzs = 'X'.
Delete Basis where ARBPL NE '2056.
Elseif .... = 'X'.
Delete Basis where ARBPL NE '2301'.
Delete Basis where ARBPL NE '2302'.
Delete Basis where ARBPL NE '2303'.
endif.
Regards,
Suganya
2013 Jun 12 9:52 AM
Hi,
I think you have multiple check boxes on selection screen.
Say you have
checkbox1 2056
checkbox2 2301
checkbox3 2302
checkbox4 2303
create one RANGE say r_number using RANGES keyword
you have to take AT SELECTION SCREEN Event..in this
if checkbox1 EQ 'X'
r_number-low = '2056'.
r_number-sign = 'I'.
r_number-option = 'EQ'.
append r_number.
ENDIF.
if checkbox2 EQ 'X'
r_number-low = '2301'.
r_number-sign = 'I'.
r_number-option = 'EQ'.
append r_number.
ENDIF.
and so on for other check boxes..
Now in the logic for deleting entries from table BASIS.. do as following..
your table must be containing all records with field ARBPL
so write
DELETE BASIS where ARBPL NOT IN r_number.
please try this..
Regards
Tejas
Message was edited by: tejas patil
2013 Jun 12 9:53 AM
If you use multiple checkbox I think you can use case statement.
example, if you used for pa_wkzs for arbpl 2056, pa_wkzs1 for arbpl 2301, pa_wkzs2 for arbpl 2302
CASE 'X'.
WHEN PA_WKZS.
DELETE BASIS WHERE ARBPL NE '2056'.
WHEN PA_WKZS1.
DELETE BASIS WHERE ARBPL NE '2301'.
WHEN PA_WKZS2.
DELETE BASIS WHERE ARBPL NE '2302'.
ENDCASE.
Regards,
Ikrar
2013 Jun 12 10:18 AM
Try below logic.
data: table1 type standard table of basis,
table2 type standard table of basis,
table3 type standard table of basis,
table4 type standard table of basis.
table1 = BASIS.
table2 = BASIS.
table3 = BASIS.
table4 = BASIS.
refresh basis.
if cb1 = 'X'.
DELETE table1 where ARBPL NE '2056'.
endif.
if cb2 = 'X'.
DELETE table2 where ARBPL NE '2031'.
endif.
if cb3 = 'X'.
DELETE table3 where ARBPL NE '2032'.
endif.
if cb4 = 'X'.
DELETE table4 where ARBPL NE '2033'.
endif.
append lines of table1 to basis.
append lines of table2 to basis.
append lines of table3 to basis.
append lines of table4 to basis.
2013 Jun 12 10:26 AM
Hi Aaron,
Seems you need two level filtering.
Try this,
data : lt_tab1 "Internal table of type of structure of Basis Table
ls_basis " Work area of type of structure of Basis Table
If pa_1 = 'X'.
read table basis into ls_basis with key arbpl = '2056' "arbpl may need leading zeroes just check
if sy-subrc eq 0.
append ls_basis to lt_tab1.
endif.
elseif pa_2 = 'X'.
read table basis into ls_basis with key arbpl = '<Value 2>' "arbpl may need leading zeroes just check
if sy-subrc eq 0.
append ls_basis to lt_tab1.
endif.
elseif......
endif.
BR,
Ankit.
2013 Jun 12 10:44 AM
Are you speaking of checkboxes or of a radiobutton group, in second case the code could look like
CASE abap_true.
WHEN p_option1.
DELETE itab WHERE field NE value1.
WHEN p_option2.
DELETE itab WHERE field NE value2.
WHEN p_option3.
DELETE itab WHERE field NE value3.
WHEN OTHERS.
" etc.
ENDCASE.With independant checkboxes, a delete where statement should not be adequate, try a loop like
LOOP AT itab ASSIGNING <fs>.
CHECK NOT ( p_option1 EQ abap_true AND <fs>-field EQ value1 ). " valid ercord, next
CHECK NOT ( p_option2 EQ abap_true AND <fs>-field EQ value2 ).
CHECK NOT ( p_option3 EQ abap_true AND <fs>-field EQ value3 ).
DELETE itab." invalide record, delete
ENDLOOP.Regards,
Raymond
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |