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: 

FILTER THE INTERNAL TABLE DATA BASED ON THE SELECTION SCREEN VALUES

Former Member
0 Kudos

HI EXPERTS .

COULD YOU PLZ TELL ME HOW TO FILTER THE DATA OF INTERNAL TABLE

BASED ON THE SELECTION SCREEN VALUES.

THE BELOW CODE IS NOT WORKING .

CAN YOU TELL ME WITH READ STATEMENT.

LOOP AT IT_MAIN1.

IF ( IT_MAIN1-TDLNR = S_TDLNR ) AND

(IT_MAIN1-ROUTE = S_ROUTE ).

APPEND IT_MAIN1 TO IT_FINAL.

ENDIF.

ENDLOOP.

THANKS

SURESH

8 REPLIES 8

former_member223537
Active Contributor
0 Kudos

<b>LOOP AT IT_MAIN1 WHERE TDLNR IN S_TDLNR AND

ROUTE IN S_ROUTE .</b>

APPEND IT_MAIN1 TO IT_FINAL.

ENDIF.

ENDLOOP.

0 Kudos

HI THANKS TO YOUR RESPONCE.

BUT IN OUR PROJECT AS PER THE CODING STD'S ,

LOOP WITH WHERE CONDITION IS RESTRICTED .

COULD YOU PLZ GIVE ME ONE MORE IDEA.

THANKS

Former Member
0 Kudos

Hello,

Try this

LOOP AT IT_MAIN1 WHERE TDLNR = S_TDLNR AND ROUTE = S_ROUTE .

APPEND IT_MAIN1 TO IT_FINAL.

ENDLOOP.

Regards,

LIJO

Former Member
0 Kudos

Hello Suresh,

LOOP AT IT_MAIN1.

IF ( IT_MAIN1-TDLNR <b>IN</b> S_TDLNR ) AND

(IT_MAIN1-ROUTE <b>IN</b> S_ROUTE ).

APPEND IT_MAIN1 TO IT_FINAL.

ENDIF.

ENDLOOP.

Select option is an internal table with for fields: sign, option, low and high.

you need to check the value in the internal table.

U can use IT_MAIN1-TDLNR = S_TDLNR-LOW. (If you enter the value in left field of select option.), But it is not suggestable.

Or else.. U can validate this in loop statement itself.

LOOP AT IT_MAIN1 where IT_MAIN1-TDLNR <b>IN</b> S_TDLNR AND

IT_MAIN1-ROUTE <b>IN</b> S_ROUTE .

APPEND IT_MAIN1 TO IT_FINAL.

ENDLOOP.

Reward If Helpful.

Regards

--

Sasidhar Reddy Matli.

Message was edited by:

Sasidhar Reddy Matli

Former Member
0 Kudos

Hi Sursh ,

Try following code ,

LOOP AT IT_MAIN1.

IF ( IT_MAIN1-TDLNR = S_TDLNR-LOW OR

IT_MAIN1-TDLNR = S_TDLNR-HIGH )

AND

(IT_MAIN1-ROUTE = S_ROUTE-LOW OR

IT_MAIN1-ROUTE = S_ROUTE-HIGH ).

APPEND IT_MAIN1 TO IT_FINAL.

ENDIF.

ENDLOOP.

former_member223537
Active Contributor
0 Kudos

LOOP AT IT_MAIN1.

<b>read table s_tdlnr with key tdlnr = it_main1-tdlnr.</b>

if sy-subrc eq 0.

<b>read table s_route with key route = it_main1-route.</b>

if sy-subrc eq 0.

APPEND IT_MAIN1 TO IT_FINAL.

ENDIF.

endif.

ENDLOOP.

Former Member
0 Kudos

hi,

try like this,

THIS BELOW CODE ONLY WORKS WHEN IT_MAIN1 IS A INTERNAL TABLE WITH HEADER LINE.

LOOP AT IT_MAIN1 WHERE TDLNR = S_TDLNR AND ROUTE = S_ROUTE .

IF SY-SUBRC EQ 0.

APPEND IT_MAIN1 TO IT_FINAL.

ELSE.

MESSAGE 'NO RECORDS FOUND' TYPE 'I'.

ENDIF.

ENDLOOP.

IF HELPFUL REWARD SOME POINTS.

WITH REGARDS,

SURESH ALURI.

Former Member
0 Kudos

Hi Suresh,

For select-options, you should use IN instead of equal sign.

Try this.

LOOP AT IT_MAIN1.

IF ( IT_MAIN1-TDLNR <b>IN</b> S_TDLNR ) AND

(IT_MAIN1-ROUTE <b>IN</b> S_ROUTE ).

APPEND IT_MAIN1 TO IT_FINAL.

ENDIF.

ENDLOOP.

or you can try using below code.

DELETE IT_MAIN1

WHERE TDLNR NOT IN S_TDLNR

OR ROUTE NOT IN S_ROUTE.

APPEND LINES OF IT_MAIN1 TO IT_FINAL.