‎2009 Dec 06 5:12 AM
Hi All,
I want to compare 2 values in same internal table.
like.
belnr qty qty1
1234 12 1
1234 12 2
I want to compare belnr value and put qty = 0 if belnr is duplicate.
like
belnr qty qty1
1234 12 1
1234 00 2
please help me.
thanks in advance.
‎2009 Dec 07 5:20 AM
Hi Ankita,
Try this code:
Create one more field at the end of the record of internal table as flag type c.
I have consider matnr for belnr.
data: temp_matnr like mara-matnr.
clear temp_matnr.
sort itab by matnr.
loop at itab.
if itab-matnr = temp_matnr and itab-flag = ''.
itab-qty = '0.00'.
itab-flag = 'X'.
modify itab TRANSPORTING qty flag.
endif.
temp_matnr = itab-matnr.
endloop.
Hope fully it will work for your requirement.
Thanks..
Regards,
Mukul Bopche
Edited by: Mukul TATA on Dec 7, 2009 6:43 AM
‎2009 Dec 06 7:24 AM
Hi,
You can sort the internal table by belnr, then loop the internal table, and compare the belnr, if identical, modify the internal table.
‎2009 Dec 06 7:30 AM
Hi,
Please try this:-
sort t_belnr by belnr.
loop at t_belnr into wa_belnr.
v_temp = wa_belnr-qty.
at new belnr.
continue.
endat.
clear wa_belnr-qty.
modify t_belnr from wa_belnr index sy-tabix.
endloop.
Regards,
Subhashini
‎2009 Dec 06 8:28 AM
‎2009 Dec 06 8:37 AM
HI all,
My actual problem is like :
40559178 110.000 40559178 138.000
40559178 004.000 40559178 138.000
40559178 024.000 40559178 138.000
here i want to put 0 on place of 138 in 2nd and 3rd row...
please help me...
‎2009 Dec 06 9:51 AM
sort itab by <field1>.
loop at itab into wa.
l_tabix = sy-tabix.
at new wa-<field1>.
continue.
endat.
clear wa-qty.
modify itab index l_tabix from wa transporting <field4>
clear wa.
endloop.
‎2009 Dec 06 10:00 AM
‎2009 Dec 06 10:08 AM
‎2009 Dec 06 10:09 AM
‎2009 Dec 06 10:12 AM
HI,
the code is written assuming that your itab sturcture is like
field1 field2 field3 field4
40559178 110.000 40559178 138.000
40559178 004.000 40559178 138.000
40559178 024.000 40559178 138.000
if there is any change in the structure the control break statement may not work.
‎2009 Dec 06 10:13 AM
HI
i AM USING FOLLOWING CODE..
ITAB , AND ITAB1 BOTH R INTERNAL TABLES
AND I AM APPENDING THEM IN ONE..
i AM GATING OUT PUT LIKE THIS:
40559178 110.000 138.000 701002 202630
40559178 4.000 138.000 701002 202630
40559178 24.000 138.000 701002 202630
I WANT OUTPUT LIKE :
40559178 110.000 138.000 701002 202630
40559178 4.000 000.000 701002 202630
40559178 24.000 000.000 701002 202630
FOR THIS OUTPUT I AM USING FOLLOWING CODE.
DATA : CHECK TYPE C.
LOOP AT ITAB.
LOOP AT ITAB1 WHERE MBLNR_REG = ITAB-MBLNR_SRP .
MOVE : ITAB-MBLNR_SRP TO ITAB3-MBLNR_SRP,
ITAB-MATNR_SRP TO ITAB3-MATNR_SRP,
ITAB-MENGE_SRP TO ITAB3-MENGE_SRP,
ITAB1-MENGE_REG TO ITAB3-MENGE_REG,
ITAB1-MATNR_REG TO ITAB3-MATNR_REG.
APPEND ITAB3.
CHECK = 'X'.
ENDLOOP.
IF CHECK = ' '.
ITAB3-MATNR_REG = SPACE.
ITAB3-MENGE_REG = SPACE.
APPEND ITAB3.
CLEAR CHECK.
ENDIF.
ENDLOOP.
IS IT RIGHT?
‎2009 Dec 06 10:15 AM
Try this :
Sort your table based on your field1 .
After this use below code :
loop at itab.
lv_tabix = sy-tabix. " Required to modify field
at new field1.
continue.
endat.
clear field. " This will make the field blank
modify itab index lv_tabix transporting field
endloop.
‎2009 Dec 06 10:15 AM
YES U R RIGHT.
BUT I WANT 0 ONPLACE OF 138 IN 2ND & 3RD ROW.
40559178 110.000 138.000
40559178 4.000 138.000
40559178 24.000 138.000
‎2009 Dec 06 10:18 AM
You code is a bit confusing
Consider this data
40559178 110.000 138.000 701002 202630
40559178 4.000 138.000 701002 202630
40559178 24.000 138.000 701002 202630
My previos code will work.
sort the itab based on field1.
loop at itab into wa.
at new wa-field1. "Gets triggered when a new belnr is found
continue.
endat.
wa-field4 = 0. "For other records make it 0
modify itab from wa.
endloop.
Please debug and find the solution.
‎2009 Dec 06 10:25 AM
hI KSD
I AM USING SAME CODE
BUT OUTPUT IS SAME NO CHANGE..
MY CODE IS :
SORT ITAB BY MBLNR_SRP.
loop at itab3.
at new MBLNR_SRP.
continue.
endat.
ITAB3-MENGE_REG = 0 .
modify itab3 .
endloop.
‎2009 Dec 06 10:37 AM
is the field MBLNR_SRP the first field in your internal table ?
‎2009 Dec 06 10:39 AM
‎2009 Dec 06 10:41 AM
my first field is mblnr_srp ,
2nd is menge_srp
3rd is menge_reg
4th is matnr_srp
5th is matnr_reg
‎2009 Dec 06 10:44 AM
Now debugging is the only solution.
Check whether its changing the value to zero or not.
‎2009 Dec 06 10:53 AM
‎2009 Dec 06 11:05 AM
NO idea how to help you,
Try moving the data to another table.
loop at itab.
at new field1.
read table itab index sy-tabix.
move itab-field1 to itab1-field1.
-
-
move itab-field4 to itab1-field4.
append itab1.
clear itab1.
continue.
endat.
move itab-field1 to itab1-field1.
"Donot move the field Quantity
move itab-field4 to itab1-field4.
append itab1.
clear itab1.
endloop.
‎2009 Dec 06 11:14 AM
‎2009 Dec 07 4:06 AM
Hi ankita,
you wrote this
"MY CODE IS :
SORT ITAB BY MBLNR_SRP.
loop at itab3.
at new MBLNR_SRP.
continue.
endat.
ITAB3-MENGE_REG = 0 .
modify itab3 .
endloop.
"
in your internal table (ITAB3) MBLNR_SRP must be first field. So please check it and then write the following.
Data : tabix like sy-tabix.
SORT ITAB3 BY MBLNR_SRP.
loop at itab3.
tabix = sy-tabix.
at new MBLNR_SRP.
continue.
endat.
ITAB3-MENGE_REG = 0 .
modify itab3 index tabix transporting MENGE_REG.
endloop.
with regards
MADAN NAMDEO
‎2009 Dec 06 10:30 PM
Please do not use all caps.
And what is the problem? it looks pretty basic to me.
Rob
‎2009 Dec 07 12:36 AM
Hi,
Assume your table is itab.
declare one variable name z_belnr.
loop at itab.
if z_belnr is not initial.
if z_belnr = itab-belnr.
itab-qty = 0.
modify itab.
endif.
endif.
z_belnr = itab-belnr.
endloop.
Regards,
Simon
‎2009 Dec 07 5:20 AM
Hi Ankita,
Try this code:
Create one more field at the end of the record of internal table as flag type c.
I have consider matnr for belnr.
data: temp_matnr like mara-matnr.
clear temp_matnr.
sort itab by matnr.
loop at itab.
if itab-matnr = temp_matnr and itab-flag = ''.
itab-qty = '0.00'.
itab-flag = 'X'.
modify itab TRANSPORTING qty flag.
endif.
temp_matnr = itab-matnr.
endloop.
Hope fully it will work for your requirement.
Thanks..
Regards,
Mukul Bopche
Edited by: Mukul TATA on Dec 7, 2009 6:43 AM