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

BOM upload program

Former Member
0 Kudos

Hi All,

I have been given a scenario where Prior to project Go-Live all Bill of Material is to be uploaded into new Organization structures respectively.

The program will have functionality to accept an external file in MS EXCEL format for BOM data to be uploaded. The BOM data received from MS EXCEL file will be stored into Internal Tables for further process.

After data gathering into Internal Tables, system will run pre-recorded BDC Or BAPI to upload BOM in new Org Structures.

On successful completion or error, program should provide the respective message in terms of Completion Log.

I have never done any conversion program earlier and i am not able to figure out how to proceed.

Kindly help me.

Regards.

13 REPLIES 13

Former Member
0 Kudos

This message was moderated.

Former Member
0 Kudos

Hi,

Check this BAPI BAPI_MATERIAL_BOM_GROUP_CREATE

Regards,

Jyothi CH.

Former Member
0 Kudos

Check for uploading the data with LSMW.

SAP has suggested a standard procedure for uploading material BOM's in the Direct Input option.

Regards

Vinayak

Former Member
0 Kudos

I guess my purpose would get served by BAPI_BOM_UPLOAD_SAVE...

0 Kudos

Hi Napsterr,

Is your problem solved...!

If not, Can you say for which transaction you need this BOM, I mean is it for CS01 or anyother.

Thanks & regards,

Dileep .C

0 Kudos

Hi Napsterr ,

There are multiple choices for you for BOM uploading :

1. BAPIs : BAPI_MATERIAL_BOM_GROUP_CREATE => Creation of a Material BOM Group

BAPI_MAT_BOM_EXISTENCE_CHECK => Check Whether BOM for Material Exists

BAPI_BOM_UPLOAD_SAVE

2. FMs : CS_BOM_EXPL_MAT_V2

CSAI_BOM_CREATE

3. RCSBI0* : Batch Input Programs for BOM creation.

4. IDoc : MATERIALBOM_CREATEBOMGROUP

Hope this will help.

Regards,

Vivek

0 Kudos

Hi Dileep.

No my problem still remains unsolved.

Yes i am supposed to use it for CS01....

Regards.

0 Kudos

You can use the FM CSAP_MAT_BOM_CREATE to create Material BOMs after you read the data from excel file. Read the documentation of this function module, it also has sample code explaining how to use the FM.

0 Kudos

Hi

Please advice me how to upload BOM by t-code cs01. Is there any BAPI and how to use it.

shegar

Former Member
0 Kudos

here is the bdc code to upload bom.

but like this u need to create recording using shdb and then use that recording in ur program.



report ZBOM_PROG
       no standard page heading line-size 255.

DATA: bdcdata LIKE bdcdata    OCCURS 0 WITH HEADER LINE.

DATA: BEGIN OF itab OCCURS 0,
            MATNR(18) TYPE c,           "EQUIPMENT NUMBER
            werks(4)  TYPE c,           "PLANT
            stlan(1)  TYPE c,           "BOM USAGE
            datuv type RC29N-DATUV,     "date
            ztext type RC29K-ZTEXT ,    "header text
            bmeng(13) TYPE c,           "BASE QUANTITY
            stlst(2)  TYPE c,           "BOM STATUS
            idnrk(36) TYPE c,           "COMPONENT
            menge(13) TYPE c,           "QUANTITY
*            meins(3)  TYPE c,           "UOM                      "asim
            KNNAM TYPE RCUKD-KNNAM ,      "DEPENDENCIES
      END OF itab .

 DATA: BEGIN OF itab1 OCCURS 0,
           MATNR(18) TYPE c,           "EQUIPMENT NUMBER
           werks(4)  TYPE c,           "PLANT
           stlan(1)  TYPE c,           "BOM USAGE
           datuv type RC29N-DATUV,     "date
           ztext type RC29K-ZTEXT ,    "header text
