Skip to main content
Question

SQL for Position Structure

  • July 17, 2020
  • 5 replies
  • 239 views

Forum|alt.badge.img+11

Hello

Has anyone written SQL to present the IFS Position Structure in the same way as the Graphical Pos Structure?

So need to be ordered and show parent/child as per the screen display. 

Regards

Shaun

5 replies

durette
Superhero (Customer)
Forum|alt.badge.img+19
  • Superhero (Customer)
  • July 17, 2020

SELECT company_id, LEVEL, pos_code, sup_pos_code
  FROM company_position
 WHERE company_id = '10'
 START WITH sup_pos_code = '*'
CONNECT BY PRIOR pos_code = sup_pos_code
       AND PRIOR company_id = company_id;


SELECT company_id, RPAD('+', LEVEL, '+') || pos_code
  FROM company_position
 START WITH sup_pos_code = '*'
CONNECT BY PRIOR pos_code = sup_pos_code
       AND PRIOR company_id = company_id;


0guz
Hero (Employee)
Forum|alt.badge.img+10
  • Hero (Employee)
  • July 18, 2020

Hello @durette can it possible to write same code for product structure?

I want to see structure levels for parts from '0' as top product until last one.

I tried to wroten that code but a part can exist in case x at level 2, same part can exist in case y at level 4. So we had to use LISTAGG maybe idk. Can u help me for this problem?


durette
Superhero (Customer)
Forum|alt.badge.img+19
  • Superhero (Customer)
  • July 19, 2020

same code for product structure

Sure, but it’s better to start a new question so future users of the forum can find it.


durette
Superhero (Customer)
Forum|alt.badge.img+19
  • Superhero (Customer)
  • July 19, 2020

Forum|alt.badge.img+11
  • Author
  • Hero (Customer)
  • July 20, 2020

@durette Thank you for the SQL.

I want to only show the valid positions as of the current date in the hierarchy structure. However when i run IFS debug and capture the SQL produced by IFS it seems to be using IFSAPP.company_position_structure.valid_from AND
IFSAPP.company_position_structure.valid_to. But the two positions show as not valid (red cross) in the user interface but are shown in the SQL query as they have values of 01/01/0001 and 31/12/9999. 

The dates for IFSAPP.company_position.valid_from and IFSAPP.company_position.valid_to show as 08/10/1950 09:20:12 and 26/06/2016 though. 

Any guidance on this?

Thanks