1

We're attempting to use the HIERARCHY function in HANA to speed up the BOM explosion process that is currently being done in ABAP. The base query works, but we're trying to refine it more for the end-user. The goal is we want to normalize the assemblies and display a grandparent-parent-child relationship in the output so that every root node will display all sub-components below it before moving on to the next assembly in the output. This is my first post here, so if I need to add any code or further clarify I'd be happy to.

Current output Current output

Desired output Desired output

CREATE COLUMN TABLE "BOM_EXPLOSION" ("HIERARCHY_TREE_SIZE" NVARCHAR(10),
     "PARENT_ID" NVARCHAR(15),
     "NODE_ID" NVARCHAR(15),
     "QUANTITY" NVARCHAR(10),
     "VALID_FROM" NVARCHAR(10),
     "VALID_TO" NVARCHAR(10)) UNLOAD PRIORITY 5 AUTO MERGE  

insert into "BOM_EXPLOSION" values('6','X-000-XXX-01','Y-000-XXX-S1','1','20171221','99991231');
insert into "BOM_EXPLOSION" values('1','Y-000-XXX-S1','COMP1','1','20171221','99991231');
insert into "BOM_EXPLOSION" values('1','Y-000-XXX-S1','COMP2','1','20171221','99991231');
insert into "BOM_EXPLOSION" values('1','Y-000-XXX-S1','COMP3','2','20171221','99991231');
insert into "BOM_EXPLOSION" values('1','Y-000-XXX-S1','COMP4','1','20171221','99991231');
insert into "BOM_EXPLOSION" values('1','Y-000-XXX-S1','COMP5','2','20171221','99991231');
insert into "BOM_EXPLOSION" values('4','X-000-XXX-01','Y-000-XXX-S2','1','20171221','99991231');
insert into "BOM_EXPLOSION" values('1','Y-000-XXX-S2','COMP1','2','20171221','99991231');
insert into "BOM_EXPLOSION" values('1','Y-000-XXX-S2','COMP2','1','20171221','99991231');
insert into "BOM_EXPLOSION" values('1','Y-000-XXX-S2','COMP3','1','20171221','99991231');
insert into "BOM_EXPLOSION" values('1','X-000-XXX-01','COMP4','1','20170530','20171221');
5
  • 2
    Please provide the data that should be used as text, ideally with CREATE TABLE and INSERT commands. That way we can actually work with it. Commented May 7, 2020 at 21:46
  • 1
    So what are you struggling with? I see no notable differences between current and desired. You don't know how to add top level? Commented May 8, 2020 at 7:16
  • @LarsBr. Added code per your request. Thanks! Commented May 8, 2020 at 19:18
  • I got to agree with Suncatcher ... what's the difference between the outputs? What is the actual question? Commented May 10, 2020 at 5:17
  • In current format, Parent ID – Assembly Node ID - Components under assembly. X-000-XXX-01 is top level assembly which has another sub-assembly Y-000-XXX-S1. We are able use to Hierarchy function exploding BOM. Our requirement is to have “top level assembly” as separated and repeat it for all sub-assemblies below. For e.g. Y-0000-XXX-S1 has “5” components under it and they all belong indirectly to “Top_LEVEL”. Commented May 12, 2020 at 14:45

1 Answer 1

1

I believe you're looking for the Root node in your Hierarchy. I'd recommend reading the Hierarchy functions in HANA: https://help.sap.com/viewer/4f9859d273254e04af6ab3e9ea3af286/2.0.04/en-US/a93c356d32ef4e7fbd6143b554278eab.html

Specifically for your need, look at the "Root" example in this link: https://help.sap.com/viewer/4f9859d273254e04af6ab3e9ea3af286/2.0.04/en-US/83cf843bfe3c4fd8a5d2aa828fb383c5.html

It's basically a self join on the hierarchy_root_rank attribute with the node actual rank.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.