on 07-11-2007 6:36 AM
hi ,
can anybody tell me,
I am looking for a report or multiple reports (if I need to
link them that is fine) which show the following in bom
1) part number
2) Movement (Z_MAT_MOVE - should give me this)
3) If the part is on an active BOM (YES/NO column)
4) Forecast of next three months
1)part number _ MARA-MATNR
2) Movement (Z_MAT_MOVE - should give me this) -BSEG -TABLE
3) If the part is on an active BOM (YES/NO column) -
Mast-matnr
Stko-datvu
4) Forecast of next three months
Function module :BAPI_REQUIREMENts_getdetail
Report SEquence:
1.Selection Should be : Material and plant
2.Get the input from the Selection scrren and then pass it to the table
Mast-matnr / Stko -datu( which are linked by STLNR)
3.If the input return value then keep in a internal table t_01
4.The T_01 table needs to have the
material
plant
5.Now with this input give it to the Bapi_requirement_getdetaial
input as - material plant version
output - Reqqty for the next 3 months.
6. fill this in the t_01
You can desihn the layout..
i didint understan the movement type - requirment
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Check with below program and here i am getting BOM ..
I have done similar to CS11,CS12,CS13 Transaction ,see the BOM Program
Use FM to get BOM based on material number,
TABLES: mast,
stko,
stpo.
makt.
----
Internal Table Declaration *
----
DATA: t_mast LIKE STANDARD TABLE OF mast WITH HEADER LINE.
*DATA: t_makt LIKE STANDARD TABLE OF makt WITH HEADER LINE.
BOM Function module Related
DATA: t_matcat LIKE cscmat OCCURS 0 WITH HEADER LINE.
DATA: t_stb LIKE stpox OCCURS 0 WITH HEADER LINE.
Internal Table for STPO
*-- BOM Line item
TYPES: BEGIN OF ty_stpo,
stlty TYPE stpo-stlty,
stlnr TYPE stpo-stlnr,
stlkn TYPE stpo-stlkn,
stpoz TYPE stpo-stpoz,
idnrk TYPE stpo-idnrk,
meins TYPE stpo-meins,
menge TYPE stpo-menge, "Component Qty
END OF ty_stpo.
DATA: t_stpo TYPE STANDARD TABLE OF ty_stpo WITH HEADER LINE.
*-- BOM Header
TYPES: BEGIN OF ty_stko,
stlty TYPE stko-stlty,
stlnr TYPE stko-stlnr,
stlal TYPE stko-stlal,
stkoz TYPE stko-stkoz,
bmein TYPE stko-bmein,
bmeng TYPE stko-bmeng,
END OF ty_stko.
DATA: t_stko TYPE STANDARD TABLE OF ty_stko WITH HEADER LINE .
data : t_makt like makt occurs 0 with header line.
Variables
data : v_maktx like makt-maktx.
data wa_stko like stko.
----
Selection Screen *
----
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: p_werks LIKE marc-werks DEFAULT '1000' OBLIGATORY.
SELECT-OPTIONS s_stlal FOR mast-stlal .
SELECT-OPTIONS s_stlan FOR mast-stlan DEFAULT '1'.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
SELECTION-SCREEN SKIP.
PARAMETERS: p_bomlst RADIOBUTTON GROUP g1 DEFAULT 'X'.
SELECT-OPTIONS s_matnr FOR mast-matnr.
SELECTION-SCREEN SKIP.
PARAMETERS: p_compon RADIOBUTTON GROUP g1.
SELECT-OPTIONS: s_idnrk FOR stpo-idnrk.
SELECTION-SCREEN END OF BLOCK b2.
SELECTION-SCREEN END OF BLOCK b1.
************************************************************************
S T A R T - O F - S E L E C T I O N *******************
************************************************************************
start-of-selection.
Get the data from MAST and MAKT Table
if p_bomlst = 'X'.
perform get_data.
else.
perform get_data_component.
endif.
&----
*& Form get_data
&----
Get data from MAST and MAKT Table
----
FORM get_data.
data : wa_lines type sy-index.
Get the data from MAST Table
Get all the information from MAST - BOM Table
SELECT * FROM mast INTO TABLE t_mast WHERE matnr IN s_matnr AND
werks = p_werks AND
stlan IN s_stlan AND
stlal IN s_stlal.
describe table t_mast lines wa_lines.
if wa_lines is initial.
Write:/2 'List contains no data'.
stop.
endif.
loop at t_mast.
clear : v_maktx.
if sy-tabix ne 1.
new-page.
endif.
Get the material Description
select single maktx from makt into v_maktx
where matnr = t_mast-matnr
and spras = 'E'.
Get the material details from STKO Table
select single * from stko into wa_stko
where STLTY = 'M'
and STLNR = t_mast-stlnr
and STLAL = t_mast-stlal.
Main Header for Each Material
format color 5 on.
write:/2 'Material',20 'Material Description',65 'Alternative BOM',
90 'Base Qty', 115 'Base Unit'.
format color 5 off.
format color 1 on.
write:/2 t_mast-matnr,20 v_maktx,65 wa_stko-STLAL, 85 wa_stko-BMENG,
115 wa_stko-BMEIN.
format color 1 off.
CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'
EXPORTING
capid = 'PP01'
datuv = sy-datum
mktls = 'X'
mehrs = 'X'
mtnrv = t_mast-matnr
stlal = '01'
stlan = '1'
stpst = 0
svwvo = 'X'
werks = p_werks
vrsvo = 'X'
TABLES
stb = t_stb
matcat = t_matcat
EXCEPTIONS
alt_not_found = 1
call_invalid = 2
material_not_found = 3
missing_authorization = 4
no_bom_found = 5
no_plant_data = 6
no_suitable_bom_found = 7
conversion_error = 8
OTHERS = 9.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
loop at t_stb.
Get the material details from STKO Table
select single * from stpo into wa_stko1
where STLTY = t_stb-stlty
and STLNR = t_stb-stlnr
and STpoz = t_stb-stpoz
and stlkn = t_stb-stlkn
and idnrk = t_stb-idnrk.
if sy-tabix = 1.
format color 3 on.
write:/2 'Level',15 'Component',35 'Material Description',
75 'Alternative BOM',100 'Base Qty', 115 'Base Unit'.
.
format color 3 on.
endif.
if t_stb-STUFE = '1'.
format color 1 on.
write:/2 t_stb-STUFE,15 t_stb-idnrk,35 t_stb-OJTXP,75 t_stb-stlal,
90 t_stb-mngko,115 t_stb-MEINs.
format color 1 off.
elseif t_stb-STUFE = '2'.
format color 2 on.
write:/2 t_stb-STUFE,15 t_stb-idnrk,35 t_stb-OJTXP,75 t_stb-stlal,
90 t_stb-mngko,115 t_stb-MEINs.
format color 2 off.
elseif t_stb-STUFE = '3'.
format color 3 on.
write:/2 t_stb-STUFE,15 t_stb-idnrk,35 t_stb-OJTXP,75 t_stb-stlal,
90 t_stb-mngko,115 t_stb-MEINs.
format color 3 off.
elseif t_stb-STUFE = '4'.
format color 4 on.
write:/2 t_stb-STUFE,15 t_stb-idnrk,35 t_stb-OJTXP,75 t_stb-stlal,
90 t_stb-mngko,115 t_stb-MEINs.
format color 4 off.
elseif t_stb-STUFE = '5'.
format color 5 on.
write:/2 t_stb-STUFE,15 t_stb-idnrk,35 t_stb-OJTXP,75 t_stb-stlal,
90 t_stb-mngko,115 t_stb-MEINs.
format color 5 off.
elseif t_stb-STUFE = '6'.
format color 6 on.
write:/2 t_stb-STUFE,15 t_stb-idnrk,35 t_stb-OJTXP,75 t_stb-stlal,
90 t_stb-mngko,115 t_stb-MEINs.
format color 6 off.
elseif t_stb-STUFE = '7'.
format color 7 on.
write:/2 t_stb-STUFE,15 t_stb-idnrk,35 t_stb-OJTXP,75 t_stb-stlal,
90 t_stb-mngko,115 t_stb-MEINs.
format color 7 off.
else.
format color 1 on.
write:/2 t_stb-STUFE,15 t_stb-idnrk,35 t_stb-OJTXP,75 t_stb-stlal,
90 t_stb-mngko,115 t_stb-MEINs.
format color 1 off.
endif.
endloop.
endloop.
ENDFORM. " get_data
----
Top of page *
----
top-of-page.
perform report_header .
&----
*& Form report_header
&----
text
----
--> p1 text
<-- p2 text
----
FORM report_header.
new-page line-size 160 .
format color col_heading intensified on.
write:/ sy-uline(160) .
*--- Write Company Name.
perform calc_col_and_write using text-h00
sy-linsz.
*--- Write Report Title.
perform calc_col_and_write using sy-title
sy-linsz.
*--- Write User Id, Date / Time, Program Id, Page etc.
perform write_other_hdr_details.
write:/ sy-uline(160) .
ENDFORM. " report_header
&----
*& Form calc_col_and_write
&----
text
----
-->P_TEXT_H00 text
-->P_SY_LINSZ text
----
FORM calc_col_and_write USING P_TEXT
P_LINSZ.
data: col1 type i,
col2 type i,
len type i,
str type i.
str = strlen( p_text ).
col1 = ( p_linsz / 2 ) - ( str / 2 ) .
len = p_linsz - col1 - 2.
write: at /1 '|'.
write: at col1 p_text,
at sy-colno(len) space.
write at 160 '|'.
ENDFORM. " calc_col_and_write
&----
*& Form write_other_hdr_details
&----
text
----
--> p1 text
<-- p2 text
----
FORM write_other_hdr_details.
data: col1 type i,
col2 type i,
len type i.
col1 = 3.
write:/1 '|'.
write: at col1 'UserId : ',
sy-uname.
len = sy-linsz - 1.
write at sy-colno(len) space.
col2 = sy-linsz - 18.
write: at col2 'Date: ',
sy-datum mm/dd/yyyy.
write: at sy-linsz '|'.
write:/1 '|'.
write: at col1 'ReportId: ',
sy-repid.
write at sy-colno(len) space.
col2 = sy-linsz - 18.
write: at col2 'Page: ',
sy-pagno.
write: at sy-linsz '|'.
ENDFORM. " write_other_hdr_details
&----
*& Form get_data_component
&----
Get the data based on Component level
----
FORM get_data_component.
data wa_lines type i.
*-- Get the BOM item details
SELECT stlty stlnr stlkn stpoz idnrk meins menge
FROM stpo
INTO TABLE t_stpo
WHERE idnrk IN s_idnrk.
IF sy-subrc = 0.
CLEAR wa_lines.
DESCRIBE TABLE t_stpo LINES wa_lines.
IF wa_lines > 0.
SELECT stlty stlnr stlal stkoz bmein bmeng
FROM stko
INTO TABLE t_stko
FOR ALL ENTRIES IN t_stpo
WHERE stlnr = t_stpo-stlnr.
CLEAR wa_lines.
DELETE ADJACENT DUPLICATES FROM t_stko COMPARING ALL FIELDS.
DESCRIBE TABLE t_stko LINES wa_lines.
IF wa_lines > 0.
*-- Get the BOM item details
SELECT * FROM mast INTO TABLE t_mast FOR ALL ENTRIES IN t_stko
WHERE werks = p_werks AND
stlnr = t_stko-stlnr
and stlal in s_stlal.
ENDIF.
ENDIF.
else.
Write:/2 'List contains no data'.
stop.
endif.
loop at t_mast.
clear : v_maktx.
if sy-tabix ne 1.
new-page.
endif.
Get the material Description
select single maktx from makt into v_maktx
where matnr = t_mast-matnr
and spras = 'E'.
Get the material details from STKO Table
select single * from stko into wa_stko
where STLTY = 'M'
and STLNR = t_mast-stlnr
and STLAL = t_mast-stlal.
Main Header for Each Material
format color 5 on.
write:/2 'Material',20 'Material Description',65 'Alternative BOM',
90 'Base Qty', 115 'Base Unit'.
format color 5 off.
format color 1 on.
write:/2 t_mast-matnr,20 v_maktx,65 wa_stko-STLAL, 85 wa_stko-BMENG,
115 wa_stko-BMEIN.
format color 1 off.
CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'
EXPORTING
capid = 'PP01'
datuv = sy-datum
mktls = 'X'
mehrs = 'X'
mtnrv = t_mast-matnr
stlal = '01'
stlan = '1'
stpst = 0
svwvo = 'X'
werks = p_werks
vrsvo = 'X'
TABLES
stb = t_stb
matcat = t_matcat
EXCEPTIONS
alt_not_found = 1
call_invalid = 2
material_not_found = 3
missing_authorization = 4
no_bom_found = 5
no_plant_data = 6
no_suitable_bom_found = 7
conversion_error = 8
OTHERS = 9.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
loop at t_stb.
Get the material details from STKO Table
select single * from stpo into wa_stko1
where STLTY = t_stb-stlty
and STLNR = t_stb-stlnr
and STpoz = t_stb-stpoz
and stlkn = t_stb-stlkn
and idnrk = t_stb-idnrk.
if sy-tabix = 1.
format color 3 on.
write:/2 'Level',15 'Component',35 'Material Description',
75 'Alternative BOM',100 'Base Qty', 115 'Base Unit'.
.
format color 3 on.
endif.
if t_stb-STUFE = '1'.
format color 1 on.
write:/2 t_stb-STUFE,15 t_stb-idnrk,35 t_stb-OJTXP,75 t_stb-stlal,
90 t_stb-mngko,115 t_stb-MEINs.
format color 1 off.
elseif t_stb-STUFE = '2'.
format color 2 on.
write:/2 t_stb-STUFE,15 t_stb-idnrk,35 t_stb-OJTXP,75 t_stb-stlal,
90 t_stb-mngko,115 t_stb-MEINs.
format color 2 off.
elseif t_stb-STUFE = '3'.
format color 3 on.
write:/2 t_stb-STUFE,15 t_stb-idnrk,35 t_stb-OJTXP,75 t_stb-stlal,
90 t_stb-mngko,115 t_stb-MEINs.
format color 3 off.
elseif t_stb-STUFE = '4'.
format color 4 on.
write:/2 t_stb-STUFE,15 t_stb-idnrk,35 t_stb-OJTXP,75 t_stb-stlal,
90 t_stb-mngko,115 t_stb-MEINs.
format color 4 off.
elseif t_stb-STUFE = '5'.
format color 5 on.
write:/2 t_stb-STUFE,15 t_stb-idnrk,35 t_stb-OJTXP,75 t_stb-stlal,
90 t_stb-mngko,115 t_stb-MEINs.
format color 5 off.
elseif t_stb-STUFE = '6'.
format color 6 on.
write:/2 t_stb-STUFE,15 t_stb-idnrk,35 t_stb-OJTXP,75 t_stb-stlal,
90 t_stb-mngko,115 t_stb-MEINs.
format color 6 off.
elseif t_stb-STUFE = '7'.
format color 7 on.
write:/2 t_stb-STUFE,15 t_stb-idnrk,35 t_stb-OJTXP,75 t_stb-stlal,
90 t_stb-mngko,115 t_stb-MEINs.
format color 7 off.
else.
format color 1 on.
write:/2 t_stb-STUFE,15 t_stb-idnrk,35 t_stb-OJTXP,75 t_stb-stlal,
90 t_stb-mngko,115 t_stb-MEINs.
format color 1 off.
endif.
endloop.
endloop.
ENDFORM. " get_data_component
Forecast related tables :
tables: mara, " General Material Data
marc, " Plant Data for Material
marm, " Units of Measure for Material
mbew, " Material Valuation
likp, " SD Document: Delivery Header Data
ekpo, " Purchasing Document Item
lqua, " Quants
eket. " Scheduling Agreement Schedule Lines
Thanks
Seshu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear Narayan,
You can link <b>MARA, MKPF, MSEG, STKO, STPO</b> Tables to get the data.
Part Number - MATNR (MARA, MKPF, MSEG) or IDNRK (STPO)
Movement Type - BWART (MSEG)
BOM Active - DATUV (STPO)
Link between STPO and MARA is MARA-MANTR and STPO-IDNRK
Link between MARA and MSEG is MARA-MATNR and MSEG-MATNR
Regards,
Naveen.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
108 | |
12 | |
11 | |
6 | |
6 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.