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: 

MODIFY ... TRANSPORTING (FIELD_1)...(FIELD_n) dynamically

sinan_keklik
Associate
Associate
0 Kudos
2,494

Hi,

why does this not work. I want to set Fields to be updated dynamically. Sometimes I want to update Field 1, another time Field 2 or 3.

In the F1 HELP is written that an initial dynamic Field will be ignored. But in the SAP HELP is written that an invalid name triggers a dump.

I get a dump. Any ideas how i can get this Code to ignore initial dynamic Fields?

DATA lt_table TYPE HASHED TABLE OF EORD WITH UNIQUE KEY MANDT MATNR WERKS ZEORD.

DATA lt_table2 TYPE HASHED TABLE OF EORD WITH UNIQUE KEY MANDT MATNR WERKS ZEORD.

DATA l_ERDAT TYPE fieldname .

DATA l_ERNAM TYPE fieldname .

DATA l_VDATU TYPE fieldname .

LOOP AT lt_table INTO ls_table.

IF NOT ls_table-ERDAT IS INITIAL.

l_ERDAT = 'ERDAT' .

ENDIF.

IF NOT ls_table-ERNAM IS INITIAL.

l_ERNAM = 'ERNAM' .

ENDIF.

IF NOT ls_table-VDATU IS INITIAL.

l_VDATU = 'VDATU' .

ENDIF.

MODIFY TABLE lt_table2 FROM ls_table TRANSPORTING

(l_ERDAT)

(l_ERNAM)

(l_VDATU)

.

ENDLOOP.

Sinan

4 REPLIES 4

Former Member
0 Kudos
222

The dump could be because you have omitted the INDEX addition for the MODIFY statement, and the program does not know which line is to be updated.

An F1 on the MODIFY statement should tell you about the WHERE and the INDEX additions.

Hope this helps.

Sudha

0 Kudos
222

In the dump is written that the table with the type eord has no " " Component. I use HASHED TABLES. Index operations are forbidden with HASHED Tables.

Sinan

former_member583013
Active Contributor
0 Kudos
222

> LOOP AT lt_table INTO ls_table.

> IF NOT ls_table-ERDAT IS INITIAL.

> l_ERDAT = 'ERDAT' .

> ENDIF.

>

> IF NOT ls_table-ERNAM IS INITIAL.

> l_ERNAM = 'ERNAM' .

> ENDIF.

>

> IF NOT ls_table-VDATU IS INITIAL.

> l_VDATU = 'VDATU' .

> ENDIF.

>

> MODIFY TABLE lt_table2 FROM ls_table TRANSPORTING

> (l_ERDAT)

> (l_ERNAM)

> (l_VDATU)

> .

> ENDLOOP.

If ERDAT, ERNAM or VDATU are empty, you not passing values to the variables....So, in that case, you going to do something like...


MODIFY TABLE lt_table2 FROM ls_table TRANSPORTING
ERDAT SPACE VDATU

And of course....SPACE is not a valid field.....You need to pass all fields no matter is they're empty or not....

Greetings,

Blag.

0 Kudos
222

Thanks for the answers.

Any idea how I can handle this without to write for each case a MODIFY.

Sinan