cancel
Showing results for 
Search instead for 
Did you mean: 

data shuffling in itab

Former Member

Accepted Solutions (1)

Accepted Solutions (1)

former_member186741
Active Contributor
0 Kudos

instead of appending the lines of t_ekkn to the t_disp you need to be changing the existing entries in t_disp with reference to t_ekkn.

Something like:

loop at t_disp.

*read table t_ekkn with key aufnr = t_disp-aufnr ebeln = t_disp-ebeln.

read table t_ekkn with key qmnum = t_disp-qmnum aufnr = t_disp-aufnr.

if sy-subrc = 0.

*move the fields you need here

  • from t_ekkn to t_disp

*maybe you can use move-corresponding maybe you need

*seperate moves

modify t_disp.

endif.

endloop.

Message was edited by: Neil Woodruff

Former Member
0 Kudos

Hi experts,

Finally i got the data like this.


 Notif  No     Prd Order       Mat Issued PO   Purchase Order                                                         

200000140      EAE200000140       X       X                  
200000140      EAE200000140       X       X    4510003407    
<b>200000141      EAF200000141       X       X</b>                  
200000141      EAF200000141       X       X    4510003408    
200000141      EAF200000141       X       X    4510003410    
200000142      EAG200000142       X       X                  
200000143      EAH200000143       X       X                  
200000144      EAI200000144       X       X                  
ETINT01        ETINT01            X       X                  
ETINT01        ETINT01            X       X    4510003405    
ETINT02        ETINT02            X       X                  
ETINT02        ETINT02            X       X    4510003406    
ETINT02        ETINT02            X       X    4510003409    
ETINT03        ETINT03            X       X                  
ETINT04        ETINT04                                       
ETINTXYZ001A   ETINTXYZ001A       X

 

Now i want to delete where repeted data.How can i do this?

Adjacent duplicates will not work.Let us see this one


200000141      EAF200000141       X       X                  
200000141      EAF200000141       X       X    4510003408    
200000141      EAF200000141       X       X    4510003410 

Since ebeln is not there in first record i want to delete.

But some ot the records are not having EBELN.But it should not delete.

Former Member
0 Kudos

SORT t_disp BY qmnum aufnr.
LOOP AT t_disp.
 DELETE ADJACENT DUPLICATES FROM t_disp.
ENDLOOP.
former_member186741
Active Contributor
0 Kudos

there are no exact duplicates... to specify you can say:

DELETE ADJACENT DUPLICATES FROM t_disp comparing ebeln aufnr.

  • or whatever fields you need

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

As per your requirment, this may be a little better.




DATA count TYPE i.
LOOP AT t_disp.
 d_qmnum = t_disp-qmnum.
 d_aufnr = t_disp-aufnr.
 d_ebeln = t_disp-ebeln.
 cnt = 0.

* If you have at least one record with a PO 
* then get rid of the one that has no PO.
* Otherwise the one with no PO will remain.
 LOOP AT t_disp WHERE qmnum = d_qmnum 
                  AND aufnr = d_aufnr
  <b>                and ebeln <> space.</b>
   cnt = cnt + 1.
 ENDLOOP.
 IF cnt > 0.
   DELETE t_disp WHERE qmnum = d_qmnum AND aufnr = d_aufnr AND d_ebeln IS INITIAL.
 ENDIF.
 ENDLOOP.
ENDLOOP.




Regards,

Rich Heilman

former_member186741
Active Contributor
0 Kudos

LOOP AT t_disp where ebeln <> ''.

LOOP AT t_disp wherE qmnum = t_disp-qmnum

AND aufnr = t_disp-aufnr

and ebeln is initial

transporting no fields.

exit.

ENDLOOP.

IF sy-subrc = 0.

DELETE t_disp WHERE qmnum = t_disp-qmnum AND aufnr = t_disp-aufnr AND ebeln = ''.

ENDIF.

ENDLOOP.

ENDLOOP.

Former Member
0 Kudos

Hi all,

Thanks for all replies.

points alloted all.

cheers

kaki

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Kaki,

This code will work for you.

DATA count TYPE i.
LOOP AT t_disp.
 d_qmnum = t_disp-qmnum.
 d_aufnr = t_disp-aufnr.
 d_ebeln = t_disp-ebeln.
 cnt = 0.
 LOOP AT t_disp WHERE qmnum = d_qmnum AND aufnr = d_aufnr.
   cnt = cnt + 1.
 ENDLOOP.
 IF cnt > 0.
   DELETE t_disp WHERE qmnum = d_qmnum AND aufnr = d_aufnr AND d_ebeln IS INITIAL.
 ENDIF.
 ENDLOOP.
ENDLOOP.

Message was edited by: Wenceslaus G

Former Member
0 Kudos

Hi Kaki,

Try this...

LOOP AT t_ekkn.

MOVE-CORRESPONDING t_ekkn to t_disp.

APPEND t_disp.

ENDLOOP.

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Kaki, are the structures of the T_EKKN an T_DISP the same? If not, then this may be your problem. You will need to move the data "manually".

Loop at T_EKKN.
clear t_disp.
move-corresponding t_ekkn to t_disp.
append t_disp.
endloop.

