Application Development and Automation 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: 
Read only

Problem while filtering the data

Former Member
0 Likes
500

Dear All,

I want to display a list of Material Nos and their descriptions for whom descriptions does not have any words like "NOT USE" or "DISCONTINUED" or "DELETE".

I have fetched all the data in an internal table but is not able to filter the data based on the description filter.

Please guide me on this.

Warm Regards,

N.Jain

4 REPLIES 4
Read only

Former Member
0 Likes
466

Nishu,

Take strings to store all the 3 conditions you want to filter out as below.

data: s1(7) value 'NOT USE',

S2(12) VALUE 'DISCONTINUED',

S3(6) VALUE 'DELETE'.

*Say the internal table in which you taken the entire data ( Before filtering is ITAB )

*Where say again the ITAB is an internal table with header line.

DATA:BEGIN OF ITAB OCCURS 0,

MARA LIKE MAKT-MARA,

MAKTX LIKE MAKT-MAKTX,

.

.

END OF ITAB.

DATA: ITAB1 LIKE ITAB OCCURS 0 WITH HEADER LINE.

loop at itab where maktx NE S1 OR MAKTX NE S2 OR MAKTX NE S3.

ITAB1 = ITAB.

APPEND ITAB1.

CLEAR ITAB.

CLEAR ITAB1.

ENDLOOP.

Reward with out fail if found use full.

Cheers,

Rama.

Read only

rajesh_akarte2
Active Participant
0 Likes
466

Hi Nishu,

Go through following sample code.

DATA:BEGIN OF t_comp OCCURS 0,

posnr LIKE resb-posnr,

matnr LIKE resb-matnr,

revlv LIKE resb-revlv,

END OF t_comp.

t_comp-posnr = '0001'.

t_comp-matnr = 'mat1'.

t_comp-revlv = 'A'.

APPEND t_comp.

t_comp-posnr = '0002'.

t_comp-matnr = 'DELETE HI'.

t_comp-revlv = 'B'.

APPEND t_comp.

t_comp-posnr = '0003'.

t_comp-matnr = 'mat3'.

t_comp-revlv = 'A'.

APPEND t_comp.

t_comp-posnr = '0004'.

t_comp-matnr = 'mat4'.

t_comp-revlv = 'C'.

APPEND t_comp.

LOOP AT t_comp.

IF t_comp-matnr NS 'DELETE'.

WRITE:/ t_comp-posnr,6 t_comp-matnr.

ENDIF.

ENDLOOP.

Reward if helpful.

Regards,

Rajesh Akarte

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
466

get the data to itab.

loop at itab.

if itab-maktx cs 'NOT USE'.

move to itab2.

elseif itab-maktx cs 'DISCONTINUED'.

move to itab2.

elseif itab-maktx cs 'DELETE'.

move to itab2.

endif.

endloop.

reward if useful.....:-)

Read only

0 Likes
466

Hi,

Better ignore my previus post please follow the enclosed code this will serve you better, for before I had little misunderstanding with your requirement.

Take strings to store all the 3 conditions you want to filter out as below.

data: s1(7) value 'NOT USE',

S2(12) VALUE 'DISCONTINUED',

S3(6) VALUE 'DELETE',

r1(7),

r2(12),

r3(6).

*Say the internal table in which you taken the entire data ( Before filtering is ITAB )

*Where say again the ITAB is an internal table with header line.

DATA:BEGIN OF ITAB OCCURS 0,

MARA LIKE MAKT-MARA,

MAKTX LIKE MAKT-MAKTX,

.

.

END OF ITAB.

DATA: ITAB1 LIKE ITAB OCCURS 0 WITH HEADER LINE.

loop at itab .

r1 = itab-maktx + 0(6).

r2 = itab-maktx + 0(11).

r3 = itab-maktx + 0(5).

if ( (r1 NE s1) or (r2 NE s2) or (r3 NE s3) ).

ITAB1 = ITAB.

APPEND ITAB1.

CLEAR ITAB.

CLEAR ITAB1.

endif.

ENDLOOP.

Reward with out fail if found use full.

Cheers,

Rama.