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

Changing field values

Former Member
0 Likes
706

Hi I have a table

asd sdf sdf fgh fgh hjh jgj htr

1 1 4 5 6 3 x 56

2 1 4 5 6 3 0 56

These are the fields of internal table

now if JGJ value is 'X' then all the remaining

values should become zero except ASD and SDF fields

and if JGJ value is not 'X' then all the remaining

values should become 5 except ASD and SDF fields.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
629

Hello,

Just loop at the internal table, check the value of jgj and mofify the remaining fields as per your requirement. What problem are you facing in this?

This seems to be a basic question

Vikranth

5 REPLIES 5
Read only

Former Member
0 Likes
630

Hello,

Just loop at the internal table, check the value of jgj and mofify the remaining fields as per your requirement. What problem are you facing in this?

This seems to be a basic question

Vikranth

Read only

Former Member
0 Likes
629

Hi,

Try this



loop at it_tab into wa_tab where jgj = 'X'.
  wa_tab-fgh = '0'.
  wa_tab-hjh = '0'. 
  modify it_tab from wa_tab index sy-tabix.
endloop.

loop at it_tab into wa_tab where jgj NE ' X'.
  wa_tab-fgh = '5'.
  wa_tab-hjh = '5'. 
  modify it_tab from wa_tab index sy-tabix.
endloop.

Read only

Subhankar
Active Contributor
0 Likes
629

Hi ,

Check the sample code. You will get ur answer. Here you no need to loop the table

TYPES: BEGIN OF x_data,

f1 TYPE char10,

f2 TYPE char10,

f3 TYPE char10,

f4 TYPE char10,

f5 TYPE char10,

f6 TYPE char10,

f7 TYPE char10,

END OF x_data.

DATA: i_data TYPE STANDARD TABLE OF x_data,

wa_data TYPE x_data.

wa_data-f1 = 1.

wa_data-f2 = 2.

wa_data-f3 = 3.

wa_data-f4 = 4.

wa_data-f5 = 5.

wa_data-f6 = 'X'.

wa_data-f7 = 7.

APPEND wa_data TO i_data.

wa_data-f1 = 'ONE'.

wa_data-f2 = 'TWO'.

wa_data-f3 = 'Three'.

wa_data-f4 = 'four'.

wa_data-f5 = 'five'.

wa_data-f6 = 'Six'.

wa_data-f7 = 'Seven'.

APPEND wa_data TO i_data.

wa_data-f1 = 123.

wa_data-f2 = 4123.

wa_data-f3 = 2342.

wa_data-f4 = 123.

wa_data-f5 = 21323.

wa_data-f6 = 123123.

wa_data-f7 = 34324.

APPEND wa_data TO i_data.

CLEAR wa_data.

wa_data-f3 = 0.

wa_data-f4 = 0.

wa_data-f5 = 0.

wa_data-f7 = 0.

MODIFY i_data FROM wa_data TRANSPORTING f3 f4 f5 f7

WHERE f6 = 'X'.

CLEAR: wa_data.

wa_data-f3 = 5.

wa_data-f4 = 5.

wa_data-f5 = 5.

wa_data-f7 = 5.

MODIFY i_data FROM wa_data TRANSPORTING f3 f4 f5 f7

WHERE f6 <> 'X'.

IF sy-subrc = 0.

ENDIF.

Edited by: Subhankar Garani on Nov 9, 2009 2:04 PM

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
629

For the sake of answering, you can try something like:

LOOP AT ITAB ASSIGNING <FS>.
IF <FS>-JGJ = 'X'.
<FS>-HGH = <FS>-FGH = ... = 0.
ELSE.
<FS>-HGH = <FS>-FGH = ... = 5.
ENDLOOP.

@OP: Was this hard or incomprehensive or complicated that you needed our help ??

No MODIFY reqd

Read only

Former Member
0 Likes
629

Thank u