Application Development and Automation 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: 
Read only

USE BAPI BAPI_ROUTING_CREATE

Former Member
0 Likes
5,883

HI ,

THIS IS FIRST TIME I AM USING BAPI FOR CREATING ROUTING .

I NEED HELP REGARDING DATA DECLERATION THAT I NEED TO TRANSFER TO THE FUNCTION MODULE,

A HELP IS NEEDED SO THAT I CAN START.PLEASE TELL ME HOW TO PROCEDE TO UPLOAD DATA USING BAPI.

PLEASE HELP ME.

3 REPLIES 3
Read only

Former Member
0 Likes
2,113

Hi James,

This method serves to create routings with all their subordinated objects.

Here, you can generate a key date view as well as the complete history of a routing. The latter is particularly useful for data transfers from non-SAP systems.

Example

You want to create a routing with its sequences, operations and inspection characteristics on the key date 01.01.2000.

You generate an entry for each object in the following table by always entering the date 01.01.2000 in the attribute VALID_FROM:

TASK

Enter the relevant task list header data here. The attributes TASK_LIST_GROUP and GROUP_COUNTER only have to be supplied if you work with external number assignment. For internal number assignment the task list group and the group counter are determined automatically.

SEQUENCE

Here, only entries for alternative or parallel sequences are allowed. The standard sequence of a routing is always generated automatically and therefore does not have to be entered. Here also, the attributes TASK_LIST_GROUP and GROUP_COUNTER need only be supplied in the case of external number assignment.

OPERATION

You generate an entry for each operation in this table. To identify the operations, you have to enter an external operation identifier in the field OPERATION_ID. This identifier has to contain at least one character that is not a number (such as VORG0010). This external identifier is used by the definition of the alternative or parallel sequences to identify the corresponding branch or return operation. You only have to supply the TASK_LIST_GROUP and GROUP_COUNTER in the case of external number assignment.

INSPCHARACTERISTIC

You generate an entry for each inspection characteristic in this table. To identify the inspection characteristics you have to enter an inspection characteristic number in the field INSPCHAR. You can create inspection characteristics with or without reference to a master inspection characteristic. In the field CHA_MASTER_IMPORT_MODUS (Modus for the reference to the master inspection characteristic) enter the reference to the master inspection characteristic: 'L' for reference. In this case, the master inspection characteristic has to be completely maintained. In the parameter INSPCHARACTERISTIC you only have to supply those fields that could not be copied from the master inspection characteristic; 'C' for copy the data from the master inspection characteristic into the inspection characteristic, 'N' for create a lockable and unlockable reference to the master inspection characteristic without a data transfer from the master inspection characteristic. In this case manually fill out all fields in the parameter INSPCHARACTERISTIC.

You can either transfer the inspection characteristic control indicator directly from the master inspection characteristic, enter it individually or in the field PRESET_CTRL_INDS_KEY you enter a key for the control indicator if you have stored this key in Customizing.

If you have individually entered a control indicator, note the following special features:

SCOPE_IND: Inspection scope. This indicator can have different

characteristics:

You set " " for: Free inspection scope

You set "<" for: Smaller inspection scope permitted

You set ">" for: Larger inspection scope permitted

You set "=" for: Defined inspection scope

RESULT_RECORDING_TYPE: Record entry type. This indicator can have different characteristics:

You set "-" for: No record entry

You set "*" for: Classified record entry

You set "+" for: Single record entry

You set " " for: Summarized record entry

DOCU_REQU: Documentation required for check results. This indicator can

have different characteristics:

You set " " for: No documention required

You set "." for: Documentation for rejection

You set "+" for: Document all check results

You set "+" for: Document all check results.

CONFIRMATION_CATEGORY Characteristic category

You set " " for: Optional characteristic

You set "+" for: Limited to the acceptance of the previous mandatory characteristic

You set "-" for: Limited to the rejection of the previous mandatory characteristic

You set "X" for: Mandatory characteristic

PRINT_IND: Print control

This indicator can have different characteristics:

You set " " for: Print

You set "x" for: Do not print

You set "*" for: Do not print at skip

If you want to assign an inspection equipment to the inspection characteristic in the field ITEM_NO_OF_PRODUCTION_RESOURCE, note that this has to be assigned to the operation in the PARAMETER PRODUCTIONRESOURCE.

Notes

Provided that during the data transfer no errors can be found, the export parameters GROUP and GROUPCOUNTER contain the key for the generated task list. To secure the data in the database, you now have to carry out a COMMIT WORK.

All error that occur are logged in the external parameter RETURN. In the case of inconsistencies, the entire routing to be generated is rejected.

Hope it helps...

Lokesh

pls. reward appropriate points

Read only

Former Member
0 Likes
2,113
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,

        TESTRUN             TYPE BAPIFLAG,
        PROFILE             TYPE BAPI1012_CONTROL_DATA-PROFILE,

        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.
