Skip to Content
author's profile photo Former Member
Former Member

replace duplicate values with ZERO

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Dec 19, 2008 at 06:24 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 19, 2008 at 06:24 AM
    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 19, 2008 at 07:51 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 19, 2008 at 08:09 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.