Modular Bill of Material (bome05)

/**************************************************************/
/*                                                            */
/*             S A S   S A M P L E   L I B R A R Y            */
/*                                                            */
/*    NAME: BOME05                                            */
/*   TITLE: Modular Bill of Material (bome05)                 */
/* PRODUCT: OR                                                */
/*  SYSTEM: ALL                                               */
/*    KEYS: OR                                                */
/*   PROCS: BOM, PRINT, SORT, BOM MACROS                      */
/*    DATA:                                                   */
/*                                                            */
/* SUPPORT:                             UPDATE:               */
/*     REF:                                                   */
/*    MISC: Example 5 from the BOM Procedure chapter of the   */
/*          BOM book.                                         */
/*                                                            */
/**************************************************************/

/**************************************************************

            Use PMaster3 and PMaster4 from BOME04

**************************************************************/

/* Part master records from BOME03 */

data PMaster3;
   input Part      $8.
         Desc      $24.
         Unit      $8.
         LeadTime  8.0
         ;
datalines;
1100    Finished shaft          Each           2
1200    6-Diameter steel plate  Each           3
1300    Hub                     Each           2
1400    1/4-20 Screw            Each           1
1500    Steel holder            Each           2
1600    One-way socket          Each           2
1700    Wiring assembly         Each           1
2100    3/8 Steel tubing        Inches         3
2200    16-Gauge lamp cord      Feet           2
2210    14-Gauge lamp cord      Feet           2
2300    Standard plug terminal  Each           1
A100    Socket assembly         Each           1
B100    Base assembly           Each           1
LA01    Lamp LA                 Each           2
S100    Black shade             Each           2
;


/* Generic and phantom part master data from BOME04 */

data Phantom4;
   format Part $8.;
   input Part      $8.
         Desc      $24.
         Req       8.0
         Unit      $8.
         LeadTime  4.0
         ;
datalines;
LAXX    Lamp LA                    10000 Each      3
4000    Common parts                   . Each      0
A10X    Socket assembly options        . Each      0
B10X    Base assembly options          . Each      0
S10X    Shade options                  . Each      0
;


/* Additional optional and alternative parts from BOME04 */

data Option4;
   format Part $8.;
   input Part      $8.
         Desc      $24.
         Req       8.0
         Unit      $8.
         LeadTime  4.0
         ;
datalines;
A101    Three-way socket assem.        . Each      1
B101    7in Base assembly              . Each      1
B102    8in Base assembly              . Each      1
S101    14in White shade               . Each      2
S102    14in Cream shade               . Each      2
S103    14in Yellow shade              . Each      2
S104    15in Black shade               . Each      2
S105    15in White shade               . Each      2
S106    15in Cream shade               . Each      2
S107    15in Yellow shade              . Each      2
1201    7-Diameter steel plate         . Each      3
1202    8-Diameter steel plate         . Each      3
1601    Three-way socket               . Each      2
;

data PMaster4;
set Phantom4
    Option4
    PMaster3(where=(Part NE 'LA01' AND Part NE '2210'));
run;

proc sort data=PMaster4;
   by Part;
run;


/**************************************************************

                        Begin example

**************************************************************/

/* Product Structure data */
data ParComp5;
   format Parent $8. Component $8. QtyPer 8.2 ;
   input Parent $ Component $ QtyPer;
datalines;
LAXX    4000        1.00
LAXX    B10X        1.00
LAXX    S10X        1.00
LAXX    A10X        1.00
4000    1100        1.00
4000    1300        1.00
4000    1400        4.00
4000    1500        1.00
4000    1700        1.00
B100    1200        1.00
B101    1201        1.00
B102    1202        1.00
A100    1600        1.00
A101    1601        1.00
1100    2100       26.00
1500    1400        2.00
1700    2200       12.00
1700    2300        1.00
;

/* Generate the indented BOM data set */
proc bom data=ParComp5 pmdata=PMaster4 out=IndBOM5;
   structure / part=Part
               leadtime=LeadTime
               parent=Parent
               component=Component
               quantity=QtyPer
               id=(Desc Unit);
run;

/* Display the indented BOM data */
proc print data=IndBOM5 noobs;
var _Level_ _Parent_ _Part_ Desc QtyPer Qty_Prod
    Unit LeadTime Tot_Lead _Prod_;
title 'ABC Lamp Company';
title3 'Indented Bill of Material';
run;

/* Copy LAXX to LA01 with B10X replaced by B100 */
%bomtsae(root='LA01', sameas='LAXX', except='B10X', repby='B100',
      in=IndBOM5, pmdata=PMaster3, part=Part, quantity=QtyPer,
      leadtime=LeadTime, id=Desc Unit, out=BomOut5);

/* Merge the bill of material for S100 to the new BOM */
data BomOut51;
set BomOut5
    IndBOM5(where=(_Prod_='S100'));
run;

/* Replace S10X with S100 */
%bomtrep(root='S10X', repby='S100', in=BomOut51, quantity=QtyPer,
      leadtime=LeadTime, id=Desc Unit, del=1, out=BomOut52);

/* Merge the bill of material for A100 to the new BOM */
data BomOut53;
set BomOut52
    IndBOM5(where=(_Prod_='A100'));
run;

/* Replace A10X with A100 */
%bomtrep(root='A10X', repby='A100', in=BomOut53, quantity=QtyPer,
      leadtime=LeadTime, id=Desc Unit, del=1, out=BomOut5);


/* Display the indented BOM data */

proc print data=BomOut5 noobs;
var _Level_ _Parent_ _Part_ Desc QtyPer Qty_Prod
    Unit LeadTime Tot_Lead _Prod_;
title 'ABC Lamp Company';
title3 'Indented Bill of Material, Part LA01';
run;