SAP PM BAPI CA01

From SapWiki
Revision as of 15:54, 5 April 2020 by WikiSysop (talk | contribs) (Created page with " <nowiki>*&---------------------------------------------------------------------* *& Report ZPP_CREAR_HR *& *&----------------------------------------------------------------...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
*&---------------------------------------------------------------------*
*& Report  ZPP_CREAR_HR
*&
*&---------------------------------------------------------------------*
*& Descripcion   : Creación de Hojas de Ruta (CA01)
*&---------------------------------------------------------------------*

REPORT  ZPP_CREAR_HR.
*--------------------------------------------------------------------*
type-POOLs : SLIS.

Data: Begin of gs_data,
      MATERIAL        like BAPI1012_MTK_C-MATERIAL,         "Material
      PLANT           like BAPI1012_MTK_C-PLANT,            "Centro
      TASK_LIST_GROUP like BAPI1012_TSK_C-TASK_LIST_GROUP,  "Grp. Hoja de Ruta
      GROUP_COUNTER   like BAPI1012_TSK_C-GROUP_COUNTER,    "Contador
      IDENT_KEY       like BAPI1012_TSK_C-IDENT_KEY,        "Pto. Inspección
      INSPPOINT_PARTIALLOT_ASSGNMT like BAPI1012_TSK_C-INSPPOINT_PARTIALLOT_ASSGNMT, "Datos Parciales
      DYN_MODIF_LEVEL like BAPI1012_TSK_C-DYN_MODIF_LEVEL,  "Nivel Dinamizacion
      ACTIVITY        like BAPI1012_OPR_C-ACTIVITY,         "Numero de Operacion
      WORK_CNTR       like BAPI1012_OPR_C-WORK_CNTR,        "Puesto de Trabajo
      CONTROL_KEY     like BAPI1012_OPR_C-CONTROL_KEY,      "Clave de Control
      DESCRIPTION     like BAPI1012_OPR_C-DESCRIPTION,      "Descrip. Operación
      INSP_POINT_COMPLT_FLOW_VARIANT like BAPI1012_OPR_C-INSP_POINT_COMPLT_FLOW_VARIANT, "Variante de Proceso
      TIME_GRID       like BAPI1012_OPR_C-TIME_GRID,        "Secuencial Hora
      TIME_FACTOR     like BAPI1012_OPR_C-TIME_FACTOR,      " Factor de Tiempo
      TIME_UNIT       like BAPI1012_OPR_C-TIME_UNIT,        "Unidad de Tiempo
      DENOMINATOR     like BAPI1012_OPR_C-DENOMINATOR,      "Denominador para conversión u.medida hoja ruta y operación
      NOMINATOR       like BAPI1012_OPR_C-NOMINATOR,        "Contador para conversión u.medida hoja de ruta y operación
      base_quantity   like BAPI1012_OPR_C-base_quantity,    "Cantidad base
      INSPCHAR        like BAPI1012_CHA_C-INSPCHAR,         "Numero de Caracteristica
      CHAR_DESCR      like BAPI1012_CHA_C-CHAR_DESCR,       "Texto breve para característica inspección
      MSTR_CHAR       like BAPI1012_CHA_C-MSTR_CHAR,        "Caracteristica
      SMPL_PROCEDURE  like BAPI1012_CHA_C-SMPL_PROCEDURE,   "Procedimiento
      SMPL_UNIT       like BAPI1012_CHA_C-SMPL_UNIT,        "Unidad de Medida
      SMPL_QUANT      like BAPI1012_CHA_C-SMPL_QUANT,       "Cantidad para muestra
      DYN_MODIF_RULE  like BAPI1012_CHA_C-DYN_MODIF_RULE,   "Regla Dinamizacion
      SPC_CRITERION_KEY like BAPI1012_CHA_C-SPC_CRITERION_KEY,"Criterio SPC
      UP_TOL_LMT      like BAPI1012_CHA_C-UP_TOL_LMT,        "Tolerancia Superior
      LW_TOL_LMT      like BAPI1012_CHA_C-LW_TOL_LMT,        "Tolerancia Inferior
      FORMULA_CHECK_BY_SAP like BAPI1012_CHA_C-FORMULA_CHECK_BY_SAP, "Verificar y calcular fórmula en QM
      FORMULA_FIELD_1 like BAPI1012_CHA_C-FORMULA_FIELD_1,
      FORMULA_FIELD_2 like BAPI1012_CHA_C-FORMULA_FIELD_2,
      TASK_MEASURE_UNIT like BAPI1012_TSK_C-TASK_MEASURE_UNIT,
      end of gs_data.
data gt_data like TABLE OF gs_data.

data: begin of gs_data_material,
  MATERIAL like BAPI1012_MTK_C-MATERIAL,            "Material
PLANT like BAPI1012_MTK_C-PLANT,                  "Centro
TASK_LIST_GROUP like BAPI1012_TSK_C-TASK_LIST_GROUP, "Grp. Hoja de Ruta
GROUP_COUNTER like BAPI1012_TSK_C-GROUP_COUNTER,  "Contador
IDENT_KEY like BAPI1012_TSK_C-IDENT_KEY,          "Pto. Inspección
INSPPOINT_PARTIALLOT_ASSGNMT like BAPI1012_TSK_C-INSPPOINT_PARTIALLOT_ASSGNMT, "Datos Parciales
DYN_MODIF_LEVEL like BAPI1012_TSK_C-DYN_MODIF_LEVEL, "Nivel Dinamizacion
  end of gs_data_material.

data: begin of gs_data_operacion,
MATERIAL like BAPI1012_MTK_C-MATERIAL,            "Material
PLANT like BAPI1012_MTK_C-PLANT,                  "Centro
TASK_LIST_GROUP like BAPI1012_TSK_C-TASK_LIST_GROUP, "Grp. Hoja de Ruta
GROUP_COUNTER like BAPI1012_TSK_C-GROUP_COUNTER,  "Contador
  ACTIVITY like BAPI1012_OPR_C-ACTIVITY,            "Numero de Operacion
WORK_CNTR like BAPI1012_OPR_C-WORK_CNTR,          "Puesto de Trabajo
CONTROL_KEY like BAPI1012_OPR_C-CONTROL_KEY,      "Clave de Control
DESCRIPTION like BAPI1012_OPR_C-DESCRIPTION,      "Descrip. Operación
INSP_POINT_COMPLT_FLOW_VARIANT like BAPI1012_OPR_C-INSP_POINT_COMPLT_FLOW_VARIANT, "Variante de Proceso
TIME_GRID like BAPI1012_OPR_C-TIME_GRID,          "Secuencial Hora
TIME_FACTOR like BAPI1012_OPR_C-TIME_FACTOR,      " Factor de Tiempo
TIME_UNIT like BAPI1012_OPR_C-TIME_UNIT,          "Unidad de Tiempo
  DENOMINATOR like BAPI1012_OPR_C-DENOMINATOR,
NOMINATOR     like BAPI1012_OPR_C-NOMINATOR,
base_quantity like BAPI1012_OPR_C-base_quantity,
  end of gs_data_operacion.

data: begin of gs_data_cha,
MATERIAL like BAPI1012_MTK_C-MATERIAL,            "Material
PLANT like BAPI1012_MTK_C-PLANT,                  "Centro
TASK_LIST_GROUP like BAPI1012_TSK_C-TASK_LIST_GROUP, "Grp. Hoja de Ruta
GROUP_COUNTER like BAPI1012_TSK_C-GROUP_COUNTER,  "Contador
ACTIVITY like BAPI1012_OPR_C-ACTIVITY,            "Numero de Operacion
INSPCHAR like BAPI1012_CHA_C-INSPCHAR,            "Numero de Caracteristica
CHAR_DESCR like BAPI1012_CHA_C-CHAR_DESCR,
MSTR_CHAR like BAPI1012_CHA_C-MSTR_CHAR,          "Caracteristica
SMPL_PROCEDURE like BAPI1012_CHA_C-SMPL_PROCEDURE,"Procedimiento
SMPL_UNIT like BAPI1012_CHA_C-SMPL_UNIT,          "Unidad de Medida
SMPL_QUANT like BAPI1012_CHA_C-SMPL_QUANT,        "Cantidad para muestra
DYN_MODIF_RULE like BAPI1012_CHA_C-DYN_MODIF_RULE,"Regla Dinamizacion
SPC_CRITERION_KEY like BAPI1012_CHA_C-SPC_CRITERION_KEY,"Criterio SPC
UP_TOL_LMT like BAPI1012_CHA_C-UP_TOL_LMT,        "Tolerancia Superior
LW_TOL_LMT like BAPI1012_CHA_C-LW_TOL_LMT,        "Tolerancia Inferior
FORMULA_CHECK_BY_SAP like BAPI1012_CHA_C-FORMULA_CHECK_BY_SAP,
FORMULA_FIELD_1 like BAPI1012_CHA_C-FORMULA_FIELD_1,
FORMULA_FIELD_2 like BAPI1012_CHA_C-FORMULA_FIELD_2,
END OF gs_data_cha.

data gt_data_material like table of gs_data_material.
data gt_data_operacion like table of gs_data_operacion.
data gt_data_cha like table of gs_data_cha.


data DECSTEL(2) TYPE C.

data gd_tfile type IBIPPARMS-PATH.

types: begin of ty_log,
MATERIAL like BAPI1012_MTK_C-MATERIAL,            "Material
PLANT like BAPI1012_MTK_C-PLANT,                  "Centro
TASK_LIST_GROUP like BAPI1012_TSK_C-TASK_LIST_GROUP, "Grp. Hoja de Ruta
GROUP_COUNTER like BAPI1012_TSK_C-GROUP_COUNTER,  "Contador
        type type BAPI_MTYPE,
        message type BAPI_MSG,
end of ty_log.

data gt_log type TABLE OF ty_log.
data gs_log like LINE OF gt_log.

*alv data
data gr_table  type ref to cl_salv_table.
data: gr_selections type ref to cl_salv_selections,
      gt_rows       type salv_t_row.
data: gr_functions type ref to cl_salv_functions_list.
*--------------------------------------------------------------------*
*--------------------------------------------------------------------*
PARAMETERS: p_file type string LOWER CASe OBLIGATORY,
            p_test type BAPIFLAG DEFAULT 'X'.

*--------------------------------------------------------------------*
at selection-screen on value-request for p_file.
*--------------------------------------------------------------------*
  gd_tfile = p_file.

  call function 'F4_FILENAME'
    EXPORTING
      field_name = 'P_FILE'
    IMPORTING
      file_name  = gd_tfile.

  move gd_tfile to p_file.
*--------------------------------------------------------------------*
START-OF-SELECTION.
*--------------------------------------------------------------------*

  PERFORM upload.

*--------------------------------------------------------------------*
end-of-SELECTION.
*--------------------------------------------------------------------*
  if gt_data[] is INITIAL.
    write:/ 'No se seleccionaron datos'.
    RETURN.
  endif.

  PERFORM crear_hoja_de_ruta.

  PERFORM display_log.
*&---------------------------------------------------------------------*
*&      Form  get_task_list_group
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM get_task_list_group using i_change
                               gs_bapi_mtk type BAPI1012_MTK_C
                                gs_bapi_tsk  type BAPI1012_TSK_C.

  DATA: BEGIN OF ls_h,
          valid_to TYPE sydatum,
          lin      TYPE i,
        END OF ls_h,
        ls_mtk_int TYPE maplb,
        lt_mtk_int TYPE TABLE OF maplb,
        ls_tsk_int TYPE plko.

  ls_h-valid_to = sy-datum.
* read material task allocation
  CALL FUNCTION 'CP_DB_MAPL_READ'
    EXPORTING
      datub      = ls_h-valid_to
      datuv      = gs_bapi_mtk-valid_from
      matnr      = gs_bapi_mtk-material
      werks      = gs_bapi_mtk-plant
    TABLES
      matpl      = lt_mtk_int
    EXCEPTIONS
      no_records = 1
      OTHERS     = 2.
  CHECK: sy-subrc = 0.
* delete deleted material task allocations
  DELETE lt_mtk_int WHERE loekz = 'X'.
*  IF gs_cntrl-flg_change_mode = const-flg_yes.
  if i_change = 'X'.
    DELETE lt_mtk_int WHERE plnal <> gs_bapi_mtk-group_counter.
  ENDIF.
  DESCRIBE TABLE lt_mtk_int LINES ls_h-lin.
  IF ls_h-lin = 1 OR i_change is INITIAL.
    READ TABLE lt_mtk_int INTO ls_mtk_int INDEX 1.
    CHECK: sy-subrc = 0.
*    gs_cntrl-task_list_group = ls_mtk_int-plnnr.
  ELSE.
    SORT lt_mtk_int BY datuv DESCENDING.
    LOOP AT lt_mtk_int INTO ls_mtk_int.
* read task list header
      CALL FUNCTION 'CI03_READ_PLKO'
        EXPORTING
          i_plnty         = ls_mtk_int-plnty
          i_plnnr         = ls_mtk_int-plnnr
          i_plnal         = ls_mtk_int-plnal
          i_date          = ls_mtk_int-datuv
        IMPORTING
          e_plko          = ls_tsk_int
        EXCEPTIONS
          tl_not_existent = 1
          tl_not_valid    = 2
          OTHERS          = 3.
      CHECK: sy-subrc = 0.
      IF ls_tsk_int-verwe = gs_bapi_tsk-task_list_usage.
*        gs_cntrl-task_list_group = ls_tsk_int-plnnr.
        EXIT.
      ENDIF.
    ENDLOOP.
  ENDIF.

ENDFORM.                    " get_task_list_group
*&---------------------------------------------------------------------*
*&      Form  select_data
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
form crear_hoja_de_ruta.

  data lt_MATERIALTASKALLOCATION type TABLE OF BAPI1012_MTK_C .
  data lt_task type TABLE OF BAPI1012_TSK_C.
  data lt_OPERATION type TABLE OF BAPI1012_OPR_C.
  data lt_INSPCHARACTERISTIC type TABLE OF BAPI1012_CHA_C.

  data ls_MATERIALTASKALLOCATION type BAPI1012_MTK_C .
  data ls_task type BAPI1012_TSK_C.
  data ls_OPERATION type BAPI1012_OPR_C.
  data ls_INSPCHARACTERISTIC type BAPI1012_CHA_C.

  data lt_return type TABLE OF bapiret2.
  data ls_return like LINE OF lt_return.


  loop at gt_data into gs_data.
    clear: gt_data_material[].
    clear: gt_data_operacion[].
    clear: gt_data_cha[].

    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
        INPUT  = gs_data-GROUP_COUNTER
      IMPORTING
        OUTPUT = gs_data-GROUP_COUNTER.

    CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
      EXPORTING
        INPUT        = gs_data-MATERIAL
      IMPORTING
        OUTPUT       = gs_data-MATERIAL
      EXCEPTIONS
        LENGTH_ERROR = 1
        OTHERS       = 2.
    IF SY-SUBRC <> 0.
      clear gs_data-MATERIAL.
    ENDIF.

    CALL FUNCTION 'CONVERSION_EXIT_NUMCV_INPUT'
      EXPORTING
        INPUT  = gs_data-ACTIVITY
      IMPORTING
        OUTPUT = gs_data-ACTIVITY.

    MOVE-CORRESPONDING gs_data to gs_data_material.
    MOVE-CORRESPONDING gs_data to gs_data_operacion.
    MOVE-CORRESPONDING gs_data to gs_data_cha.

    append gs_data_material to gt_data_material.
    append gs_data_operacion to gt_data_operacion.
    append gs_data_cha to gt_data_cha.
*  ENDLOOP.


    loop at gt_data_material into gs_data_material.
      clear: lt_OPERATION[],
             lt_INSPCHARACTERISTIC[],
             lt_MATERIALTASKALLOCATION[],
             lt_task[],
             lt_return[].

*    clear gs_data-TASK_LIST_GROUP.
*    gs_data-GROUP_COUNTER = 2.

      MOVE-CORRESPONDING gs_data to ls_MATERIALTASKALLOCATION.
      if ls_MATERIALTASKALLOCATION-MATERIAL is NOT INITIAL.
        append ls_MATERIALTASKALLOCATION to lt_MATERIALTASKALLOCATION.
      endif.

      MOVE-CORRESPONDING gs_data to ls_task.
      ls_task-TASK_LIST_USAGE = '1'.
      ls_task-TASK_LIST_STATUS = '4'.

      ls_task-valid_from = sy-datum.
      ls_task-valid_to_date = '99991231'.

*    ls_task-TASK_MEASURE_UNIT = 'KI'.  "CA
      APPEND ls_task to lt_task.


      loop at gt_data_operacion into gs_data_operacion where
           MATERIAL =  gs_data_material-MATERIAL
           and PLANT    = gs_data_material-plant
           and TASK_LIST_GROUP = gs_data_material-TASK_LIST_GROUP
           and GROUP_COUNTER  = gs_data_material-GROUP_COUNTER
        and ACTIVITY is NOT INITIAL.

        ls_OPERATION-TASK_LIST_GROUP = gs_data_material-TASK_LIST_GROUP.
        ls_OPERATION-GROUP_COUNTER   = gs_data_material-GROUP_COUNTER.
        ls_OPERATION-ACTIVITY = gs_data_operacion-ACTIVITY.
        ls_OPERATION-WORK_CNTR  = gs_data_operacion-WORK_CNTR.
        ls_OPERATION-CONTROL_KEY  = gs_data_operacion-CONTROL_KEY.
        ls_OPERATION-DESCRIPTION  = gs_data_operacion-DESCRIPTION.
        ls_OPERATION-INSP_POINT_COMPLT_FLOW_VARIANT  = gs_data_operacion-INSP_POINT_COMPLT_FLOW_VARIANT.
        ls_OPERATION-TIME_GRID  = gs_data_operacion-TIME_GRID.
        ls_OPERATION-TIME_FACTOR  = gs_data_operacion-TIME_FACTOR.
        ls_OPERATION-TIME_UNIT  = gs_data_operacion-TIME_UNIT.
        ls_OPERATION-DENOMINATOR  = gs_data_operacion-DENOMINATOR.
        ls_OPERATION-NOMINATOR   = gs_data_operacion-NOMINATOR.
        ls_OPERATION-base_quantity = gs_data_operacion-base_quantity.

        append ls_OPERATION to lt_OPERATION.

        loop at gt_data_cha into gs_data_cha where
                 MATERIAL =  gs_data_material-MATERIAL
                 and PLANT    = gs_data_material-plant
                 and TASK_LIST_GROUP = gs_data_material-TASK_LIST_GROUP
                 and GROUP_COUNTER  = gs_data_material-GROUP_COUNTER
                 and ACTIVITY = gs_data_operacion-ACTIVITY
                 and INSPCHAR is NOT INITIAL.

          ls_INSPCHARACTERISTIC-TASK_LIST_GROUP = gs_data_material-TASK_LIST_GROUP.
          ls_INSPCHARACTERISTIC-GROUP_COUNTER   = gs_data_material-GROUP_COUNTER.
          ls_INSPCHARACTERISTIC-ACTIVITY = gs_data_cha-ACTIVITY.
          ls_INSPCHARACTERISTIC-INSPCHAR  = gs_data_cha-INSPCHAR.
          ls_INSPCHARACTERISTIC-MSTR_CHAR  = gs_data_cha-MSTR_CHAR.
          ls_INSPCHARACTERISTIC-SMPL_PROCEDURE  = gs_data_cha-SMPL_PROCEDURE.
          ls_INSPCHARACTERISTIC-SMPL_UNIT  = gs_data_cha-SMPL_UNIT.
          ls_INSPCHARACTERISTIC-SMPL_QUANT  = gs_data_cha-SMPL_QUANT.
          ls_INSPCHARACTERISTIC-DYN_MODIF_RULE  = gs_data_cha-DYN_MODIF_RULE.
          ls_INSPCHARACTERISTIC-SPC_CRITERION_KEY  = gs_data_cha-SPC_CRITERION_KEY .
          ls_INSPCHARACTERISTIC-UP_TOL_LMT  = gs_data_cha-UP_TOL_LMT.
          ls_INSPCHARACTERISTIC-LW_TOL_LMT  = gs_data_cha-LW_TOL_LMT.
          ls_INSPCHARACTERISTIC-FORMULA_CHECK_BY_SAP  = gs_data_cha-FORMULA_CHECK_BY_SAP.
          ls_INSPCHARACTERISTIC-FORMULA_FIELD_1  = gs_data_cha-FORMULA_FIELD_1 .
          ls_INSPCHARACTERISTIC-FORMULA_FIELD_2  = gs_data_cha-FORMULA_FIELD_2 .
          ls_INSPCHARACTERISTIC-CHAR_DESCR = gs_data_cha-CHAR_DESCR.

          append ls_INSPCHARACTERISTIC to lt_INSPCHARACTERISTIC.

        endloop.

      endloop.

*    MOVE-CORRESPONDING gs_data to ls_OPERATION.
*    MOVE-CORRESPONDING gs_data to ls_INSPCHARACTERISTIC.
*    append ls_OPERATION to lt_OPERATION.
*    APPEND ls_INSPCHARACTERISTIC to lt_INSPCHARACTERISTIC.

      data ld_testrun TYPE  BAPIFLAG.

      ld_testrun = 'X'.

      data ld_BOMUSAGE type  BAPI1012_CONTROL_DATA-BOM_USAGE .

      ld_BOMUSAGE = '1'. "fabricacion

      CALL FUNCTION 'BAPI_ROUTING_CREATE'
       EXPORTING
         TESTRUN                      = p_test
*   PROFILE                      =
         BOMUSAGE                     = ld_BOMUSAGE
*   APPLICATION                  =
* IMPORTING
*   GROUP                        =
*   GROUPCOUNTER                 =
        TABLES
           TASK                         = lt_task
           MATERIALTASKALLOCATION       = lt_MATERIALTASKALLOCATION
*   SEQUENCE                     =
           OPERATION                    = lt_OPERATION
*   LENGTHCALCULATION            =
*   SUBOPERATION                 =
*   REFERENCEOPERATION           =
*   WORKCENTERREFERENCE          =
*   COMPONENTALLOCATION          =
*   PRODUCTIONRESOURCE           =
           INSPCHARACTERISTIC           = lt_INSPCHARACTERISTIC
*   TEXTALLOCATION               =
*   TEXT                         =
           RETURN                       = lt_return
                  .

      MOVE-CORRESPONDING gs_data_material to gs_log.
      loop at lt_return into ls_return where type = 'E' or type = 'A'.
        MOVE-CORRESPONDING ls_return to gs_log.
        append gs_log to gt_log.
      endloop.

      if sy-subrc <> 0.
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
*     EXPORTING
*       WAIT          =
*     IMPORTING
*       RETURN        =
                  .
        gs_log-type = 'S'.
        gs_log-message = 'Hoja de ruta creada'.
        append gs_log to gt_log.
      endif.
*    BREAK-POINT.
    ENDLOOP.
  ENDLOOP.
*PERFORM get_task_list_group using 'X'
*                               ls_MATERIALTASKALLOCATION
*                                ls_task.



endform.                    "select_data

*&---------------------------------------------------------------------*
*&      Form  upload
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
form upload.

  CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
      FILENAME                = p_file
      FILETYPE                = 'DAT'
    TABLES
      DATA_TAB                = gt_data
    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.


endform.                    "upload

*&---------------------------------------------------------------------*
*&      Form  display_log
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM display_log.
*... Create Instance
  TRY.
    cl_salv_table=>factory( IMPORTING r_salv_table = DATA(gr_table)
                             CHANGING t_table = gt_log ).
    CATCH cx_salv_msg.
  ENDTRY.

*... Enable Generic ALV functions
  data(gr_functions) = gr_table->get_functions( ).
**  gr_functions->set_default( ).
  gr_functions->set_all( ).

  data(lr_columns) = gr_table->get_columns( ).

* set column text
  TRY.
      data(lr_column) = lr_columns->get_column( 'EQUIPMENT_O' ).
      lr_column->set_long_text( 'Equipo Original' ).
      lr_column->set_medium_text( 'Equi.Ori.' ).
      lr_column->set_short_text( 'Equi.Ori.' ).
    CATCH cx_salv_not_found.
    CATCH cx_salv_existing.
    CATCH cx_salv_data_error.
  ENDTRY.

*... Display table
  gr_table->display( ).

ENDFORM.                    "display_log