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 with modifying dynamic internal table

Former Member
0 Likes
860

Hi All,

Im populating a dynamic internal table from the static internal table where the dynamic internal table has columns that repeats based on the selection criteria. Eg: static internal table columns - ov,cf,... dynamic internal table columns - ov1,cf1, ov2,cf2,...

While populating value to dynamic structure, im changing the column names ov1,ov2,cf1,cf2... to ov,cf,.. so that the corresponding fieldname will be recognized in the static internal table otherwise the 'assign component' statement fails because dynamic fieldname will not match exactly with static fieldname. Now the field-symbol pointing to the dynamic internal table is fetching the correct value but while modifying the internal table, its modifying all the rows.

Say, the value for column ov1 = '1', ov2 = '2'. The structure captures these values one at a time, so it becomes ov1 = '0' and ov2 = '2'. and it wrongly modifies both the columns for a particular row and the value for ov1 becomes '0' instead of required value '1' when i need to modify only the column 'ov2'.

Is it possible to use 'TRANSPORTING' functionality with the dynamic internal table for modifying the required column alone? Note: the no of rows in my alv output is fixed.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
546

Hi Sudharsana,

It is possible to use TRANSPORTING options with dynamic internal tables.

case1:

MODIFY <fs_itab> INDEX sy-tabix

FROM <fs_wa>

TRANSPORTING ('OV2')

('CF2').

You need to use brackets and quotes, if you know field name in advance.

case 2:

MODIFY <fs_itab> INDEX sy-tabix

FROM <fs_wa>

TRANSPORTING (w_column). "assuming w_column is dynamically populated with the column name.

You need to use brackets, if you determine the fieldname at run time.

Regards,

Nisha Vengal.

3 REPLIES 3
Read only

Sm1tje
Active Contributor
0 Likes
546

I'm lost, maybe you can give an example here with both internal tables including some coding. It sounds like your pointer is not correct since it points to a whole internal table and not just a row (or even field).

To answer your question: I don't know of way of using TRANSPORTING combined with ASSIGNING.

Read only

Former Member
0 Likes
546

Hi ,

After studying your problem I want to give some logic like below :

Suppose your static table say s_itab and your dynamic table say d_itab.

field-symbols : <dyn_wa>, <FIELD1 > < FIELD2>, <key1>.

DATA : WA LIKE S_ITAB.

CREATE DATA IT_LINE LIKE LINE OF <D_ITAB>.

ASSIGN IT_LINE->* TO <DYN_WA>.

LOOP AT S_ITAB.

move-corresponding S_ITAB TO <DYN_WA>.

ASSIGN COMPONENT 'KEY_CODE' OF STRUCTURE <dyn_wa> TO <KEY1>. "uSE KEY FOR READ STATIC TABLE

ASSIGN COMPONENT FN1 OF STRUCTURE <dyn_wa> TO <field1>. " WHERE FN1 = 'OV'

ASSIGN COMPONENT FN2 OF STRUCTURE <dyn_wa> TO <field2>. " WHERE FN2 = 'OC' etc

ASSIGN COMPONENT FN3 OF STRUCTURE <dyn_wa> TO <field3>.

ASSIGN COMPONENT FN4 OF STRUCTURE <dyn_wa> TO <field4>.

READ TABLE S_ITAB WITH KEY KEY_CODE = <KEY1> INTO WA.

IF SY-SUBRC = 0.

CLEAR WA.

READ TABLE IT_TRANS WITH KEY KEY_CODE = <KEY1> INTO WA.

<field1> = WA-PRODUCTION.

<field2> = WA-LOCAL_SALE.

<field3> = WA-EXPORT.

<field4> = WA-LOCAL_SALE + WA-EXPORT.

MODIFY <D_ITAB> FROM <DYN_WA> INDEX CNT. "tAKE A VARIABLE FOR INDEXING

ENDIF.

ENDLOOP.

HOPE THIS WILL RESOLVE YOUR PROBLEM.

THANKS

Edited by: CONTACTSANKU on Nov 30, 2009 1:10 PM

Read only

Former Member
0 Likes
547

Hi Sudharsana,

It is possible to use TRANSPORTING options with dynamic internal tables.

case1:

MODIFY <fs_itab> INDEX sy-tabix

FROM <fs_wa>

TRANSPORTING ('OV2')

('CF2').

You need to use brackets and quotes, if you know field name in advance.

case 2:

MODIFY <fs_itab> INDEX sy-tabix

FROM <fs_wa>

TRANSPORTING (w_column). "assuming w_column is dynamically populated with the column name.

You need to use brackets, if you determine the fieldname at run time.

Regards,

Nisha Vengal.