Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

BOM-FM

Former Member
0 Likes
1,493

can anyone tell me about function module cs_bom_expl_mat_v2

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,269

Sure this function module takes a material number and plant and explodes the bill of material for all components of the parent.



data: begin of stpox occurs 1000.
        include structure stpox.
data: end of stpox.

parameters: p_matnr type marc-matnr,
            p_werks type marc-werks.

  call function 'CS_BOM_EXPL_MAT_V2'
       exporting
            capid                 = 'PP01'
            mehrs                 = 'X'
            datuv                 = sy-datum
            mtnrv                 = P_matnr
            werks                 = p_werks
            emeng                 = '1'
       tables
            stb                   = stpox
       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
            others                = 8.

loop at stpox.
write:/ stpox.
endloop.


For example, take material "A", we pass this to the function module. Say that material "A" bom includes components B C D. These would should in the result table. It will also show the component of B, C, and D if they are BOMs, and so on.

Regards,

Rich Heilman

8 REPLIES 8
Read only

Former Member
0 Likes
1,269

hi Ravi,

Check this out

call function <b>'CS_BOM_EXPL_MAT_V2'</b>

exporting

capid = 'PP01'

datuv = sy-datum

emeng = p_req_menge

mktls = 'X'

mehrs = 'X'

mtnrv = p_material

stlal = p_w_stlal

stlan = '1'

stpst = 0

svwvo = 'X'

werks = p_plant

vrsvo = 'X'

tables

stb = w_stpox

matcat = w_cscmat.

<b>http://www.geocities.com/victorav15/sapr3/abapfun.html

http://sap.ittoolbox.com/groups/technical-functional/SAP-R3-DEV/fm-cs_bom_expl_mat_v2-188319

Regards,

santosh

Message was edited by: Santosh Kumar P

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,270

Sure this function module takes a material number and plant and explodes the bill of material for all components of the parent.



data: begin of stpox occurs 1000.
        include structure stpox.
data: end of stpox.

parameters: p_matnr type marc-matnr,
            p_werks type marc-werks.

  call function 'CS_BOM_EXPL_MAT_V2'
       exporting
            capid                 = 'PP01'
            mehrs                 = 'X'
            datuv                 = sy-datum
            mtnrv                 = P_matnr
            werks                 = p_werks
            emeng                 = '1'
       tables
            stb                   = stpox
       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
            others                = 8.

loop at stpox.
write:/ stpox.
endloop.


For example, take material "A", we pass this to the function module. Say that material "A" bom includes components B C D. These would should in the result table. It will also show the component of B, C, and D if they are BOMs, and so on.

Regards,

Rich Heilman

Read only

0 Likes
1,269

thank u rich,

problem is solved,but

why did u use

write:\ stpox.

will it work in release 4.7?

and what mehrs mean?

Read only

0 Likes
1,269

Write:/stpox is just mearly writing out the results. I didn't want to take to the time to write out individual fields. In your case, I would suggest writing our whatever fields you want to see in the output.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
1,269

Hi,

this will expolde all the components to highest BOM level.

- S

Read only

former_member181966
Active Contributor
0 Likes
1,269

<b>FYI</b>

FU CS_BOM_EXPL_MAT_V2 ____________________________________________________ short text inventories solution; got into: Material

Doku of the parameters: Parameter BESSL - selection mark by place part basically counts: If the parameter is set, is looked over in table T417 with the by place-mark of the inventories position whether there customers by place is marked part or suppliers by place part. If not, is not selected the position. Possible values for give parameter are: X: The position counts than selects 1: Delivers only customer by place parts 2: Only supplier by place part parameter BEIKZ delivers - by place mark reviewed whether you give by place mark of the position is identical, is with that petition out of table T417.

Parameter FTREL ALEKZ ALTVO AUFSW AUMGB AUMNG AUSKZ AMIND BRAKE CAPID CHLST COSPR CUOBJ CUOVS CUOLS DATUV DELNL of WORKS NORVL MDNOT PANOT QVERW VERID VRSVO

TOPMAT DSTST

Exceptions OLD_NEED_ALT CALL_INVALID MATERIAL_NEED_MATERIAL MISSING_AUTHORIZATION NEED_BOM_FOUND NEED_PLANS_DATES NEED_SUITABLE_BOM_NOT CONVERSION_ERROR

Function group CSS4

Hope this’ll give you idea!!

<b>Pl... award the points.</b>

Good luck

Thanks

Saquib Khan

"Some are wise and some are otherwise"

Read only

Former Member
0 Likes
1,269

hi Ravi,

explanation:

