10-17-2008 6:57 AM
hi friends
i am to make a screen where i am to explode the BOM up to semifinished level for each lineitem
of the sales order & i am to add acondition extra for all BOM materials .
can somebody suggest me if in detailed will be very much thankful .
regards
digvijay
10-17-2008 7:04 AM
Hi,
Please check the link below, it may help you.
Also check the code below which does not require Function module approach.
include zbom_data_declarartion.
include zbom_selection_screen.
include zform_used.
*initialization
initialization.
prm1 = 'SELECTION'.
prm2 = 'Materials'.
&----
START-OF-SELECTION
&----
start-of-selection.
Get the data from data base tablees
perform get_data.
*Format the final data
perform final_data.
*Display the final data
perform display_final.
&----
*& Include ZBOM_DATA_DECLARARTION
&----
************************************************************************
T Y P E - P O O L S
************************************************************************
tables: mara, "Material Master
mast, "Material to BOM Linkage
stpo. "BOM item
type-pools: slis .
types: begin of ty_mara,
matnr type matnr,
mtart type mtart,
end of ty_mara.
types: begin of ty_mast,
matnr type matnr,
werks type werks_d,
stlan type stlan,
stlnr type stnum,
stlal type stalt,
end of ty_mast.
types: begin of ty_header,
matnr type matnr,
werks type werks_d,
end of ty_header.
types: begin of ty_stpo,
stlty type stlty,
stlnr type stnum,
stlkn type stlkn,
stpoz type cim_count,
idnrk type idnrk,
meins type kmpme,
menge type kmpmg,
preis type cprei,
peinh type peinh,
end of ty_stpo.
types: begin of ty_bom,
matnr type matnr,
werks type werks_d,
idnrk type idnrk,
meins type kmpme,
menge type kmpmg,
end of ty_bom.
Internal tables used in the code
data: it_stpo type standard table of ty_stpo,
it_mara1 type standard table of ty_mara,
it_mara2 type standard table of ty_mara,
it_mast type standard table of ty_mast,
it_bom type standard table of ty_bom,
it_header type standard table of ty_header.
Work Areas used in the code
data: wa_mast type ty_mast,
wa_stpo type ty_stpo,
wa_mara type ty_mara,
wa_bom type ty_bom,
wa_header type ty_header.
data: v_matnr type mara-matnr.
data: col_pos type i.
data: sortcat type slis_t_sortinfo_alv,
sortcat_ln type slis_sortinfo_alv,
fcat type slis_t_fieldcat_alv,
s_fcat type slis_fieldcat_alv.
data: obj_hieralv type ref to cl_salv_hierseq_table.
data: it_binding type salv_t_hierseq_binding,
wa_binding type salv_s_hierseq_binding.
&----
*& Include ZBOM_SELECTION_SCREEN
&----
*-Declaration of selection screen forthe program-*
selection-screen begin of block blk1 with frame title prm1.
selection-screen begin of line.
selection-screen comment (10) prm2 for field so_matnr.
Selection Option.
select-options : so_matnr for v_matnr.
selection-screen end of line.
selection-screen end of block blk1.
&----
*& Include ZFORM_USED
&----
&----
*& Form GET_DATA
&----
text
----
form get_data .
*LOADING FINISHED MATERIALS INTO AN INTERNAL TABLE
select matnr
mtart
into table it_mara1
from mara
where matnr in so_matnr
and mtart = 'FERT'.
if sy-subrc = 0.
sort it_mara1 by matnr.
endif.
*LOADING CORRESPONDING FROM Material to BOM LINK TABLE
if it_mara1 is not initial.
select matnr
werks
stlan
stlnr
stlal
into table it_mast
from mast
for all entries in it_mara1
where matnr = it_mara1-matnr .
if sy-subrc = 0.
sort it_mast by stlnr.
loop at it_mast into wa_mast.
move-corresponding wa_mast to wa_header.
*
append wa_header to it_header.
endloop.
endif.
endif.
*LOADING CORRESPONDING BOM COMPONENTS FRON BOM ITEM TABLE
if it_mast is not initial.
select stlty
stlnr
stlkn
stpoz
idnrk
meins
menge
preis
peinh
from stpo
into table it_stpo
for all entries in it_mast
where stlnr = it_mast-stlnr.
if sy-subrc eq 0.
sort it_stpo by stlnr.
endif.
endif.
*LOAD SEMIFINISHED MATERIAL
select matnr
mtart
from mara
into table it_mara2
where mtart = 'HALB'.
if sy-subrc eq 0.
sort it_mara2 by matnr.
endif.
endform. " GET_SELECT
&----
*& Form FINAL_data
&----
text
----
form final_data .
loop at it_stpo into wa_stpo.
clear wa_mara.
read table it_mara2 into wa_mara
with key matnr = wa_stpo-idnrk
binary search.
if sy-subrc ne 0.
continue.
else.
read table it_mast into wa_mast
with key stlnr = wa_stpo-stlnr
binary search.
if sy-subrc eq 0.
clear wa_bom.
wa_bom-matnr = wa_mast-matnr.
wa_bom-werks = wa_mast-werks.
wa_bom-idnrk = wa_stpo-idnrk.
wa_bom-meins = wa_stpo-meins.
wa_bom-menge = wa_stpo-menge.
collect wa_bom into it_bom.
move-corresponding wa_mast to wa_header.
append wa_header to it_header.
endif.
endif.
endloop.
sort it_header by matnr werks.
sort it_bom by matnr werks idnrk.
delete adjacent duplicates from it_header comparing matnr werks.
endform. " FINAL_data
&----
*& Form display_summary
&----
text
----
form display_final.
wa_binding-master = 'MATNR'.
wa_binding-slave = 'MATNR'.
append wa_binding to it_binding.
*Process of binding the header and BOM info in hirarchial form
try.
call method cl_salv_hierseq_table=>factory
exporting
t_binding_level1_level2 = it_binding
importing
r_hierseq = obj_hieralv
changing
t_table_level1 = it_header
t_table_level2 = it_bom.
catch cx_salv_data_error .
catch cx_salv_not_found .
endtry.
*to dispay the info
call method obj_hieralv->display.
endform.
Edited by: pr murthy on Oct 17, 2008 8:04 AM