*           menge(13) TYPE c,           "QUANTITY
*           meins(3)  TYPE c,           "UOM
           bmeng(13) TYPE c,           "BASE QUANTITY
           stlst(2)  TYPE c,           "BOM STATUS
           END OF itab1  .

  DATA: BEGIN OF itab2 OCCURS 0,
             MATNR(18) TYPE c,           "EQUIPMENT NUMBER
             werks(4)  TYPE c,           "PLANT
             stlan(1)  TYPE c,           "BOM USAGE
             datuv type RC29N-DATUV,     "date
            idnrk(36) TYPE c,           "COMPONENT
            menge(13) TYPE c,           "QUANTITY
*            meins(3)  TYPE c,           "UOM                             "asim
            KNNAM TYPE RCUKD-KNNAM ,    "DEPENDENCIES
        END OF itab2.


data : begin of itab3 occurs 0,
           MATNR(18) TYPE c,           "EQUIPMENT NUMBER
           werks(4)  TYPE c,           "PLANT
           stlan(1)  TYPE c,           "BOM USAGE
           datuv type RC29N-DATUV,     "date
           idnrk(36) TYPE c,           "COMPONENT
           menge(13) TYPE c,           "QUANTITY
*           meins(3)  TYPE c,           "UOM                            "asim
           KNNAM TYPE RCUKD-KNNAM ,    "DEPENDENCIES
           end of itab3.

 data : v_count2 type i.
 data : v_posnr type i.

 data : v_page type i.
v_page = 0.

*----------------------------------------------------------------------*
* Selection Screen
*----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text_001.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(20) text_1_1.
PARAMETERS: p_file LIKE rlgrap-filename OBLIGATORY.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b1.

*----------------------------------------------------------------------*
* Initialization Event
*----------------------------------------------------------------------*
INITIALIZATION.
  text_001 = 'File path selection'.
  text_1_1 = 'File Path'.

*----------------------------------------------------------------------*
* At Selection Screen Event
*----------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
  CALL FUNCTION 'F4_FILENAME'
    IMPORTING
      file_name = p_file.

*&---------------------------------------------------------------------*
*& Start of Selection
*&---------------------------------------------------------------------*
START-OF-SELECTION.

  PERFORM data_upload.
    PERFORM manipulate_data.
  IF itab[] IS NOT INITIAL.
    PERFORM open_group.

      REFRESH bdcdata.
      PERFORM bdcdata.

    PERFORM close_group.
  ENDIF.

*&---------------------------------------------------------------------*
*&      Form  DATA_UPLOAD
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM data_upload.

  DATA: loc_filename TYPE string.

  loc_filename = p_file.

  CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
      filename                = loc_filename
      filetype                = 'ASC'
      has_field_separator     = 'X'
    TABLES
      data_tab                = itab
    EXCEPTIONS
      file_open_error         = 1
      file_read_error         = 2
      no_batch                = 3
      gui_refuse_filetransfer = 4
      invalid_type            = 5
      no_authority            = 6
      unknown_error           = 7
      bad_data_format         = 8
      header_not_allowed      = 9
      separator_not_allowed   = 10
      header_too_long         = 11
      unknown_dp_error        = 12
      access_denied           = 13
      dp_out_of_memory        = 14
      disk_full               = 15
      dp_timeout              = 16
      OTHERS                  = 17.

  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

ENDFORM.                    " DATA_UPLOAD

*----------------------------------------------------------------------*
*        Start new screen                                              *
*----------------------------------------------------------------------*
FORM bdc_dynpro USING program dynpro.
  CLEAR bdcdata.
  bdcdata-program  = program.
  bdcdata-dynpro   = dynpro.
  bdcdata-dynbegin = 'X'.
  APPEND bdcdata.
ENDFORM.                    "BDC_DYNPRO

*----------------------------------------------------------------------*
*        Insert field                                                  *
*----------------------------------------------------------------------*
FORM bdc_field USING fnam fval.
  CLEAR bdcdata.
  bdcdata-fnam = fnam.
  bdcdata-fval = fval.
  APPEND bdcdata.
