Application Development 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: 

linking table between material number and BOM number

Former Member
0 Kudos

Hi All,

I am using external material number. While creating the BOM for the material it creates once again different number for this material. but i need to know linkning table between the material number and BOM number.

thanks,

rajesh

3 REPLIES 3

Former Member

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

  • DESCRIPTION: This program will extract BOM data from production SAP *

  • and store it in a flat file. The output file uses the *

  • same file format as the input file for BOM conversion *

  • Program. *

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

TABLES: STKO, STPO, MAST,MARC, T002,T001W.

----


  • I N T E R N A L T A B L E S *

----


  • Internal table for Header

DATA: BEGIN OF tbl_bicsk OCCURS 0.

INCLUDE STRUCTURE bicsk.

DATA: END OF tbl_bicsk.

DATA: BEGIN OF tbl_cstmat OCCURS 0.

INCLUDE STRUCTURE cstmat.

DATA: END OF tbl_cstmat.

DATA: BEGIN OF tbl_stko OCCURS 0,

stlty LIKE stko-stlty,

stlnr LIKE stko-stlty,

stlal LIKE stko-stlty,

stkoz LIKE stko-stlty,

aennr LIKE stko-aennr,

END OF tbl_stko.

  • Internal table for Item

DATA: BEGIN OF tbl_bicsp OCCURS 0.

INCLUDE STRUCTURE bicsp.

DATA: END OF tbl_bicsp.

DATA: BEGIN OF tbl_item OCCURS 0.

INCLUDE STRUCTURE stpox.

DATA: END OF tbl_item.

  • Internal table for output

DATA: BEGIN OF tbl_output OCCURS 0,

v_data(1024),

END OF tbl_output.

DATA: BEGIN OF tbl_mast OCCURS 0 ,

matnr LIKE mast-matnr,

stlal LIKE mast-stlal,

stlan LIKE mast-stlan,

werks LIKE mast-werks,

END OF tbl_mast.

DATA: BEGIN OF tbl_altbom OCCURS 0,

count TYPE i VALUE '01',

matnr LIKE cstmat-matnr,

END OF tbl_altbom.

DATA tbl_header LIKE tline OCCURS 0 WITH HEADER LINE.

DATA: BEGIN OF tbl_plant OCCURS 0,

werks LIKE t001w-werks,

END OF tbl_plant.

DATA: BEGIN OF tbl_matnr OCCURS 0,

matnr LIKE marc-matnr,

werks LIKE marc-werks,

END OF tbl_matnr.

DATA: tbl_dynpfields LIKE dynpread OCCURS 0 WITH HEADER LINE.

DATA: BEGIN OF tbl_file OCCURS 0,

material(18) TYPE c,

END OF tbl_file.

DATA: BEGIN OF tbl_material OCCURS 0,

matnr LIKE marc-matnr,

END OF tbl_material.

----


  • D A T A D E C L A R A T I O N *

----


DATA: v_stlty LIKE stko-stlty.

DATA: v_stlnr LIKE stko-stlnr.

DATA tdname_header LIKE thead-tdname.

DATA tdname_alter LIKE thead-tdname.

DATA tdname_item LIKE thead-tdname.

DATA: BEGIN OF tbl_text,

stype LIKE bicsk-stype,

lang LIKE sy-langu,

tdformat LIKE tline-tdformat,

tdline(72),

isolang(2),

END OF tbl_text.

DATA v_stkoz LIKE stko-stkoz.

DATA v_filesize TYPE i.

DATA: v_download_lines(9) TYPE n,

v_mapl_lines_read(9) TYPE n,

v_plpo_lines_read(9) TYPE n,

v_plko_lines_read(9) TYPE n,

v_plas_lines_read(9) TYPE n,

v_prev_plnnr LIKE mapl-plnnr,

v_prev_plnal LIKE mapl-plnal,

v_repid LIKE sy-repid,

v_length TYPE i,

v_suppress_report(1) TYPE c,

v_answer(1) TYPE c,