* Initialization
  GROUP_COUNTER     = '01'.
  TASK_LIST_USAGE   = '1'.
  TASK_LIST_STATUS  = '4'.
  LOT_SIZE_FROM     = '0'.
  LOT_SIZE_TO       = '999999999'.
  TASK_MEASURE_UNIT = 'ST'.


  TASK-GROUP_COUNTER       =  GROUP_COUNTER.
  TASK-VALID_FROM          =  VALID_FROM.
  TASK-TASK_LIST_USAGE     =  BOMUSAGE.
  TASK-PLANT               =  PLANT.
  TASK-TASK_LIST_STATUS    =  TASK_LIST_STATUS.
  TASK-DESCRIPTION         =  MATERIAL.
  TASK-LOT_SIZE_FROM       =  LOT_SIZE_FROM.
  TASK-LOT_SIZE_TO         =  LOT_SIZE_TO.
  TASK-TASK_MEASURE_UNIT   =  TASK_MEASURE_UNIT.
  APPEND TASK.

  MATERIALTASKALLOCATION-MATERIAL      = MATERIAL.
  MATERIALTASKALLOCATION-PLANT         = PLANT.
  MATERIALTASKALLOCATION-GROUP_COUNTER = GROUP_COUNTER.
  MATERIALTASKALLOCATION-VALID_FROM    = VALID_FROM.
  APPEND MATERIALTASKALLOCATION.

*  SEQUENCE-GROUP_COUNTER       = '01'.
*  SEQUENCE-SEQUENCE_NO         = '000000'.
*  SEQUENCE-VALID_FROM          = '20040816'.
*  SEQUENCE-SEQUENCE_CATEGORY   = '0'.
*  SEQUENCE-REFERENCE_SEQUENCE  = ''.
*  SEQUENCE-DESCRIPTION         = '4587201_JK'.
*  SEQUENCE-TASK_MEASURE_UNIT   = 'PC'.
*  APPEND SEQUENCE.
  REFRESH : IT_REF.
*  LOOP AT rout_list WHERE component = material. 
  LOOP AT ROUT_LIST.

    IF ROUT_LIST-REFSET = 'X' AND
       NOT ROUT_LIST-VPLNR IS INITIAL.
      REFERENCEOPERATION-GROUP_COUNTER              = GROUP_COUNTER.
      REFERENCEOPERATION-SEQUENCE_NO                = SEQUENCE_NO.
      REFERENCEOPERATION-VALID_FROM                 = VALID_FROM.
      REFERENCEOPERATION-ACTIVITY                   = ROUT_LIST-VORNR.
      REFERENCEOPERATION-REFERENCED_TASK_LIST_GROUP = ROUT_LIST-VPLNR.
      REFERENCEOPERATION-REFERENCED_GROUP_COUNTER   = GROUP_COUNTER.
      APPEND REFERENCEOPERATION.

      IT_REF-VPLNR = ROUT_LIST-VPLNR.
      IT_REF-VORNR = ROUT_LIST-VORNR.
      APPEND IT_REF.
      CLEAR IT_REF.

    ELSE.
      OPERATION-GROUP_COUNTER      = GROUP_COUNTER.
      OPERATION-SEQUENCE_NO        = SEQUENCE_NO.
      OPERATION-VALID_FROM         = VALID_FROM.
      OPERATION-ACTIVITY           = ROUT_LIST-VORNR.
      OPERATION-CONTROL_KEY        = ROUT_LIST-STEUS.
      OPERATION-WORK_CNTR          = ROUT_LIST-ARBPL.
      OPERATION-PLANT              = PLANT.
      OPERATION-DESCRIPTION        = ROUT_LIST-LTXA1.
      OPERATION-DENOMINATOR        = ROUT_LIST-UMREN.
* Start of changes STC001
      IF ROUT_LIST-UMREZ IS INITIAL.
        OPERATION-NOMINATOR          = '1'.
      ELSE.
        OPERATION-NOMINATOR          = ROUT_LIST-UMREZ.
      ENDIF.
* End of changes STC001
      OPERATION-BASE_QUANTITY      = ROUT_LIST-BMSCH.

      OPERATION-STD_VALUE_01       = ROUT_LIST-VGW01.
      OPERATION-STD_VALUE_02       = ROUT_LIST-VGW02.
      OPERATION-STD_VALUE_03       = ROUT_LIST-VGW03.
      OPERATION-STD_VALUE_04       = ROUT_LIST-VGW04.
      OPERATION-STD_VALUE_05       = ROUT_LIST-VGW05.
      OPERATION-STD_VALUE_06       = ROUT_LIST-VGW06.
      APPEND OPERATION.
    ENDIF.
  ENDLOOP.

  SORT IT_REF BY VPLNR VORNR.
  DELETE ADJACENT DUPLICATES FROM IT_REF COMPARING VPLNR.

  LOOP AT REFERENCEOPERATION.
    L_TABIX  = SY-TABIX.
    READ TABLE IT_REF
    WITH KEY VPLNR = REFERENCEOPERATION-REFERENCED_TASK_LIST_GROUP
             VORNR = REFERENCEOPERATION-ACTIVITY.

    IF SY-SUBRC <> 0.
      DELETE REFERENCEOPERATION INDEX L_TABIX.
    ENDIF.
  ENDLOOP.

  CALL FUNCTION 'BAPI_ROUTING_CREATE'
