‎2009 Jan 27 7:34 AM
Hi,
Below is my code.
LOOP AT <t_dyntable_ord> ASSIGNING <t_line_tmp>." WHERE check EQ 'X'.
ASSIGN COMPONENT 1 OF STRUCTURE <t_line_tmp> to <tmp>.
if <tmp> = 'X'.
lv_counter = lv_counter + 1.
" LOOP AT it_index_rows INTO wa_index_rows.
ASSIGN COMPONENT 2 OF STRUCTURE <t_line_tmp> to <mat>.
SET PARAMETER ID 'MAT' FIELD <mat>.
"READ TABLE it_prd_pld INTO wa_prd_pld WITH KEY
SET PARAMETER ID 'WRK' FIELD p_werks.
CALL TRANSACTION 'MD02' AND SKIP FIRST SCREEN.
endif.
ENDLOOP.Can we have a condition while looping the dynamic internal table?
In the above code where condition is not working for me.
I solved the problem by inserting if condition ->
ASSIGN COMPONENT 1 OF STRUCTURE <t_line_tmp> to <tmp>.
if <tmp> = 'X'.but this will cause the performance problem.
Please sujjest.
Regards,
Prathap
‎2009 Jan 27 10:54 AM
Did you try using the WHERE clause of the LOOP AT statement ?
I am not sure, however, if you can access one of the components of the assigned worked area.
Hope it helps
Avraham
‎2009 Jan 27 11:25 AM
If you've an internal table with the structure of your dynamic table u can use it in order to change the data:
DATA: <WA> TYPE ANY,
<FIELD> TYPE ANY.
LOOP AT <ITAB> ASSIGNING <WA>.
LOOP AT STRUT_TAB WHERE FIELDNAME = .......
ASSIGN COMPONENT STRUT_TAB-FIELDNAME OF STRUCTURE <WA> TO <FIELD>.
CASE STRUT_TAB-FIELDNAME.
WHEN ......... <FIELD> = ......
WHEN ........ <FIELD> = ......
ENDCASE.
ENDIF.
ENDLOOP.
ENDLOOP.
or try like this.
LOOP AT <dyn_table> INTO <dyn_wa>.
DO.
ASSIGN COMPONENT sy-index
OF STRUCTURE <dyn_wa> TO <dyn_field>.
IF sy-subrc 0.
EXIT.
ENDIF.
IF sy-index = 1.
WRITE:/ <dyn_field>.
ELSEIF sy-index = 4.
<dyn_field> = 'ABCD'.
WRITE: <dyn_field>.
ELSE.
WRITE: <dyn_field>.
ENDIF.
ENDDO.
ENDLOOP.
i hope you get some idea
check this link too
‎2009 Jan 27 11:35 AM
I have 1000s of records in my internal table, but only few of them have the status code checked.
I need to select only those records for which the status if 'X'.
if i loop through the internal table it follows 1000s of iterations,
My code is now doing that.
I tried inserting where clause in LOOP AT statement but it din't work.
Please suggest how this can be done?
Regards,
Prathap
‎2009 Feb 26 3:48 PM
‎2009 Feb 26 4:13 PM