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

itab updation

Former Member
0 Likes
1,276

Hi experts,

I have itab like this.


QMNUM       |INDTX

000200000014|X    
000200000014|X    
000200000014|X  
000200000014|X 
   
000200000034|X    
000200000034|
000200000034|
   
000200000035|X    
000200000035|X  
000200000036|X    
000200000036|X  

In the above table if all the INDTX values are 'X' i want to fill the t_disp table with FLAG = 'X'.If <b>any one</b> of INDTX is empty i want to fill the FLAG = '-'.

So t_disp table should display like this.


QMNUM       FLAG
000200000014|X
000200000034|-
000200000035|X 
000200000036|X 

How can i do this?

reward guaranteed

thanks

kaki

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,204

Hi ,

My previous code works if t_disp is initialized. Else use this.

LOOP AT itab.
  t_disp-qmnum = itab-qmnum.
  APPEND t_disp.
  DELETE ADJACENT DUPLICATES FROM t_disp.
ENDLOOP.

DATA cnt TYPE i.
SORT itab BY qmnum.
LOOP AT t_disp.
 cnt = 0.
 LOOP AT itab WHERE qmnum = t_disp-qmnum.
  IF itab-indtx NE 'X'.
    cnt = 1.
  ENDIF.
 ENDLOOP.
 IF cnt = 0.
   t_disp-flag = 'X'.
 ELSE.
   t_disp-flag = '-'.
 ENDIF.
 MODIFY t_disp TRANSPORTING flag.
ENDLOOP.

Hi experts,

I have itab like this.


QMNUM       |INDTX

000200000014|X    
000200000014|X    
000200000014|X  
000200000014|X 
   
000200000034|X    
000200000034|
000200000034|
   
000200000035|X    
000200000035|X  
000200000036|X    
000200000036|X  

In the above table if all the INDTX values are 'X' i want to fill the t_disp table with FLAG = 'X'.If <b>any one</b> of INDTX is empty i want to fill the FLAG = '-'.

So t_disp table should display like this.


QMNUM       FLAG
000200000014|X
000200000034|-
000200000035|X 
000200000036|X 

How can i do this?

reward guaranteed

thanks

kaki

7 REPLIES 7
Read only

Former Member
0 Likes
1,204

Hi Kaki,

Try this :

Data : L_tabix type sy-tabix.

Loop at itab.

L_tabix = Sy-tabix.

IF itab-INDTX = ' '.

move '-' to itab-INDTX.

Modify Itab idex l_tabix.

Endif.

Endloop.

Lanka

Read only

0 Likes
1,204

Kaki,

Lanka's solution will work, but before you utilise it, make sure you sort your table accordingly:

ie.

sort itab by qmnum ascending indtx descending.

Cheers,

Pat.

Read only

Former Member
0 Likes
1,204
DATA cnt TYPE i.
LOOP AT t_disp.
 cnt = 0.
 LOOP itab WHERE qmnum = t_disp-qmnum.
  IF itab-indtx NE 'X'.
    cnt = 1.
  ENDIF.
 ENDLOOP.
 IF cnt = 0.
   t_disp-flag = 'X'.
 ELSE.
   t_disp-flag = '-'.
 ENDIF.
 MODIFY t_disp TRANSPORTING flag.
ENDLOOP.
Read only

jayanthi_jayaraman
Active Contributor
0 Likes
1,204

Hi,

Try the following.

sort itab by qmnum indtx.

loop at itab into wa.

wa_disp-qmnum = wa1-qmnum.

read table itab into wa1 with key qmnum = wa-qunum

indtx = ' '.

if sy-subrc eq 0.

wa_disp-flag = '-'.

else.

wa_disp-flag = 'X'.

endif.

append wa_disp to t_disp.

delete itab where qmnum = wa-qmnum.

endloop.

Read only

Former Member
0 Likes
1,205

Hi ,

My previous code works if t_disp is initialized. Else use this.

LOOP AT itab.
  t_disp-qmnum = itab-qmnum.
  APPEND t_disp.
  DELETE ADJACENT DUPLICATES FROM t_disp.
ENDLOOP.

DATA cnt TYPE i.
SORT itab BY qmnum.
LOOP AT t_disp.
 cnt = 0.
 LOOP AT itab WHERE qmnum = t_disp-qmnum.
  IF itab-indtx NE 'X'.
    cnt = 1.
  ENDIF.
 ENDLOOP.
 IF cnt = 0.
   t_disp-flag = 'X'.
 ELSE.
   t_disp-flag = '-'.
 ENDIF.
 MODIFY t_disp TRANSPORTING flag.
ENDLOOP.

Read only

0 Likes
1,204

Thank you Wenceslaus G .

full points alloted

kaki

Read only

former_member186741
Active Contributor
0 Likes
1,204

LOOP AT t_disp.

read itab with key qmnum = t_disp-qmnum and indtx = ''.

IF sy-subrc = 0.

t_disp-flag = '-'.

ELSE.

t_disp-flag = 'X'.

ENDIF.

MODIFY t_disp TRANSPORTING flag.

ENDLOOP.