*    DESTINATION 'NONE'
    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.

Regards

vijay

Read only

Former Member
0 Likes
2,113

HI

vijay here

******DECLARATION*******

DATA : path TYPE string.

DATA : flag type c.

data: count(2) TYPE n.

DATA : intern TYPE TABLE OF alsmex_tabline,

wa_intern TYPE alsmex_tabline.

DATA :

testrun TYPE bapiflag,

profile TYPE PROFID_STD, "bapi1012_control_data-profile,

bomusage TYPE STLAN , "bapi1012_control_data-bom_usage,

application TYPE CAPID. " bapi1012_control_data-application.

  • internal tables declaration.

DATA :

it_task TYPE TABLE OF bapi1012_tsk_c,

it_materialtaskallocation TYPE TABLE OF bapi1012_mtk_c,

it_operation TYPE TABLE OF bapi1012_opr_c,

it_COMPONENTALLOCATION TYPE TABLE OF BAPI1012_COM_C,

*text TYPE TABLE OF bapi1012_txt_c,

return TYPE TABLE OF bapiret2,

it_return TYPE TABLE OF bapiret2.

  • Work area declaration.

DATA :

wa_items_task TYPE bapi1012_tsk_c ,

wa_item_materailtask TYPE bapi1012_mtk_c,

wa_item_operation TYPE bapi1012_opr_c,

wa_item_componentallocation TYPE BAPI1012_COM_C,

  • wa_item_text TYPE bapi1012_txt_c,

wa_return TYPE return.

DATA : v_group TYPE bapi1012_tsk_c-task_list_group,

v_groupcounter TYPE bapi1012_tsk_c-group_counter.

DATA : filename TYPE string.

*************INTERNAL TABLE DECLARATION***************

TYPES: BEGIN OF routing,

valid_from1 TYPE datuv, "TASK(HEADER)

valid_todate1 TYPE datub,

usage TYPE pln_verwe ,

werkstask(6),

status TYPE plnst,

task_measure_unit(3) TYPE c,

lot_size_from(010),

lot_size_to(020),

matnr(010), " MATERIAL ALLOCATION(INITIAL SCREEN)

werks2(006),

valid_from2 TYPE datuv,

valid_todate2 TYPE datub,

valid_from3 TYPE datuv,

valid_todate3 TYPE datub,

optno TYPE VORNR,

controlkey(004),

work_cntr(006),

werks3(006),

  • description(20),

denominator,

quant(20),

setup TYPE vgwrt,

machine TYPE vgwrt,

labor TYPE vgwrt,

reqsplit TYPE splittung,

noofsplits TYPE dec03,

unitmax TYPE vgwrteh,

maxwaittime TYPE dzlmax,

unitstd TYPE vgwrteh,

stdqtime TYPE dzwnor,

unitmin TYPE vgwrteh,

minqtime TYPE dzwmin,

unitstdmove TYPE vgwrteh,

stdmovetime TYPE dztnor,

unitminmove TYPE vgwrteh,

minmovetime TYPE dztmin,

palnnedel TYPE dec03, " IF CONTROL KEY PP02

netprice(20) TYPE c,

priceunit TYPE pack3,

COSTELEMENT TYPE KSTAR,

currency TYPE waers,

purchorg(4) TYPE c,

purchgrp(3) TYPE c,

matgrp(9) TYPE c ,

subcontracting(1) TYPE c,

valid_from4 TYPE datuv, " COMPONENT ALLOCATION

valid_todate4 TYPE datub,

optno1(5),

itemno(5),

TEXT TYPE TDLINE,

END OF routing.

DATA: it_record TYPE STANDARD TABLE OF record1.

DATA: record TYPE record1.

PARAMETERS : fname TYPE rlgrap-filename.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR fname .

CALL FUNCTION 'KD_GET_FILENAME_ON_F4'

EXPORTING

program_name = syst-repid

dynpro_number = syst-dynnr

CHANGING

file_name = fname

EXCEPTIONS

mask_too_long = 1

OTHERS = 2.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

                      • START OF SLECTION*************

START-OF-SELECTION.

filename = fname.

                        • UPLOADING DATA***************

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = filename

filetype = 'ASC'

has_field_separator = 'X'