v_unix_filename LIKE rlgrap-filename,

v_filename LIKE rlgrap-filename,

v_directory LIKE draw-filep,

v_file LIKE draw-filep .

----


  • S E L E C T - O P T I O N S / P A R A M E T E R S *

----


SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

SELECTION-SCREEN BEGIN OF LINE.

PARAMETERS: r_allmat RADIOBUTTON GROUP 004.

SELECTION-SCREEN COMMENT 4(42) text-103.

SELECTION-SCREEN END OF LINE.

SELECT-OPTIONS: s_matnr FOR marc-matnr.

SELECTION-SCREEN BEGIN OF LINE.

PARAMETERS: r_matfil RADIOBUTTON GROUP 004.

SELECTION-SCREEN COMMENT 4(42) text-104.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN POSITION 4.

PARAMETERS: r_matapp RADIOBUTTON GROUP 003.

SELECTION-SCREEN COMMENT 7(40) text-105.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN POSITION 4.

PARAMETERS p_appnam LIKE filename-fileextern

DEFAULT '/usr/sap/data/ice/matfile.txt'.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN POSITION 4.

PARAMETERS: r_matpre RADIOBUTTON GROUP 003.

SELECTION-SCREEN COMMENT 7(40) text-106.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN POSITION 4.

PARAMETERS P_PRENAM LIKE RLGRAP-FILENAME.

SELECTION-SCREEN END OF LINE.

SELECT-OPTIONS: s_werks FOR marc-werks OBLIGATORY,

s_stlan for mast-stlan.

SELECTION-SCREEN END OF BLOCK b1.

SELECTION-SCREEN SKIP 2.

SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.

PARAMETERS: p_unix RADIOBUTTON GROUP rg01.

PARAMETERS: p_path LIKE rlgrap-filename DEFAULT

'/usr/sap/data/ice/'.

PARAMETERS: p_unfile LIKE rlgrap-filename.

SELECTION-SCREEN SKIP 1.

PARAMETERS: p_pc RADIOBUTTON GROUP rg01.

PARAMETERS: P_OFILE LIKE RLGRAP-FILENAME

OBLIGATORY DEFAULT 'c:/BOM.txt'.

SELECTION-SCREEN END OF BLOCK b2.

----


  • A T S E L E C T I O N - S C R E E N *

----


AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_prenam.

CALL FUNCTION 'KD_GET_FILENAME_ON_F4'

EXPORTING

program_name = v_repid

CHANGING

file_name = p_prenam

EXCEPTIONS

mask_too_long = 1

OTHERS = 2.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_ofile.

CALL FUNCTION 'KD_GET_FILENAME_ON_F4'

EXPORTING

program_name = v_repid

CHANGING

file_name = p_ofile

EXCEPTIONS

mask_too_long = 1

OTHERS = 2.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

  • Check valid materials are entered

AT SELECTION-SCREEN ON s_matnr.

PERFORM material_check.

----


  • I N I T I A L I Z A T I O N *

----


INITIALIZATION.

*Refresh internal tables.

REFRESH:tbl_bicsk,

tbl_cstmat,

tbl_bicsp,

tbl_item,

tbl_output,

tbl_mast,

tbl_header,

tbl_plant,

tbl_matnr,

tbl_stko,

tbl_dynpfields.

  • Retrieve langauge from table T002 (Language keys table)

SELECT SINGLE * FROM t002 WHERE spras = sy-langu.

  • Hold the report/program name

v_repid = sy-repid.

----


  • S T A R T - O F - S E L E C T I O N *

----


START-OF-SELECTION.

  • Check valid plant is entered

PERFORM plant_check.

  • check the filenames are entered

PERFORM check_filenames.

  • Get Data

PERFORM get_data.

  • Download output data

PERFORM download_data.

END-OF-SELECTION.

&----


*& Form GET_DATA

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM get_data.

DATA: v_msg(100) TYPE c.

IF r_matfil EQ 'X'.

IF r_matapp EQ 'X'.

  • PERFORM open_dataset USING p_appnam 'I' 'T' 1.

