Skip to Content
avatar image
Former Member

To Extend Materials from one Plant to Another

Hi All,

i have to extend materials from one plant to another plant using BAPI

BAPI_MATERIAL_SAVEDATA. I already got the sample program from SDN .

The material should be extended with account,storage,warehouse views.

what r the mandatory fields to pass the values in the exporting , importing parameters and tables in BAPI_MATERIAL_SAVEDATA..

Regards,

V.GaneshRaja.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

5 Answers

  • avatar image
    Former Member
    May 30, 2007 at 11:56 AM

    Hi Ganesh,

    you need to pass,

    Texts: application object

    Name

    Text ID

    Language key

    Language according to ISO 639

    Tag column

    Text line

    Delete Data Record

    Thanks,

    reward If helpful.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 28, 2007 at 07:56 PM

    How can I make this BAPI to copy the accounting view with the average price converted to the currency of the country's plant. Prsently I am coyng materials from a canadian plant to a plant in europe, the price in canadian is 10.00 but still show in the new plant 10.00. It suppose to convert it. Which parameter am I missing.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 28, 2007 at 08:09 PM

    Hi Ganesh,

    Check this, You have answer

    http://www.sap-img.com/abap/bapi-to-copy-materials-from-one-plant-to-another.htm

    Regards,

    Satish

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 29, 2007 at 06:57 AM

    Hi,

    Try this report:

    &----


    *& Report ZDMPMMULTIPLANT *

    *& *

    &----


    *& *

    *& *

    &----


    REPORT ZDMPMMULTIPLANT NO STANDARD PAGE HEADING

    MESSAGE-ID zdmmm

    LINE-SIZE 255.

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

    • TABLE DECLARATION *

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

    TABLES: mara, "General Material Data

    mard, "Storage location data

    mdma, "MRP data for material

    marc. "Plant Data for Material

    include zdmmulti_top.

    include zdmmulti_f00.

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

    • AT SELECTION-SCREEN *

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

    AT SELECTION-SCREEN.

    IF NOT s_matnr[] IS INITIAL.

    *Subroutine to perform the Material Number validation

    PERFORM sub_validate_matnr.

    ELSEIF p_ersda IS INITIAL.

    MESSAGE e003 .

    ENDIF.

    IF NOT s_werks[] IS INITIAL.

    • Subroutine to perform the plant validation

    PERFORM sub_validate_plant.

    ENDIF.

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

    • START-OF-SELECTION

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

    START-OF-SELECTION.

    *To retrive all possible material numbers that have to be

    *extended.

    PERFORM sub_get_mara.

    *To retrieve all possible plants to which the material needs

    *to be extended.

    IF s_werks IS INITIAL.

    PERFORM sub_get_werks.

    ENDIF.

    *For retrieving Procurement status data from T134.

    PERFORM sub_get_pstat.

    *To determine the plants to which the Materials have

    *already been extended.

    PERFORM sub_get_marc.

    *To determine all Storage Locations for individual Plants.

    PERFORM sub_get_t001l.

    *To retrieve company code

    PERFORM sub_get_t001k.

    *To determine the storage locations and plants to which the Material

    *has already extended.

    PERFORM sub_get_mard.

    *To determine the MRP Areas to which the materials need to be extended.

    PERFORM sub_get_mdlv.

    *To determine the MRP Areas to which the materials already been extended

    .

    PERFORM sub_get_mdma.

    *To retrieve the MRP Area related data from customized table.

    PERFORM sub_get_zdmmm_mrp_area.

    *TO retrieve the Scalabilty info

    PERFORM sub_get_scalability.

    • For extending Material to Plant, all possible Storage Location and

    • corresponding MRP Area .

    PERFORM sub_mat_extn.

    *For creating success and error log.

    PERFORM sub_create_log.

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

    &----


    *& Include ZDMMULTI_TOP

    &----


    &----


    *& Include ZDMMULTI_TOP *

    &----


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

    • Types

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

    *Type declaration to hold material no.

    TYPES: BEGIN OF ty_matnr,

    matnr TYPE matnr, "Material Number

    mtart TYPE mtart, "Material Type

    ersda TYPE ersda, "Creation date

    mbrsh TYPE mbrsh, "Industry Sector

    vkorg TYPE vkorg, "Sales Organization

    vtweg TYPE vtweg, "Distribution Channel

    mtartz TYPE mtart, "Material Type (Customized)

    END OF ty_matnr.

    *Type declaration to hold plant.

    TYPES: BEGIN OF ty_plant,

    werks TYPE werks_d, "Plant

    bwkey TYPE bwkey, "Valuation area

    END OF ty_plant.

    *Type declaration to hold data from marc.

    TYPES: BEGIN OF ty_marc,

    matnr TYPE matnr, "Material Number

    werks TYPE werks_d, "Plant

    bwkey TYPE bwkey,

    END OF ty_marc.

    *Type declaration to hold data from mard.

    TYPES: BEGIN OF ty_mard,

    matnr TYPE matnr, "Material Number

    werks TYPE werks_d, "Plant

    lgort TYPE lgort_d, "Storage Location

    mtart TYPE mtart, "Material Type

    END OF ty_mard.

    *Type declaration to hold data from t001l.

    TYPES: BEGIN OF ty_sloc,

    werks TYPE werks_d, "Plant

    lgort TYPE lgort_d, "Storage Location

    END OF ty_sloc.

    *Type declaration to hold data from mdlv.

    TYPES: BEGIN OF ty_mdlv,

    berid TYPE berid, "MRP Area

    werzg TYPE werks_d, "Plant

    ortzg TYPE lgort_d, "Storage Location

    END OF ty_mdlv.

    *Type declaration to hold data from custom table ZDMMM_MRP_AREA.

    TYPES: BEGIN OF ty_refmdma,

    zmtart TYPE zdmmm_mrp_area-zmtart, "Material Type (Customized)

    zwerks TYPE zdmmm_mrp_area-zwerks, "Plant

    zberid TYPE zdmmm_mrp_area-zberid, "MRP Area

    zdismm TYPE zdmmm_mrp_area-zdismm, "MRP Type

    zeisbe TYPE zdmmm_mrp_area-zeisbe, "Safety Stock

    zdisls TYPE zdmmm_mrp_area-zdisls, "Lot Size

    zdispo TYPE zdmmm_mrp_area-zdispo, "MRP Controller

    zfxhor TYPE zdmmm_mrp_area-zfxhor, "Plant Delivery Time (In days)

    END OF ty_refmdma.

    *Type declaration to hold data for success log.

    TYPES: BEGIN OF ty_succ,

    mat(18) TYPE c, "Material

    plant(8) TYPE c, "Plant

    sloc(15) TYPE c, "Storage Location

    comm(150) TYPE c, "Comments

    END OF ty_succ.

    *Type declaration to hold data for error log.

    TYPES: BEGIN OF ty_error,

    mat(18) TYPE c, "Material

    plant(8) TYPE c, "Plant

    sloc(15) TYPE c, "Storage Location

    comm(150) TYPE c, "Comments

    END OF ty_error.

    *Type declaration for holding data from mvke

    TYPES: BEGIN OF ty_mvke,

    matnr TYPE matnr, "Material Number

    vkorg TYPE vkorg, "Sales Org

    vtweg TYPE vtweg, "Distribution Channel

    END OF ty_mvke.

    *Type declaration for holding data from qmat

    TYPES: BEGIN OF ty_qmat,

    matnr type matnr,

    werks type werks_d,

    art TYPE qmat-art,

    ppl TYPE qmat-ppl,

    spezueber TYPE qmat-spezueber,

    conf TYPE qmat-conf,

    tls TYPE qmat-tls,

    app TYPE qmat-app,

    mer TYPE qmat-mer,

    insmk TYPE qmat-insmk,

    ave TYPE qmat-ave,

    stichprver TYPE qmat-stichprver,

    dynregel TYPE qmat-dynregel,

    sproz TYPE qmat-sproz,

    hpz TYPE qmat-hpz,

    dyn TYPE qmat-dyn,

    mpb TYPE qmat-mpb,

    mst TYPE qmat-mst,

    ein TYPE qmat-ein,

    mpdau TYPE qmat-mpdau,

    chg TYPE qmat-chg,

    qkzverf TYPE qmat-qkzverf,

    qpmat TYPE qmat-qpmat,

    kzprfkost TYPE qmat-kzprfkost,

    aufnr_co TYPE qmat-aufnr_co,

    aktiv TYPE qmat-aktiv,

    apa TYPE qmat-apa,

    afr TYPE qmat-afr,

    mma TYPE qmat-mma,

    feh TYPE qmat-feh,

    prfrq TYPE qmat-prfrq,

    nkmpr TYPE qmat-nkmpr,

    END OF ty_qmat.

    *Type declaration for MARA and MARC data for reference material

    TYPES: BEGIN OF ty_ref_data,

    matnr TYPE matnr, "Material Number

    ladgr TYPE ladgr, "Loading Group

    bklas TYPE bklas, "Valuation class

    peinh TYPE peinh, "Price unit

    losgr TYPE losgr, "Costing Lot Size

    hkmat TYPE hkmat, "Material Origin

    herkl TYPE herkl, "Country Of Origin

    dismm TYPE dismm, "MRP Type

    dispo TYPE dispo, "MRP Controller

    fxhor TYPE fxhor, "Planned delivery time (In days)

    disls TYPE disls, "Lot size

    fhori TYPE fhori, "Scheduling Margin Key for Floats

    magrv TYPE magrv,

    vhart TYPE vhart,

    ergew TYPE ergew,

    ervol TYPE ervol,

    fuelg TYPE fuelg,

    stfak TYPE stfak,

    gewto TYPE gewto,

    volto TYPE volto,

    prctr TYPE prctr,

    kzgvh TYPE kzgvh,

    stawn TYPE stawn,

    mtver TYPE mtver,

    casnr TYPE casnr,

    gpnum TYPE gpnum,

    steuc TYPE steuc,

    herkr TYPE herkr,

    mownr TYPE mownr,

    mogru TYPE mogru,

    prenc TYPE prenc,

    preno TYPE preno,

    prend TYPE prend,

    itark TYPE itark,

    bstme TYPE bstme,

    vabme TYPE vabme,

    nrfhg TYPE nrfhg,

    mfrgr TYPE mfrgr,

    ekwsl TYPE ekwsl,

    webaz TYPE webaz,

    insmk TYPE insmk,

    kzkri TYPE kzkri,

    usequ TYPE usequ,

    kordb TYPE kordb,

    mprof TYPE mprof,

    ekgrp TYPE ekgrp,

    disgr TYPE disgr,

    maabc TYPE maabc,

    minbe TYPE minbe,

    lfrhy TYPE lfrhy,

    bstmi TYPE bstmi,

    bstma TYPE bstma,

    bstfe TYPE bstfe,

    mabst TYPE mabst,

    losfx TYPE losfx,

    lagpr TYPE lagpr,

    ausss TYPE ausss,

    takzt TYPE takzt,

    rdprf TYPE rdprf,

    bstrf TYPE bstrf,

    megru TYPE megru,

    sobsl TYPE sobsl,

    kzech TYPE kzech,

    lgpro TYPE lgpro,

    vspvb TYPE vspvb,

    rgekz TYPE rgekz,

    lgfsb TYPE lgfsb,

    fabkz TYPE fabkz,

    eprio TYPE eprio,

    schgt TYPE schgt,

    plifz TYPE plifz,

    mrppp TYPE mrppp,

    eisbe TYPE eisbe,

    lgrad TYPE lgrad,

    eislo TYPE eislo,

    rwpro TYPE rwpro,

    shflg TYPE shflg,

    shzet TYPE shzet,

    shpro TYPE shpro,

    periv TYPE periv,

    auftl TYPE auftl,

    strgr TYPE strgr,

    vrmod TYPE vrmod,

    vint2 TYPE vint2,

    umref TYPE umref,

    prgrp TYPE prgrp,

    vint1 TYPE vint1,

    miskz TYPE miskz,

    prwrk TYPE prwrk,

    mtvfp TYPE mtvfp,

    wzeit TYPE wzeit,

    kzpsp TYPE kzpsp,

    stdpd TYPE stdpd,

    perkz TYPE perkz,

    altsl TYPE altsl,

    kausf TYPE kausf,

    sbdkz TYPE sbdkz,

    kzbed TYPE kzbed,

    ahdis TYPE ahdis,

    kzaus TYPE kzaus,

    ausdt TYPE ausdt,

    nfmat TYPE nfmat,

    sauft TYPE sauft,

    sfepr TYPE sfepr,

    mdach TYPE mdach,

    dplfs TYPE dplfs,

    dplpu TYPE dplpu,

    dplho TYPE dplho,

    tempb TYPE tempb,

    raube TYPE raube,

    behvo TYPE behvo,

    stoff TYPE stoff,

    abcin TYPE abcin,

    ccfix TYPE ccfix,

    wesch TYPE wesch,

    etiar TYPE etiar,

    etifo TYPE etifo,

    xgchp TYPE xgchp,

    maxlz TYPE maxlz,

    lzeih TYPE lzeih,

    mhdrz TYPE mhdrz,

    mhdhb TYPE mhdhb,

    iprkz TYPE dattp,

    rdmhd TYPE rdmhd,

    mhdlp TYPE mhdlp,

    brgew TYPE brgew,

    ntgew TYPE ntgew,

    volum TYPE volum,

    voleh TYPE voleh,

    groes TYPE groes,

    xmcng TYPE xmcng,

    loggr TYPE loggr,

    sernp TYPE serail,

    serlv TYPE serlv,

    fprfm TYPE fprfm,

    ausme TYPE ausme,

    qmata TYPE qmatauth,

    kzdkz TYPE kzdkz,

    prfrq TYPE prfrq,

    rbnrm TYPE rbnr,

    qmpur TYPE qmpur,

    ssqss TYPE ssqss,

    qzgtp TYPE qzgtyp,

    qssys TYPE qssys,

    bwtty TYPE bwtty,

    eklas TYPE eklas,

    qklas TYPE qklas,

    verpr TYPE verpr,

    stprs TYPE stprs,

    zkprs TYPE dzkprs,

    zkdat TYPE dzkdat,

    bwprs TYPE bwprs,

    bwprh TYPE bwprh,

    bwps1 TYPE bwps1,

    bwph1 TYPE bwph1,

    vjbws TYPE vjbws,

    vjbwh TYPE vjbwh,

    abwkz TYPE abwkz,

    bwpei TYPE bwpei,

    xlifo TYPE xlifo,

    mypol TYPE mypool,

    ncost TYPE ck_no_costing,

    ekalr TYPE ck_ekalrel,

    hrkft TYPE hrkft,

    kosgr TYPE ck_kosgr,

    awsls TYPE awsls,

    mmsta TYPE mmsta,

    mmstd TYPE mmstd,

    stlal TYPE stlal,

    stlan TYPE stlan,

    plnnr TYPE plnnr,

    aplal TYPE plnal,

    plnty TYPE plnty,

    sobsk TYPE ck_sobsl,

    zplpr TYPE dzplpr,

    zplp1 TYPE dzplp1,

    zpld1 TYPE dzpld1,

    zplp2 TYPE dzplp2,

    zpld2 TYPE dzpld2,

    zplp3 TYPE dzplp3,

    zpld3 TYPE dzpld3,

    lvolg TYPE lvolg,

    diskz TYPE diskz,

    lsobs TYPE lsobs,

    lminb TYPE lminb,

    lbstf TYPE lbstf,

    lgpbe TYPE lgpbe,

    END OF ty_ref_data.

    *Type declaration for holding data from mdma

    TYPES: BEGIN OF ty_mdma,

    matnr TYPE mdma-matnr, "Material Number

    berid TYPE mdma-berid, "MRP Area

    werks TYPE mdma-werks, "Plant

    END OF ty_mdma.

    *Type declaration for holding Company code data

    TYPES: BEGIN OF ty_bukrs,

    bwkey TYPE bwkey, "Valuation Area

    bukrs TYPE bukrs, "Company code

    END OF ty_bukrs.

    *Type declaration for holding T001w Data

    TYPES: BEGIN OF ty_t001w,

    werks TYPE werks_d, "Plant

    bwkey TYPE bwkey, "Valuation Area

    END OF ty_t001w.

    *Type declaration for holding T134 Data

    TYPES: BEGIN OF ty_t134,

    mtart TYPE mtart, " Material type

    pstat TYPE pstat, "Condensed status display

    END OF ty_t134.

    • Type declaration for Holding TWLAD data

    TYPES: BEGIN OF ty_twlad,

    werks TYPE werks_d,

    lgort TYPE lgort_d,

    adrnr TYPE adrnr,

    END OF ty_twlad.

    *Type declaration for holding ADRC data

    TYPES: BEGIN OF ty_adrc,

    adrnr TYPE adrnr, "Address number

    sort2 TYPE ad_sort2, "Search Term

    END OF ty_adrc.

    TYPES: BEGIN OF ty_dev00160,

    pkey TYPE zkey, "parameter key

    item TYPE zitem, "Item No

    value TYPE zvalue,

    END OF ty_dev00160.

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

    • Constants

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

    CONSTANTS: c_header(1) TYPE c VALUE 'H', "Header

    c_true(1) TYPE c VALUE 'X', "value = x

    c_v(1) TYPE c VALUE 'V', "Sales View

    c_e(1) TYPE c VALUE 'E', "Purchasing View

    c_d(1) TYPE c VALUE 'D', "MRP View

    c_p(1) TYPE c VALUE 'P', "Forecasting View

    c_a(1) TYPE c VALUE 'A', "Work Scheduling view

    c_l(1) TYPE c VALUE 'L', "Storage View

    c_q(1) TYPE c VALUE 'Q', "Quality View

    c_b(1) TYPE c VALUE 'B', "Accounting

    c_g(1) TYPE c VALUE 'G', "Costing View

    c_f(1) TYPE c VALUE 'F', "PRT View

    c_k(1) TYPE c VALUE 'K'. "Basic View

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

    • Internal tables

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

    *Internal table to hold material no and material type

    DATA: i_matnr TYPE STANDARD TABLE OF ty_matnr INITIAL SIZE 0.

    *Internal table to hold plant

    DATA: i_plant TYPE STANDARD TABLE OF ty_plant INITIAL SIZE 0.

    *Internal table to hold marc data

    DATA: i_marc TYPE STANDARD TABLE OF ty_marc INITIAL SIZE 0.

    *Internal table to hold marc data

    DATA: i_tmarc TYPE STANDARD TABLE OF ty_marc INITIAL SIZE 0.

    *Internal table to hold mard data

    DATA: i_mard TYPE STANDARD TABLE OF ty_mard INITIAL SIZE 0.

    *Internal table to hold t001l data

    DATA: i_sloc TYPE STANDARD TABLE OF ty_sloc INITIAL SIZE 0.

    *Internal table to hold MRP Area

    DATA: i_mdlv TYPE STANDARD TABLE OF ty_mdlv INITIAL SIZE 0.

    *Internal table to hold already extended MRP Area

    DATA: i_mdma TYPE STANDARD TABLE OF ty_mdma INITIAL SIZE 0.

    *Internal table to hold MRP Area data from customized table

    DATA: i_refmdma TYPE STANDARD TABLE OF ty_refmdma INITIAL SIZE 0.

    *Internal table to hold success messages

    DATA: i_succ TYPE STANDARD TABLE OF ty_succ INITIAL SIZE 0.

    *Internal table to hold error messages

    DATA: i_error TYPE STANDARD TABLE OF ty_error INITIAL SIZE 0.

    *Internal table to hold mvke data

    DATA: i_mvke TYPE STANDARD TABLE OF ty_mvke INITIAL SIZE 0.

    *Internal table for company code data

    DATA: i_bukrs TYPE STANDARD TABLE OF ty_bukrs INITIAL SIZE 0.

    *Internal table for T001W data

    DATA: i_t001w TYPE STANDARD TABLE OF ty_t001w INITIAL SIZE 0.

    *Internal table for T134 data

    DATA: i_t134 TYPE STANDARD TABLE OF ty_t134 INITIAL SIZE 0.

    *Internal table for TWLAD data

    DATA: i_twlad TYPE STANDARD TABLE OF ty_twlad INITIAL SIZE 0.

    *Internal table for ADRC data

    DATA: i_adrc TYPE STANDARD TABLE OF ty_adrc INITIAL SIZE 0.

    *Internal table for dev00160 data

    DATA: i_dev00160 TYPE STANDARD TABLE OF ty_dev00160 INITIAL SIZE 0.

    *Internal table for qmat data

    DATA: i_qmat TYPE STANDARD TABLE OF ty_qmat INITIAL SIZE 0.

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

    • Work areas

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

    *Work Area for Internal table i_mara

    DATA: wa_matnr TYPE ty_matnr.

    *Work Area for Internal table i_werks

    DATA: wa_plant TYPE ty_plant.

    *Work Area for Internal table i_marc

    DATA: wa_marc TYPE ty_marc.

    *Work Area for Internal table i_t001l

    DATA: wa_sloc TYPE ty_sloc.

    *Work Area for Internal table i_mdlv

    DATA: wa_mdlv TYPE ty_mdlv.

    *Work Area for Internal table i_bukrs

    DATA: wa_bukrs TYPE ty_bukrs.

    *Work Area for Internal table i_refmdma.

    DATA: wa_refmdma TYPE ty_refmdma.

    *Work Area for Internal table i_succ

    DATA: wa_succ TYPE ty_succ.

    *Work Area for Internal table i_error

    DATA: wa_error TYPE ty_error.

    *Work Area for Internal table i_selfields

    DATA: wa_selfields TYPE sdibe_massfields.

    *Work Area for Internal table i_mvke

    DATA: wa_mvke TYPE ty_mvke.

    *Work Area for Internal table i_ref_data

    DATA: wa_ref_data TYPE ty_ref_data.

    *Work Area for internal table I_t001w

    DATA: wa_t001w TYPE ty_t001w.

    *Work Area for internal table I_t001w

    DATA: wa_twlad TYPE ty_twlad.

    *Work Area for internal table I_t134

    DATA: wa_t134 TYPE ty_t134.

    • WOrk Area for ADRC Table

    DATA: wa_adrc TYPE ty_adrc.

    • WOrk Area for MARD Table

    DATA: wa_mard TYPE ty_mard.

    *Work Area for Internal table i_mvke

    DATA: wa_dev00160 TYPE ty_dev00160.

    *Work Area for Internal table i_mvke

    DATA: wa_qmat TYPE ty_qmat.

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

    • SELECTION SCREEN *

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

    SELECTION-SCREEN : BEGIN OF BLOCK b_001

    WITH FRAME

    TITLE text-001 . "Start of selection-screen

    SELECT-OPTIONS: s_matnr FOR mara-matnr. "Material Number

    PARAMETERS : p_ersda LIKE mara-ersda. "Creation Data

    SELECT-OPTIONS: s_werks FOR marc-werks NO INTERVALS. "Plant

    SELECTION-SCREEN : END OF BLOCK b_001 . "End of Selection-screen

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

    &----


    *& Include ZDMMULTI_F00

    &----


    &----


    *& Include ZDMMULTI_F00 *

    &----


    &----


    *& Form sub_validate_matnr

    &----


    • Subroutine for validating material number

    ----


    FORM sub_validate_matnr .

    SELECT matnr "Material Number

    mtart "Material Type

    ersda "Creation date

    mbrsh "Industry Sector

    FROM mara "Table for General Material Data

    INTO TABLE i_matnr

    WHERE matnr IN s_matnr.

    *If no material is found an error message is given

    IF sy-subrc <> 0.

    MESSAGE e001.

    ENDIF.

    ENDFORM. " sub_validate_matnr

    &----


    *& Form sub_validate_plant

    &----


    • Subroutine to validate Plant

    ----


    FORM sub_validate_plant .

    SELECT werks "Plant

    bwkey "Valuation area

    FROM t001w "Table for Plants/Branches

    INTO TABLE i_plant

    WHERE werks IN s_werks.

    *If no plant is found an error message is given

    IF sy-subrc NE 0.

    MESSAGE e002.

    ENDIF.

    ENDFORM. " sub_validate_plant

    &----


    *& Form sub_get_mara

    &----


    *Determine all the materials that need to be extended to new plants,

    *storage locations and MRP areas

    *----


    FORM sub_get_mara .

    IF NOT s_matnr[] IS INITIAL.

    SORT i_matnr BY matnr.

    IF p_ersda IS NOT INITIAL.

    DELETE i_matnr WHERE ersda NE p_ersda.

    ENDIF.

    ELSE.

    *If only Creation Date is given

    SELECT matnr "Material No.

    mtart "Material Type

    ersda "Creation date

    mbrsh "Industry Sector

    FROM mara "Table for General Material Data

    INTO TABLE i_matnr

    WHERE ersda EQ p_ersda.

    IF sy-subrc EQ 0.

    SORT i_matnr BY matnr.

    ELSE.

    MESSAGE i000 WITH 'No data found for given Selection.'(002).

    LEAVE LIST-PROCESSING.

    ENDIF.

    ENDIF.

    • Subroutine to get data from mvke.

    PERFORM sub_get_mvke.

    LOOP AT i_matnr INTO wa_matnr.

    CLEAR wa_mvke.

    READ TABLE i_mvke INTO wa_mvke WITH KEY matnr = wa_matnr-matnr

    BINARY SEARCH.

    IF sy-subrc EQ 0.

    wa_matnr-vkorg = wa_mvke-vkorg.

    wa_matnr-vtweg = wa_mvke-vtweg.

    ENDIF.

    IF wa_matnr-mtart = 'AD01'.

    wa_matnr-mtartz = 'AD01'.

    ELSE.

    wa_matnr-mtartz = 'NAD01'.

    ENDIF.

    MODIFY i_matnr FROM wa_matnr TRANSPORTING vkorg vtweg mtartz.

    ENDLOOP.

    ENDFORM. " sub_get_mara

    &----


    *& Form sub_get_werks

    &----


    *Determine all the plants to which the Materials need to be extended

    ----


    FORM sub_get_werks .

    SELECT werks "Plant

    bwkey "Valuation Area

    FROM t001w "Check table for Plants/Branches

    INTO TABLE i_plant.

    IF sy-subrc EQ 0.

    SORT i_plant BY werks.

    ENDIF.

    ENDFORM. " sub_get_werks

    &----


    *& Form sub_get_marc

    &----


    *Determine the status of the materials with respect to which plants

    *they have already been extended to

    ----


    FORM sub_get_marc .

    CHECK i_matnr[] IS NOT INITIAL.

    SELECT m~matnr "Material Number

    m~werks "Plant

    t~bwkey

    INTO TABLE i_marc

    FROM marc AS m "Table for Plant Data for Material

    INNER JOIN t001w AS t

    ON mwerks = twerks

    FOR ALL ENTRIES IN i_matnr

    WHERE matnr EQ i_matnr-matnr.

    IF sy-subrc EQ 0.

    *Append the plants that have been extended to

    • to the list of plants to which they have to be extended

    • only when no plants are given in the selection screen

    IF s_werks IS INITIAL.

    LOOP AT i_marc INTO wa_marc.

    wa_plant-werks = wa_marc-werks.

    wa_plant-bwkey = wa_marc-bwkey.

    APPEND wa_plant TO i_plant.

    CLEAR wa_plant.

    ENDLOOP.

    SORT i_plant BY werks bwkey.

    DELETE ADJACENT DUPLICATES FROM i_plant

    COMPARING werks bwkey.

    ENDIF.

    SORT i_marc BY matnr werks.

    *Retrieve the Valutaion Area for the plants to which the material

    *has already been extended.

    SELECT werks "Plant

    bwkey "Valuation area

    INTO TABLE i_t001w

    FROM t001w "Table for Plants/Branches

    FOR ALL ENTRIES IN i_marc

    WHERE werks = i_marc-werks.

    *If selection succeed.

    IF sy-subrc EQ 0.

    • Sort by Plant

    SORT i_t001w BY werks.

    ENDIF.

    ENDIF.

    *Copy the content of MARC into a temporary internal table

    i_tmarc[] = i_marc[].

    DELETE ADJACENT DUPLICATES FROM i_tmarc

    COMPARING matnr.

    *Retrieving Inspection type - material parameters (QMAT)

    *data

    SELECT matnr "Material Number

    werks "Plant

    art "Inspection Type

    ppl "Inspection with Task List

    spezueber "Inspect with Material Specification

    conf "Inspection Specifications from

    " Configuration

    tls "Inspection Specifications from Batch

    " Determination

    app "Automatic Specification Assignment

    mer "nspect by Characteristics

    insmk "Post to Inspection Stock

    ave "Automatic Usage Decision Planned

    stichprver "Sampling Procedure

    dynregel "Dynamic Modification Rule

    sproz "Inspection Percentage

    hpz "100% Inspection

    dyn "Skips Allowed

    mpb "Enter the Sample Manually

    mst "Trigger Sample Calculation Manually

    ein "Serial Number Management Possible

    mpdau "Average Inspection Duration

    chg "Control of Inspection Lot Creation (Lot

    "Summary)

    qkzverf "Procedure for Calculating Quality Score

    qpmat "Allowed Share of Scrap (Percent) in

    "Inspection Lot

    kzprfkost "Record Appraisal Costs in Individual QM

    "Order

    aufnr_co "Order Number for Recording Appraisal

    "Costs

    aktiv "Inspection Type - Material Combination is

    "Active

    apa "Preferred Inspection Type

    afr "Inspection for Handling Unit

    mma "Field Not Used as of 3.0 Field

    "Reserved for SAP

    feh "Field Not Used as of 3.0 Field

    "Reserved for SAP

    prfrq "Field Not Used as of 3.0 Field

    "Reserved for SAP

    nkmpr "Field Not Used as of 3.0 Field

    "Reserved for SAP

    INTO TABLE i_qmat

    FROM qmat "Table of "Inspection type - material

    "parameters"

    FOR ALL ENTRIES IN i_tmarc

    WHERE matnr = i_tmarc-matnr "Material no. of temporary internal

    "table

    AND werks = i_tmarc-werks. "Plant of temporary internal table

    *If selection succeed

    IF sy-subrc EQ 0.

    SORT i_qmat BY matnr.

    ENDIF.

    ENDFORM. " sub_get_marc

    &----


    *& Form sub_get_mard

    &----


    • Determine the storage locations for the Plants i_plant.

    ----


    FORM sub_get_mard .

    CHECK i_marc[] IS NOT INITIAL.

    SELECT matnr "Material Number

    werks "Plant

    lgort "Storage Location

    FROM mard "Table for Storage Location Data for Material

    INTO TABLE i_mard

    FOR ALL ENTRIES IN i_marc

    WHERE matnr EQ i_marc-matnr

    AND werks EQ i_marc-werks.

    *If selection succeed

    IF sy-subrc EQ 0.

    *Sort internal table by Material no , Plant and Storage Location

    SORT i_mard BY matnr werks lgort .

    ENDIF.

    ENDFORM. " sub_get_mard

    &----


    *& Form sub_get_t001l

    &----


    • Determine the storage locations for the Plants i_plant.

    ----


    FORM sub_get_t001l .

    CHECK i_plant[] IS NOT INITIAL.

    SELECT werks "Plant

    lgort "Storage Location

    FROM t001l "Check table for Storage Location

    INTO TABLE i_sloc

    FOR ALL ENTRIES IN i_plant

    WHERE werks EQ i_plant-werks.

    *If selection succeed

    IF sy-subrc EQ 0.

    *Sort by Plant and Storage Location

    SORT i_sloc BY werks lgort.

    • For all the storage location get the Storage Location Address

    *Number

    SELECT werks "Plant

    lgort "Storage Location

    adrnr "Address Number

    FROM twlad "Table of 'Determination of Address from Plant and

    "Storage Location'

    INTO TABLE i_twlad

    FOR ALL ENTRIES IN i_sloc

    WHERE werks = i_sloc-werks

    AND lgort = i_sloc-lgort.

    *If selection succeed

    IF sy-subrc EQ 0.

    *Sort by Plant, Storage Location and Address number

    SORT i_twlad BY werks lgort adrnr.

    • For all address numbers retrieved get the search term

    SELECT addrnumber "Address number

    sort2 "Search Term 2

    INTO TABLE i_adrc

    FROM adrc "Table of 'Addresses (Business Address

    "Services)'

    FOR ALL ENTRIES IN i_twlad

    WHERE addrnumber = i_twlad-adrnr.

    IF sy-subrc EQ 0.

    SORT i_adrc BY adrnr.

    ENDIF.

    ENDIF.

    ENDIF.

    ENDFORM. " sub_get_t001l

    &----


    *& Form sub_get_mdlv

    &----


    • Determine the MRP Areas to which the materials need to be extended.

    ----


    FORM sub_get_mdlv .

    CHECK i_sloc[] IS NOT INITIAL.

    SELECT berid "MRP Area

    werzg "Plant

    ortzg "Receiving Storage Location

    FROM mdlv "Table for Customizing MRP Area

    INTO TABLE i_mdlv

    FOR ALL ENTRIES IN i_sloc

    WHERE werzg EQ i_sloc-werks

    AND ortzg EQ i_sloc-lgort.

    *If selection succeed.

    IF sy-subrc EQ 0.

    *Sort by Plant and Storage Location

    SORT i_mard BY werks lgort.

    ENDIF.

    ENDFORM. " sub_get_mdlv

    *&----


    *& Form sub_get_zdmmm_mrp_area

    *&----


    • Determine required fields w.r.t Plant and MRP Area from customized

    *table

    *----


    FORM sub_get_zdmmm_mrp_area .

    CHECK i_mdlv[] IS NOT INITIAL.

    *Retrieving MRP data from Customized table

    SELECT zmtart "Material Type

    zwerks "Plant

    zberid "MRP Area

    zdismm "MRP Type

    zeisbe "Safety Stock

    zdisls "Lot Size

    zdispo "Mrp Controller

    zfxhor "Planned Delivery Time (In Days)

    FROM zdmmm_mrp_area "Customized table for MRP Area wrt

    "plant and mat type.

    INTO TABLE i_refmdma

    FOR ALL ENTRIES IN i_mdlv

    WHERE zberid = i_mdlv-berid

    AND zwerks = i_mdlv-werzg.

    *If selection succeed

    IF sy-subrc <> 0.

    *Sort by MRP Area and Plant

    SORT i_refmdma BY zberid zwerks.

    ENDIF.

    ENDFORM. " sub_get_zdmmm_mrp_area

    &----


    *& Form sub_mat_extn

    &----


    • For extending Material to Plant, all possible Storage Location and

    • corresponding MRP Area .

    ----


    FORM sub_mat_extn .

    *Local variable declaration

    DATA: l_index TYPE sytabix. "For storing sy-tabix

    DATA: l_counter TYPE i VALUE 0. "For formatting Error log.

    DATA: l_sloc_extend TYPE c. "Flag for Extending the material

    DATA: wa_dpop LIKE dpop. "For sending as a exporting

    "parameter

    DATA: wa_mdma LIKE mdma. "For sending as a exporting

    "parameter

    DATA: l_stat TYPE c. "For checking the Storage Location

    "is Seviceable or not.

    DATA: wa_bapireturn1 TYPE bapiret1. "Return Work area of

    "'MD_MRP_LEVEL_CREATE_DATA'

    *No material is selected.

    CHECK i_matnr[] IS NOT INITIAL.

    SORT i_plant BY werks.

    SORT i_marc BY matnr werks.

    SORT i_mard BY matnr werks lgort.

    *For extending the material to Plant Storage Location and possible MRP

    *Area

    LOOP AT i_matnr INTO wa_matnr.

    CLEAR wa_marc.

    • Checking whether Reference Material Exists or not

    READ TABLE i_marc INTO wa_marc WITH KEY matnr = wa_matnr-matnr

    BINARY SEARCH.

    • If no reference material exists..populate data for error log.

    IF sy-subrc NE 0.

    CLEAR wa_error.

    PERFORM material_convert USING wa_matnr-matnr

    CHANGING wa_error-mat.

    wa_error-comm = 'Reference material is not maintained'(003).

    APPEND wa_error TO i_error.

    CLEAR wa_error.

    CONTINUE.

    ENDIF.

    • For retrieving the reference data

    PERFORM sub_retrieve_refdata.

    LOOP AT i_plant INTO wa_plant.

    READ TABLE i_marc INTO wa_marc WITH KEY matnr = wa_matnr-matnr

    werks = wa_plant-werks

    BINARY SEARCH.

    IF sy-subrc EQ 0.

    CLEAR wa_error.

    PERFORM material_convert USING wa_matnr-matnr

    CHANGING wa_error-mat.

    wa_error-plant = wa_plant-werks.

    wa_error-comm = 'Material is already extended to the plant'(004)

    .

    APPEND wa_error TO i_error.

    CLEAR wa_error.

    ENDIF.

    CLEAR wa_sloc.

    • Reading the index for parallel cursor logic

    READ TABLE i_sloc INTO wa_sloc WITH KEY werks = wa_plant-werks

    BINARY SEARCH.

    • If it finds a record ...hold that index in a variable

    IF sy-subrc EQ 0.

    l_index = sy-tabix.

    ENDIF.

    LOOP AT i_sloc INTO wa_sloc FROM l_index.

    • When there is no record for that plant

    IF wa_sloc-werks NE wa_plant-werks.

    CLEAR l_counter.

    EXIT.

    ENDIF.

    CLEAR wa_mard.

    • Checking whether that material is extended to this plant

    • and storage location already

    READ TABLE i_mard INTO wa_mard WITH KEY matnr = wa_matnr-matnr

    werks = wa_plant-werks

    lgort = wa_sloc-lgort

    BINARY SEARCH.

    • If material is extended to this plant

    • and storage location already...populate error log

    IF sy-subrc EQ 0.

    CLEAR wa_error.

    PERFORM material_convert USING wa_matnr-matnr

    CHANGING wa_error-mat.

    wa_error-plant = wa_plant-werks.

    wa_error-sloc = wa_sloc-lgort.

    wa_error-comm = 'Already extended'(008).

    APPEND wa_error TO i_error.

    CLEAR wa_error.

    CLEAR l_counter.

    ELSE.

    CLEAR l_sloc_extend.

    l_sloc_extend = 'X'.

    ENDIF.

    • For extending the material to the Plant Storage Location

    IF l_sloc_extend EQ 'X'.

    DO.

    CALL FUNCTION 'ENQUEUE_EMMARCS'

    EXPORTING

    mode_marc = 'E'

    mandt = sy-mandt

    matnr = wa_matnr-matnr

    werks = wa_plant-werks

    EXCEPTIONS

    foreign_lock = 1

    system_failure = 2

    OTHERS = 3.

    IF sy-subrc EQ 0.

    EXIT.

    ENDIF.

    ENDDO.

    PERFORM sub_extend_material.

    ENDIF.

    SEARCH wa_t134-pstat FOR c_d.

    IF sy-subrc EQ 0.

    *Check Whether the Storage Location is Serviceable or Not

    CLEAR l_stat.

    PERFORM sub_sloc_check CHANGING l_stat.

    CHECK l_stat IS NOT INITIAL.

    • Getting all MRP area for the specific plant and storage location

    READ TABLE i_mdlv INTO wa_mdlv WITH KEY werzg = wa_plant-werks

    ortzg = wa_sloc-lgort

    BINARY SEARCH.

    SORT i_refmdma BY zmtart zwerks zberid.

    CLEAR wa_refmdma.

    • Get MRP area data from customized table

    READ TABLE i_refmdma INTO wa_refmdma

    WITH KEY zmtart = wa_matnr-mtartz

    zwerks = wa_plant-werks

    zberid = wa_mdlv-berid

    BINARY SEARCH.

    IF sy-subrc EQ 0.

    *For populating data MRP Area Selection Fields for Mass Data Maintenance

    PERFORM sub_populate_selfields.

    *Populating data for structure i_mdma from customized table

    wa_mdma-matnr = wa_matnr-matnr. "Material no

    wa_mdma-werks = wa_refmdma-zwerks. "Plant

    wa_mdma-berid = wa_refmdma-zberid. "MRP area

    wa_mdma-dismm = wa_refmdma-zdismm. "MRP type

    wa_mdma-eisbe = wa_refmdma-zeisbe. "Safety stock

    wa_mdma-disls = wa_refmdma-zdisls. "Lot size

    wa_mdma-dispo = wa_refmdma-zdispo. "MRP controller

    wa_mdma-plifz = wa_refmdma-zfxhor. "Planned delivery time

    "(In days)

    *Function module for extending the material to the all possible MRP Area

    .

    CALL FUNCTION 'MD_MRP_LEVEL_CREATE_DATA'

    EXPORTING

    i_matnr = wa_matnr-matnr

    i_werk = wa_plant-werks

    i_mrp_area = wa_refmdma-zberid

    i_selfields = wa_selfields

    i_mdma = wa_mdma

    i_dpop = wa_dpop

    i_queue_flag = 'X'

    i_save_flag = 'X'

    i_external_commit = ' '

    IMPORTING

    e_error_return = wa_bapireturn1.

    IF wa_bapireturn1-number = '000'.

    PERFORM material_convert USING wa_matnr-matnr

    CHANGING wa_succ-mat.

    wa_succ-plant = wa_plant-werks.

    wa_succ-sloc = wa_sloc-lgort.

    CONCATENATE 'Material extended for MRP Area'(006)

    wa_refmdma-zberid

    INTO wa_succ-comm SEPARATED BY space.

    APPEND wa_succ TO i_succ.

    CLEAR wa_succ.

    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

    EXPORTING

    wait = c_true.

    CALL FUNCTION 'DEQUEUE_ALL'

    EXPORTING

    synchron = ctrue.

    ELSE.

    CLEAR wa_error.

    PERFORM material_convert USING wa_matnr-matnr

    CHANGING wa_error-mat.

    wa_error-plant = wa_plant-werks.

    wa_error-sloc = wa_sloc-lgort.

    wa_error-comm = wa_bapireturn1-message.

    APPEND wa_error TO i_error.

    CLEAR wa_error.

    ENDIF.

    ENDIF.

    ENDIF.

    ENDLOOP.

    ENDLOOP.

    ENDLOOP.

    ENDFORM. " sub_mat_extn

    &----


    *& Form sub_retrieve_refdata

    &----


    • For retrieving the reference data

    ----


    FORM sub_retrieve_refdata .

    *Local variable declaration

    DATA: wa_mara1 LIKE mara. "MARA structure

    DATA: wa_mara2 LIKE mara. "MARA structure

    DATA: wa_marc1 LIKE marc. "MARC structure

    DATA: wa_mbew LIKE mbew. "MBEW structure

    DATA: wa_mpop LIKE mpop. "MPOP structure

    DATA: wa_mvke LIKE mvke. "MVKE structure

    DATA: wa_mpgd LIKE mpgd . "MPGD structure

    DATA: wa_mard LIKE mard . "MPGD structure

    DATA: wa_wrmmg1 TYPE rmmg1. "Material Master maintenence

    DATA: wa_wrmmg1_ref TYPE rmmg1_ref. "Material Master maintenence

    CLEAR wa_bukrs.

    CLEAR wa_plant.

    • For getting valuation area of the reference material

    READ TABLE i_t001w INTO wa_t001w WITH KEY werks = wa_marc-werks

    BINARY SEARCH.

    IF sy-subrc EQ 0.

    • For getting company code of the reference material

    READ TABLE i_bukrs INTO wa_bukrs WITH KEY bwkey = wa_t001w-bwkey

    BINARY SEARCH.

    ENDIF.

    *Populating data for the original material

    wa_wrmmg1-matnr = wa_matnr-matnr. "Material no

    wa_wrmmg1-mtart = wa_matnr-mtart. "Material Type

    wa_wrmmg1-werks = wa_marc-werks. "Plant

    wa_wrmmg1-mbrsh = wa_matnr-mbrsh. "Industry Sector

    wa_wrmmg1-vkorg = wa_matnr-vkorg. "Sales Org

    wa_wrmmg1-vtweg = wa_matnr-vtweg. "Distribution Channel

    wa_wrmmg1-bukrs_vko = wa_bukrs-bukrs. "Company code

    wa_wrmmg1-bwkey = wa_t001w-bwkey. "Valuation area

    • Function module for retrieving mara structure.

    CALL FUNCTION 'MARA_SINGLE_READ'

    EXPORTING

    matnr = wa_matnr-matnr

    IMPORTING

    wmara = wa_mara1

    EXCEPTIONS

    lock_on_material = 1

    lock_system_error = 2

    wrong_call = 3

    not_found = 4

    OTHERS = 5.

    *If function module succeed

    IF sy-subrc EQ 0.

    • Function module for retrieving mara marc mbew mpop structure.

    CALL FUNCTION 'MATERIAL_READ_ALL'

    EXPORTING

    herkunft = space

    aktyp = c_header

    wrmmg1 = wa_wrmmg1

    aktvstatus = wa_mara1-pstat

    tmara = wa_mara1

    rmara = wa_mara1

    wrmmg1_ref = wa_wrmmg1_ref

    IMPORTING

    tmara = wa_mara2

    tmarc = wa_marc1

    tmbew = wa_mbew

    tmpop = wa_mpop

    tmvke = wa_mvke

    tmpgd = wa_mpgd

    tmard = wa_mard

    EXCEPTIONS

    aktyp_wrong = 1

    matnr_missing = 2

    herkunft_wrong = 3

    herkunft_aktyp_mismatch = 4

    aktvstatus_missing = 5

    mara_inp_missing = 6

    material_not_found = 7

    marc_not_found = 8

    plant_data_not_found = 9

    mbew_not_found = 10

    bukrs_data_not_found = 11

    bwkey_data_not_found = 12

    mlgn_not_found = 13

    mlgt_not_found = 14

    mvke_not_found = 15

    mard_not_found = 16

    table_data_not_found = 17

    reserved_matnr_exists = 18

    reserved_matnr_missing = 19

    spec_sign_in_matnr = 20

    lock_on_material = 21

    lock_on_marc = 22

    lock_on_mbew = 23

    lock_on_mlgn = 24

    lock_on_mvke = 25

    lock_system_error = 26

    ext_number_not_allowed = 27

    ext_number_not_in_range = 28

    ext_number_wo_check_error = 29

    internal_number_not_allowed = 30

    materialtype_missing = 31

    mtart_not_found = 32

    industry_missing = 33

    mbrsh_not_found = 34

    aktvstatus_empty = 35

    no_authority = 36

    kstatus_empty = 37

    tkstatus_empty = 38

    t001w_not_found = 39

    bukrs_not_found = 40

    marv_not_found = 41

    vkorg_bukrs_not_found = 42

    t149_not_found = 43

    t149b_not_found = 44

    valuation_uniform = 45

    mbew_header_not_found = 46

    unknown_table = 47

    already_maintained = 48

    ref_material_not_found = 49

    ref_marc_not_found = 50

    ref_plant_data_not_found = 51

    ref_mbew_not_found = 52

    ref_bukrs_data_not_found = 53

    ref_bwkey_data_not_found = 54

    ref_mlgn_not_found = 55

    ref_mlgt_not_found = 56

    ref_mvke_not_found = 57

    ref_mard_not_found = 58

    ref_table_data_not_found = 59

    mara_inp_ref_missing = 60

    tkstatus_missing_for_ref = 61

    orglevel_error = 62

    tcurm_error = 63

    internal_error = 64

    other_error = 65

    profile_not_found = 66

    aennr_error = 67

    aennr_required = 68

    OTHERS = 69.

    *If function module succeed

    IF sy-subrc EQ 0.

    *Populating fields for views

    wa_ref_data-matnr = wa_mara2-matnr. "Material no

    wa_ref_data-ladgr = wa_marc1-ladgr. "Loading gr.

    wa_ref_data-herkl = wa_marc1-herkl. "Country of origin

    wa_ref_data-losgr = wa_marc1-losgr. "Costing lot size

    wa_ref_data-hkmat = wa_mbew-hkmat. "Material Origin

    wa_ref_data-peinh = wa_mbew-peinh. "Price unit

    wa_ref_data-bklas = wa_mbew-bklas. "Valuation class

    wa_ref_data-dismm = wa_marc1-dismm. "MRP type

    wa_ref_data-dispo = wa_marc1-dispo. "MRP controller

    wa_ref_data-fxhor = wa_marc1-fxhor. "Planned delivery time (In

    "days)

    wa_ref_data-disls = wa_marc1-disls. "Lot size

    wa_ref_data-fhori = wa_marc1-fhori. "Scheduling margin key

    wa_ref_data-magrv = wa_mara2-magrv. "Material Group: Packaging

    "Materials

    wa_ref_data-vhart = wa_mara2-vhart. "Packaging Material Type

    wa_ref_data-ergew = wa_mara2-ergew. "Allowed packaging weight

    wa_ref_data-ervol = wa_mara2-ervol. "Allowed packaging volume

    wa_ref_data-fuelg = wa_mara2-fuelg. "Maximum level (by volume)

    wa_ref_data-stfak = wa_mara2-stfak. "Stacking factor

    wa_ref_data-gewto = wa_mara2-gewto. "Excess Weight Tolerance for

    "Handling unit

    wa_ref_data-volto = wa_mara2-volto. "Excess Volume Tolerance of

    "the Handling Unit

    wa_ref_data-prctr = wa_marc1-prctr. "Profit Center

    wa_ref_data-kzgvh = wa_mara2-kzgvh. "Packaging Material is

    "Closed Packaging

    wa_ref_data-stawn = wa_marc1-stawn. "Commodity code / Import

    "code number for foreign

    "trade

    wa_ref_data-mtver = wa_marc1-mtver. "Export/import material

    "group

    wa_ref_data-casnr = wa_marc1-casnr. "CAS number for

    "pharmaceutical products in

    "foreign trade

    wa_ref_data-gpnum = wa_marc1-gpnum. "Production statistics:

    "PRODCOM number for foreign

    "trade

    wa_ref_data-steuc = wa_marc1-steuc. "Control code for

    "consumption taxes in

    "foreign trade

    wa_ref_data-herkr = wa_marc1-herkr. "Region of origin of

    "material (non-preferential

    "origin)

    wa_ref_data-mownr = wa_marc1-mownr. "CAP: Number of CAP products

    "list

    wa_ref_data-mogru = wa_marc1-mogru. "Common Agricultural Policy:

    "CAP products group-Foreign

    "Trade

    wa_ref_data-prenc = wa_marc1-prenc. "Exemption certificate:

    "Indicator for legal control

    wa_ref_data-preno = wa_marc1-preno. "Number of exemption

    "certificate in export/import

    wa_ref_data-prend = wa_marc1-prend. "Exemption certificate:

    "Issue date of exemption

    "certificate

    wa_ref_data-itark = wa_marc1-itark. "Indicator: Military goods

    wa_ref_data-bstme = wa_mara2-bstme. "Order unit

    wa_ref_data-vabme = wa_mara2-vabme. "Variable order unit active

    wa_ref_data-nrfhg = wa_mara2-nrfhg. "Material qualifies for

    "discount in kind

    wa_ref_data-mfrgr = wa_marc1-mfrgr. "Material freight group

    wa_ref_data-ekwsl = wa_mara2-ekwsl. "Purchasing Value Key

    wa_ref_data-webaz = wa_marc1-webaz. "Goods receipt processing

    "time in days

    wa_ref_data-insmk = wa_marc1-insmk. "Stock type

    wa_ref_data-kzkri = wa_marc1-kzkri. "Indicator: Critical part

    wa_ref_data-usequ = wa_marc1-usequ. "Quota arrangement usage

    wa_ref_data-kordb = wa_marc1-kordb. "Indicator: Source list

    "requirement

    wa_ref_data-mprof = wa_mara2-mprof. "Mfr part profile

    wa_ref_data-ekgrp = wa_marc1-ekgrp. "Purchasing Group

    wa_ref_data-disgr = wa_marc1-disgr. "MRP Group

    wa_ref_data-maabc = wa_marc1-maabc. "ABC indicator

    wa_ref_data-minbe = wa_marc1-minbe. "Reorder point

    wa_ref_data-lfrhy = wa_marc1-lfrhy. "Planning cycle

    wa_ref_data-bstmi = wa_marc1-bstmi. "Minimum lot size

    wa_ref_data-bstma = wa_marc1-bstma. "Maximum lot size

    wa_ref_data-bstfe = wa_marc1-bstfe. "Fixed lot size

    wa_ref_data-mabst = wa_marc1-mabst. "Maximum stock level

    wa_ref_data-losfx = wa_marc1-losfx. "Ordering costs

    wa_ref_data-lagpr = wa_marc1-lagpr. "Storage costs indicator

    wa_ref_data-ausss = wa_marc1-ausss. "Assembly scrap in percent

    wa_ref_data-takzt = wa_marc1-takzt. "Takt time

    wa_ref_data-rdprf = wa_marc1-rdprf. "Rounding profile

    wa_ref_data-bstrf = wa_marc1-bstrf. "Rounding value for purchase

    "order quantity

    wa_ref_data-megru = wa_marc1-megru. "Unit of measure group

    wa_ref_data-sobsl = wa_marc1-sobsl. "Special procurement type

    wa_ref_data-kzech = wa_marc1-kzech. "Determination of batch

    "entry in the production/process

    "order

    wa_ref_data-lgpro = wa_marc1-lgpro. "Issue Storage Location

    wa_ref_data-vspvb = wa_marc1-vspvb. "Proposed Supply Area in

    "Material Master Record

    wa_ref_data-rgekz = wa_marc1-rgekz. "Indicator: Backflush

    wa_ref_data-lgfsb = wa_marc1-lgfsb. "Default storage location

    "for external procurement

    wa_ref_data-fabkz = wa_marc1-fabkz. "Indicator: Item relevant to

    "JIT delivery schedules

    wa_ref_data-eprio = wa_marc1-eprio. "Withdrawal sequence group

    "for stocks

    wa_ref_data-schgt = wa_marc1-schgt. "Indicator: bulk material

    wa_ref_data-plifz = wa_marc1-plifz. "Planned delivery time in

    "days

    wa_ref_data-mrppp = wa_marc1-mrppp. "PPC planning calendar

    wa_ref_data-eisbe = wa_marc1-eisbe. "Safety stock

    wa_ref_data-lgrad = wa_marc1-lgrad. "Service level

    wa_ref_data-eislo = wa_marc1-eislo. "Minimum Safety Stock

    wa_ref_data-rwpro = wa_marc1-rwpro. "Range of coverage profile

    wa_ref_data-shflg = wa_marc1-shflg. "Safety time indicator (with

    " or without safety time)

    wa_ref_data-shzet = wa_marc1-shzet. "Safety time (in workdays)

    wa_ref_data-shpro = wa_marc1-shpro. "Period profile for safety

    "time

    wa_ref_data-periv = wa_marc1-periv. "Fiscal Year Variant

    wa_ref_data-auftl = wa_marc1-auftl. "Splitting Indicator

    wa_ref_data-strgr = wa_marc1-strgr. "Planning strategy group

    wa_ref_data-vrmod = wa_marc1-vrmod. "Consumption mode

    wa_ref_data-vint2 = wa_marc1-vint2. "Consumption period: forward

    wa_ref_data-umref = wa_mpgd-umref. "Conversion factor

    wa_ref_data-prgrp = wa_mpgd-prgrp. "Name of the product group

    wa_ref_data-vint1 = wa_marc1-vint1. "Consumption period:

    "backward

    wa_ref_data-miskz = wa_marc1-miskz. "Mixed MRP indicator

    wa_ref_data-prwrk = wa_mpgd-prwrk. "Production plant

    wa_ref_data-mtvfp = wa_marc1-mtvfp. "Checking Group for

    "Availability Check

    wa_ref_data-wzeit = wa_marc1-wzeit. "Total replenishment lead

    "time (in workdays)

    wa_ref_data-kzpsp = wa_marc1-kzpsp. "Indicator for cross-project

    "material

    wa_ref_data-stdpd = wa_marc1-stdpd. "Configurable material

    wa_ref_data-perkz = wa_marc1-perkz. "Period indicator

    wa_ref_data-altsl = wa_marc1-altsl. "Method for Selecting

    "Alternative Bills of Material

    wa_ref_data-kausf = wa_marc1-kausf. "Component scrap in percent

    wa_ref_data-sbdkz = wa_marc1-sbdkz. "Dependent requirements ind.

    "for individual and coll. reqmts

    wa_ref_data-kzbed = wa_marc1-kzbed. "Indicator for Requirements

    "Grouping

    wa_ref_data-ahdis = wa_marc1-ahdis. "MRP relevancy for dependent

    "requirements

    wa_ref_data-kzaus = wa_marc1-kzaus. "Discontinuation indicator

    wa_ref_data-ausdt = wa_marc1-ausdt. "Effective-Out Date

    wa_ref_data-nfmat = wa_marc1-nfmat. "Follow-up material

    • wa_ref_data-sauft = wa_marc1-sauft. "Total of the sales values

    • "for the credit limit check

    wa_ref_data-sfepr = wa_marc1-sfepr. "Repetitive manufacturing

    "profile

    wa_ref_data-mdach = wa_marc1-mdach. "Action control: planned

    "order processing

    wa_ref_data-dplfs = wa_marc1-dplfs. "Fair share rule

    wa_ref_data-dplpu = wa_marc1-dplpu. "Indicator: push

    "distribution

    wa_ref_data-dplho = wa_marc1-dplho. "Deployment horizon in days

    wa_ref_data-tempb = wa_mara2-tempb. "Temperature conditions

    "indicator

    wa_ref_data-raube = wa_mara2-raube. "Storage conditions

    wa_ref_data-behvo = wa_mara2-behvo. "Container requirements

    wa_ref_data-stoff = wa_mara2-stoff. "Hazardous material number

    wa_ref_data-abcin = wa_marc1-abcin. "Physical inventory

    "indicator for cycle counting

    wa_ref_data-ccfix = wa_marc1-ccfix. "CC indicator is fixed

    wa_ref_data-wesch = wa_mara2-wesch. "Quantity: Number of GR/GI

    "Slips to Print

    wa_ref_data-etiar = wa_mara2-etiar. "Label type

    wa_ref_data-etifo = wa_mara2-etifo. "Label form

    wa_ref_data-xgchp = wa_mara2-xgchp. "Indicator: Approved batch

    "record required

    wa_ref_data-maxlz = wa_marc1-maxlz. "Maximum storage period

    wa_ref_data-iprkz = wa_marc1-perkz. "Period indicator for shelf

    "life expiration date

    wa_ref_data-lzeih = wa_marc1-lzeih. "Unit for maximum storage

    "period

    wa_ref_data-mhdrz = wa_mara2-mhdrz. "Minimum remaining shelf

    "life

    wa_ref_data-mhdhb = wa_mara2-mhdhb. "Total shelf life

    wa_ref_data-rdmhd = wa_mara2-rdmhd. "Rounding rule for

    "calculation of SLED

    wa_ref_data-mhdlp = wa_mara2-mhdlp. "Storage percentage

    wa_ref_data-brgew = wa_mara2-brgew. "Gross weight

    wa_ref_data-ntgew = wa_mara2-ntgew.

    wa_ref_data-volum = wa_mara2-volum.

    wa_ref_data-voleh = wa_mara2-voleh. "Volume unit

    wa_ref_data-groes = wa_mara2-groes. "Size/dimensions

    wa_ref_data-xmcng = wa_marc1-xmcng. "Negative stocks

    "allowed in plant

    wa_ref_data-loggr = wa_marc1-loggr. "Logistics handling

    "group for workload calculation

    wa_ref_data-sernp = wa_marc1-sernp. "Serial number profile

    wa_ref_data-serlv = wa_mara2-serlv. "Level of explicitness

    "for serial number

    wa_ref_data-fprfm = wa_marc1-fprfm. "Distribution profile

    "of material in plant

    wa_ref_data-ausme = wa_marc1-ausme. "Unit of issue

    wa_ref_data-qmata = wa_marc1-qmata. "Material

    "authorization group for activities in qm

    wa_ref_data-kzdkz = wa_marc1-kzdkz. "Documentation

    "required indicator

    wa_ref_data-prfrq = wa_marc1-prfrq. "Interval until next

    "recurring inspection

    wa_ref_data-rbnrm = wa_mara2-rbnrm. "Catalog profile

    wa_ref_data-qmpur = wa_mara2-qmpur. "Qm in procurement is

    "active

    wa_ref_data-ssqss = wa_marc1-ssqss. "Qa control key

    wa_ref_data-qzgtp = wa_marc1-qzgtp. "Certificate type

    wa_ref_data-qssys = wa_marc1-qssys. "Target qm system for

    "vendor

    wa_ref_data-bwtty = wa_mbew-bwtty. "Material master view:

    "valuation category of valuation area

    wa_ref_data-eklas = wa_mbew-eklas. "Valuation class for

    "sales order stock

    wa_ref_data-qklas = wa_mbew-qklas. "Valuation class for

    "project stock

    wa_ref_data-verpr = wa_mbew-verpr * 100. "Moving average

    "price/periodic unit price

    wa_ref_data-stprs = wa_mbew-stprs. "Standard price

    wa_ref_data-zkprs = wa_mbew-zkprs. "Future price

    wa_ref_data-zkdat = wa_mbew-zkdat. "Date as of which the

    "price is valid

    wa_ref_data-bwprs = wa_mbew-bwprs. "Valuation price based

    "on tax law: level 1

    wa_ref_data-bwprh = wa_mbew-bwprh. "Valuation price based

    "on commercial law: level 1

    wa_ref_data-bwps1 = wa_mbew-bwps1. "Valuation price based

    "on tax law: level 2

    wa_ref_data-bwph1 = wa_mbew-bwph1. "Valuation price based

    "on commercial law: level 2

    wa_ref_data-vjbws = wa_mbew-vjbws. "Valuation price based

    "on tax law: level 3

    wa_ref_data-vjbwh = wa_mbew-vjbwh. "Valuation price based

    "on commercial law: level 3

    wa_ref_data-abwkz = wa_mbew-abwkz. "Lowest value:

    "devaluation indicator

    wa_ref_data-bwpei = wa_mbew-bwpei. "Price unit for

    "valuation prices based on tax/commercial law

    wa_ref_data-xlifo = wa_mbew-xlifo. "Lifo/fifo-relevant

    wa_ref_data-mypol = wa_mbew-mypol. "Pool number for lifo

    "valuation

    wa_ref_data-ncost = wa_marc1-ncost. "Do not cost

    wa_ref_data-ekalr = wa_mbew-ekalr. "Material is costed

    "with quantity structure

    wa_ref_data-hrkft = wa_mbew-hrkft. "Origin group as

    "subdivision of cost element

    wa_ref_data-kosgr = wa_mbew-kosgr. "Costing overhead

    "group

    wa_ref_data-awsls = wa_marc1-awsls. "Variance key

    wa_ref_data-mmsta = wa_marc1-mmsta. "Plant-specific

    "material status

    wa_ref_data-mmstd = wa_marc1-mmstd. "Date from which the

    "plant-specific material status is valid

    wa_ref_data-stlal = wa_marc1-stlal. "Alternative bom

    wa_ref_data-stlan = wa_marc1-stlan. "Bom usage

    wa_ref_data-plnnr = wa_marc1-plnnr. "Key for task list

    "group

    wa_ref_data-aplal = wa_marc1-aplal. "Group counter

    wa_ref_data-plnty = wa_marc1-plnty. "Task list type

    wa_ref_data-sobsk = wa_marc1-sobsk. "Special procurement

    "type for costing

    wa_ref_data-zplpr = wa_mbew-zplpr. "Future planned price

    wa_ref_data-zplp1 = wa_mbew-zplp1. "Future planned price1

    wa_ref_data-zpld1 = wa_mbew-zpld1. "Date from which

    "future planned price 1 is valid

    wa_ref_data-zplp2 = wa_mbew-zplp2. "Future planned price2

    wa_ref_data-zpld2 = wa_mbew-zpld2. "Date from which

    "future planned price 2 is valid

    wa_ref_data-zplp3 = wa_mbew-zplp3. "Future planned price3

    wa_ref_data-zpld3 = wa_mbew-zpld3. "Date from which

    "future planned price 3 is valid

    wa_ref_data-lvolg = wa_mard-lvorm. "Deletion indicator

    wa_ref_data-diskz = wa_mard-diskz. "Storage location mrp

    "indicator

    wa_ref_data-lsobs = wa_mard-lsobs. "Special procurement

    "type at storage location level

    wa_ref_data-lminb = wa_mard-lminb. "Reorder point for

    "storage location mrp

    wa_ref_data-lbstf = wa_mard-lbstf. "Replenishment

    "quantity for storage location mrp

    wa_ref_data-lgpbe = wa_mard-lgpbe. "Storage bin

    ENDIF.

    ENDIF.

    CLEAR wa_bukrs.

    CLEAR wa_plant.

    ENDFORM. " sub_retrieve_refdata

    &----


    *& Form sub_assign_to_bapi_mard

    &----


    • For extending the material to the Plant Storage Location

    • and all possible MRP Area

    ----


    FORM sub_extend_material .

    *Declaring local structure

    DATA: wa_header TYPE bapimathead. "Hdr sgmnt with cntrl info

    DATA: wa_client TYPE bapi_mara. "Client data

    DATA: wa_clientx TYPE bapi_marax. "Client data

    DATA: wa_plant1 TYPE bapi_marc. "plant matdata

    DATA: wa_plant1x TYPE bapi_marcx. "plant matdata

    DATA: wa_sales TYPE bapi_mvke. "Sales matdata

    DATA: wa_salesx TYPE bapi_mvkex. "Sales matdata

    DATA: wa_planning TYPE bapi_mpgd. "Planning data

    DATA: wa_planningx TYPE bapi_mpgdx. "Planning data

    DATA: wa_forecast TYPE bapi_mpop. "Forecast matdata

    DATA: wa_forecastx TYPE bapi_mpopx. "forecast matdata

    DATA: wa_valuation TYPE bapi_mbew. "valuation matdata

    DATA: wa_valuationx TYPE bapi_mbewx. "valuation matdata

    DATA: wa_storage TYPE bapi_mard. "Storage Loc matdata

    DATA: wa_storagex TYPE bapi_mardx. "Storage Loc matdata

    DATA: wa_warehouse TYPE bapi_mlgn. "Warehouse matdata

    DATA: wa_warehousex TYPE bapi_mlgnx. "Warehouse matdata

    DATA: wa_return TYPE bapiret2. "Return Parameters

    DATA: itab_return_tmp TYPE STANDARD TABLE OF bapi_matreturn2

    INITIAL SIZE 0.

    DATA: wa_inspcnt TYPE bapi1001004_qmat.

    DATA: i_inspectionctrl TYPE STANDARD TABLE OF bapi1001004_qmat

    INITIAL SIZE 0.

    DATA: i_return TYPE STANDARD TABLE OF bapiret2

    INITIAL SIZE 0.

    DATA: l_tabix TYPE sytabix.

    CLEAR wa_t134.

    • Getting view status as per CONFIG for specific material type

    READ TABLE i_t134 INTO wa_t134 WITH KEY mtart = wa_matnr-mtart

    BINARY SEARCH.

    IF sy-subrc EQ 0.

    *--Check for WORK SCHEDULE view, if not there create with default data

    *-- from ref material

    SEARCH wa_t134-pstat FOR c_a.

    IF sy-subrc EQ 0.

    wa_header-work_sched_view = c_true.

    ENDIF.

    *--Check for ACCOUNTING view, if not there create with default data

    *-- from ref material

    SEARCH wa_t134-pstat FOR c_b.

    IF sy-subrc EQ 0.

    wa_header-account_view = c_true.

    wa_header-material = wa_matnr-matnr.

    wa_header-ind_sector = wa_matnr-mbrsh.

    wa_header-matl_type = wa_matnr-mtart.

    wa_plant1-plant = wa_plant-werks.

    wa_plant1x-plant = wa_plant-werks.

    wa_valuation-val_class = wa_ref_data-bklas.

    wa_valuationx-val_class = c_true.

    wa_valuation-val_area = wa_plant-werks.

    wa_valuationx-val_area = wa_plant-werks.

    wa_valuation-price_unit = wa_ref_data-peinh.

    wa_valuationx-price_unit = c_true.

    wa_valuation-val_cat = wa_ref_data-bwtty.

    wa_valuation-vm_so_stk = wa_ref_data-eklas.

    wa_valuation-vm_p_stock = wa_ref_data-qklas.

    wa_valuation-moving_pr = wa_ref_data-verpr.

    wa_valuation-std_price = wa_ref_data-stprs.

    wa_valuation-future_pr = wa_ref_data-zkprs.

    wa_valuation-valid_from = wa_ref_data-zkdat.

    wa_valuation-taxprice_1 = wa_ref_data-bwprs.

    wa_valuation-commprice1 = wa_ref_data-bwprh.

    wa_valuation-taxprice_2 = wa_ref_data-bwps1.

    wa_valuation-commprice2 = wa_ref_data-bwph1.

    wa_valuation-taxprice_3 = wa_ref_data-vjbws.

    wa_valuation-commprice3 = wa_ref_data-vjbwh.

    wa_valuation-deval_ind = wa_ref_data-abwkz.

    wa_valuation-tax_cml_un = wa_ref_data-bwpei.

    wa_valuation-lifo_fifo = wa_ref_data-xlifo.

    wa_valuation-poolnumber = wa_ref_data-mypol.

    wa_valuationx-val_cat = c_true.

    wa_valuationx-vm_so_stk = c_true.

    wa_valuationx-vm_p_stock = c_true.

    wa_valuationx-moving_pr = c_true.

    wa_valuationx-std_price = c_true.

    wa_valuationx-future_pr = c_true.

    wa_valuationx-valid_from = c_true.

    wa_valuationx-taxprice_1 = c_true.

    wa_valuationx-commprice1 = c_true.

    wa_valuationx-taxprice_2 = c_true.

    wa_valuationx-commprice2 = c_true.

    wa_valuationx-taxprice_3 = c_true.

    wa_valuationx-commprice3 = c_true.

    wa_valuationx-deval_ind = c_true.

    wa_valuationx-tax_cml_un = c_true.

    wa_valuationx-lifo_fifo = c_true.

    wa_valuationx-poolnumber = c_true.

    ENDIF.

    *--Check for MRP view, if not there create with default data from

    *-- ref material

    SEARCH wa_t134-pstat FOR c_d.

    IF sy-subrc EQ 0.

    wa_header-mrp_view = c_true.

    wa_plant1-mrp_type = wa_ref_data-dismm. "MRP type

    wa_plant1-mrp_ctrler = wa_ref_data-dispo. "MRP controller

    wa_plant1-pl_ti_fnce = wa_ref_data-fxhor."Plantdelivery time (in

    "days)

    wa_plant1-lotsizekey = wa_ref_data-disls. "Lot size

    wa_plant1-sm_key = wa_ref_data-fhori. "Schedulingmargin key

    wa_plant1x-mrp_type = c_true.

    wa_plant1x-mrp_ctrler = c_true.

    wa_plant1x-pl_ti_fnce = c_true.

    wa_plant1x-lotsizekey = c_true.

    wa_plant1x-sm_key = c_true.

    wa_plant1-pur_group = wa_ref_data-ekgrp.

    wa_plant1-mrp_group = wa_ref_data-disgr.

    wa_plant1-abc_id = wa_ref_data-maabc.

    wa_plant1-pur_status = wa_ref_data-mmsta.

    wa_plant1-pvalidfrom = wa_ref_data-mmstd.

    wa_plant1-reorder_pt = wa_ref_data-minbe.

    wa_plant1-plng_cycle = wa_ref_data-lfrhy.

    wa_plant1-minlotsize = wa_ref_data-bstmi.

    wa_plant1-maxlotsize = wa_ref_data-bstma.

    wa_plant1-fixed_lot = wa_ref_data-bstfe.

    wa_plant1-max_stock = wa_ref_data-mabst.

    wa_plant1-ord_costs = wa_ref_data-losfx.

    wa_plant1-stor_costs = wa_ref_data-lagpr.

    wa_plant1-assy_scrap = wa_ref_data-ausss.

    wa_plant1-cycle_time = wa_ref_data-takzt.

    wa_plant1-round_prof = wa_ref_data-rdprf.

    wa_plant1-round_val = wa_ref_data-bstrf.

    wa_plant1-unit_group = wa_ref_data-megru.

    wa_plant1-spproctype = wa_ref_data-sobsl.

    wa_plant1-batchentry = wa_ref_data-kzech.

    wa_plant1-iss_st_loc = wa_ref_data-lgpro.

    wa_plant1-quotausage = wa_ref_data-usequ.

    wa_plant1-supply_area = wa_ref_data-vspvb.

    wa_plant1-backflush = wa_ref_data-rgekz.

    wa_plant1-sloc_exprc = wa_ref_data-lgfsb.

    wa_plant1-jit_relvt = wa_ref_data-fabkz.

    wa_plant1-determ_grp = wa_ref_data-eprio.

    wa_plant1-bulk_mat = wa_ref_data-schgt.

    wa_plant1-gr_pr_time = wa_ref_data-webaz.

    wa_plant1-plnd_delry = wa_ref_data-plifz.

    wa_plant1-ppc_pl_cal = wa_ref_data-mrppp.

    wa_plant1-safety_stk = wa_ref_data-eisbe.

    wa_plant1-serv_level = wa_ref_data-lgrad.

    wa_plant1-min_safety_stk = wa_ref_data-eislo.

    wa_plant1-covprofile = wa_ref_data-rwpro.

    wa_plant1-safty_t_id = wa_ref_data-shflg.

    wa_plant1-safetytime = wa_ref_data-shzet.

    wa_plant1-period_profile_safety_time = wa_ref_data-shpro.

    wa_plant1-fy_variant = wa_ref_data-periv.

    wa_plant1-split_ind = wa_ref_data-auftl.

    wa_plant1-plan_strgp = wa_ref_data-strgr.

    wa_plant1-consummode = wa_ref_data-vrmod.

    wa_plant1-fwd_cons = wa_ref_data-vint2.

    wa_planning-convfactor = wa_ref_data-umref.

    wa_planning-plng_matl = wa_ref_data-prgrp.

    wa_planning-plng_plant = wa_ref_data-prwrk.

    wa_plant1-bwd_cons = wa_ref_data-vint1.

    wa_plant1-mixed_mrp = wa_ref_data-miskz.

    wa_plant1-availcheck = wa_ref_data-mtvfp.

    wa_plant1-replentime = wa_ref_data-wzeit.

    wa_plant1-avail_check_all_proj_segments = wa_ref_data-kzpsp.

    wa_plant1-period_ind = wa_ref_data-perkz.

    wa_plant1-alt_bom_id = wa_ref_data-altsl.

    wa_plant1-comp_scrap = wa_ref_data-kausf.

    wa_plant1-dep_req_id = wa_ref_data-sbdkz.

    wa_plant1-grp_reqmts = wa_ref_data-kzbed.

    wa_plant1-mrp_relevancy_dep_requirements = wa_ref_data-ahdis.

    wa_plant1-discontinu = wa_ref_data-kzaus.

    wa_plant1-eff_o_day = wa_ref_data-ausdt.

    wa_plant1-follow_up = wa_ref_data-nfmat.

    wa_plant1-repmanprof = wa_ref_data-sfepr.

    wa_plant1-plord_ctrl = wa_ref_data-mdach.

    wa_plant1-fair_share_rule = wa_ref_data-dplfs.

    wa_plant1-push_distrib = wa_ref_data-dplpu.

    wa_plant1-deploy_horiz = wa_ref_data-dplho.

    wa_plant1x-pur_group = c_true.

    wa_plant1x-mrp_group = c_true.

    wa_plant1x-abc_id = c_true.

    wa_plant1x-pur_status = c_true.

    wa_plant1x-pvalidfrom = c_true.

    wa_plant1x-reorder_pt = c_true.

    wa_plant1x-plng_cycle = c_true.

    wa_plant1x-minlotsize = c_true.

    wa_plant1x-maxlotsize = c_true.

    wa_plant1x-fixed_lot = c_true.

    wa_plant1x-max_stock = c_true.

    wa_plant1x-ord_costs = c_true.

    wa_plant1x-stor_costs = c_true.

    wa_plant1x-assy_scrap = c_true.

    wa_plant1x-cycle_time = c_true.

    wa_plant1x-round_prof = c_true.

    wa_plant1x-round_val = c_true.

    wa_plant1x-unit_group = c_true.

    wa_plant1x-spproctype = c_true.

    wa_plant1x-batchentry = c_true.

    wa_plant1x-iss_st_loc = c_true.

    wa_plant1x-quotausage = c_true.

    wa_plant1x-supply_area = c_true.

    wa_plant1x-backflush = c_true.

    wa_plant1x-sloc_exprc = c_true.

    wa_plant1x-jit_relvt = c_true.

    wa_plant1x-determ_grp = c_true.

    wa_plant1x-bulk_mat = c_true.

    wa_plant1x-gr_pr_time = c_true.

    wa_plant1x-plnd_delry = c_true.

    wa_plant1x-ppc_pl_cal = c_true.

    wa_plant1x-safety_stk = c_true.

    wa_plant1x-serv_level = c_true.

    wa_plant1x-min_safety_stk = c_true.

    wa_plant1x-covprofile = c_true.

    wa_plant1x-safty_t_id = c_true.

    wa_plant1x-safetytime = c_true.

    wa_plant1x-period_profile_safety_time = c_true.

    wa_plant1x-fy_variant = c_true.

    wa_plant1x-split_ind = c_true.

    wa_plant1x-plan_strgp = c_true.

    wa_plant1x-consummode = c_true.

    wa_plant1x-fwd_cons = c_true.

    wa_planningx-convfactor = c_true.

    wa_planningx-plng_matl = c_true.

    wa_planningx-plng_plant = c_true.

    wa_plant1x-bwd_cons = c_true.

    wa_plant1x-mixed_mrp = c_true.

    wa_plant1x-availcheck = c_true.

    wa_plant1x-replentime = c_true.

    wa_plant1x-avail_check_all_proj_segments = c_true.

    wa_plant1x-period_ind = c_true.

    wa_plant1x-alt_bom_id = c_true.

    wa_plant1x-comp_scrap = c_true.

    wa_plant1x-dep_req_id = c_true.

    wa_plant1x-grp_reqmts = c_true.

    wa_plant1x-mrp_relevancy_dep_requirements = c_true.

    wa_plant1x-discontinu = c_true.

    wa_plant1x-eff_o_day = c_true.

    wa_plant1x-follow_up = c_true.

    wa_plant1x-repmanprof = c_true.

    wa_plant1x-plord_ctrl = c_true.

    wa_plant1x-fair_share_rule = c_true.

    wa_plant1x-push_distrib = c_true.

    wa_plant1x-deploy_horiz = c_true.

    ENDIF.

    *--Check for PURCHASING view, if not there create with default data from

    *-- ref material

    SEARCH wa_t134-pstat FOR c_e.

    IF sy-subrc EQ 0.

    wa_header-purchase_view = c_true.

    wa_plant1-plant = wa_plant-werks.

    wa_plant1x-plant = wa_plant-werks.

    wa_plant1-countryori = wa_ref_data-herkl. "Country of origin

    wa_plant1x-countryori = c_true.

    wa_plant1-comm_code = wa_ref_data-stawn.

    wa_plant1-expimpgrp = wa_ref_data-mtver.

    wa_plant1-cas_no = wa_ref_data-casnr.

    wa_plant1-prodcom_no = wa_ref_data-gpnum.

    wa_plant1-ctrl_code = wa_ref_data-steuc.

    wa_plant1-regionorig = wa_ref_data-herkr.

    wa_plant1-eu_list_no = wa_ref_data-mownr.

    wa_plant1-eu_mat_grp = wa_ref_data-mogru.

    wa_plant1-ex_cert_id = wa_ref_data-prenc.

    wa_plant1-ex_cert_dt = wa_ref_data-prend.

    wa_plant1-milit_id = wa_ref_data-itark.

    wa_client-po_unit = wa_ref_data-bstme.

    wa_client-var_ord_un = wa_ref_data-vabme.

    wa_plant1-pur_group = wa_ref_data-ekgrp.

    wa_plant1-pur_status = wa_ref_data-mmsta.

    wa_plant1-pvalidfrom = wa_ref_data-mmstd.

    wa_client-qual_dik = wa_ref_data-nrfhg.

    wa_plant1-matfrgtgrp = wa_ref_data-mfrgr.

    wa_client-pur_valkey = wa_ref_data-ekwsl.

    wa_plant1-gr_pr_time = wa_ref_data-webaz.

    wa_plant1-ind_post_to_insp_stock = wa_ref_data-insmk.

    wa_plant1-crit_part = wa_ref_data-kzkri.

    wa_plant1-quotausage = wa_ref_data-usequ.

    wa_plant1-sourcelist = wa_ref_data-kordb.

    wa_plant1-jit_relvt = wa_ref_data-fabkz.

    wa_plant1x-comm_code = c_true.

    wa_plant1x-expimpgrp = c_true.

    wa_plant1x-cas_no = c_true.

    wa_plant1x-prodcom_no = c_true.

    wa_plant1x-ctrl_code = c_true.

    wa_plant1x-regionorig = c_true.

    wa_plant1x-eu_list_no = c_true.

    wa_plant1x-eu_mat_grp = c_true.

    wa_plant1x-ex_cert_id = c_true.

    wa_plant1x-ex_cert_dt = c_true.

    wa_plant1x-milit_id = c_true.

    wa_clientx-po_unit = c_true.

    wa_clientx-var_ord_un = c_true.

    wa_plant1x-pur_group = c_true.

    wa_plant1x-pur_status = c_true.

    wa_plant1x-pvalidfrom = c_true.

    wa_clientx-qual_dik = c_true.

    wa_plant1x-matfrgtgrp = c_true.

    wa_clientx-pur_valkey = c_true.

    wa_plant1x-gr_pr_time = c_true.

    wa_plant1x-ind_post_to_insp_stock = c_true.

    wa_plant1x-crit_part = c_true.

    wa_plant1x-quotausage = c_true.

    wa_plant1x-sourcelist = c_true.

    wa_plant1x-jit_relvt = c_true.

    ENDIF.

    *--Check for Production Resources/Tools (PRT) view, if not there create

    *with default data

    *-- from ref material

    SEARCH wa_t134-pstat FOR c_f.

    IF sy-subrc EQ 0.

    wa_header-prt_view = c_true.

    ENDIF.

    *--Check for COSTING view, if not there create with default data

    *-- from ref material

    SEARCH wa_t134-pstat FOR c_g.

    IF sy-subrc EQ 0.

    wa_header-cost_view = c_true.

    wa_valuation-orig_mat = wa_ref_data-hkmat.

    wa_header-material = wa_matnr-matnr.

    "Material no

    wa_header-ind_sector = wa_matnr-mbrsh.

    "Industry sector

    wa_header-matl_type = wa_matnr-mtart.

    "Material type

    wa_plant1-plant = wa_plant-werks. "Plant

    wa_plant1-lot_size = wa_ref_data-losgr. "Lot

    "Size for Product Costing

    wa_storage-plant = wa_plant-werks. "Plant

    wa_storage-stge_loc = wa_sloc-lgort.

    "Storage location

    wa_valuation-val_area = wa_plant-werks. "Plant

    wa_valuation-price_unit = wa_ref_data-peinh. "Price unit

    wa_plant1x-plant = wa_plant-werks. "Plant

    wa_plant1x-lot_size = c_true.

    wa_storagex-plant = wa_plant-werks.

    wa_storagex-stge_loc = wa_sloc-lgort.

    wa_valuationx-val_area = wa_plant-werks.

    wa_valuationx-orig_mat = c_true.

    wa_valuationx-price_unit = c_true.

    wa_plant1-no_costing = wa_ref_data-ncost.

    wa_plant1-variance_key = wa_ref_data-awsls.

    wa_plant1-pur_status = wa_ref_data-mmsta.

    wa_plant1-pvalidfrom = wa_ref_data-mmstd.

    wa_plant1-production_scheduler = wa_ref_data-prctr.

    wa_plant1-alternative_bom = wa_ref_data-stlal.

    wa_plant1-bom_usage = wa_ref_data-stlan.

    wa_plant1-planlistgrp = wa_ref_data-plnnr.

    wa_plant1-planlistcnt = wa_ref_data-aplal.

    wa_plant1-task_list_type = wa_ref_data-plnty.

    wa_plant1-specprocty = wa_ref_data-sobsk.

    wa_valuation-qty_struct = wa_ref_data-ekalr.

    wa_valuation-orig_group = wa_ref_data-hrkft.

    wa_valuation-orig_mat = wa_ref_data-hkmat.

    wa_valuation-overhead_grp = wa_ref_data-kosgr.

    wa_valuation-plnd_price = wa_ref_data-zplpr.

    wa_valuation-plndprice1 = wa_ref_data-zplp1.

    wa_valuation-plndprdate1 = wa_ref_data-zpld1.

    wa_valuation-plndprice2 = wa_ref_data-zplp2.

    wa_valuation-plndprdate2 = wa_ref_data-zpld2.

    wa_valuation-plndprice3 = wa_ref_data-zplp3.

    wa_valuation-plndprdate3 = wa_ref_data-zpld3.

    wa_valuation-val_class = wa_ref_data-bklas.

    wa_valuation-val_cat = wa_ref_data-bwtty.

    wa_valuation-vm_so_stk = wa_ref_data-eklas.

    wa_valuation-vm_p_stock = wa_ref_data-qklas.

    wa_valuation-moving_pr = wa_ref_data-verpr.

    wa_valuation-std_price = wa_ref_data-stprs.

    wa_plant1x-no_costing = c_true.

    wa_plant1x-variance_key = c_true.

    wa_plant1x-pur_status = c_true.

    wa_plant1x-pvalidfrom = c_true.

    wa_plant1x-production_scheduler = c_true.

    wa_plant1x-alternative_bom = c_true.

    wa_plant1x-bom_usage = c_true.

    wa_plant1x-planlistgrp = c_true.

    wa_plant1x-planlistcnt = c_true.

    wa_plant1x-task_list_type = c_true.

    wa_plant1x-specprocty = c_true.

    wa_valuationx-qty_struct = c_true.

    wa_valuationx-orig_group = c_true.

    wa_valuationx-orig_mat = c_true.

    wa_valuationx-overhead_grp = c_true.

    wa_valuationx-plnd_price = c_true.

    wa_valuationx-plndprice1 = c_true.

    wa_valuationx-plndprdate1 = c_true.

    wa_valuationx-plndprice2 = c_true.

    wa_valuationx-plndprdate2 = c_true.

    wa_valuationx-plndprice3 = c_true.

    wa_valuationx-plndprdate3 = c_true.

    wa_valuationx-val_class = c_true.

    wa_valuationx-val_cat = c_true.

    wa_valuationx-vm_so_stk = c_true.

    wa_valuationx-vm_p_stock = c_true.

    wa_valuationx-moving_pr = c_true.

    wa_valuationx-std_price = c_true.

    ELSE.

    *If Costing view is not maintained for the specific Material type

    • populate data for extending to storage location.

    wa_storage-plant = wa_plant-werks. "Plant

    wa_storagex-plant = wa_plant-werks.

    wa_storage-stge_loc = wa_sloc-lgort.

    "Storage location

    wa_storagex-stge_loc = wa_sloc-lgort.

    wa_storage-del_flag = wa_ref_data-lvolg.

    wa_storage-mrp_ind = wa_ref_data-diskz.

    wa_storage-spec_proc = wa_ref_data-lsobs.

    wa_storage-reorder_pt = wa_ref_data-lminb.

    wa_storage-repl_qty = wa_ref_data-lbstf.

    wa_storage-stge_bin = wa_ref_data-lgpbe.

    wa_storagex-del_flag = c_true.

    wa_storagex-mrp_ind = c_true.

    wa_storagex-spec_proc = c_true.

    wa_storagex-reorder_pt = c_true.

    wa_storagex-repl_qty = c_true.

    wa_storagex-stge_bin = c_true.

    ENDIF.

    *--Check for Basic view, if not there create with default data from ref

    *--material

    SEARCH wa_t134-pstat FOR c_k.

    IF sy-subrc EQ 0.

    wa_header-basic_view = c_true.

    ENDIF.

    *--Check for STORAGE view, if not there create with default data

    *-- from ref material

    SEARCH wa_t134-pstat FOR c_l.

    IF sy-subrc EQ 0.

    wa_header-storage_view = c_true.

    wa_plant1-plant = wa_plant-werks.

    wa_plant1x-plant = wa_plant-werks.

    wa_plant1-issue_unit = wa_ref_data-ausme.

    wa_client-temp_conds = wa_ref_data-tempb.

    wa_client-stor_conds = wa_ref_data-raube.

    wa_client-container = wa_ref_data-behvo.

    wa_client-haz_mat_no = wa_ref_data-stoff.

    wa_client-qty_gr_gi = wa_ref_data-wesch.

    wa_client-label_type = wa_ref_data-etiar.

    wa_client-label_form = wa_ref_data-etifo.

    wa_client-appd_b_rec = wa_ref_data-xgchp.

    wa_plant1-cc_ph_inv = wa_ref_data-abcin.

    wa_plant1-cc_fixed = wa_ref_data-ccfix.

    wa_plant1-stgeperiod = wa_ref_data-maxlz.

    wa_plant1-stge_pd_un = wa_ref_data-lzeih.

    wa_client-minremlife = wa_ref_data-mhdrz.

    wa_client-shelf_life = wa_ref_data-mhdhb.

    wa_client-round_up_rule_expiration_date = wa_ref_data-rdmhd.

    wa_client-stor_pct = wa_ref_data-mhdlp.

    wa_client-net_weight = wa_ref_data-ntgew.

    wa_client-pack_vo_un = wa_ref_data-voleh.

    wa_client-allwd_vol = wa_ref_data-volum.

    wa_client-size_dim = wa_ref_data-groes.

    wa_plant1-neg_stocks = wa_ref_data-xmcng.

    wa_plant1-handlg_grp = wa_ref_data-loggr.

    wa_plant1-serno_prof = wa_ref_data-sernp.

    wa_plant1-distr_prof = wa_ref_data-fprfm.

    wa_plant1-production_scheduler = wa_ref_data-prctr.

    wa_plant1-determ_grp = wa_ref_data-eprio.

    wa_client-serialization_level = wa_ref_data-serlv.

    wa_plant1x-issue_unit = c_true.

    wa_clientx-temp_conds = c_true.

    wa_clientx-stor_conds = c_true.

    wa_clientx-container = c_true.

    wa_clientx-haz_mat_no = c_true.

    wa_clientx-qty_gr_gi = c_true.

    wa_clientx-label_type = c_true.

    wa_clientx-label_form = c_true.

    wa_clientx-appd_b_rec = c_true.

    wa_plant1x-cc_ph_inv = c_true.

    wa_plant1x-cc_fixed = c_true.

    wa_plant1x-stgeperiod = c_true.

    wa_plant1x-stge_pd_un = c_true.

    wa_clientx-minremlife = c_true.

    wa_clientx-shelf_life = c_true.

    wa_clientx-round_up_rule_expiration_date = c_true.

    wa_clientx-stor_pct = c_true.

    wa_clientx-net_weight = c_true.

    wa_clientx-pack_vo_un = c_true.

    wa_clientx-allwd_vol = c_true.

    wa_clientx-size_dim = c_true.

    wa_plant1x-neg_stocks = c_true.

    wa_plant1x-handlg_grp = c_true.

    wa_plant1x-serno_prof = c_true.

    wa_plant1x-distr_prof = c_true.

    wa_plant1x-production_scheduler = c_true.

    wa_plant1x-determ_grp = c_true.

    wa_clientx-serialization_level = c_true.

    ENDIF.

    *--Check for FORECASTING view, if not there create with default data

    *-- from ref material

    SEARCH wa_t134-pstat FOR c_p.

    IF sy-subrc EQ 0.

    wa_header-forecast_view = c_true.

    wa_forecast-plant = wa_plant-werks.

    wa_forecastx-plant = wa_plant-werks.

    ENDIF.

    *--Check for QUALITY view, if not there create with default data

    *-- from ref material

    SEARCH wa_t134-pstat FOR c_q.

    IF sy-subrc EQ 0.

    wa_header-quality_view = c_true.

    wa_plant1-issue_unit = wa_ref_data-ausme.

    wa_plant1-ind_post_to_insp_stock = wa_ref_data-insmk.

    wa_plant1-qm_authgrp = wa_ref_data-qmata.

    wa_plant1-doc_reqd = wa_ref_data-kzdkz.

    wa_plant1-gr_pr_time = wa_ref_data-webaz.

    wa_plant1-insp_int = wa_ref_data-prfrq.

    wa_plant1-ctrl_key = wa_ref_data-ssqss.

    wa_plant1-pur_status = wa_ref_data-mmsta.

    wa_plant1-pvalidfrom = wa_ref_data-mmstd.

    wa_plant1-qm_rgmts = wa_ref_data-qssys.

    wa_client-catprofile = wa_ref_data-rbnrm.

    wa_client-qm_procmnt = wa_ref_data-qmpur.

    wa_client-catprofile = wa_ref_data-rbnrm.

    wa_plant1-cert_type = wa_ref_data-qzgtp.

    wa_plant1-qm_rgmts = wa_ref_data-qssys.

    wa_plant1x-issue_unit = c_true.

    wa_plant1x-ind_post_to_insp_stock = c_true.

    wa_plant1x-qm_authgrp = c_true.

    wa_plant1x-doc_reqd = c_true.

    wa_plant1x-gr_pr_time = c_true.

    wa_plant1x-insp_int = c_true.

    wa_plant1x-pur_status = c_true.

    wa_plant1x-pvalidfrom = c_true.

    wa_plant1x-qm_rgmts = c_true.

    wa_clientx-catprofile = c_true.

    wa_clientx-qm_procmnt = c_true.

    wa_clientx-catprofile = c_true.

    wa_plant1x-cert_type = c_true.

    wa_plant1x-qm_rgmts = c_true.

    wa_plant1x-ctrl_key = c_true.

    ENDIF.

    *--Check for SALES view, if not there create with default data from ref

    *--material

    SEARCH wa_t134-pstat FOR c_v.

    IF sy-subrc EQ 0.

    wa_header-sales_view = c_true.

    wa_header-material = wa_matnr-matnr. "Material no

    wa_header-ind_sector = wa_matnr-mbrsh. "Industry sector

    wa_header-matl_type = wa_matnr-mtart. "Material type

    wa_plant1-plant = wa_plant-werks. "Plant

    wa_plant1x-plant = wa_plant-werks.

    wa_plant1-loadinggrp = wa_ref_data-ladgr. "Loading gr

    wa_plant1x-loadinggrp = c_true.

    wa_client-net_weight = wa_ref_data-ntgew.

    wa_plant1-availcheck = wa_ref_data-mtvfp.

    wa_client-qual_dik = wa_ref_data-nrfhg.

    wa_plant1-matfrgtgrp = wa_ref_data-mfrgr.

    wa_client-mat_grp_sm = wa_ref_data-magrv.

    wa_client-allowed_wt = wa_ref_data-ergew.

    wa_client-allwd_vol = wa_ref_data-ervol.

    wa_client-fill_level = wa_ref_data-fuelg.

    wa_client-stack_fact = wa_ref_data-stfak.

    wa_client-wt_tol_lt = wa_ref_data-gewto.

    wa_client-vol_tol_lt = wa_ref_data-volto.

    wa_plant1-production_scheduler = wa_ref_data-prctr.

    wa_client-appd_b_rec = wa_ref_data-xgchp.

    wa_client-closed_box = wa_ref_data-kzgvh.

    wa_plant1-neg_stocks = wa_ref_data-xmcng.

    wa_plant1-serno_prof = wa_ref_data-sernp.

    wa_plant1-distr_prof = wa_ref_data-fprfm.

    wa_client-serialization_level = wa_ref_data-serlv.

    wa_clientx-net_weight = c_true.

    wa_plant1x-availcheck = c_true.

    wa_clientx-qual_dik = c_true.

    wa_plant1x-matfrgtgrp = c_true.

    wa_clientx-mat_grp_sm = c_true.

    wa_clientx-allowed_wt = c_true.

    wa_clientx-allwd_vol = c_true.

    wa_clientx-fill_level = c_true.

    wa_clientx-stack_fact = c_true.

    wa_clientx-wt_tol_lt = c_true.

    wa_clientx-vol_tol_lt = c_true.

    wa_plant1x-production_scheduler = c_true.

    wa_clientx-appd_b_rec = c_true.

    wa_clientx-closed_box = c_true.

    wa_plant1x-neg_stocks = c_true.

    wa_plant1x-serno_prof = c_true.

    wa_plant1x-distr_prof = c_true.

    wa_clientx-serialization_level = c_true.

    ENDIF.

    ENDIF.

    *Function module for extending the material to the Plant Storage

    *Location.

    CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'

    EXPORTING

    headdata = wa_header

    clientdata = wa_client

    clientdatax = wa_clientx

    plantdata = wa_plant1

    plantdatax = wa_plant1x

    planningdata = wa_planning

    planningdatax = wa_planningx

    forecastparameters = wa_forecast

    forecastparametersx = wa_forecastx

    storagelocationdata = wa_storage

    storagelocationdatax = wa_storagex

    valuationdata = wa_valuation

    valuationdatax = wa_valuationx

    warehousenumberdata = wa_warehouse

    warehousenumberdatax = wa_warehousex

    salesdata = wa_sales

    salesdatax = wa_salesx

    IMPORTING

    return = wa_return

    TABLES

    returnmessages = itab_return_tmp.

    SORT itab_return_tmp BY type id number.

    *---Check if the material has been extended

    READ TABLE itab_return_tmp INTO wa_return WITH KEY type = 'S'

    id = 'M3'

    number = 364

    BINARY SEARCH.

    IF sy-subrc EQ 0.

    CLEAR wa_succ.

    PERFORM material_convert USING wa_matnr-matnr

    CHANGING wa_succ-mat.

    wa_succ-plant = wa_plant-werks.

    wa_succ-sloc = wa_sloc-lgort.

    wa_succ-comm = 'Successfully extended'(007).

    APPEND wa_succ TO i_succ.

    CLEAR wa_succ.

    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

    EXPORTING

    wait = c_true.

    *The control will not go to the next part of the code untill

    *database table (MARC) is updated with the new record

    • DO.

    • SELECT SINGLE *

    • FROM marc

    • WHERE matnr = wa_matnr-matnr AND

    • werks = wa_plant-werks .

    *

    • IF sy-subrc EQ 0.

    • EXIT.

    • ENDIF.

    *

    • ENDDO.

    *The control will not go to the next part of the code untill

    *database table (MARD) is updated with the new record

    • DO.

    • SELECT SINGLE *

    • FROM mard

    • WHERE matnr = wa_matnr-matnr AND

    • werks = wa_plant-werks AND

    • lgort = wa_sloc-lgort.

    *

    • IF sy-subrc EQ 0.

    • EXIT.

    • ENDIF.

    *

    • ENDDO.

    *For creating "Inspection setup" in the quality view.

    READ TABLE i_qmat INTO wa_qmat WITH KEY matnr = wa_matnr-matnr.

    IF sy-subrc EQ 0.

    l_tabix = sy-tabix.

    LOOP AT i_qmat INTO wa_qmat FROM l_tabix.

    IF wa_qmat-matnr NE wa_matnr-matnr.

    EXIT.

    ENDIF.

    wa_inspcnt-function = '009'.

    wa_inspcnt-insptype = wa_qmat-art.

    wa_inspcnt-material = wa_matnr-matnr.

    wa_inspcnt-plant = wa_plant-werks.

    wa_inspcnt-ind_insp_with_tsk_list = wa_qmat-ppl.

    wa_inspcnt-ind_spec_matspec = wa_qmat-spezueber.

    wa_inspcnt-ind_spec_config = wa_qmat-conf.

    wa_inspcnt-ind_spec_batch = wa_qmat-tls.

    wa_inspcnt-ind_auto_assign = wa_qmat-app.

    wa_inspcnt-ind_insp_by_charac = wa_qmat-mer.

    wa_inspcnt-ind_post_to_insp_stock = wa_qmat-insmk.

    wa_inspcnt-ind_automatic_ud = wa_qmat-ave.

    wa_inspcnt-sampling_procedure = wa_qmat-stichprver.

    wa_inspcnt-dyn_modif_rule = wa_qmat-dynregel.

    wa_inspcnt-insp_percentage = wa_qmat-sproz.

    wa_inspcnt-ind_100_percent_inspection = wa_qmat-hpz.

    wa_inspcnt-ind_skips_allowed = wa_qmat-dyn.

    wa_inspcnt-ind_manual_sample = wa_qmat-mpb.

    wa_inspcnt-ind_manual_sample_calc = wa_qmat-mst.

    wa_inspcnt-ind_single_units_possible = wa_qmat-ein.

    wa_inspcnt-ave_insp_duration = wa_qmat-mpdau.

    wa_inspcnt-contr_insp_lot_create = wa_qmat-chg.

    wa_inspcnt-qual_score_procedure = wa_qmat-qkzverf.

    wa_inspcnt-allowed_scrap_share = wa_qmat-qpmat.

    wa_inspcnt-ind_special_qm_order = wa_qmat-kzprfkost.

    wa_inspcnt-qm_orderid = wa_qmat-aufnr_co.

    wa_inspcnt-ind_insptype_mat_active = wa_qmat-aktiv.

    wa_inspcnt-preferred_insptype = wa_qmat-apa.

    wa_inspcnt-insptype_delete = wa_qmat-afr.

    wa_inspcnt-creation_time = wa_qmat-mma.

    wa_inspcnt-material_external = wa_qmat-feh.

    wa_inspcnt-material_guid = wa_qmat-prfrq.

    wa_inspcnt-material_version = wa_qmat-nkmpr.

    APPEND wa_inspcnt TO i_inspectionctrl .

    CLEAR wa_inspcnt.

    ENDLOOP.

    IF i_inspectionctrl[] IS NOT INITIAL.

    *----- To maintain Inspection Setup Data

    CALL FUNCTION 'BAPI_MATINSPCTRL_SAVEREPLICA'

    TABLES

    return = i_return

    inspectionctrl = i_inspectionctrl.

    *----- Read table of Return Messages for error Messages

    IF i_return[] IS INITIAL.

    *----- For Commit work

    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

    EXPORTING

    wait = c_true.

    CALL FUNCTION 'DEQUEUE_ALL'

    EXPORTING

    synchron = ctrue.

    ENDIF.

    ENDIF.

    ENDIF.

    ELSE.

    LOOP AT itab_return_tmp INTO wa_return WHERE type = 'E'.

    CLEAR wa_error.

    PERFORM material_convert USING wa_matnr-matnr

    CHANGING wa_error-mat.

    wa_error-plant = wa_plant-werks.

    wa_error-sloc = wa_sloc-lgort.

    wa_error-comm = wa_return-message.

    APPEND wa_error TO i_error.

    CLEAR wa_error.

    ENDLOOP.

    CLEAR wa_return.

    ENDIF.

    ENDFORM. " sub_extend_material .

    &----


    *& Form sub_get_mvke

    &----


    • Subroutine to get data from mvke.

    ----


    FORM sub_get_mvke .

    CHECK i_matnr[] IS NOT INITIAL.

    SELECT matnr "Material Number

    vkorg "Sales org

    vtweg "Distribution channel

    FROM mvke "Table for Sales Data for Material

    INTO TABLE i_mvke

    FOR ALL ENTRIES IN i_matnr

    WHERE matnr = i_matnr-matnr.

    IF sy-subrc EQ 0.

    SORT i_mvke BY matnr.

    ENDIF.

    ENDFORM. " sub_get_mvke

    &----


    *& Form sub_get_mdma

    &----


    • Subroutine to get data from mdma.

    &----


    FORM sub_get_mdma .

    CHECK i_matnr[] IS NOT INITIAL.

    SELECT matnr "Material No.

    berid "Receiving Storage Location

    werks "Plant

    FROM mdma "Table for MRP Area for Material

    INTO TABLE i_mdma

    FOR ALL ENTRIES IN i_matnr

    WHERE matnr = i_matnr-matnr.

    IF sy-subrc EQ 0.

    SORT i_mdma BY werks berid.

    ENDIF.

    ENDFORM. " sub_get_mdma

    &----


    *& Form sub_populate_selfields

    &----


    • For populating data MRP Area Selection Fields for Mass

    • Data Maintenance

    ----


    FORM sub_populate_selfields .

    *Populating data for I_SELFIELDS

    wa_selfields-xdismm = 'X'.

    wa_selfields-xeisbe = 'X'.

    wa_selfields-xdisls = 'X'.

    wa_selfields-xdispo = 'X'.

    wa_selfields-xplifz = 'X'.

    ENDFORM. " sub_populate_selfields

    &----


    *& Form sub_get_pstat

    &----


    • For retrieving Procurement status data from T134.

    ----


    FORM sub_get_pstat .

    CHECK i_matnr[] IS NOT INITIAL.

    SELECT mtart

    pstat

    FROM t134

    INTO TABLE i_t134

    FOR ALL ENTRIES IN i_matnr

    WHERE mtart = i_matnr-mtart.

    IF sy-subrc EQ 0.

    SORT i_t134 BY mtart.

    ENDIF.

    ENDFORM. " sub_get_pstat

    &----


    *& Form sub_get_t001k

    &----


    • To retrieve company code

    ----


    FORM sub_get_t001k .

    CHECK i_t001w[] IS NOT INITIAL.

    SELECT bwkey "Valuation area

    bukrs "Company code

    FROM t001k "Table for Valuation area

    INTO TABLE i_bukrs

    FOR ALL ENTRIES IN i_t001w

    WHERE bwkey = i_t001w-bwkey.

    IF sy-subrc EQ 0.

    SORT i_bukrs BY bukrs.

    ENDIF.

    ENDFORM. " sub_get_t001k

    &----


    *& Form sub_create_log

    &----


    • Creating success and error log *

    ----


    FORM sub_create_log .

    WRITE:/ 'FOLLOWING MATERIALS ARE EXTENDED. :-'.

    SKIP 1 .

    ULINE 1(175).

    WRITE:/1 'MATERIAL', 20 sy-vline NO-GAP,

    21(9) 'PLANT', 31 sy-vline NO-GAP,

    32(30) 'STORAGE LOCATION' ,64 sy-vline NO-GAP,

    65(35) 'COMMENTS' , 175 sy-vline NO-GAP.

    ULINE /1(175).

    LOOP AT i_succ INTO wa_succ.

    WRITE: /1 wa_succ-mat, 20 sy-vline NO-GAP,

    21 wa_succ-plant, 31 sy-vline NO-GAP,

    32 wa_succ-sloc, 64 sy-vline NO-GAP,

    65 wa_succ-comm , 175 sy-vline NO-GAP.

    ULINE /1(175).

    ENDLOOP.

    SKIP 5.

    WRITE:/ 'FOLLOWING MATERIALS ARE NOT EXTENDED. :-'.

    SKIP 1 .

    ULINE 1(175).

    WRITE:/1(20) 'MATERIAL', 20 sy-vline NO-GAP,

    21(9) 'PLANT', 31 sy-vline NO-GAP,

    32(30) 'STORAGE LOCATION' ,64 sy-vline NO-GAP,

    65(35) 'COMMENTS' , 175 sy-vline NO-GAP.

    ULINE /1(175).

    LOOP AT i_error INTO wa_error.

    WRITE: /1 wa_error-mat, 20 sy-vline NO-GAP,

    21 wa_error-plant, 31 sy-vline NO-GAP,

    32 wa_error-sloc, 64 sy-vline NO-GAP,

    65 wa_error-comm , 175 sy-vline NO-GAP.

    ULINE /1(175).

    ENDLOOP.

    ENDFORM. " sub_errorlog

    &----


    *& Form material_convert

    &----


    • For converting material name

    ----


    FORM material_convert USING p_input

    CHANGING p_output.

    • CALL FUNCTION 'CONVERSION_EXIT_MATN2_OUTPUT'

    CALL FUNCTION 'CONVERSION_EXIT_MATN1_OUTPUT'

    EXPORTING

    input = p_input

    IMPORTING

    output = p_output.

    ENDFORM. " material_convert

    &----


    *& Form sub_sloc_check

    &----


    • For checking that the MRP area is limited to

    • only regular serviceable storage locations.

    ----


    FORM sub_sloc_check CHANGING p_stat.

    READ TABLE i_twlad INTO wa_twlad WITH KEY werks = wa_plant-werks

    lgort = wa_sloc-lgort

    BINARY SEARCH.

    IF sy-subrc EQ 0.

    READ TABLE i_adrc INTO wa_adrc WITH KEY adrnr = wa_twlad-adrnr

    BINARY SEARCH.

    IF sy-subrc EQ 0.

    SORT i_dev00160 BY value.

    READ TABLE i_dev00160 INTO wa_dev00160 WITH KEY value =

    wa_adrc-sort2 BINARY SEARCH.

    IF sy-subrc EQ 0.

    p_stat = 'X'.

    ELSE.

    • Getting all MRP area for the specific plant and storage location

    CLEAR wa_mdlv.

    READ TABLE i_mdlv INTO wa_mdlv WITH KEY werzg = wa_plant-werks

    ortzg = wa_sloc-lgort

    BINARY SEARCH.

    IF sy-subrc NE 0.

    ENDIF.

    IF wa_mdlv IS NOT INITIAL.

    CLEAR wa_error.

    PERFORM material_convert USING wa_matnr-matnr

    CHANGING wa_error-mat.

    wa_error-plant = wa_plant-werks.

    wa_error-sloc = wa_sloc-lgort.

    wa_error-comm =

    'Not a seviceable storage location Cannot be extended to MRP Area'(009)

    .

    CONCATENATE wa_error-comm

    wa_mdlv-berid

    INTO wa_error-comm

    SEPARATED BY space .

    APPEND wa_error TO i_error.

    CLEAR wa_error.

    ENDIF.

    ENDIF.

    ENDIF.

    ENDIF.

    ENDFORM. " sub_sloc_check

    &----


    *& Form sub_get_scalability

    &----


    • Retrieve the scalability features

    ----


    FORM sub_get_scalability .

    SELECT pkey

    item

    value

    FROM zdm_par_dev00160

    INTO TABLE i_dev00160

    WHERE pkey = '1'.

    IF sy-subrc EQ 0.

    SORT i_dev00160 BY pkey item.

    ENDIF.

    ENDFORM. " sub_get_scalability

    cheers

    Aveek

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 14, 2015 at 06:08 AM

    Hi every one,

    By using bapi : Bapi_material_Savedata u can achieve it..

    u have to pass only these values to extend material from one plant to another plant.

    Example Requirement : Material 100-101 is available only in plant 1000, So lets Copy material 100-101 to a plant 1200.

    Note : Pass values in block letters only

    In headdata structure :

    1.headdata-material " matnr : '100-101'

    2.headdata-ind_sector " mbrsh : 'M'

    3.headdata-matl_type " mtart : 'HALB'

    4.headdata-basic_view " kzsel : 'X'

    5.headdata-purchase_view "kzsel : 'X'

    In Clientdata structure :

    1.Clientdata-base_uom " meins : 'PC'

    In Clientdatax structure :

    1.Clientdatax-base_uom "meins : 'X'

    In Plantdata Structure :

    1. plantdata-plant "werks : '1200'

    2. plantdata-countryori "herkl : 'DE'

    In PlantdataX Structure :

    1. plantdataX-plant "werks : 'X'

    2. plantdataX-countryori "herkl : 'X'

    By passing above data u can extend material from one plant to another plant..😊

    Add comment
    10|10000 characters needed characters exceeded