cancel
Showing results for 
Search instead for 
Did you mean: 

Sales BOM

Former Member
0 Kudos

Hi  I have created a BOM with pricing, inventory & delivery at sub item & NOT at MAIN ITEM.  In SO the main item (ZFST) & sub item (ZFTN) is picked up properly with pricing carried  out at sub item (ZFTN).  However, in delivery the sub item (ZFTN) is not picked up & only the main item is picked.  Can you advice why the sub item (ZFTN) is not picked up in delivery.  Thanks in advance.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi   I have checked the routines in VTLA & also the OVLP transaction everthing according to me seems fine, however I have notice the DELIVERY ITEM CATEGORY DETERMINATION is not maintained for   Del.     Itcg     USG     Itmc ZFLF     NORM     -      ZFST which is the Main item & this item gets picked up in delivery.  Kindy advice if there is any other possiblity why the sub item ZFTN doesnt get picked up in delivery.  Thanks.

mahendra_jani3
Contributor
0 Kudos

Hi Ramesh,

Your Schedule Line category determined for that Item Category ZFTN should be relevant for delivery.

Your Copy control between Order to Delivery should be proper.

Delivery Item Category determination should be correct.

if this 3 points are there, then in normal case your Item will be picked up in Delivery.

Regards,

MJ.

gurunathkumar_dadamu
Active Contributor
0 Kudos

Hi Ramesh B,

Try to use the following logic,but do the small changes according to your requirement.we did for like same your requirement.

REPORT  zptp_sales_bom_create.

*-global declarations.

INCLUDE zptp_sales_bom_decl.

*-selection details.

INCLUDE zptp_sales_bom_sel.

*- from routines.

INCLUDE zptp_sales_bom_forms.

*&---------------------------------------------------------------------*

*&  Include           ZPTP_SALES_BOM_DECL

*&---------------------------------------------------------------------*

TYPE-POOLS:slis.

*-tables.

TABLES: mara,

        marc,

        mast.

*- structure.

*- for mara table.

TYPES: BEGIN OF ty_mara,

       matnr                TYPE mara-matnr,             " material no

       matkl                TYPE mara-matkl,             " materail group

       END OF   ty_mara.

*- for marc table

TYPES: BEGIN OF ty_marc,

       matnr                TYPE marc-matnr,            " material no

       werks                TYPE marc-werks,            " plant

       END OF   ty_marc.

*- to material check bapi

TYPES : BEGIN OF ty_bapi_material_check,

         material           TYPE bapi1080_mbm_c-material,

         plant              TYPE bapi1080_mbm_c-plant,

         bomusage           TYPE bapi1080_bgr_c-bom_usage,

         END   OF ty_bapi_material_check.

*- Strucure for error details

TYPES:

  BEGIN OF ty_details,

         matnr         TYPE  mast-matnr,

         msg(250)      TYPE c,

         type(3)       TYPE c,

  END OF ty_details.

*- tables.

DATA: it_mara                TYPE STANDARD TABLE OF ty_mara,

      it_marc                TYPE STANDARD TABLE OF ty_marc,

      it_item                TYPE STANDARD TABLE OF stpo_api01,

      it_return              TYPE TABLE OF bapiret2,

      it_fieldcat            TYPE     slis_t_fieldcat_alv,

      it_events              TYPE slis_t_event,

      it_records             TYPE STANDARD TABLE OF ty_details.

*- work area.

DATA: wa_mara                TYPE ty_mara,

      wa_marc                TYPE ty_marc,

      wa_marc1               TYPE ty_marc,

      wa_header              TYPE stko_api01,

      wa_item                TYPE stpo_api01,

      wa_bapi_materail_check TYPE ty_bapi_material_check,

      wa_sucess              TYPE ty_details,

      wa_error               TYPE ty_details,

      wa_exist               TYPE ty_details,

      wa_fieldcat            LIKE LINE OF it_fieldcat,

      wa_event               TYPE slis_alv_event.

*- local varaibles