OPEN DATASET p_appnam FOR INPUT IN TEXT MODE MESSAGE v_msg.

CHECK syst-subrc = 0.

DO.

READ DATASET p_appnam INTO tbl_file.

IF syst-subrc <> 0.

EXIT.

ELSE.

APPEND tbl_file.

CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'

EXPORTING

input = tbl_file-material

IMPORTING

output = tbl_material-matnr

EXCEPTIONS

number_not_found = 1

OTHERS = 2.

CHECK syst-subrc = 0.

APPEND tbl_material.

CLEAR: tbl_file, tbl_material.

ENDIF.

ENDDO.

CLOSE DATASET p_appnam.

ELSE.

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

filename = p_prenam

filetype = 'ASC'

TABLES

data_tab = tbl_file

EXCEPTIONS

conversion_error = 1

file_open_error = 2

file_read_error = 3

invalid_type = 4

no_batch = 5

unknown_error = 6

invalid_table_width = 7

gui_refuse_filetransfer = 8

customer_error = 9

OTHERS = 10.

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 tbl_file.

CLEAR tbl_material.

CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'

EXPORTING

input = tbl_file-material

IMPORTING

output = tbl_material-matnr

EXCEPTIONS

number_not_found = 1

OTHERS = 2.

CHECK syst-subrc = 0.

APPEND tbl_material.

ENDLOOP.

ENDIF.

ENDIF.

IF r_matfil EQ 'X'.

IF NOT tbl_material[] IS INITIAL.

SELECT matnr stlal stlan werks FROM mast

INTO TABLE tbl_mast

FOR ALL ENTRIES IN tbl_material

WHERE matnr EQ tbl_material-matnr

AND werks IN s_werks

and stlan in s_stlan.

ENDIF.

ELSE.

SELECT matnr stlal stlan werks FROM mast

INTO TABLE tbl_mast

WHERE matnr IN s_matnr

AND werks IN s_werks

and stlan in s_stlan.

ENDIF.

IF NOT tbl_mast[] IS INITIAL.

LOOP AT tbl_mast.

CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'

EXPORTING

capid = 'PP01'

datuv = sy-datum

mtnrv = tbl_mast-matnr

stlal = tbl_mast-stlal

stlan = tbl_mast-stlan

werks = tbl_mast-werks

IMPORTING

topmat = tbl_cstmat

  • DSTST =

TABLES

stb = tbl_item

  • 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.

PERFORM header_data.

PERFORM long_text USING 'MZU' '2' tdname_header.

PERFORM long_text USING 'MKO' '3' tdname_alter.

PERFORM item_data.

ENDIF.

CLEAR:tbl_cstmat,tbl_item.

REFRESH:tbl_cstmat,tbl_item.

ENDLOOP.

ELSE.

WRITE:/ text-010. "No Bill of Material Found'

STOP.

ENDIF.

ENDFORM. " GET_DATA

&----


*& Form header_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM header_data.

SORT tbl_cstmat.

READ TABLE tbl_cstmat INDEX 1.

  • Batch Input Interface record Type

tbl_bicsk-stype = '1'.

  • Transaction Code

tbl_bicsk-tcode = 'CS01'.

  • Change Number

tbl_bicsk-aennr = tbl_cstmat-aennr.

  • BOM Base unit of measure

tbl_bicsk-bmein = tbl_cstmat-bmein.

  • Base quanity

IF NOT tbl_cstmat-bmeng IS INITIAL.

tbl_bicsk-bmeng = tbl_cstmat-bmeng.

ENDIF.

  • CAD indicator

tbl_bicsk-cadkz = tbl_cstmat-cadkz.

  • Valid to date

  • IF NOT tbl_cstmat-datub IS INITIAL.

  • tbl_bicsk-datub = tbl_cstmat-datub.

  • ENDIF.

  • Valid from date

IF NOT tbl_cstmat-datuv IS INITIAL.

tbl_bicsk-datuv = tbl_cstmat-datuv.

