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

Full Sample code for CS_BOM_EXPL_MAT_V2?

Former Member
0 Likes
7,602

Hello, I need to get BoM simulating the transaction CS03.

That's the parameters that I enter to CS03 selection screen to get the BoM that I need:

Material 0000030

Plant 0101

BOM usage 1 Production

Alternative BOM 1

Valid from 04.04.2008 (sy-datum)

Valid to 04.04.2008 (sy-datum)

Now I'm trying to get the same result by code. But the FM doesn't return me a result. What I'm doing wrong? I've tried all the possible values of CAPID and always the result is "error material not found". Then, when I commented the field capid the result is "Error, BoM not found"...

This is my full abap code:

data : it_stb like stpox occurs 0 with header line,

it_matcat like cscmat occurs 0 with header line.

call function 'CS_BOM_EXPL_MAT_V2'

exporting

  • capid = 'SD01'

datuv = sy-datum

mehrs = 'X'

mtnrv = '0000030'

werks = '0101'

tables

stb = it_stb

matcat = it_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

others = 8.

IF SY-SUBRC <> 0.

WRITE: 'SY-SUBRC = ', sy-subrc.

ENDIF.

5 REPLIES 5
Read only

Former Member
0 Likes
2,730

Hi,

data : it_stb2    like stpox occurs 0 with header line,
       it_spma2x like it_spma2 occurs 0 with header line,
       it_matcat  like cscmat occurs 0 with header line,
       it_dwl1    like it_dwl occurs 0 with header line,
 call function 'CS_BOM_EXPL_MAT_V2'
    exporting
      capid                 = 'PP01'
      datuv                 = sy-datum
      mktls                 = 'X'
      mehrs                 = 'X'
      mmory                 = '1'
      mtnrv                 = it_spma2-matnr
      werks                 = werks
    tables
      stb                   = it_stb2
      matcat                = it_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
      others                = 8.

Reward if usefull

Read only

0 Likes
2,730

HI,

how to link the IT_MATCAT and IT_STB2 tables?

what is the difference between material BOM and sales order BOM?

The BOM which we are extracting from FM which BOM is this either Material or Sales order?
If this is material BOM how we can extract the sales order BOM from CSKB transaction?

Read only

rahul_kamble2
Participant
0 Likes
2,730

Please try following code.

CONSTANTS: lc_mehrs LIKE csdata-xfeld VALUE 'X',

lc_capid LIKE t159l-capid VALUE 'Z001'.

gc_c1 TYPE mast-stlal VALUE '1',

gc_2 TYPE mast-stlan VALUE '2',

  • Call Function to Explode the BOM till Last Level

CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'

EXPORTING

capid = lc_capid

datuv = gv_datum

mehrs = lc_mehrs

mtnrv = gwa_bom-matnr

stlal = gc_c1

stlan = gc_2

werks = space

TABLES

stb = git_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

conversion_error = 8

OTHERS = 9.

Also try to pass the value of material & plant in a variable of appropriate type instead of hard coding the values.

Reward if helpful

Read only

Former Member
0 Likes
2,730

actually u are not passing fields stlal and stlan

see samlpe code

now to explode BOM

loop at p_it_header into wa_header .

call function 'CS_BOM_EXPL_MAT_V2'

exporting

capid = c_capid

datuv = sy-datum

  • mehrs = c_x

mtnrv = wa_header-matnr

stlal = wa_header-stlal

stlan = wa_header-stlan

werks = wa_header-werks

tables

stb = p_it_final

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.

endloop.

PLZ REWARD IF HELPFUL

VIVEK

Edited by: Vivek Gaur on Apr 4, 2008 12:06 PM

Read only

Former Member