DATA: lv_material            TYPE csap_mbom-matnr,

      lv_plant               TYPE csap_mbom-werks,

      lv_bom_usage           TYPE csap_mbom-stlan,

      lv_date                TYPE csap_mbom-datuv,

      lv_bom_no              TYPE stko_api02-bom_no,

      lv_idnrk               TYPE stpo-idnrk,

      lv_error(200)          TYPE c,

      lv_sucess(200)         TYPE c,

      lv_text(200)           TYPE c,

      lv_text1(200)          TYPE c,

      lv_exist(200)          TYPE c.

*- constants

CONSTANTS:c_base_quan(1)     TYPE c VALUE '1',

          c_base_unit(2)     TYPE c VALUE 'EA',

          c_item_no(4)       TYPE c VALUE '0010',

          c_lan(2)           TYPE c VALUE 'EN',

          c_error(1)         TYPE c VALUE 'E'.

*&---------------------------------------------------------------------*

*&  Include           ZPTP_SALES_BOM_SEL

*&---------------------------------------------------------------------*

*- selection-screen.

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

SELECT-OPTIONS: s_werks FOR marc-werks OBLIGATORY,                     " plant

                s_mtart FOR mara-mtart OBLIGATORY,                     " material type

                s_ersda FOR mara-ersda,                                " creted on

                s_mstae FOR mara-mstae OBLIGATORY,                     " cross-plant material status

                s_matnr FOR mara-matnr.                                " materail no

PARAMETERS: p_bchild   TYPE mara-matnr OBLIGATORY,                     " bom child materail no

            p_stlan    TYPE mast-stlan OBLIGATORY.                     " bom usage

SELECTION-SCREEN END OF BLOCK b1.

*- start-of-selection.

START-OF-SELECTION.

*- get the data.

  PERFORM get_material.

*- sales bom creation & bom check.

  PERFORM material_exist_check.

*&---------------------------------------------------------------------*

*&  Include           ZPTP_SALES_BOM_FORMS

*&---------------------------------------------------------------------*

*&---------------------------------------------------------------------*

*&      Form  GET_MATERIAL

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

*  -->  p1        text

*  <--  p2        text

*----------------------------------------------------------------------*

FORM get_material .

*- select the materail deends upon the selction

*   input ie only for materil types 'ZMEM' 'ZSUP'.

  SELECT matnr

         matkl

         FROM mara

         INTO TABLE it_mara

         WHERE matnr IN s_matnr

         AND mtart IN s_mtart

         AND  mstae IN s_mstae

         AND  ersda IN s_ersda.

*- if suceess.

  IF sy-subrc = 0.

*- sort  it_mara by matnr.

    SORT it_mara BY  matnr.

*- if it_mara is not intial.

    IF it_mara IS NOT INITIAL.

*- select the matnr depends upon plant.

      SELECT matnr

             werks

             FROM marc

             INTO TABLE it_marc

             FOR ALL ENTRIES IN it_mara

             WHERE matnr = it_mara-matnr

             AND   werks IN s_werks.

*- if sucess.

      IF sy-subrc = 0.

*- sort it_marc by matnr.

        SORT it_marc BY matnr.

      ELSE.

        MESSAGE e000(zotc).

      ENDIF.

    ENDIF.

  ELSE.

    MESSAGE e000(zotc).

  ENDIF.

ENDFORM.                    " GET_MATERIAL

*&---------------------------------------------------------------------*

*&      Form  MATERIAL_EXIST_CHECK

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

*  -->  p1        text

*  <--  p2        text

*----------------------------------------------------------------------*

FORM material_exist_check .

*- sort it_marc by matnr werks.

  SORT it_marc BY matnr werks.

*- loop it_marc.

  LOOP AT it_marc INTO wa_marc.

*-if materail is not intial.

    IF wa_marc-matnr IS NOT INITIAL.

*- move wa_marc to wa_marc1.

      MOVE wa_marc TO wa_marc1.

*- dividing header data and item data.

      AT NEW matnr.

*- clear wa.

        CLEAR :wa_bapi_materail_check,

               wa_header.

*- pass the data to wa_bapi_materail_check:to check the materail bom

        MOVE:wa_marc1-matnr TO wa_bapi_materail_check-material,

             wa_marc1-werks TO wa_bapi_materail_check-plant,

             p_stlan        TO wa_bapi_materail_check-bomusage,