ENDIF.

  • Required Quanity

  • IF NOT tbl_cstmat-emeng IS INITIAL.

  • tbl_bicsk-emeng = tbl_cstmat-emeng.

  • ENDIF.

  • tbl_bicsk-equnr = v_space. " Equipment number

  • BOM Group

tbl_bicsk-exstl = tbl_cstmat-exstl.

  • Laboratory/design office

tbl_bicsk-labor = tbl_cstmat-labor.

  • Deletion indicator for BOMs

tbl_bicsk-loekz = tbl_cstmat-loekz.

  • To lot size

IF NOT tbl_cstmat-losbs IS INITIAL.

tbl_bicsk-losbs = tbl_cstmat-losbs.

ENDIF.

  • From lot size

IF NOT tbl_cstmat-losvn IS INITIAL.

tbl_bicsk-losvn = tbl_cstmat-losvn.

ENDIF.

  • Material Number

tbl_bicsk-matnr = tbl_cstmat-matnr.

  • Alternative BOM : sequential nos.

tbl_altbom-count = 01.

tbl_altbom-matnr = tbl_cstmat-matnr.

LOOP AT tbl_altbom WHERE matnr = tbl_altbom-matnr.

tbl_altbom-count = tbl_altbom-count + 1.

ENDLOOP.

APPEND tbl_altbom.

tbl_bicsk-selal = tbl_altbom-count .

CLEAR tbl_altbom.

  • tbl_bicsk-serge = . "Manufacturer serial number

  • Alernative BOM text

tbl_bicsk-stktx = tbl_cstmat-stktx.

  • Alternative BOM

tbl_bicsk-stlal = tbl_cstmat-stlal.

  • BOM usage

tbl_bicsk-stlan = tbl_cstmat-stlan.

  • Authorization group for bills of material

tbl_bicsk-stlbe = tbl_cstmat-stlbe.

  • BOM status

IF NOT tbl_cstmat-stlst IS INITIAL.

tbl_bicsk-stlst = tbl_cstmat-stlst.

ELSE.

REPLACE '00' WITH ' ' INTO tbl_cstmat-stlst.

ENDIF.

  • tbl_bicsk-VMTNR = . "Material Variant

  • Plant

tbl_bicsk-werks = tbl_cstmat-werks.

  • Bom text

  • tbl_bicsk-ZTEXT = ?.

  • Revision level

tbl_bicsk-revlv = tbl_cstmat-revlv.

  • tbl_bicsk-TPLNR = . "Function location

  • tbl_bicsk-DOKAR = . "Document type

  • tbl_bicsk-DOKNR = . "Document number

  • tbl_bicsk-DOKTL = . "Document part

  • tbl_bicsk-DOKVR = . "Document version

  • tbl_bicsk-VBELN = . "Sales order

  • Sales order item

REPLACE '000000' WITH ' ' INTO tbl_bicsk-vbpos.

  • tbl_bicsk-STOBJ = . "Standard object

  • tbl_bicsk-VDKNR = . "Document(Variant)

  • tbl_bicsk-VDKAR = "Document type(Variant)

  • tbl_bicsk-VDKTL = "Document part(Variant)

  • tbl_bicsk-VDKVR = "Document version (Variant)

  • tbl_bicsk-VEQNR = "Equipment (Variant)

  • tbl_bicsk-VTPNR = "Function location (Variant)

  • tbl_bicsk-PSPNR = "WBS element BI BOMs

  • tbl_bicsk-OITXT =

  • Header long text

CONCATENATE sy-mandt tbl_cstmat-stlty tbl_cstmat-stlnr INTO

tdname_header.

  • Sort the BOM header data internal table

SORT tbl_stko.

  • Read the internal table (BOM Header data)

READ TABLE tbl_stko

WITH KEY stlty = tbl_cstmat-stlty

stlnr = tbl_cstmat-stlnr

stlal = tbl_cstmat-stlal

aennr = tbl_cstmat-aennr

BINARY SEARCH.

IF sy-subrc EQ 0.

