Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 9159

Re: Bapi of ca02 to load excel file

$
0
0

Hi Aniruddha,

 

reading the code, it appears that the BAPI_ROUTING_CREATE is called at each loop pass, for every row in the excel file (that is, for each operation), this resulting in the creation of different routing groups.

I would suggest to have an external loop based on each material code, and an inner loop for every operation for a given material. Before ending the external loop, have the BAPI call for that given material.

 

The concerned part of code (the fill_bdcdata_table form) should be looking like the following:

 

FORM fill_bdcdata_table.

  it_tab1[] = it_tab[].

 

  DELETE ADJACENT DUPLICATES FROM it_tab COMPARING matnr.

 

  LOOP at it_tab INTO w_tab.

 

    LOOP AT it_tab1 INTO w_tab1 WHERE matnr = w_tab-matnr.

 

      wa_item_operation-control_key     = w_tab1-steus.

      wa_item_operation-work_cntr       = w_tab1-arbpl.

      wa_item_operation-denominator     = '1'.

 

      wa_item_operation-nominator      = '1'.

      wa_item_operation-activity       = w_tab1-vornr.

*     wa_item_operation-description    = record-description.

      wa_item_operation-base_quantity  = w_tab1-bmsch.

 

      wa_item_operation-std_value_01   = w_tab1-vgw01.

      wa_item_operation-std_value_02   = w_tab1-vgw02.

      wa_item_operation-std_value_03   = w_tab1-vgw03.

     

      APPEND wa_item_operation TO it_operation.

 

    ENDLOOP.

 

    CALL FUNCTION 'CONVERSION_EXIT_CUNIT_INPUT'

      EXPORTING

        input                = w_tab1-meinh

        language             = sy-langu

      IMPORTING

        output               = w_tab1-nos

*     EXCEPTIONS

*       UNIT_NOT_FOUND       = 1

*       OTHERS               = 2

           .

    IF sy-subrc = 0.

*     move uom_result to BAPI structure MARM.

    ENDIF.

 

*   group_counter = '1'.

    wa_items_task-task_list_usage       = '1'.

*   wa_items_task-description           = '1602T Forging Press'.

    wa_items_task-task_list_status      = '4'.

    wa_items_task-VALID_FROM            = sy-datum.

    wa_items_task-VALID_to_date         = '99991231'.

**  wa_items_task-task_list_group       = group.

    wa_items_task-group_counter         = group_counter.

*   wa_items_task-task_measure_unit     = '1'.

    wa_items_task-plant                 = w_tab1-werks.

*   wa_items_task-task_list_status      = record-status.

    wa_items_task-task_measure_unit     = w_tab1-nos.

    wa_items_task-lot_size_from         = '1'.

    wa_items_task-lot_size_to           = '99999999'.

 

    APPEND wa_items_task TO it_task.

 

*      w_SEQ-SEQUENCE_NO = '000000'.

*      w_seq-SEQUENCE_CATEGORY = '0'.

*      append w_SEQ to it_seq.

    bomusage           = '1'.

    application        = 'PP01'.

    wa_item_materailtask-material      = w_tab1-matnr.

    wa_item_materailtask-plant         = w_tab1-werks.

    APPEND wa_item_materailtask TO it_materialtaskallocation.

 

    CALL FUNCTION 'BAPI_ROUTING_CREATE'

      EXPORTING

        bomusage                  = bomusage

        application               = application

      IMPORTING

        group                     = v_group

        groupcounter              = v_group_counter

      TABLES

        task                      = it_task

        materialtaskallocation    = it_materialtaskallocation

*     SEQUENCE                    = it_seq

        operation                 = it_operation

*     SUBOPERATION                =

*     REFERENCEOPERATION          =

*     WORKCENTERREFERENCE         =

*     componentallocation         =  componentallocation

*     PRODUCTIONRESOURCE          =

*     INSPCHARACTERISTIC          =

*     TEXTALLOCATION              =

*     text                        = text

      return                      = return.

  

      IF sy-subrc = 0.

 

        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

          EXPORTING

            WAIT          = 'X'

*         IMPORTING

*           RETURN        =

               .

      ENDIF.

 

      CLEAR : v_group.

 

      REFRESH it_task.

      REFRESH it_materialtaskallocation.

      REFRESH it_operation.

 

  ENDLOOP.

ENDFORM.

 

 

 

The loop at it_tab is the external one for each material, the internal one at it_tab1 is dealing with operations for the related material. BAPI call is performed for each material, this assuring the creation of a single group, multiple operations, for every material.

 

I do hope this will fix the issue.

 

Thank you and bye,

 

Flavio


Viewing all articles
Browse latest Browse all 9159

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>