Regards,

Rich Heilman

Former Member
0 Kudos

Hi Rich,

I have used your code.Data is coming properly.can u see this.Earlier my t_disp is like this.


 Notif  No   Prd Order   Mat Issued  PO    Purchase Order

 <b>ETINT02     ETINT02     X           X</b>    

after passing t_ekkn to t_disp iam getting like this.


 Notif  No   Prd Order   Mat Issued  PO    Purchase Order

 ETINT02     ETINT02     X           X                    
 ETINT02     ETINT02                       4510003406     
 ETINT02     ETINT02                       4510003409 

My intention is to get like this.

(Since iam passing 2 different POs to t_disp, i want to add another line with PO.)


 Notif  No   Prd Order   Mat Issued  PO    Purchase Order

<b> ETINT02     ETINT02     X           X     4510003406 
 ETINT02     ETINT02     X           X     4510003409</b> 

How can i do?

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Here is a sample program to illistrate what I'm talking about. Notice that the internal tables do not have the same structure, therefore when using the "APPEND LINES OF" statement, it will move the characters byte by byte to the other structure, not taking into account the fields specified. Doing a loop, and moving "Manually" will solve the problem.



report  zrich_0001.

data: begin of itab1 occurs 0,
      fld1(10) type c,
      fld3(10) type c,
      fld5(10) type c,
      end of itab1.

data: begin of itab2 occurs 0,
      fld1(10) type c,
      fld2(10) type c,
      fld3(10) type c,
      fld4(10) type c,
      fld5(10) type c,
      end of itab2.

* Setup the data
itab1-fld1 = '0000000001'.
itab1-fld3 = '0000000002'.
itab1-fld5 = '0000000003'.
append itab1.

itab1-fld1 = '0000000004'.
itab1-fld3 = '0000000005'.
itab1-fld5 = '0000000006'.
append itab1.


* Data in the wrong fields.
append lines of itab1 to itab2.

loop at itab2.
  write:/ itab2.
endloop.


* Skip a space and start again
skip 1.  clear itab2. refresh itab2.


* Data in the correct fields.
loop at itab1.
  clear itab2.
  move-corresponding itab1 to itab2.
  append itab2.
endloop.

loop at itab2.
  write:/ itab2.
endloop.

Regards,

Rich Heilman

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Still having trouble, please post the "data" statements for the internal tables as well as the code that is moving from one to the other.

REgards,

Rich Heilman

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Are you saying that you have three records in your t_ekkn table with the same notif no and prd order, and that the first one doesn't have a purchase order tied to it?

I'm not sure what is happening here since I can't see your data.

REgards,

Rich Heilman

Former Member
0 Kudos

Yes Rich,

t_ekkn is like this.


QMNUM        EBELN      EBELP AUFNR        ELIKZ KNTTP
000200000141|4510003410|00001|EAF200000141|     |F                        |
ETINT01     |4510003405|00001|ETINT01     |     |F                        |
ETINT02     |<b>4510003406|00001|ETINT02</b>     |X    |F                        |
000200000140|4510003407|00001|EAE200000140|X    |F                        |
000200000141|4510003408|00001|EAF200000141|     |F                        |
ETINT02     |<b>4510003409|00001|ETINT02</b>     |X    |F                        |
000200000141|4510003410|00001|EAF200000141|     |F                        |

t_disp is like this.


QMNUM        MNCOD AUFNR        XLOEK EBELN      ELIKZ CONFR
000200000010|     |            |     |          |     |                   |
000200000020|X    |            |     |          |     |                   |
000200000140|     |EAE200000140|X    |          |     |X                  |
000200000141|     |EAF200000141|X    |          |     |X                  |
000200000142|     |EAG200000142|X    |          |     |X                  |
000200000143|     |EAH200000143|X    |          |     |X                  |
000200000144|     |EAI200000144|X    |          |     |X                  |
ETINT01     |X    |ETINT01     |X    |          |     |X                  |
ETINT02     |     |ETINT02     |X    |          |     |X                  |
ETINT03     |     |ETINT03     |X    |          |     |X                  |
ETINT04     |     |ETINT04     |     |          |     |                   |
ETINTXYZ001A|     |ETINTXYZ001A|X    |          |     |                   |

In the t_ekkn table Two EBELNs are there for each AUFNR.

Former Member
0 Kudos

Hi Kaki,

I think this must be the logic

SORT itab BY qmnum aufnr.
LOOP AT t_disp.
 READ TABLE itab WITH KEY qmnum = t_disp-qmnum AND aufnr = t_disp-aufnr.
 IF sy-subrc EQ 0.
  t_disp-xloek = itab-xloek.
  t_disp-ebeln = itab-ebeln.
 MODIFY t_disp TRANSPORTING xloek ebeln.
 ENDIF.
 
ENDLOOP.

APPEND LINES OF T_EKKN TO T_DISP will just append the contents to t_disp they won't update the table contents

Message was edited by: Wenceslaus G

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

So, is the problem that you are only getting one record for in t_disp for the two in T_ekkn, or that the EBELN field is not being moved?

Make sure that the EBELN field is defined EXACTLY the same in both tables.

Regards,

Rich Heilman