v_stkoz = tbl_stko-stkoz.

ELSE.

  • Retrieve BOM header data from table STKO (BOM Header data)

SELECT stlty

stlnr

stlal

stkoz

aennr

FROM stko

INTO TABLE tbl_stko

WHERE stlty = tbl_cstmat-stlty

AND stlnr = tbl_cstmat-stlnr

AND stlal = tbl_cstmat-stlal

AND aennr = tbl_cstmat-aennr.

  • Variable to hold the counter

v_stkoz = tbl_stko-stkoz.

ENDIF.

CONCATENATE sy-mandt tbl_cstmat-stlty tbl_cstmat-stlnr

tbl_cstmat-stlal v_stkoz INTO tdname_alter.

tbl_output-v_data = tbl_bicsk.

APPEND tbl_bicsk.

APPEND tbl_output.

CLEAR tbl_bicsk.

CLEAR tbl_output.

CLEAR v_stkoz.

  • endif.

ENDFORM. " header_data

&----


*& Form download_data

&----


  • Download the data to local file

----


FORM download_data.

IF p_pc = 'X'.

IF NOT tbl_output[] IS INITIAL.

CALL FUNCTION 'WS_DOWNLOAD'

EXPORTING

filename = p_ofile

filetype = 'ASC'

IMPORTING

filelength = v_filesize

TABLES

data_tab = tbl_output

  • FIELDNAMES =

EXCEPTIONS

file_open_error = 1

file_write_error = 2

invalid_filesize = 3

invalid_type = 4

no_batch = 5

unknown_error = 6

invalid_table_width = 7

gui_refuse_filetransfer = 8

customer_error = 9

OTHERS = 10

.

IF sy-subrc = 0.

WRITE:/ v_filesize,' ',text-006. " No of bytes downloaded sucessfully

ENDIF.

ELSE.

IF sy-subrc <> 0.

WRITE:/ 'Error writing PC download file - return code'(003),

sy-subrc.

STOP.

ENDIF.

ENDIF.

ENDIF.

IF p_unix = 'X'.

CONCATENATE p_path p_unfile INTO v_unix_filename.

DELETE DATASET v_unix_filename.

  • Open Unix file

OPEN DATASET v_unix_filename FOR OUTPUT IN TEXT MODE.

  • Issue error message

IF sy-subrc NE 0.

  • message e009. " Error while getting the file name

WRITE:/ text-007. "Error while opening/writing the file unix server

STOP.

ENDIF.

LOOP AT tbl_output.

  • Transfer the record to the file

TRANSFER tbl_output-v_data TO v_unix_filename.

ENDLOOP.

ENDIF.

  • Close the Unix file

CLOSE DATASET v_unix_filename.

ENDFORM. " download_data

&----


*& Form item_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM item_data.

LOOP AT tbl_item.

  • Batch input interface record type

tbl_bicsp-stype = '4'.

  • Line indiex

REPLACE '0000' WITH ' ' INTO tbl_bicsp-xline.

  • Indicator: Sub-items exist

tbl_bicsp-upskz = tbl_item-upskz. "Indicator:sub-items exist

  • tbl_bicsp-AUSKZ = . "selection Indicator

  • Indicator: Alternative item

tbl_bicsp-alpos = tbl_item-alpos.

  • Component scrap in percent

IF NOT tbl_item-ausch IS INITIAL.

tbl_bicsp-ausch = tbl_item-ausch. "Component scrap in percent

ENDIF.

  • Operation scrap

IF NOT tbl_item-avoau IS INITIAL.

tbl_bicsp-avoau = tbl_item-avoau.

ENDIF.

  • Material provision indicator

tbl_bicsp-beikz = tbl_item-beikz.

  • CAD indicator

tbl_bicsp-cadpo = tbl_item-cadpo.

  • Purchasing group

tbl_bicsp-ekgrp = tbl_item-ekgrp.

  • Indicator: Spare part

tbl_bicsp-erskz = tbl_item-erskz.

  • Fixed qty

