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

replace duplicate values with ZERO

Former Member
0 Likes
800

Dear Experts,

In my Purchase Register i have the following output coming:


*mat type	plant	po no		po date		vend code	vendor				mat descr	mat qty	inv no		inv value*
NLAG		JW01	4800002660	14.07.2008	400904		PROMISE STATIONERY STORES	BALL PEN BLACK	50	6080701038	1071
NLAG		JW01	4800002660	14.07.2008	400904		PROMISE STATIONERY STORES	BALL PEN BLACK	3	6080701038	1071
NLAG		JW01	4800002660	14.07.2008	400904		PROMISE STATIONERY STORES	BALL PEN BLACK	1	6080701038	1071
NLAG		JW01	4800002660	14.07.2008	400904		PROMISE STATIONERY STORES	BALL PEN BLACK	20	6080701038	1071
NLAG		JW01	4800002660	14.07.2008	400904		PROMISE STATIONERY STORES	BALL PEN BLACK	1	6080701038	1071
NLAG		JW01	4800002660	14.07.2008	400904		PROMISE STATIONERY STORES	BALL PEN BLACK	6	6080701038	1071
NLAG		JW01	4800002660	14.07.2008	400904		PROMISE STATIONERY STORES	BALL PEN BLACK	6	6080701038	1071

you can see the invoice value is repeating. i want to update the value Zero for every repeated value for that invoice no.

Please let me know how to achieve the same.

Regards,

Jitesh

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
725

Hi,

YOu can use control-break commands for that

eg.

loop at <internal_tab>

at new <invoice>

endat.

<internal_tab>-value = 0

modify <internal_tab>.

endloop.

Hope this helps.

Rajat

4 REPLIES 4
Read only

Former Member
0 Likes
725

Check out my solution here:

pk

Read only

Former Member
0 Likes
726

Hi,

YOu can use control-break commands for that

eg.

loop at <internal_tab>

at new <invoice>

endat.

<internal_tab>-value = 0

modify <internal_tab>.

endloop.

Hope this helps.

Rajat

Read only

Former Member
0 Likes
725

Hi,

Try like this:

DATA: BEGIN OF LINE,

mattype(7) TYPE C,

PLANT(5) TYPE C,

PONO(10) TYPE C,

VENDCODE(6) TYPE N,

VENDOR(25) TYPE C,

MAT_DESC(14) TYPE C,

QTY(3) TYPE N,

INVOICENO(10) TYPE N,

INVVALUE(4) TYPE N,

END OF LINE.

DATA ITAB LIKE STANDARD TABLE OF LINE.

*WITH NON-UNIQUE KEY COL2.

LINE-mattype = 'NLAG'. LINE-PLANT = 'JW01'. LINE-PONO = '4800002660'. LINE-VENDCODE = 400904. LINE-VENDOR = 'PROMISE STATIONERY STORES'. LINE-MAT_DESC = 'BALL PEN BLACK'. line-QTY = 50. LINE-INVOICENO = 6080701038. LINE-INVVALUE = 1071

. APPEND LINE TO ITAB.

LINE-mattype = 'NLAG'. LINE-PLANT = 'JW01'. LINE-PONO = '4800002660'. LINE-VENDCODE = 400904. LINE-VENDOR = 'PROMISE STATIONERY STORES'. LINE-MAT_DESC = 'BALL PEN BLACK'. line-QTY = 3. LINE-INVOICENO = 6080701038. LINE-INVVALUE = 1071

. APPEND LINE TO ITAB.

LINE-mattype = 'NLAG'. LINE-PLANT = 'JW01'. LINE-PONO = '4800002660'. LINE-VENDCODE = 400904. LINE-VENDOR = 'PROMISE STATIONERY STORES'. LINE-MAT_DESC = 'BALL PEN BLACK'. line-QTY = 1. LINE-INVOICENO = 6080701038. LINE-INVVALUE = 1071

. APPEND LINE TO ITAB.

LINE-mattype = 'NLAG'. LINE-PLANT = 'JW01'. LINE-PONO = '4800002660'. LINE-VENDCODE = 400904. LINE-VENDOR = 'PROMISE STATIONERY STORES'. LINE-MAT_DESC = 'BALL PEN BLACK'. line-QTY = 20. LINE-INVOICENO = 6080701038. LINE-INVVALUE = 1071

. APPEND LINE TO ITAB.

LINE-mattype = 'NLAG'. LINE-PLANT = 'JW01'. LINE-PONO = '4800002660'. LINE-VENDCODE = 400904. LINE-VENDOR = 'PROMISE STATIONERY STORES'. LINE-MAT_DESC = 'BALL PEN BLACK'. line-QTY = 1. LINE-INVOICENO = 6080701038. LINE-INVVALUE = 1071

. APPEND LINE TO ITAB.

LINE-mattype = 'NLAG'. LINE-PLANT = 'JW01'. LINE-PONO = '4800002660'. LINE-VENDCODE = 400904. LINE-VENDOR = 'PROMISE STATIONERY STORES'. LINE-MAT_DESC = 'BALL PEN BLACK'. line-QTY = 6. LINE-INVOICENO = 6080701038. LINE-INVVALUE = 1071

. APPEND LINE TO ITAB.

LINE-mattype = 'NLAG'. LINE-PLANT = 'JW01'. LINE-PONO = '4800002660'. LINE-VENDCODE = 400904. LINE-VENDOR = 'PROMISE STATIONERY STORES'. LINE-MAT_DESC = 'BALL PEN BLACK'. line-QTY = 6. LINE-INVOICENO = 6080701038. LINE-INVVALUE = 1071

. APPEND LINE TO ITAB.

PERFORM LIST.

FORM LIST.

data: cl like line-invoiceno.

write : / 'mattype', 9 'plant', 15 'po no', 26 'vendco', 33 'vendor', 59 'mat desc', 74 'qty', 78 'invoiceno', 89 'value'.

uline at /1(95).

sort itab by MATTYPE INVOICENO.

LOOP AT ITAB INTO LINE.

if cl <> LINE-INVOICENO.

write : / line-MATTYPE, line-PLANT, line-PONO, line-VENDCODE, line-VENDOR, line-mat_desc, line-qty, line-INVOICENO, LINE-INVVALUE.

else.

line-invvalue = 0.

write : / line-MATTYPE, line-PLANT, line-PONO, line-VENDCODE, line-VENDOR, line-mat_desc, line-qty, line-INVOICENO, LINE-INVVALUE.

endif.

cl = line-INVOICENO.

ENDLOOP.

ENDFORM.

Regards,

Bhaskar

Read only

Former Member
0 Likes
725

Hi,

For your requirement you can try the following logic.

Here the tables it_tab,it_tab1 have similar structure with two fields namely f1,f2 where f2 is similar to invoice in your table which has duplicate entries.

LOOP AT it_tab INTO wa_tab.
  w_hold = wa_tab-f2. "Copy to another variable
  wa_tab-f2 = 0. "Make the field zero
  AT NEW f2.
    wa_tab-f2 = w_hold. "For first entry re assign the value
  ENDAT.
  APPEND wa_tab TO it_tab1. "Append the row to another target table
ENDLOOP.

Source table:

f1             f2
1.111       1.234
1.111       1.234
1.111       1.234
2.222       4.567
2.222       4.567

Target table:

f1             f2
1.111       1.234
1.111           0
1.111           0
2.222       4.567
2.222           0

Regards,

Manoj Kumar P