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: 

itab updation

Former Member
0 Kudos

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

Former Member
0 Kudos

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.

7 REPLIES 7

Former Member
0 Kudos

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

0 Kudos

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.

Former Member
0 Kudos
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.

jayanthi_jayaraman
Active Contributor
0 Kudos

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.

Former Member
0 Kudos

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.

0 Kudos

Thank you Wenceslaus G .

full points alloted

kaki

former_member186741
Active Contributor
0 Kudos

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.