tbl_bicsp-fmeng = tbl_item-fmeng.

  • BOM Component

tbl_bicsp-idnrk = tbl_item-idnrk.

  • Account number of vendor/creditor

tbl_bicsp-lifnr = tbl_item-lifnr.

  • Delivery time in days

IF NOT tbl_item-lifzt IS INITIAL.

tbl_bicsp-lifzt = tbl_item-lifzt.

ENDIF.

  • Material group

tbl_bicsp-matkl = tbl_item-matkl.

  • Component unit of measure

tbl_bicsp-meins = tbl_item-meins.

  • Componet quantity

IF NOT tbl_item-menge IS INITIAL.

tbl_bicsp-menge = tbl_item-menge.

ENDIF.

  • Indicator: Net scrap

tbl_bicsp-netau = tbl_item-netau.

  • Follow-up Material in BOM item

tbl_bicsp-nfmat = tbl_item-nfmat.

  • Follow-up item

IF NOT tbl_item-nlfzt IS INITIAL.

tbl_bicsp-nlfzt = tbl_item-nlfzt.

ENDIF.

  • Price unit

IF NOT tbl_item-peinh IS INITIAL.

tbl_bicsp-peinh = tbl_item-peinh.

ENDIF.

  • BOM item number

tbl_bicsp-posnr = tbl_item-posnr.

  • Item catergory (Bill of material)

tbl_bicsp-postp = tbl_item-postp.

  • Price (BTCI)

IF NOT tbl_item-preis IS INITIAL.

tbl_bicsp-preis = tbl_item-preis.

ENDIF.

  • BOM item text (line 1)

tbl_bicsp-potx1 = tbl_item-potx1.

  • BOM item text (line 2)

tbl_bicsp-potx2 = tbl_item-potx2.

  • Issusing plant

tbl_bicsp-pswrk = tbl_item-pswrk. "Issuing plant

  • Indicator: recursiveness allowed

tbl_bicsp-rekrs = tbl_item-rekrs.

  • Formula key

tbl_bicsp-rform = tbl_item-rform.

  • Number of variable-size items

IF NOT tbl_item-roanz IS INITIAL.

tbl_bicsp-roanz = tbl_item-roanz.

ENDIF.

*tbl_bicsp-ROAME = . "Unit of measure for variable-size items

*tbl_bicsp-ROKME = . "Unit of measure for variable-size component

  • Unit of measure for sizes 1 to 3

tbl_bicsp-romei = tbl_item-romei.

  • Quantity of variable-size item

IF NOT tbl_item-romen IS INITIAL.

tbl_bicsp-romen = tbl_item-romen.

ENDIF.

  • Size 1

IF NOT tbl_item-roms1 IS INITIAL.

tbl_bicsp-roms1 = tbl_item-roms1.

ENDIF.

  • Size 2

IF NOT tbl_item-roms2 IS INITIAL.

tbl_bicsp-roms2 = tbl_item-roms2.

ENDIF.

  • Size 3

IF NOT tbl_item-roms3 IS INITIAL.

tbl_bicsp-roms3 = tbl_item-roms3.

ENDIF.

  • Indicator: item relevant to sales

tbl_bicsp-rvrel = tbl_item-rvrel.

  • Cost element

tbl_bicsp-sakto = tbl_item-sakto.

  • Indicator: item relevant to production

IF NOT tbl_item-sanfe IS INITIAL.

tbl_bicsp-sanfe = tbl_item-sanfe.

ELSE.

tbl_bicsp-sanfe = '!'.

ENDIF.

  • Indicator: item relevant to plant maintenance

tbl_bicsp-sanin = tbl_item-sanin.

  • Indicator for relevancy of costing

tbl_bicsp-sanka = tbl_item-sanka.

  • Indicator: item relevant to engineering

tbl_bicsp-sanko = tbl_item-sanko.

  • Indicator: high-level configuration

tbl_bicsp-sanvs = tbl_item-sanvs.

  • Indicator: bulk material

tbl_bicsp-schgt = tbl_item-schgt.

  • Alternative BOM

