‎2013 Oct 24 8:29 PM
Hi,
I'm using dynamic itab and now I need to update several rows with same values - these rows has also the same value in "key column". I
For classic itab I can use:
modify itab from work_area transportating field1 field2 where pspnr = wa-pspnr.
for dynamic I tried:
modify <itab> from <work_area> transportating ('FIELD1') ('FIELD2) where ???? - how to write where condition? I need to update all rows with same PSPNR value in work area...
Many thanks Jiri
‎2013 Oct 24 9:52 PM
MOVE 'pspnr' TO LV_STRING.
ASSIGN COMPONENT lv_string OF STRUCTURE <itab> TO <fs_symbol>.
in your WHERE statement use <fs_symbol> = XXX
‎2013 Oct 24 9:52 PM
MOVE 'pspnr' TO LV_STRING.
ASSIGN COMPONENT lv_string OF STRUCTURE <itab> TO <fs_symbol>.
in your WHERE statement use <fs_symbol> = XXX
‎2013 Oct 24 10:07 PM
Hi Carlos,
for this code (I have more rows with same PSPNR value in itab and I want to update them all):
ASSIGN COMPONENT 'PSPNR' OF STRUCTURE <fs_data> TO <fs_cell>.
MODIFY <gt_fin_spp> FROM <fs_data> TRANSPORTING ('BELNR') ('STATUS') WHERE <fs_cell> = <fs_cell>.
Still getting error:
| In "LOOP ... WHERE ..." the row type of the table must be statically |
| defined . |
Thanks Jiri
‎2013 Oct 24 11:00 PM
Hello Jiri,
maybe this can help you:
" <fs_tab> is a field symbol that is an alias to dynamic internal table
LOOP AT <fs_tab> ASSIGNING <fs_line>.
ASSIGN COMPONENT 'PSPNR' OF STRUCTURE <fs_line> TO <fs_field>.
IF <fs_field> EQ 'VAL'. " Field PSPNR has value VAL
" Modify fields FIELD1 and FIELD2, for example
ASSIGN COMPONENT 'FIELD1' OF STRUCTURE <fs_line> TO <fs_field>.
<fs_field> = 1000.
ASSIGN COMPONENT 'FIELD2' OF STRUCTURE <fs_line> TO <fs_field>.
<fs_field> = 2000.
ENDIF.
ENDLOOP.
Hope it helps
‎2013 Oct 25 7:18 AM
Hi David,
this is one of the other possibilities, but what about performance?
I'm loopiing first dynamic itab with more than 50 000 lines:
lv_string = 'PSPNR'
LOOP AT <fs_tab> ASSIGNING <fs_line>.
AT END OF (lv_string)
*Do some CO accoutning for WBS elements
*so here I have to loop the same table:
LOOP AT <fs_tab> ASSIGNING <fs_line2>.
ASSIGN COMPONENT 'PSPNR' OF STRUCTURE <fs_line> TO <fs_field>.
ASSIGN COMPONENT 'PSPNR OF STRUCTURE <fs_line2> TO <fs_field2>.
IF <fs_field> = <fs_field2>.
ASSIGN COMPONENT 'STATUS' OF STRUCTURE <fs_line> TO <fs_field>.
<fs_field> = 'something'.
ENDIF.
ENDLOOP.
ENDAT.
ENDLOOP
Code above will work, but what about performance?
Thanks Jiri
‎2013 Nov 05 3:16 AM
Hi Jiri,
You can try like this,
ASSIGN COMPONENT 'PSPNR' OF STRUCTURE <fs_data> TO <fs_cell>.
MODIFY <gt_fin_spp> FROM <fs_data> TRANSPORTING ('BELNR') ('STATUS')
WHERE ( 'PSPNR = <fs_cell>').
if you need to specify two conditions in the where just specify like this without space before open and closing quotes within the brackets.
ASSIGN COMPONENT 'PSPNR' OF STRUCTURE <fs_data> TO <fs_cell>.
ASSIGN COMPONENT 'STATUS' OF STRUCTURE <fs_data> TO <fs_status>.
MODIFY <gt_fin_spp> FROM <fs_data> TRANSPORTING ('BELNR') ('STATUS')
WHERE ( 'PSPNR = <fs_cell> AND STATUS = `APPROVED`').
Regards,
Uma
‎2013 Oct 25 5:30 AM
Hi
FIELD-SYMBOLS : <lt_pay_data> TYPE STANDARD TABLE,
<fs_data> TYPE any.
loop at <lt_pay_data> ASSIGNING <fs_data>.
<fs_data>-variable = '123'.
endloop.
With regards
Suneesh
‎2013 Oct 25 7:21 AM
Hi Suneesh,
your code will not work (syntax error), because:
<fs_data>-variable = '123'.
Table is dynamic, so you cannot directly access components of table line by column name. You have to use:
ASSIGN COMPONENT 'STATUS' OF STRUCTURE <fs_line> TO <fs_field>.
Another problem with your code is you will change all rows in the table.
Thanks Jiri