funcation location分配classification

 data: lt_list like table of bapi1003_alloc_list,
        lt_num  like table of bapi1003_alloc_values_num,
        lt_curr like table of bapi1003_alloc_values_curr,
        lt_char like table of bapi1003_alloc_values_char.

  clear: lt_num,
         lt_curr,
         lt_char,
         lt_list.

  clear: gv_class,gv_object,gt_return,gt_char.

  if  gs_tab-n_feg_online is initial
  and gs_tab-n_feg_outage is initial
  and gs_tab-n_i0_status  is initial
  and gs_tab-n_quality    is initial.

  else.
* 将function  location的外部编码转换为内部编码
    call function 'CONVERSION_EXIT_TPLNR_INPUT'
      exporting
        input     = gs_tab-tplnr
      importing
        output    = gv_object
      exceptions
        not_found = 1
        others    = 2.

* 获取class
    gv_class = 'N_GENERAL'.  
  gv_ctype = '003'.

    call function 'BAPI_OBJCL_GETCLASSES'
      exporting
        objectkey_imp   = gv_object
        objecttable_imp = 'IFLOT'
        classtype_imp   = gv_ctype
        read_valuations = 'X'
        keydate         = sy-datum
        language        = sy-langu
      tables
        alloclist       = lt_list
        allocvalueschar = lt_char
        allocvaluescurr = lt_curr
        allocvaluesnum  = lt_num
        return          = gt_return.

    if not lt_char is initial.
      append lines of lt_char to gt_char.
    endif.

    if not lt_curr is initial.
      append lines of lt_curr to gt_curr.
    endif.

    if not lt_num is initial.
      append lines of lt_num to gt_num.
    endif.

* 获取特征值的value
    mcr_character_value:
           'N_FEG_ONLINE'        gs_tab-n_feg_online,   
           'N_FEG_OUTAGE'        gs_tab-n_feg_outage,   " 
           'N_I0_STATUS'         gs_tab-n_i0_status ,   " 
           'N_QUALITY_AND_SAFETY_CLASS'    gs_tab-n_quality.      "
    clear gt_return.
*******************************************************
    call function 'BAPI_OBJCL_CHANGE'
      exporting
        objectkey          = gv_object
        objecttable        = 'IFLOT'
        classnum           = gv_class
        classtype          = gv_ctype
        status             = '1'
        keydate            = sy-datum
      tables
        allocvaluesnumnew  = gt_num
        allocvaluescharnew = gt_char
        allocvaluescurrnew = gt_curr
        return             = gt_return.
*/--End of Change  On 2011-02-11-----*

    clear: gs_return,gs_error.
* 记录创建失败的错误信息
    read table gt_return into gs_return with key type = 'E'.

    if sy-subrc = 0.
      move-corresponding gs_tab to gs_error.
      loop at gt_return into gs_return where type = 'E'.
        concatenate gs_error-message gs_return-message into gs_error-message
                   separated by space.
      endloop.
      gs_error-lines  = gv_lines.
      append gs_error to gt_error.


      call function 'BAPI_TRANSACTION_ROLLBACK'.

    else.
      call function 'BAPI_TRANSACTION_COMMIT'
        exporting
          wait = 'X'.
    endif.
  endif.

猜你喜欢

转载自mahone.iteye.com/blog/1234851