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

dynamic internal table

Former Member
0 Likes
543

How to apply condition to the dynamic internal table.

how to sort a dynamic internal table based on fields.

i m having some records in internal table.How to apply condition to tht dynamically & append to another table.

loop at IT assigning <l> (here i have to give where condition).

endloop.

thanks in advance.

1 ACCEPTED SOLUTION
Read only

former_member194669
Active Contributor
0 Likes
518

Hi,

You cannot give a where condition in the loop for <fs>.

Check this


        loop at i_fcat assigning <fcat>.
          assign component <fcat>-col_id of structure <xtab> to <l_f3>.
          read table i_final_cat3 assigning <final_cat3> with key
                                        tabname = p_table
                                        fieldname = <fcat>-fieldname.
          if sy-subrc eq 0.
            assign component <final_cat3>-col_id of
                                      structure <final_wa3> to <l_f4>.
            write : <l_f3> to <l_f4>.
          endif.
        endloop.

aRs

4 REPLIES 4
Read only

former_member194669
Active Contributor
0 Likes
519

Hi,

You cannot give a where condition in the loop for <fs>.

Check this


        loop at i_fcat assigning <fcat>.
          assign component <fcat>-col_id of structure <xtab> to <l_f3>.
          read table i_final_cat3 assigning <final_cat3> with key
                                        tabname = p_table
                                        fieldname = <fcat>-fieldname.
          if sy-subrc eq 0.
            assign component <final_cat3>-col_id of
                                      structure <final_wa3> to <l_f4>.
            write : <l_f3> to <l_f4>.
          endif.
        endloop.

aRs

Read only

0 Likes
518

thanks.

but how to filter the data without where condition.

In read statement also i cant give where condition.

i want to fetch the record with condition where total < 60 & append it in another table.

can u give an example

Message was edited by:

Maya Vinothini

Read only

marcelo_ramos1
SAP Mentor
SAP Mentor
0 Likes
518

Hi,

Try this, maybe it's usefull for you.

DATA: t_mara TYPE TABLE OF mara WITH HEADER LINE.

FIELD-SYMBOLS <line> TYPE ANY.

FIELD-SYMBOLS <field> TYPE ANY.

FIELD-SYMBOLS <table> TYPE table.

START-OF-SELECTION.

SELECT *

FROM mara

UP TO 20 ROWS

INTO TABLE t_mara.

ASSIGN t_mara-matnr TO <field>.

SORT t_mara BY <field>.

LOOP AT t_mara ASSIGNING <line>

WHERE ERSDA le sy-datum.

write: / <line>.

ENDLOOP.

______________________________________________

Else, you can try this.

ASSIGN t_mara[] TO <table>.

ASSIGN t_mara TO <line>.

ASSIGN t_mara-ersda TO <field>.

LOOP AT <table> INTO <line>.

IF <field> LE sy-datum.

...

ELSE.

CONTINUE.

ENDIF.

ENDLOOP.

Regards.

Marcelo Ramos

Read only

former_member194669
Active Contributor
0 Likes
518

Hi,

For example if your TOTAL field is in 4 th position then


loop at i_fcat assigning <fcat>.
     assign component 4 of structure <xtab> to <l_f3>.
         write : <l_f3> to <l_f4>.
         if <l_f4> ge 60
             <<<<< move value to internal table
         endif.
endloop.

aRs