ENDFORM.                    "BDC_FIELD

*&---------------------------------------------------------------------*
*&      Form  OPEN_GROUP
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM open_group .

  CALL FUNCTION 'BDC_OPEN_GROUP'
    EXPORTING
      client = sy-mandt
      group  = 'GROUP_NAME'
      user   = sy-uname
      keep   = 'X'.

ENDFORM.                    " OPEN_GROUP

*&---------------------------------------------------------------------*
*&      Form  CLOSE_GROUP
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM close_group .
  CALL FUNCTION 'BDC_CLOSE_GROUP'.
*  CALL TRANSACTION 'SM35'.
ENDFORM.                    " CLOSE_GROUP

*&---------------------------------------------------------------------*
*&      Form  bdcdata
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM bdcdata .

data : v_count1 type i value 0.
DATA: v_field1 TYPE string,
      v_field2 TYPE string,
      v_field3 TYPE string,
      v_field4 TYPE string,
      v_field5 TYPE string.

data : v_temp(2) type c.
data : v_temp1 type c.
data : flag type i value 0.
v_count1 = 0.

loop at itab1.
 perform bdc_dynpro      using 'SAPLCSDI' '0100'.
  perform bdc_field       using 'BDC_CURSOR'
                                'RC29N-DATUV'.
  perform bdc_field       using 'BDC_OKCODE'
                                '/00'.
  perform bdc_field       using 'RC29N-MATNR'
*                                '2790701122'.
                                itab1-matnr.
  perform bdc_field       using 'RC29N-WERKS'
*                                'ibmc'.
                                itab1-werks.
  perform bdc_field       using 'RC29N-STLAN'
                                '1'.
  perform bdc_field       using 'RC29N-DATUV'
                                itab1-datuv .



  perform bdc_dynpro      using 'SAPLCSDI' '0110'.
  perform bdc_field       using 'BDC_CURSOR'
                                'RC29K-ZTEXT'.
  perform bdc_field       using 'BDC_OKCODE'
                                '/00'.
  perform bdc_field       using 'RC29K-ZTEXT'
*                                'Test BOM'.
                                  itab1-ztext.
  perform bdc_field       using 'RC29K-BMENG'
*                                '1'.
                              itab1-bmeng.
  perform bdc_field       using 'RC29K-STLST'
*                                '1'.
                                 itab1-stlst.

  perform bdc_dynpro      using 'SAPLCSDI' '0111'.
  perform bdc_field       using 'BDC_CURSOR'
                                'RC29K-LABOR'.
  perform bdc_field       using 'BDC_OKCODE'
                                '/00'.
clear v_count1.
v_count1 = 0.
loop at itab2 where  MATNR = itab1-MATNR AND
                     werks = itab1-werks AND
                     stlan = itab1-stlan AND
                     Datuv = itab1-datuv .
*                     menge = itab1-menge and
*                      meins = itab1-meins .
if flag = 1.
v_count1 = v_count1 + 2.
else.
v_count1 = v_count1 + 1.
endif.

flag = 0.

move v_count1 to v_temp.
CONCATENATE 'RC29P-AUSKZ(' v_temp ')' INTO v_field1.
CONCATENATE 'RC29P-idnrk(' v_temp ')' INTO v_field2.
CONCATENATE 'RC29P-menge(' v_temp ')' INTO v_field3.
*CONCATENATE 'RC29P-meins(' v_temp ')' INTO v_field4.               "asim





  perform bdc_dynpro      using 'SAPLCSDI' '0140'.
  perform bdc_field       using 'BDC_CURSOR'
                                'RC29P-AUSKZ(01)'.
  perform bdc_field       using 'BDC_OKCODE'
                                '/00'.
*  perform bdc_field       using 'BDC_OKCODE'
*                                '=WIZU'.
  perform bdc_field       using v_field1
                                'X'.
  perform bdc_field       using v_field2
