VinceCoder
2/26/2019 - 4:03 PM

Conferma OT

Conferma Posizioni Ordini di Trasferimento, gestione messaggi di errore in funzione delle eccezioni del FM

FORM confirm_single_position .
  DATA: lt_ltap_conf TYPE TABLE OF ltap_conf,
        ls_ltap_conf LIKE LINE OF lt_ltap_conf,
        lv_exception TYPE fupararef-parameter,
        lv_shorttext TYPE swotlq-shorttext,
        lv_verif     TYPE lgpla.

  ls_ltap_conf-tanum = gs_ltap-tanum.
  ls_ltap_conf-tapos = gs_ltap-tapos.
  ls_ltap_conf-squit = abap_false.
  ls_ltap_conf-altme = gs_ltap-meins.
  ls_ltap_conf-nista = gv_vsolm.
  ls_ltap_conf-ndifa = 0.
  IF ls_ltap_conf-nista NE gs_ltap-vsolm.
    ls_ltap_conf-ndifa =  gs_ltap-vsolm - ls_ltap_conf-nista.

  ENDIF.
  ls_ltap_conf-charg = gs_ltap-charg.

  IF gv_trart EQ 'E'.
    ls_ltap_conf-nlpla = gv_lgpla.
  ENDIF.

  APPEND ls_ltap_conf TO lt_ltap_conf.

  CALL FUNCTION 'L_TO_CONFIRM' DESTINATION 'NONE'
    EXPORTING
      i_lgnum                        = gs_ltap-lgnum
      i_tanum                        = gs_ltap-tanum
    TABLES
      t_ltap_conf                    = lt_ltap_conf
    EXCEPTIONS
      to_confirmed                   = 1
      to_doesnt_exist                = 2
      item_confirmed                 = 3
      item_subsystem                 = 4
      item_doesnt_exist              = 5
      item_without_zero_stock_check  = 6
      item_with_zero_stock_check     = 7
      one_item_with_zero_stock_check = 8
      item_su_bulk_storage           = 9
      item_no_su_bulk_storage        = 10
      one_item_su_bulk_storage       = 11
      foreign_lock                   = 12
      squit_or_quantities            = 13
      vquit_or_quantities            = 14
      bquit_or_quantities            = 15
      quantity_wrong                 = 16
      double_lines                   = 17
      kzdif_wrong                    = 18
      no_difference                  = 19
      no_negative_quantities         = 20
      wrong_zero_stock_check         = 21
      su_not_found                   = 22
      no_stock_on_su                 = 23
      su_wrong                       = 24
      too_many_su                    = 25
      nothing_to_do                  = 26
      no_unit_of_measure             = 27
      xfeld_wrong                    = 28
      update_without_commit          = 29
      no_authority                   = 30
      lqnum_missing                  = 31
      charg_missing                  = 32
      no_sobkz                       = 33
      no_charg                       = 34
      nlpla_wrong                    = 35
      two_step_confirmation_required = 36
      two_step_conf_not_allowed      = 37
      pick_confirmation_missing      = 38
      quknz_wrong                    = 39
      hu_data_wrong                  = 40
      no_hu_data_required            = 41
      hu_data_missing                = 42
      hu_not_found                   = 43
      picking_of_hu_not_possible     = 44
      not_enough_stock_in_hu         = 45
      serial_number_data_wrong       = 46
      serial_numbers_not_required    = 47
      no_differences_allowed         = 48
      serial_number_not_available    = 49
      serial_number_data_missing     = 50
      to_item_split_not_allowed      = 51
      input_wrong                    = 52
      OTHERS                         = 53.
  IF sy-subrc <> 0.
    CLEAR lv_exception.
    SELECT SINGLE parameter FROM fupararef INTO lv_exception
      WHERE funcname  EQ 'L_TO_CONFIRM'
        AND paramtype EQ abap_true
        AND pposition EQ sy-subrc.
    IF sy-subrc EQ 0.
      CALL FUNCTION 'SWO_TEXT_FUNCTION_EXCEPTION'
        EXPORTING
          function  = 'L_TO_CONFIRM'
          exception = lv_exception
        IMPORTING
          shorttext = lv_shorttext.

      PERFORM error_message USING
                                 'ZWM'
                                 '060'
                                 lv_shorttext
                                 space
                                 space
                                 space
                                 space
                            CHANGING lv_answer.

    ELSE.
      PERFORM error_message USING
                                 'ZWM'
                                 '058'
                                 space
                                 space
                                 space
                                 space
                                 space
                            CHANGING lv_answer.
    ENDIF.

  ELSE.
    PERFORM error_message USING
                               'ZWM'
                               '059'
                               space
                               space
                               space
                               space
                               space
                          CHANGING lv_answer.
    CLEAR: gs_ltap, gv_error, gv_udm, gv_barcode, gv_verif,
           gv_vlenr, gv_meins.
    PERFORM check_confirmed.
    LEAVE TO SCREEN 5001.
  ENDIF.

ENDFORM.