tbl_bicsp-selal = tbl_item-caalt. "exist in 4.6c

  • BOM component

tbl_bicsp-selid = tbl_item-idnrk.

  • BOM item number

tbl_bicsp-selpo = tbl_item-posnr.

  • tbl_bicsp-SELSB = tbl_item-. " Sort string

  • Sort string

tbl_bicsp-sortf = tbl_item-sortf.

  • PM assembly indicator

tbl_bicsp-stkkz = tbl_item-stkkz.

*tbl_bicsp-STKTX = tbl_item-. "Aternative BOM text

  • Alternative BOM

tbl_bicsp-stlal = tbl_item-stlal.

  • Indicator:assembly

tbl_bicsp-stlkz = tbl_item-stkkz.

  • Distribution key for component consumption

tbl_bicsp-verti = tbl_item-verti.

  • Processing time for goods receipt in days

IF NOT tbl_item-webaz IS INITIAL.

tbl_bicsp-webaz = tbl_item-webaz.

ENDIF.

  • Currency key

tbl_bicsp-waers = tbl_item-waers.

  • Document type

tbl_bicsp-dokar = tbl_item-dokar.

  • Document number

tbl_bicsp-doknr = tbl_item-doknr.

  • Document version

tbl_bicsp-dokvr = tbl_item-dokvr.

  • Document part

tbl_bicsp-doktl = tbl_item-doktl.

  • Usage probability in %

IF NOT tbl_item-ewahr IS INITIAL.

tbl_bicsp-ewahr = tbl_item-ewahr.

ENDIF.

  • Purchasing Organization

tbl_bicsp-ekorg = tbl_item-ekorg.

  • Issue location for poroduction order

tbl_bicsp-lgort = tbl_item-lgort.

  • Class number

tbl_bicsp-class = tbl_item-class.

  • Class type

tbl_bicsp-klart = tbl_item-klart.

  • Resulting item category

tbl_bicsp-potpr = tbl_item-potpr.

  • Alternative item: Group

tbl_bicsp-alpgr = tbl_item-alpgr.

  • Alternative item: Strategy

tbl_bicsp-alpst = tbl_item-alpst.

  • Alternative item: Ranking order

IF NOT tbl_item-alprf IS INITIAL.

tbl_bicsp-alprf = tbl_item-alprf.

ELSE.

REPLACE '00' WITH ' ' INTO tbl_bicsp-alprf.

ENDIF.

  • Explosion type

tbl_bicsp-dspst = tbl_item-dspst.

  • Supply area

  • Strat sree

tbl_bicsp-prvbe = tbl_item-prvbe. "exist in 4.6c

  • end sree

  • Discontinuation group

tbl_bicsp-nfeag = tbl_item-nfeag.

  • Follow-up group

tbl_bicsp-nfgrp = tbl_item-nfgrp.

  • Indicator: Co-product

tbl_bicsp-kzkup = tbl_item-kzkup.

  • Intra material

tbl_bicsp-intrm = tbl_item-intrm.

  • Indicator: Classification as selection condition

tbl_bicsp-kzclb = tbl_item-kzclb.

  • Lead-time offset for operation

  • Start of sree exist in 4.6c

if not tbl_item-nlfzv is initial.

tbl_bicsp-nlfzv = tbl_item-nlfzv.

endif.

  • Unit for lead-time offset for operation

tbl_bicsp-nlfmv = tbl_item-nlfmv.

  • Reference point for BOM transfer

tbl_bicsp-rfpnt = tbl_item-rfpnt.

  • end of sree

tbl_output-v_data = tbl_bicsp.

APPEND tbl_bicsp.

APPEND tbl_output.

CLEAR tbl_bicsp.

CLEAR tbl_output.

  • Item long text

CONCATENATE sy-mandt tbl_item-bmtyp tbl_item-stlnr

tbl_item-stlkn tbl_item-stpoz INTO tdname_item.

PERFORM long_text USING 'MPO' '5' tdname_item.

