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

initializing values in an internal table

Former Member
0 Likes
1,267

hi

how to initialize values in a internal table

according to my requirement i need to initialize (both character and currency) values present in the internal table based on certain conditions

vamsi

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
955

Hello

U could clear the header of the itab..

ie <b>read table itab index 1.

clear itab</b>

Vasanth

6 REPLIES 6
Read only

Former Member
0 Likes
955

u mean to say initialize means clear the values...

if u want to clear 1 record based on condition...

loop at itab.

<condition satisfied>

itab-field1 = space.

itab-field2 = space.

modify itab index sy-tabix.

endloop.

u want to clear table contents based on condition...

<condition satisfied>

refresh itab.

clear itab.

Read only

Former Member
0 Likes
956

Hello

U could clear the header of the itab..

ie <b>read table itab index 1.

clear itab</b>

Vasanth

Read only

Former Member
0 Likes
955

Hi Vamshi,

you can take the,

tablename-fieldname(for char) = value for character

tablename-fieldname(for curr) = value for currency

append the table.

Regards,

Abir.

If it helps mark helpful answers.

Read only

Former Member
0 Likes
955

Like this:

CLEAR itab.
REFRESH itab.

Rob

Read only

Former Member
0 Likes
955

hi

As i understood you want to clear only selected fileds not the complet record..

create a Field symobl the loop at the table.. inside the loop check the condtion the just clear the filed.

example: you have itab type mara.

then

FIELD-SYMOBOLS <FS_WA_ITAB> TYPE MARA.

LOOP AT ITAB ASSIGNING <FS_WA_ITAB>.

IF X = XXX (YOUR CONDITION)

CLEAR: <FS_WA_ITAB>-FIELD2,

<FS_WA_ITAB>-FIELD3. (If u want to clear only filed2 and field3)

clear <FS_WA_ITAB>. (if you want to cleatr the complete record)

ENDIF.

ENDLOOP.

Why iam suggestin the filed-symobol is.. it is direcltly work on internal table body so u no need to update the table agian

Please Close this thread.. when u r problem is solved

Reward if Helpful

Regards

Naresh Reddy K

Read only

Former Member
0 Likes
955

thanks for ur response