*                                '2780603001'.
                                  itab2-idnrk .
  perform bdc_field       using v_field3
*                                '4'.
                                 itab2-menge.
*  Perform bdc_field       using v_field4                           "asim "changed now
**                                '4'.
*                                 itab2-meins .


  perform bdc_dynpro      using 'SAPLCSDI' '0130'.
  perform bdc_field       using 'BDC_OKCODE'
                                '/00'.
  perform bdc_field       using 'BDC_CURSOR'
                                'RC29P-POSNR'.
*  perform bdc_field       using 'RC29P-POSNR'
*                                '0010'.
  perform bdc_field       using 'RC29P-IDNRK'
*                                '2780603001'.
                                  itab2-idnrk .
  perform bdc_field       using 'RC29P-MENGE'
**                                '4'.
                                  itab2-menge .
*  perform bdc_field       using 'RC29P-MEINS'               "asim   "changed
**                                'NO'.
*                              itab2-meins .

  perform bdc_dynpro      using 'SAPLCSDI' '0131'.
  perform bdc_field       using 'BDC_OKCODE'
                                '/00'.
  perform bdc_field       using 'BDC_CURSOR'
                                'RC29P-POTX1'.
  perform bdc_field       using 'RC29P-SANKA'
                                    'X'.

 if v_count1 > 13 .           "8
v_page = v_count1 mod 14.           "9
if v_page = 0.
perform bdc_dynpro      using 'SAPLCSDI' '0140'.          " asim 24.12.2008
perform bdc_field       using 'BDC_CURSOR'
                              'RC29P-POSNR(01)'.
perform bdc_field       using 'BDC_OKCODE'
                              '=FCNP'.
*perform bdc_dynpro      using 'SAPLCSDI' '0140'.             " change now
*perform bdc_field       using 'BDC_CURSOR'
*                              'RC29P-MENGE(02)'.
*perform bdc_field       using 'BDC_OKCODE'
*                              '/00'.
flag = 1.
v_count1 = 0.
endif.

endif.
endloop.

perform bdc_dynpro      using 'SAPLCSDI' '0140'.
perform bdc_field       using 'BDC_CURSOR'
                              'RC29P-POSNR(01)'.
perform bdc_field       using 'BDC_OKCODE'
                              '=FCBU'.
call TRANSACTION 'CS01' USING BDCDATA.
CLEAR BDCDATA.
REFRESH BDCDATA.
endloop.

ENDFORM.                    " bdcdata

*&---------------------------------------------------------------------*
*&      Form  MANIPULATE_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM MANIPULATE_DATA .
LOOP AT itab.
    MOVE-CORRESPONDING itab TO itab1.
    APPEND itab1.
    MOVE-CORRESPONDING itab TO itab2.
    APPEND itab2.
    MOVE-CORRESPONDING itab TO itab3.
    APPEND itab3.
    CLEAR: itab1, itab , itab2 .

  ENDLOOP.
  DELETE ADJACENT DUPLICATES FROM itab1 COMPARING matnr werks stlan datuv.
    delete ADJACENT DUPLICATES FROM itab2 COMPARING matnr werks stlan datuv idnrk menge.  "meins." asim


ENDFORM.                    " MANIPULATE_DATA

0 Kudos

Hi monika,

thanks for the code as i am in very great need as i am working in pp for the first time

but there is a question why the three internal tables have been declared itab ,

itab 2,itab 3

and they are having nearly same fields in the structure declared.

pls help

0 Kudos

Hi Monika,

I tried to Download BOM data from 4.7 and upload it into ECC 6.0. Can you give me a good idea which is the best method for this . I tried to upload using bapi BAPI_BOM_UPLOAD_SAVE. Still i have no idea how to download the total data . Here we have 12 levels and dependecy is also there. I am asking you by seeing the thread posted by you . Can you share your ideas on this.

Regards,

Madhu.

Former Member
0 Kudos

Answered...