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

logical QA grandfather,father,son.....

i have an itab (level,matnr,parent) someting like itab tree.

my problem is the numric of the level.

here the examp.

level-1 matnr-75835 parent-

level-1.1 matnr-15500 parent-75835

level-1.1 matnr-50700 parent-75835

level-1.1.1 matnr-66300 parent-50700

level-1.1.1 matnr-66100 parent-50700

level-1.1.2 matnr-76000 parent-50700

level-1.2 matnr-72000 parent- 75835

i wnat to update the level field to the right level, ican not get duplicate level as it seams in the examp.

thanks friends.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 17, 2008 at 10:54 PM

    Hi Richi....

    try this logic.

    if you know how deep the hierarchy goes, increase the loop IF-ELSEIF condition accordingly

    LOOP AT itab_matnr INTO wa_matnr.

    IF sy-tabix = 1.

    v_level = 1.

    v_l1_matnr = wa_matnr-matnr. "save level 1 parent

    ELSEIF wa_matnr-parent = v_l1_matnr.

    v_level = 2.

    v_l2_matnr = wa_matnr-matnr. "save level 2 parent

    ELSEIF wa_matnr-parent = v_l2_matnr.

    v_level = 3.

    v_l3_matnr = wa_matnr-matnr. "save level 3 parent

    ELSEIF wa_matnr-parent = v_l3_matnr.

    v_level = 4.

    v_l4_matnr = wa_matnr-matnr. "save level 4 parent

    ELSEIF wa_matnr-parent = v_l4_matnr.

    v_level = 5.

    v_l5_matnr = wa_matnr-matnr. "save level 5 parent

    ELSE.

    MESSAGE e000 WITH 'Program only supports 5 hierarchy levels. ' .

    ENDIF.

    wa_matnr-level = v_level.

    MODIFY itab_matnr

    INDEX sy-tabix

    FROM wa_matnr

    TRANSPORTING level.

    ENDLOOP.

    Cheers

    ~Arun

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 17, 2008 at 01:32 PM

    PLS

    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.