SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

BAPI_ROUTING_CREATE



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Interfaces | Интерфейсы -> BAPI
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1639

PostPosted: Sat Apr 12, 2008 10:18 am    Post subject: BAPI_ROUTING_CREATE Reply with quote

BAPI_ROUTING_CREATE - Creation of a routing

Code:
REPORT  zpppr_routing_input MESSAGE-ID zmc95
       NO STANDARD PAGE HEADING  "??????????????
       LINE-SIZE 500.            "????????????.
*---->define table->bapi
DATA:   group               TYPE bapi1012_tsk_c-task_list_group,
        group_counter       TYPE bapi1012_tsk_c-group_counter,
        sequence_no         TYPE bapi1012_opr_c-sequence_no,
        task_list_usage     TYPE bapi1012_tsk_c-task_list_usage,
        task_list_status    TYPE bapi1012_tsk_c-task_list_status,
        lot_size_from       TYPE bapi1012_tsk_c-lot_size_from,
        lot_size_to         TYPE bapi1012_tsk_c-lot_size_to,
        task_measure_unit   TYPE bapi1012_tsk_c-task_measure_unit,
        application         TYPE bapi1012_control_data-application,
        testrun             TYPE bapiflag,
        profile             TYPE bapi1012_control_data-profile,
        bomusage            TYPE bapi1012_control_data-bom_usage,
        task                TYPE bapi1012_tsk_c OCCURS 0 WITH HEADER LINE,
        materialtaskallocation TYPE bapi1012_mtk_c OCCURS 0 WITH HEADER LINE,
        sequence            TYPE bapi1012_seq_c   OCCURS 0 WITH HEADER LINE,
        operation           TYPE bapi1012_opr_c   OCCURS 0 WITH HEADER LINE,
        suboperation        TYPE bapi1012_sub_opr_c OCCURS 0 WITH HEADER LINE,
        referenceoperation  TYPE bapi1012_ref_opr_c OCCURS 0 WITH HEADER LINE,
        workcenterreference TYPE bapi1012_wc_ref_opr_c OCCURS 0 WITH HEADER LINE,
        componentallocation TYPE bapi1012_com_c  OCCURS 0 WITH HEADER LINE,
        productionresource  TYPE bapi1012_prt_c  OCCURS 0 WITH HEADER LINE,
        inspcharacteristic  TYPE bapi1012_cha_c  OCCURS 0 WITH HEADER LINE,
        textallocation      TYPE bapi1012_txt_hdr_c OCCURS 0 WITH HEADER LINE,
        text                TYPE bapi1012_txt_c     OCCURS 0 WITH HEADER LINE,
        return              TYPE bapiret2   OCCURS 0 WITH HEADER LINE,
        bapi_retn_info      LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
*---->message table
DATA: BEGIN OF t_error OCCURS 0.
DATA  material LIKE bapi1012_mtk_c-material.
        INCLUDE STRUCTURE bapiret2.
DATA: END OF t_error.
*---->inner table
DATA: BEGIN OF itab1 OCCURS 0 ,
       material      LIKE bapi1012_mtk_c-material,
       plant         LIKE bapi1012_mtk_c-plant,
       description1  LIKE bapi1012_tsk_c-description,
       activity      LIKE bapi1012_opr_c-activity,
       work_cntr     LIKE bapi1012_opr_c-work_cntr,
       control_key   LIKE bapi1012_opr_c-control_key,
       description   LIKE bapi1012_opr_c-description,
       base_quantity LIKE bapi1012_opr_c-base_quantity,
       std_value_01  LIKE bapi1012_opr_c-std_value_01,
       std_value_02  LIKE bapi1012_opr_c-std_value_02,
*       max_no_of_splits     LIKE bapi1012_opr_c-max_no_of_splits,
       fjs(2) TYPE c,
       ind_splitting_reqrd  LIKE bapi1012_opr_c-ind_splitting_reqrd,
       required_overlapping LIKE bapi1012_opr_c-required_overlapping,
       min_send_ahead_qty   LIKE bapi1012_opr_c-min_send_ahead_qty,
       ext_proc_with_subcontract_ind LIKE bapi1012_opr_c-ext_proc_with_subcontract_ind,
       info_rec   LIKE bapi1012_opr_c-info_rec,
       purch_org  LIKE bapi1012_opr_c-purch_org,
       cost_elem  LIKE bapi1012_opr_c-cost_elem,
       cost_relevant LIKE bapi1012_opr_c-cost_relevant,
      END OF itab1.

DATA: BEGIN OF itab OCCURS 0 ,
       material      LIKE bapi1012_mtk_c-material,
       plant         LIKE bapi1012_mtk_c-plant,
       description1  LIKE bapi1012_tsk_c-description,
       activity      LIKE bapi1012_opr_c-activity,
       work_cntr     LIKE bapi1012_opr_c-work_cntr,
       control_key   LIKE bapi1012_opr_c-control_key,
       description   LIKE bapi1012_opr_c-description,
       base_quantity LIKE bapi1012_opr_c-base_quantity,
       std_value_01  LIKE bapi1012_opr_c-std_value_01,
       std_value_02  LIKE bapi1012_opr_c-std_value_02,
       max_no_of_splits     LIKE bapi1012_opr_c-max_no_of_splits,
       ind_splitting_reqrd  LIKE bapi1012_opr_c-ind_splitting_reqrd,
       required_overlapping LIKE bapi1012_opr_c-required_overlapping,
       min_send_ahead_qty   LIKE bapi1012_opr_c-min_send_ahead_qty,
       ext_proc_with_subcontract_ind LIKE bapi1012_opr_c-ext_proc_with_subcontract_ind,
       info_rec   LIKE bapi1012_opr_c-info_rec,
       purch_org  LIKE bapi1012_opr_c-purch_org,
       cost_elem  LIKE bapi1012_opr_c-cost_elem,
      END OF itab.