*- passthe materials to wa_header :To bom creation.

             wa_marc1-matnr TO lv_material,

             wa_marc1-werks TO lv_plant,

             p_stlan        TO lv_bom_usage,

             c_base_quan    TO wa_header-base_quan,

             c_base_unit    TO wa_header-base_unit.

*- concatenating the date .

        CONCATENATE  sy-datum+4(2) '/' sy-datum+6(2) '/' sy-datum+0(4) INTO lv_date.

*- clear wa.

        CLEAR wa_marc1.

      ENDAT.

    ENDIF.

*- passing the item details.

    wa_item-item_no = c_item_no.

    CLEAR: lv_idnrk.

*- converting the materil no (at item level).

    CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'

      EXPORTING

        input  = p_bchild

      IMPORTING

        output = lv_idnrk.

    wa_item-item_categ = 'Z'.

    wa_item-component  = lv_idnrk.              "Bom.Component

    wa_item-comp_qty   = c_base_quan.           "Comp.Quantity

    wa_item-comp_unit  = c_base_unit.           "Comp.unit

    APPEND wa_item TO it_item.

    CLEAR :wa_item,

           wa_marc.

*- At end of materail

    AT END OF matnr.

*- calling the bapi to check the bom materail.

      CALL FUNCTION 'BAPI_MAT_BOM_EXISTENCE_CHECK'

        EXPORTING

          material = wa_bapi_materail_check-material

          plant    = wa_bapi_materail_check-plant

          bomusage = wa_bapi_materail_check-bomusage

        TABLES

          return   = it_return.

      CLEAR: wa_bapi_materail_check.

*- if not sucess.

      IF it_return IS NOT INITIAL.

*- create the sales bom

        PERFORM bapi_creation.

      ELSE.

        CONCATENATE text-013 lv_material INTO lv_exist SEPARATED BY space.

*- moving the error details into wa_error.

        MOVE :lv_exist    TO wa_exist-msg,    "message

              lv_material TO wa_exist-matnr,  "material

              c_error     TO wa_exist-type.   "message type

        APPEND wa_exist TO it_records.

        CLEAR:wa_exist.

      ENDIF.

    ENDAT.

  ENDLOOP.

*- to display the errors in alv.

  PERFORM alv_display.

ENDFORM.                    " MATERIAL_EXIST_CHECK

*&---------------------------------------------------------------------*

*&      Form  BAPI_CREATION

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

*  -->  p1        text

*  <--  p2        text

*----------------------------------------------------------------------*

FORM bapi_creation .

*- converting the maerail no.

  CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'

    EXPORTING

      input  = lv_material

    IMPORTING

      output = lv_material.

*- Calling the fm for bom creation.

  CALL FUNCTION 'CSAP_MAT_BOM_CREATE'

    EXPORTING

      material   = lv_material           "material

      plant      = lv_plant              "plant

      bom_usage  = lv_bom_usage          "bom usage

      valid_from = lv_date               "valid date

      i_stko     = wa_header             " header

    IMPORTING

      bom_no     = lv_bom_no             " bom no

    TABLES

      t_stpo     = it_item               " item

    EXCEPTIONS

      error      = 1

      OTHERS     = 2.

*- if scuess.

  IF lv_bom_no IS NOT INITIAL.

    CONCATENATE text-011 lv_text1 lv_bom_no INTO lv_sucess SEPARATED BY space.

*- moving the sucess records into wa_sucess.

    MOVE : lv_sucess   TO wa_sucess-msg,     "message

           lv_material TO wa_sucess-matnr,   "material

           sy-msgty    TO wa_sucess-type.    "message type

    APPEND wa_sucess   TO it_records.

    CLEAR wa_sucess.

*- calling the fm to database commit

    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

  ELSE.

    IF sy-msgty = 'W'.

*- seleting the error text

      SELECT SINGLE text FROM t100 INTO lv_text WHERE sprsl = c_lan

                                                 AND  arbgb = sy-msgid

                                                 AND  msgnr = sy-msgno.

      REPLACE ALL OCCURRENCES OF '&' IN lv_text WITH space.

      IF sy-msgno NE '305'.

        CONCATENATE lv_text lv_material INTO lv_error SEPARATED BY space.

      ELSE.

        lv_error = lv_text.

      ENDIF.

    ELSE.

      CONCATENATE text-012 lv_material INTO lv_error SEPARATED BY space.

    ENDIF.