ENDLOOP.

ENDFORM. " item_data

&----


*& Form Long_text

&----


  • text

----


  • -->P_0249 text

----


FORM long_text USING text_id stype v_name.

CLEAR tbl_header.

REFRESH tbl_header.

CALL FUNCTION 'READ_TEXT'

EXPORTING

id = text_id

language = sy-langu

name = v_name

object = 'BOM'

TABLES

lines = tbl_header

EXCEPTIONS

id = 1

language = 2

name = 3

not_found = 4

object = 5

reference_check = 6

wrong_access_to_archive = 7.

IF sy-subrc = 0.

  • SELECT SINGLE * FROM t002 WHERE spras = sy-langu.

LOOP AT tbl_header.

tbl_text-stype = stype.

tbl_text-lang = t002-spras.

tbl_text-tdformat = tbl_header-tdformat.

tbl_text-tdline = tbl_header-tdline.

tbl_text-isolang = t002-laiso.

tbl_output = tbl_text.

APPEND tbl_output.

CLEAR tbl_text.

ENDLOOP.

ELSEIF sy-subrc = 4.

ENDIF.

ENDFORM. " Long_text

&----


*& Form PLANT_CHECK

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM plant_check.

IF NOT s_werks[] IS INITIAL.

SELECT werks FROM t001w INTO TABLE tbl_plant WHERE werks IN s_werks.

IF sy-subrc NE 0.

WRITE:/ text-008. " Invalid Plant

STOP.

ENDIF.

ENDIF.

ENDFORM. " PLANT_CHECK

&----


*& Form Material_check

&----


  • Validate the material

----


FORM material_check.

SELECT matnr werks FROM marc INTO TABLE tbl_matnr

WHERE werks IN s_werks

AND matnr IN s_matnr.

IF sy-subrc NE 0.

WRITE:/ text-009. " 'No material found'

STOP.

ENDIF.

  • Refresh and Free the internal table tbl_matnr

REFRESH:tbl_matnr.

FREE:tbl_matnr.

ENDFORM. " Material_check

&----


*& Form check_filenames

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM check_filenames.

  • make sure the user has entered a file name

IF p_pc = 'X' AND p_ofile = ' '.

WRITE:/ 'Please enter a PC file name'(011).

STOP.

ENDIF.

IF p_unix = 'X' AND p_unfile = ' '.

WRITE:/ 'Please enter a UNIX file name'(012).

STOP.

ENDIF.

  • If the UNIX file name exists, ask for a confirmation that the

  • file is to be over-written. The PC is for testing and we

  • do not care if it is over-written.

IF p_unix = 'X'.

CONCATENATE p_path p_unfile INTO v_unix_filename.

OPEN DATASET v_unix_filename FOR INPUT IN TEXT MODE.

IF sy-subrc = 0.

CLOSE DATASET v_unix_filename.

CALL FUNCTION 'POPUP_TO_CONFIRM'

EXPORTING

titlebar = text-005

text_question = text-004

text_button_1 = 'YES'

text_button_2 = 'NO'

default_button = '2'

start_column = 25

start_row = 6

IMPORTING

answer = v_answer

EXCEPTIONS

text_not_found = 1

OTHERS = 2.

IF v_answer = '2'. "no over-write

v_suppress_report = 'X'.

STOP.

ENDIF.

ENDIF.

ENDIF.

If it is useful please give me reward points...

Former Member
0 Kudos

Its MAST and STPO.

In MAST you can give the material number! and get the STLNR.

And with the STLNR, you may look into STPO for fetching the BOMs. ie the IDNRK field in STPO will give the material number of the BOM.

Relation Between Material and BOM Item:

  1. Go to MAST table; fill material number in MATNR
  2. TAKE Value from STLNR and place in BOM header table STKO(field STLNR).
  3. Consider STLTY value(if u find multiple entries , consider the corresponding plant entry )
  4. TAKE this STLTY and STLNR, place in BOM Item Table.

You can get the required BOM item for the material.

Best regards

Siva Kukkala