DATA : gt_itab LIKE itab OCCURS 0 WITH HEADER LINE.
DATA : lv_cancel(1) TYPE c.
*---->upload
CALL FUNCTION 'UPLOAD'
  EXPORTING
    filename                = 'C:\Documents and Settings\Administrator\Desktop\????.txt'
    filetype                = 'DAT'
  IMPORTING
    cancel                  = lv_cancel
  TABLES
    data_tab                = itab1
  EXCEPTIONS
    conversion_error        = 1
    invalid_table_width     = 2
    invalid_type            = 3
    no_batch                = 4
    unknown_error           = 5
    gui_refuse_filetransfer = 6
    OTHERS                  = 7.
IF lv_cancel EQ 'X'.
  LEAVE PROGRAM.
ENDIF.

IF sy-subrc <> 0 .
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
          WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSEIF sy-subrc = 0.
  SORT itab1 BY  material plant activity.
  LOOP AT itab1.
    MOVE-CORRESPONDING itab1 TO itab.
    CONDENSE itab1-fjs NO-GAPS.
    itab-max_no_of_splits = itab1-fjs.
    APPEND itab.
  ENDLOOP.
  SORT itab BY material plant.
  LOOP AT itab.

    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
        input  = itab-material
      IMPORTING
        output = itab-material.
    MOVE itab TO gt_itab.
    APPEND gt_itab.
*-----?item-sequence
*operation-group_counter = '1'.
    operation-activity = itab-activity.
    operation-control_key = itab-control_key.
    operation-work_cntr = itab-work_cntr.
    operation-description = itab-description.

    operation-plant = itab-plant.
*  operation-operation_measure_unit = 'EA'.
    operation-denominator = 1.
    operation-nominator = 1.
    operation-base_quantity = itab-base_quantity.
    operation-std_value_01 = itab-std_value_01.
    operation-std_value_02 = itab-std_value_02.
    operation-ind_splitting_reqrd = itab-ind_splitting_reqrd." 'X'."??
    operation-max_no_of_splits = itab-max_no_of_splits.     "'1'."???
    operation-required_overlapping  = itab-required_overlapping."'X'."????
    operation-min_send_ahead_qty = itab-min_send_ahead_qty."'10'."??????
    operation-ext_proc_with_subcontract_ind = itab-ext_proc_with_subcontract_ind."'X'.
    operation-info_rec = itab-info_rec.
    operation-purch_org = itab-purch_org.
    operation-cost_elem = itab-cost_elem.
    operation-cost_relevant = 'X'."??????
    APPEND operation.

    AT END OF material.
*-----?header
      task-task_list_usage = '1'.
      task-task_list_status = '4'.
**---->unit
      SELECT SINGLE meins INTO task-task_measure_unit
             FROM mara
             WHERE matnr = gt_itab-material.
*      task-task_measure_unit = 'EA'.
      task-description = gt_itab-description1."'TEST ROUTING'.
      task-plant = gt_itab-plant.
      task-valid_from = sy-datum.
      task-valid_to_date = '99991231'.
      APPEND task.

      materialtaskallocation-material = gt_itab-material.
      materialtaskallocation-plant = gt_itab-plant.
      task-valid_from = sy-datum.
      task-valid_to_date = '99991231'.
      APPEND materialtaskallocation.

      CALL FUNCTION 'BAPI_ROUTING_CREATE'
        EXPORTING
          testrun                = testrun
          profile                = profile
          bomusage               = bomusage
          application            = application
        IMPORTING
          group                  = group
          groupcounter           = group_counter
        TABLES
          task                   = task
          materialtaskallocation = materialtaskallocation
          sequence               = sequence
          operation              = operation
          suboperation           = suboperation
          referenceoperation     = referenceoperation
          workcenterreference    = workcenterreference
          componentallocation    = componentallocation
          productionresource     = productionresource
          inspcharacteristic     = inspcharacteristic
          textallocation         = textallocation
          text                   = text
          return                 = return.

      REFRESH task.
      REFRESH gt_itab.
      REFRESH materialtaskallocation.
      REFRESH operation.
      LOOP AT return.
        IF return-type EQ 'E' OR return-type EQ 'A'.
          t_error-material = materialtaskallocation-material.
          t_error-message = return-message.
          APPEND t_error.
        ELSE.
          COMMIT WORK.
        ENDIF.
      ENDLOOP.
      LOOP AT t_error.
        WRITE:/ t_error-material,t_error-message.
      ENDLOOP.
    ENDAT.
  ENDLOOP.

ENDIF.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Interfaces | Интерфейсы -> BAPI All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.