Skip to Content
0
Former Member
Apr 29, 2010 at 03:40 PM

Delete table entries where fields are linked in a hierarchy

109 Views

I have written an authorisation check that mostly works.... it is handling the data on failure i would like some guidance on....

the code looks a little something like this....


    *--- Read table where selection name is Functional Location
      LOOP AT lt_nodes INTO ls_nodes
      WHERE   type   = 'FLL'
        AND   nlevel = '01'.

        SELECT single * FROM iflot INTO ls_iflot
        WHERE tplnr = ls_nodes-ref_obj
          AND begru = '0001'.

          IF sy-subrc = 0.

    *--- Check the authorisation object for functional location
            AUTHORITY-CHECK OBJECT 'I_BEGRP'
            ID 'BEGRP' FIELD ls_iflot-begru.
    *        ID 'ACTVT' FIELD '03'.

            IF sy-subrc <> 0.

              DELETE lt_nodes WHERE sup_nodeid = ls_nodes-nodeid.
              DELETE lt_nodes WHERE nodeid     = ls_nodes-nodeid.

            ENDIF.

          ENDIF.
        ENDLOOP.

my issue i have is that the table i am deleting from (lt_nodes) has hierarchical structure in the data....

so the above code only handles level 1 and 2....

as level 3 sup_nodeid is linked to level 2 nodeid and 4 to 3, etc... my current code cannot handle that (obviously)...

make sense?? probably not...

i need to try and work out how i can reference the multiple levels within side a loop to delete the entries...

any suggestions??