read_by_line = 'X'

TABLES

data_tab = it_record

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.

SORT it_record BY matnr.

LOOP AT it_record INTO record.

at new matnr.

flag = 'X'.

endat.

if flag = 'X'.

count = 1.

bomusage = '1'.

application = 'PP01'.

REFRESH: task , materialtaskallocation , operation , COMPONENTALLOCATION .

*********HEADER DATA**********************

wa_items_task-valid_from = record-valid_from1.

wa_items_task-valid_to_date = record-valid_todate1.

wa_items_task-task_list_usage = record-usage.

wa_items_task-plant = record-werkstask.

wa_items_task-task_list_status = record-status.

wa_items_task-task_measure_unit = record-task_measure_unit.

wa_items_task-lot_size_from = record-lot_size_from.

wa_items_task-lot_size_to = record-lot_size_to.

APPEND wa_items_task TO task.

*************INITIAL SCREEN DATA*************

wa_item_materailtask-material = record-matnr.

wa_item_materailtask-plant = record-werks2.

wa_item_materailtask-valid_from = record-valid_from2.

wa_item_materailtask-valid_to_date = record-valid_todate2.

APPEND wa_item_materailtask TO materialtaskallocation.

flag = ' '.

endif.

IF count = 20.

count = 1.

ENDIF.

**************OPERATION DATA*******************

wa_item_operation-valid_from = record-valid_from3.

wa_item_operation-valid_to_date = record-valid_todate3.

wa_item_operation-activity = record-optno.

wa_item_operation-control_key = record-controlkey.

wa_item_operation-work_cntr = record-work_cntr.

wa_item_operation-plant = record-werks3.

  • wa_item_operation-description = record-description.

wa_item_operation-denominator = record-denominator.

wa_item_operation-base_quantity = record-quant.

wa_item_operation-std_value_01 = record-setup.

wa_item_operation-std_value_02 = record-machine.

wa_item_operation-std_value_03 = record-labor.

wa_item_operation-ind_splitting_reqrd = record-reqsplit .

wa_item_operation-max_no_of_splits = record-noofsplits.

wa_item_operation-max_wait_time_unit = record-unitmax.

wa_item_operation-max_wait_time = record-maxwaittime.

wa_item_operation-standard_queue_time_unit = record-unitstd.

wa_item_operation-standard_queue_time = record-stdqtime.

wa_item_operation-min_queue_time_unit = record-unitmin.

wa_item_operation-min_queue_time = record-minqtime.

wa_item_operation-standard_move_time_unit = record-unitstdmove.

wa_item_operation-standard_move_time = record-stdmovetime.

wa_item_operation-min_move_time_unit = record-unitminmove.

wa_item_operation-min_move_time = record-minmovetime.

************SUBCONTRACTING DATA********************

wa_item_operation-plnd_delry = record-palnnedel.

wa_item_operation-info_rec_net_price = record-netprice.

wa_item_operation-price_unit = record-priceunit.

wa_item_operation-COST_ELEM = RECORD-COSTELEMENT.

wa_item_operation-currency = record-currency.

wa_item_operation-purch_org = record-purchorg.

wa_item_operation-purch_group = record-purchgrp.

wa_item_operation-matl_group = record-matgrp.

wa_item_operation-ext_proc_with_subcontract_ind = record-subcontracting.

APPEND wa_item_operation TO operation.

*****************COMPONENT ALLOCATION****************

wa_item_componentallocation-valid_from = record-valid_from4.

wa_item_componentallocation-valid_to_date = record-valid_todate4.

wa_item_componentallocation-activity = record-optno1.

wa_item_componentallocation-item_no = record-itemno.

APPEND wa_item_componentallocation TO componentallocation.

                              • TEXT************************************

  • wa_item_text-TEXT_LINE = RECORD-TEXT.

*

  • APPEND wa_item_text TO TEXT.

*

count = count + 1.

AT END OF MATNR.

****************CALLING FUNCTION MODULE**************

CALL FUNCTION 'BAPI_ROUTING_CREATE'

EXPORTING

bomusage = bomusage

application = application

IMPORTING

group = group

groupcounter = groupcounter

TABLES

task = task

materialtaskallocation = materialtaskallocation

  • SEQUENCE =

operation = operation

  • SUBOPERATION =

  • REFERENCEOPERATION =

  • WORKCENTERREFERENCE =

componentallocation = componentallocation

  • PRODUCTIONRESOURCE =

  • INSPCHARACTERISTIC =

  • TEXTALLOCATION =

  • text = text

return = return.

loop at return into wa_return.

write: / 'message type:' ,wa_return.

endloop.

  • COMMIT WORK.

WRITE:/ 'GROUP:', group.

WRITE:/ 'GROUPCOUNTER:', groupcounter.

ENDAT.

ENDLOOP.

this will help u

@vijji