*- moving the error details into wa_error.

    MOVE :lv_error    TO wa_error-msg,    "message

          lv_material TO wa_error-matnr,  "material

          sy-msgty    TO wa_error-type.   "message type

    APPEND wa_error TO it_records.

    CLEAR:wa_error.

  ENDIF.

  CLEAR: lv_bom_no,

         lv_text,

         lv_text1,

         lv_material,

         lv_plant,

         lv_bom_usage,

         lv_date,

         lv_error,

         lv_sucess,

         sy-msgno,

         sy-msgid,

         sy-msgty.

  REFRESH : it_item.

ENDFORM.                    " BAPI_CREATION

*&---------------------------------------------------------------------*

*&      Form  ALV_DISPLAY

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

*  -->  p1        text

*  <--  p2        text

*----------------------------------------------------------------------*

FORM alv_display .

*- fieldcatlog

  PERFORM fieldlcat.

*- events

  PERFORM events.

  SORT it_records BY type DESCENDING.

* display the errors by using simple alv list

  CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

    EXPORTING

      i_callback_program = sy-repid

      it_fieldcat        = it_fieldcat

      it_events          = it_events

    TABLES

      t_outtab           = it_records.

ENDFORM.                    " ALV_DISPLAY

*&---------------------------------------------------------------------*

*&      Form  FIELDLCAT

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

*  -->  p1        text

*  <--  p2        text

*----------------------------------------------------------------------*

FORM fieldlcat .

  CLEAR wa_fieldcat.                       "material no

  wa_fieldcat-col_pos   = '1'.

  wa_fieldcat-fieldname = 'MATNR'.

  wa_fieldcat-tabname   = 'IT_RECORDS'.

  wa_fieldcat-outputlen =  18.

  wa_fieldcat-seltext_m =  text-002.

  APPEND wa_fieldcat TO it_fieldcat.

  CLEAR wa_fieldcat.

  wa_fieldcat-col_pos   = '2'.            " meaasge type

  wa_fieldcat-fieldname = 'TYPE'.

  wa_fieldcat-tabname   = 'IT_RECORDS'.

  wa_fieldcat-outputlen = 5.

  wa_fieldcat-seltext_m = text-003.

  APPEND wa_fieldcat TO it_fieldcat.

  CLEAR wa_fieldcat.

  wa_fieldcat-col_pos   = '3'.            " mesage text

  wa_fieldcat-fieldname = 'MSG'.

  wa_fieldcat-tabname   = 'IT_RECORDS'.

  wa_fieldcat-outputlen = 90.

  wa_fieldcat-seltext_m = text-004.

  APPEND wa_fieldcat TO it_fieldcat.

  CLEAR wa_fieldcat.

ENDFORM.                    " FIELDLCAT

*&---------------------------------------------------------------------*

*&      Form  EVENTS

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

*  -->  p1        text

*  <--  p2        text

*----------------------------------------------------------------------*

FORM events .

*- events for top_of-page.

  wa_event-name = slis_ev_top_of_list.

  wa_event-form = 'TOP_OF_PAGE'.

  APPEND wa_event TO it_events.

  CLEAR wa_event.

ENDFORM.                    " EVENTS

*&---------------------------------------------------------------------*

*&      Form  TOP_OF_PAGE

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

*  -->  p1        text

*  <--  p2        text

*----------------------------------------------------------------------*

FORM top_of_page .

*- displaying the top_of_page.

  WRITE: /5 text-010,sy-datum,sy-uzeit.

  ULINE.

ENDFORM.                    " TOP_OF_PAGE

let me know if any issues.

Regards,

Gurunath

moazzam_ali
Active Contributor
0 Kudos

Hi

You have to check following things.

Stock in confirmed in SO for sub items ZFTN?

Item category is relevant for delivery? and Schedule line assigned to it?

In copy control for sale order to delivery have you maintained this item category?

Please check configuration of your item categories once again and match them with standard item category TAN.

Thank$