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

IT_data2 modify

arsul_parshuram
Participant
0 Likes
743

Dear All,

i want to modify it_data2 table with latest two PO only for Material.

how to do this ..Please help on this.

My data it_data2 have 62 records and it_data3 have multiple records material and PO.

this is my po.

LOOP AT IT_DATA2 INTO WA_DATA2.

SORT IT_DATA3[] BY MATNR AEDAT DESCENDING.

LOOP AT  IT_DATA3 INTO WA_DATA3 WHERE MATNR = WA_DATA2-MATNR1.

  V_TABIX = SY-INDEX.

 IF V_TABIX = 1.

WA_DATA2-EBELN = WA_DATA3-EBELN.
WA_DATA2-AEDAT = WA_DATA3-AEDAT.

ENDIF.


IF V_TABIX = 2.

WA_DATA2-EBELN1 = WA_DATA3-EBELN.
WA_DATA2-AEDAT1 = WA_DATA3-AEDAT.

ENDIF.

MODIFY it_data2 FROM wa_data2 TRANSPORTING EBELN AEDAT EBELN1 AEDAT1.

CLEAR: WA_DATA3.

IF V_TABIX GT 2.

CLEAR V_TABIX.

EXIT.

ENDIF.

Regards

Parshuram

Moderator Message: Please use a more specific subject line in future.

Edited by: Suhas Saha on Mar 9, 2012 4:14 PM

4 REPLIES 4
Read only

former_member222709
Contributor
0 Likes
635

Hi Parshuram,

I need more details, with what is the output of your code or the problem that is happening in your code.

I believe it will be better if you do the following:

1. SORT itab3 outside the itab2 loop.

2. Instead of a nested loop on itab3, use READ TABLE inside itab2 loop using index + 1 and comparing key fields.

3. Finally use modify.

Regards,

Pranav.

Read only

0 Likes
635

Thanks Pranvaji,

Please provide sample code for the same.

Regards,

Parshuram.

Read only

SharathYaralkattimath
Contributor
0 Likes
635

Hi,

you should not use nested loops,

You used sy-index, you should use sy-yabix for table index anyways you dont need that too if your are using Loop & read statements,

As you want 1st two PO's, try this....


SORT IT_DATA3[] BY MATNR AEDAT DESCENDING.

LOOP AT IT_DATA2 INTO WA_DATA2.

READ TABLE IT_DATA3 INTO WA_WA_DATA3 INDEX 1.
  IF SY-SUBRX EQ 0.
    WA_DATA2-EBELN = WA_DATA3-EBELN.
    WA_DATA2-AEDAT = WA_DATA3-AEDAT.
    MODIFY it_data2 FROM wa_data2 TRANSPORTING EBELN AEDAT EBELN1 AEDAT1.
  ENDIF.

READ TABLE IT_DATA3 INTO WA_WA_DATA3 INDEX 2.
  IF SY-SUBRX EQ 0.
    WA_DATA2-EBELN = WA_DATA3-EBELN.
    WA_DATA2-AEDAT = WA_DATA3-AEDAT.
    MODIFY it_data2 FROM wa_data2 TRANSPORTING EBELN AEDAT EBELN1 AEDAT1.
  ENDIF.

ENDLOOP.

Read only

0 Likes
635

Thanks for replay.

below i am giving code for First PO It is working fine, i want to modify two latest PO for WA_DATA2-MATNR1.

by using Index it not not working because i have Multiple PO are available at it_data3 after

SORT IT_DATA3[] BY MATNR AEDAT DESCENDING it_data3 coming latest two PO but how to modify that particular Material

modify it_data2 PO's.

i want it_data3 pass two Po and exit from loop.

LOOP AT IT_DATA2 INTO WA_DATA2.

SORT IT_DATA3[] BY MATNR AEDAT DESCENDING.

LOOP AT IT_DATA3 INTO WA_DATA3 WHERE MATNR = WA_DATA2-MATNR1.

WA_DATA2-EBELN = WA_DATA3-EBELN.

*WA_DATA2-AEDAT = WA_DATA3-AEDAT.

MODIFY it_data2 FROM wa_data2 TRANSPORTING EBELN.

CLEAR: WA_DATA3.

EXIT.

ENDLOOP.

CLEAR:WA_DATA2.

ENDLOOP.

Regards,

Parshuram.