Annulé

MYSQL code for recursive select

Please create the MYSQL code to combine 3 tables recursively so that we can go at least 1,000 levels deep.

Essentially, we’re expanding the Bill of Materials. So, the ProdOrderRes table has the first level materials required to build the order. Then we check the Bill of materials using MAST and STPO over and over until we get to the end of the BOM and there are no more materials, basically down to the last screw.

I would do this by doing select loops on a table and then appending to that table. But, you can do it however it works. You will end up with a long table that has the order, the material(matnr), plant(werks), the quantity needed (bdmng), and BOM level.

I can string several sql statements distinctly if needed.

The code will have to compile in my Mysql system.

I would write this in ABAP as follows, but I don’t know SQL well enough.

Select *

Into table t_header

from ProdOrderRes.

***first lines are all level one

loop at t_header assigning <head>.

<head>-level = ‘1’.

Endloop.

loop at t_header assigning <head>.

If <head>-matnr is not initial.

Sel_matnr = <head>-matnr.

Else.

***this is only for the level one materials.

Sel_matnr = <head>-plnbez.

Endif.

Select stlnr

into bom_stlnr

from mast

where matnr = sel_matnr

and werks = <head>-werks.

Select idnrk pswrk menge

Into next_matnr, next_werks, next_menge

From stop

Where stlnr = bom_stlnr.

Wa-aufnr = <head>-aufnr.

Wa-auart = <head>-auart.

Wa-autyp = <head>-autyp.

Wa-werks = next_werks.

Wa-matnr = next_matnr.

Wa-gamng = next_menge.

Wa-level = <head>-level + 1.

Append wa to t_head.

Endselect.

Endselect.

Endloop.

Compétences : MySQL

Voir plus : apriori code mysql, city zip code mysql, select form php mysql, html code mysql database, ajax code mysql read, write mysql processing, write mysql query, write mysql database, using excel write mysql, visual basic code mysql

Concernant l'employeur :
( 3 commentaires ) Woodland Hills, United States

N° du projet : #12630540

Décerné à :

dghq123

Hi there.. I have read your project details completely and willing to do it for you... Check my recent reviews for our quality work on on time delivery :) Please inbox and we can discuss about project and I will re Plus

50 $ USD en 1 jour
(10 Commentaires)
4.6