Explode BOM for Production. Mostly necessary input parameters:

CAPID (Application Id): 'PP01' (Production - general)

DATUV (Validity date)

MTNRV (Material)

WERKS (Plant)

Example:

report z.

  • Explode assembly (including phantom assemblies up to last level)

parameters: p_werks like t001w-werks obligatory,

p_matnr like mara-matnr obligatory.

constants c_x value 'X'.

data: begin of it_comp occurs 0,

idnrk like stpox-idnrk,

ojtxp like stpox-ojtxp,

menge like stpox-menge,

meins like stpox-meins,

matkl like stpox-matmk,

end of it_comp.

data: w_topmat like cstmat,

*******************

start-of-selection.

*******************

perform explode_assembly.

*****************

end-of-selection.

*****************

perform write_report.

************

top-of-page.

************

perform print_header.

&----


form print_header.

write: /(18) 'Component'(h00),

(40) 'Description'(h01),

'Mat.Group'(h02),

(18) 'Quantity'(h03).

uline.

endform.

&----


form write_report.

write: / w_topmat-matnr under text-h00 color col_heading,

w_topmat-maktx under text-h01 color col_heading.

loop at it_comp.

write: /

it_comp-idnrk under text-h00,

it_comp-ojtxp under text-h01,

it_comp-matkl under text-h02,

it_comp-menge unit it_comp-meins under text-h03,

it_comp-meins.

endloop.

uline.

endform.

&----


form explode_assembly.

data: it_stb like stpox occurs 0 with header line,

it_stb2 like stpox occurs 0 with header line,

it_stb3 like stpox occurs 0 with header line,

w_msg(255) type c.

  • Explode highest level:

call function 'CS_BOM_EXPL_MAT_V2'

exporting

capid = 'PP01'

cuols = c_x

datuv = sy-datum

knfba = c_x

ksbvo = c_x

mbwls = c_x

mdmps = c_x

mtnrv = p_matnr

werks = p_werks

importing

topmat = w_topmat

tables

stb = it_stb

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

into w_msg.

write: / w_msg.

exit.

endif.

  • Don't process documents

delete it_stb where idnrk is initial.

  • Don't process valid from furure:

delete it_stb where datuv >= sy-datum.

  • Explode phantom assemblies up to last level

do.

it_stb2[] = it_stb[].

delete it_stb2 where dumps is initial.

if it_stb2[] is initial.

exit.

endif.

delete it_stb where not dumps is initial.

loop at it_stb2.

call function 'CS_BOM_EXPL_MAT_V2'

exporting

capid = 'PP01'

cuols = c_x

datuv = sy-datum

knfba = c_x

ksbvo = c_x

mbwls = c_x

mdmps = c_x

mtnrv = it_stb2-idnrk

werks = p_werks

tables

stb = it_stb3

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

into w_msg.

write: / w_msg.

else.

delete it_stb3 where idnrk is initial.

loop at it_stb3.

multiply it_stb3-menge by it_stb2-menge.

modify it_stb3 transporting menge.

endloop.

append lines of it_stb3 to it_stb.

endif.

endloop.

enddo.

  • Build table of components collecting the same components from

  • all levels

loop at it_stb.

it_comp-matkl = it_stb-matmk.

it_comp-idnrk = it_stb-idnrk.

it_comp-ojtxp = it_stb-ojtxp.

it_comp-menge = it_stb-menge.

it_comp-meins = it_stb-meins.

collect it_comp.

clear it_comp.

endloop.

endform.

Read only

Former Member
0 Likes
1,269

hi,

function module cs_bom_expl_mat_v2

The required fields for this function module are :

> Material

> Plant

> Date

> Application(CAPID)

> Values for CAPID can be found in table TC04

> For production BOM it is PP01

The required fields for this function module are :

> Material

> Plant

> Date

> Application(CAPID)

> Values for CAPID can be found in table TC04

> For production BOM it is PP01

Multi level items are exploded only if one of the Import parameters in the function module is checked. I forgot which one but you can refer to the following code for the function module which gave me multi level bom explosions.

call function 'CS_BOM_EXPL_MAT_V2'

exporting

capid = 'PP01'

datuv = sy-datum

emeng = p_req_menge

mktls = 'X'

mehrs = 'X'

mtnrv = p_material

stlal = p_w_stlal

stlan = '1'

stpst = 0

svwvo = 'X'

werks = p_plant

vrsvo = 'X'

tables

stb = w_stpox

matcat = w_cscmat.

>

> I guess this should help

regards,

keerthi.

Message was edited by: keerthi kiran varanasi