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

Modify

Former Member
0 Likes
778

Hi ,

1. How to modify an internal table without using modify statement ?

2. How we can create a dynamoic data reference ?

Kumar

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
710

Kumar,

2.

Creating Data Objects Dynamically

All of the data objects that you define in the declaration part of a program using statements such as DATA are created statically, and already exist when you start the program. To create a data object dynamically during a program, you need a data reference variable and the following statement:

CREATE DATA <dref> TYPE <type>|LIKE <obj>.

This statement creates a data object in the internal session of the current ABAP program. After the statement, the data reference in the data reference variable <dref> points to the object. The data object that you create does not have its own name. You can only address it using a data reference variable. To access the contents of the data object, you must dereference the data reference.

You must specify the data type of the object using the TYPE or LIKE addition. In the TYPE addition, you can specify the data type dynamically as the contents of a field (this is not possible with other uses of TYPE).

CREATE DATA <dref> TYPE (<name>).

Here, <name> is the name of a field that contains the name of the required data type.

1. IF you want to change the values without modify:

First take that row into other work area change whatever values you want to change in work area by using "MOVE" statement ,delete previous row from internal table and by using "INSERT" statement insert the workarea row into that internal table..

Don't forget to reward if useful...

7 REPLIES 7
Read only

Former Member
0 Likes
711

Kumar,

2.

Creating Data Objects Dynamically

All of the data objects that you define in the declaration part of a program using statements such as DATA are created statically, and already exist when you start the program. To create a data object dynamically during a program, you need a data reference variable and the following statement:

CREATE DATA <dref> TYPE <type>|LIKE <obj>.

This statement creates a data object in the internal session of the current ABAP program. After the statement, the data reference in the data reference variable <dref> points to the object. The data object that you create does not have its own name. You can only address it using a data reference variable. To access the contents of the data object, you must dereference the data reference.

You must specify the data type of the object using the TYPE or LIKE addition. In the TYPE addition, you can specify the data type dynamically as the contents of a field (this is not possible with other uses of TYPE).

CREATE DATA <dref> TYPE (<name>).

Here, <name> is the name of a field that contains the name of the required data type.

1. IF you want to change the values without modify:

First take that row into other work area change whatever values you want to change in work area by using "MOVE" statement ,delete previous row from internal table and by using "INSERT" statement insert the workarea row into that internal table..

Don't forget to reward if useful...

Read only

Former Member
0 Likes
710

1. Using field-symbols one can modify an internal tale.

ex:

loop at itab assigning <wa>.

etc...

endloop.

2.Have a look at the link ;

http://www.sap-img.com/ab030.htm

Read only

Former Member
0 Likes
710

Hi ,

Can i use field symbols to modify the data without using modify keyword ? Can anyone give coding from the start ?

Read only

Former Member
0 Likes
710

Use Field symbols ...

Refer to this thread for details

Regards,

Santosh

Read only

Former Member
0 Likes
710

Ex Code:

FIELD-SYMBOLS:

<wa> TYPE any.

LOOP AT itab assigning <wa>.

<wa>-fld1 = x.

---

etc..

endloop.

Changes done to <wa> will be automaitcally reflected to itab.

Read only

Former Member
0 Likes
710

Use field symbols:

FIELD-SYMBOLS : <fs_name> TYPE structure-name.

loop at itab assigning <fs_name>.

any change made to fs_name will update the internal table

Read only

Former Member
0 Likes
710

Hi,

try this code....

1) for doing modification for ur internal table..

<b>FIELD-SYMBOLS: <WA> TYPE ANY.

LOOP AT ITAB ASSIGNING <WA>.

<WA>-FIELD1 = X.

ENDLOOP.</b>

2) dynamic reefrence can be done by using the OOP concepts

<b>data : obj1 type ref to <class_name>.

create object obj1 .</b>

hope this is useful to u...

reward points if helpful...

Ginni..