Difference between revisions of "SAP PM BAPI IE03"

From SapWiki
(Created page with " <nowiki> *&---------------------------------------------------------------------* *& Report ZQM_EXTDAT_equi *& *&---------------------------------------------------------...")
 
 
Line 1: Line 1:
  <nowiki> *&---------------------------------------------------------------------*
+
  <nowiki>*&---------------------------------------------------------------------*
*& Report  ZQM_EXTDAT_equi
+
*& Report  ZQM_EXTDAT_equi
*&
+
*&
*&---------------------------------------------------------------------*
+
*&---------------------------------------------------------------------*
*& Descripcion  : Extractor de Datos Equipos
+
*& Descripcion  : Extractor de Datos Equipos
*&
+
*&
*&---------------------------------------------------------------------*
+
*&---------------------------------------------------------------------*
+
 
REPORT  zqm_extdat_equi.
+
REPORT  zqm_extdat_equi.
*--------------------------------------------------------------------*
+
*--------------------------------------------------------------------*
TYPE-POOLS : slis.
+
TYPE-POOLS : slis.
+
 
DATA decstel(2) TYPE c.
+
DATA decstel(2) TYPE c.
DATA: BEGIN OF gs_data,
+
DATA: BEGIN OF gs_data,
*        FUNCTLOCATION type bapi_itob_fl_sel_result-FUNCTLOCATION, "
+
*        FUNCTLOCATION type bapi_itob_fl_sel_result-FUNCTLOCATION, "
        equipment  TYPE equnr,          "N° de equipo
+
        equipment  TYPE equnr,          "N° de equipo
*        EQUICATGRY type BAPI_ITOB_EQ_ONLY-EQUICATGRY, "Tipo de equipo
+
*        EQUICATGRY type BAPI_ITOB_EQ_ONLY-EQUICATGRY, "Tipo de equipo
*STRIND type BAPI_ITOB-STRIND, " Indicador de estructura de ubicación técnica
+
*STRIND type BAPI_ITOB-STRIND, " Indicador de estructura de ubicación técnica
        equicatgry TYPE bapi_itob_eq_only-equicatgry, " Tipo de equipo
+
        equicatgry TYPE bapi_itob_eq_only-equicatgry, " Tipo de equipo
        descript  TYPE bapi_itob-descript, " Denominación de la ubicación técnic
+
        descript  TYPE bapi_itob-descript, " Denominación de la ubicación técnic
        authgrp    TYPE bapi_itob-authgrp , " Grupo de autorizaciones para objeto técnico
+
        authgrp    TYPE bapi_itob-authgrp , " Grupo de autorizaciones para objeto técnico
        obj_weight TYPE bapi_itob-obj_weight , " Peso del objeto
+
        obj_weight TYPE bapi_itob-obj_weight , " Peso del objeto
        unit_of_wt TYPE bapi_itob-unit_of_wt, " Unidad de peso
+
        unit_of_wt TYPE bapi_itob-unit_of_wt, " Unidad de peso
        obj_size  TYPE bapi_itob-obj_size , " Tamaño/Dimensión
+
        obj_size  TYPE bapi_itob-obj_size , " Tamaño/Dimensión
        inventory  TYPE bapi_itob-inventory, " Número de inventario
+
        inventory  TYPE bapi_itob-inventory, " Número de inventario
        start_from TYPE bapi_itob-start_from, " Fecha de puesta en servicio de objeto técnico
+
        start_from TYPE bapi_itob-start_from, " Fecha de puesta en servicio de objeto técnico
        objecttype TYPE bapi_itob-objecttype, " Clase de objeto técnico
+
        objecttype TYPE bapi_itob-objecttype, " Clase de objeto técnico
*      descript    type bapi_itob-descript,  "denominación  "!!!
+
*      descript    type bapi_itob-descript,  "denominación  "!!!
        acquisval  TYPE bapi_itob-acquisval , " valor de adquisición
+
        acquisval  TYPE bapi_itob-acquisval , " valor de adquisición
        currency  TYPE bapi_itob-currency ,  " clave de moneda
+
        currency  TYPE bapi_itob-currency ,  " clave de moneda
        acqdate    TYPE bapi_itob-acqdate ,  " fecha de adquisición
+
        acqdate    TYPE bapi_itob-acqdate ,  " fecha de adquisición
        manfacture TYPE bapi_itob-manfacture, " fabricante del activo fijo
+
        manfacture TYPE bapi_itob-manfacture, " fabricante del activo fijo
        mancountry TYPE bapi_itob-mancountry, " país de fabricación
+
        mancountry TYPE bapi_itob-mancountry, " país de fabricación
        manmodel  TYPE bapi_itob-manmodel,  " denominación de tipo del fabricante
+
        manmodel  TYPE bapi_itob-manmodel,  " denominación de tipo del fabricante
        constyear  TYPE bapi_itob-constyear,  " año de construcción
+
        constyear  TYPE bapi_itob-constyear,  " año de construcción
        constmonth TYPE bapi_itob-constmonth, " mes de construcción
+
        constmonth TYPE bapi_itob-constmonth, " mes de construcción
        manparno  TYPE bapi_itob-manparno,  " número de pieza de fabricante
+
        manparno  TYPE bapi_itob-manparno,  " número de pieza de fabricante
        manserno  TYPE bapi_itob-manserno,  " número de serie según el fabricante
+
        manserno  TYPE bapi_itob-manserno,  " número de serie según el fabricante
        maintplant TYPE bapi_itob-maintplant, " centro de emplazamiento
+
        maintplant TYPE bapi_itob-maintplant, " centro de emplazamiento
        maintloc  TYPE bapi_itob-maintloc  , "  emplazamiento del objeto de mantenimiento
+
        maintloc  TYPE bapi_itob-maintloc  , "  emplazamiento del objeto de mantenimiento
        maintroom  TYPE bapi_itob-maintroom,  " local
+
        maintroom  TYPE bapi_itob-maintroom,  " local
        plsectn    TYPE bapi_itob-plsectn,    "  Área de empresa
+
        plsectn    TYPE bapi_itob-plsectn,    "  Área de empresa
        work_ctr  TYPE bapi_itob-work_ctr,  " puesto de trabajo
+
        work_ctr  TYPE bapi_itob-work_ctr,  " puesto de trabajo
        abcindic  TYPE bapi_itob-abcindic,  " indicador abc para objeto técnico
+
        abcindic  TYPE bapi_itob-abcindic,  " indicador abc para objeto técnico
        sortfield  TYPE bapi_itob-sortfield,  " campo de clasificación
+
        sortfield  TYPE bapi_itob-sortfield,  " campo de clasificación
        comp_code  TYPE bapi_itob-comp_code,  " sociedad
+
        comp_code  TYPE bapi_itob-comp_code,  " sociedad
        bus_area  TYPE bapi_itob-bus_area,  " división
+
        bus_area  TYPE bapi_itob-bus_area,  " división
        asset_no  TYPE bapi_itob-asset_no ,  " número principal de activo fijo
+
        asset_no  TYPE bapi_itob-asset_no ,  " número principal de activo fijo
        sub_number TYPE bapi_itob-sub_number, " subnúmero de activo fijo
+
        sub_number TYPE bapi_itob-sub_number, " subnúmero de activo fijo
        costcenter TYPE bapi_itob-costcenter, " centro de coste
+
        costcenter TYPE bapi_itob-costcenter, " centro de coste
        wbs_elem  TYPE bapi_itob-wbs_elem,  " elemento del plan de estructura de proyecto (elemento pep)
+
        wbs_elem  TYPE bapi_itob-wbs_elem,  " elemento del plan de estructura de proyecto (elemento pep)
        standorder TYPE bapi_itob-standorder, " número de orden permanente
+
        standorder TYPE bapi_itob-standorder, " número de orden permanente
        settlorder TYPE bapi_itob-settlorder, " orden de liquidación
+
        settlorder TYPE bapi_itob-settlorder, " orden de liquidación
        planplant  TYPE bapi_itob-planplant , " centro de planificación del mantenimiento
+
        planplant  TYPE bapi_itob-planplant , " centro de planificación del mantenimiento
        plangroup  TYPE bapi_itob-plangroup , " grupo planificador p.servicio cliente y mantenimiento
+
        plangroup  TYPE bapi_itob-plangroup , " grupo planificador p.servicio cliente y mantenimiento
        pp_wkctr  TYPE bapi_itob-pp_wkctr,  " puesto de trabajo responsable en medidas de mantenimiento
+
        pp_wkctr  TYPE bapi_itob-pp_wkctr,  " puesto de trabajo responsable en medidas de mantenimiento
        catprofile TYPE bapi_itob-catprofile, "  perfil de catálogo
+
        catprofile TYPE bapi_itob-catprofile, "  perfil de catálogo
*        eqinstall  type bapi_itob_fl_only-eqinstall, " montaje de equipos permitido en ubicación técnica
+
*        eqinstall  type bapi_itob_fl_only-eqinstall, " montaje de equipos permitido en ubicación técnica
        read_supeq TYPE bapi_itob_eq_only-read_supeq,  "equipo superior
+
        read_supeq TYPE bapi_itob_eq_only-read_supeq,  "equipo superior
        read_floc  TYPE bapi_itob_eq_only-read_floc,  "Identificación de ubicación técnica
+
        read_floc  TYPE bapi_itob_eq_only-read_floc,  "Identificación de ubicación técnica
        inst_pos  TYPE bapi_itob_eq_only-inst_pos, "Posición de equipo en lugar de montaje (eq.sup./ubic.técn.)
+
        inst_pos  TYPE bapi_itob_eq_only-inst_pos, "Posición de equipo en lugar de montaje (eq.sup./ubic.técn.)
      END OF gs_data.
+
      END OF gs_data.
DATA gt_data LIKE TABLE OF gs_data.
+
DATA gt_data LIKE TABLE OF gs_data.
+
 
DATA: BEGIN OF gs_header,
+
DATA: BEGIN OF gs_header,
        colname TYPE scrtext_l,
+
        colname TYPE scrtext_l,
      END OF gs_header.
+
      END OF gs_header.
DATA gt_header LIKE TABLE OF gs_header.
+
DATA gt_header LIKE TABLE OF gs_header.
+
 
+
 
DATA gt_equipos LIKE TABLE OF bapi_itob_eq_sel_result.
+
DATA gt_equipos LIKE TABLE OF bapi_itob_eq_sel_result.
DATA gs_equipos LIKE LINE OF gt_equipos.
+
DATA gs_equipos LIKE LINE OF gt_equipos.
+
 
+
 
DATA: gt_qpmk LIKE TABLE OF qpmk,
+
DATA: gt_qpmk LIKE TABLE OF qpmk,
      gs_qpmk LIKE LINE OF gt_qpmk.
+
      gs_qpmk LIKE LINE OF gt_qpmk.
+
 
DATA gd_tfile TYPE ibipparms-path.
+
DATA gd_tfile TYPE ibipparms-path.
+
 
DATA: ls_itob_sel_maintplant LIKE TABLE OF  bapi_itob_sel_maintplant WITH HEADER LINE.
+
DATA: ls_itob_sel_maintplant LIKE TABLE OF  bapi_itob_sel_maintplant WITH HEADER LINE.
DATA: ls_bapiret2  LIKE TABLE OF bapiret2 WITH HEADER LINE.
+
DATA: ls_bapiret2  LIKE TABLE OF bapiret2 WITH HEADER LINE.
DATA: ls_itob_fl_sel_result LIKE TABLE OF  bapi_itob_fl_sel_result WITH HEADER LINE.
+
DATA: ls_itob_fl_sel_result LIKE TABLE OF  bapi_itob_fl_sel_result WITH HEADER LINE.
DATA:  es_bapi_itob LIKE TABLE OF bapi_itob WITH HEADER LINE.
+
DATA:  es_bapi_itob LIKE TABLE OF bapi_itob WITH HEADER LINE.
*--------------------------------------------------------------------*
+
*--------------------------------------------------------------------*
*--------------------------------------------------------------------*
+
*--------------------------------------------------------------------*
SELECT-OPTIONS: s_equnr FOR gs_data-equipment,
+
SELECT-OPTIONS: s_equnr FOR gs_data-equipment,
                s_swerk FOR gs_data-maintplant.
+
                s_swerk FOR gs_data-maintplant.
PARAMETERS: p_file TYPE string LOWER CASE OBLIGATORY.
+
PARAMETERS: p_file TYPE string LOWER CASE OBLIGATORY.
+
 
*--------------------------------------------------------------------*
+
*--------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
+
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
*--------------------------------------------------------------------*
+
*--------------------------------------------------------------------*
  gd_tfile = p_file.
+
  gd_tfile = p_file.
+
 
  CALL FUNCTION 'F4_FILENAME'
+
  CALL FUNCTION 'F4_FILENAME'
    EXPORTING
+
    EXPORTING
      field_name = 'P_FILE'
+
      field_name = 'P_FILE'
    IMPORTING
+
    IMPORTING
      file_name  = gd_tfile.
+
      file_name  = gd_tfile.
+
 
  MOVE gd_tfile TO p_file.
+
  MOVE gd_tfile TO p_file.
*--------------------------------------------------------------------*
+
*--------------------------------------------------------------------*
START-OF-SELECTION.
+
START-OF-SELECTION.
*--------------------------------------------------------------------*
+
*--------------------------------------------------------------------*
+
 
  PERFORM select_data.
+
  PERFORM select_data.
+
 
*--------------------------------------------------------------------*
+
*--------------------------------------------------------------------*
END-OF-SELECTION.
+
END-OF-SELECTION.
*--------------------------------------------------------------------*
+
*--------------------------------------------------------------------*
*  PERFORM process_data.
+
*  PERFORM process_data.
  IF gt_data[] IS INITIAL.
+
  IF gt_data[] IS INITIAL.
    WRITE:/ 'No se seleccionaron datos'.
+
    WRITE:/ 'No se seleccionaron datos'.
    RETURN.
+
    RETURN.
  ENDIF.
+
  ENDIF.
+
 
  PERFORM download.
+
  PERFORM download.
+
 
*&---------------------------------------------------------------------*
+
*&---------------------------------------------------------------------*
*&      Form  select_data
+
*&      Form  select_data
*&---------------------------------------------------------------------*
+
*&---------------------------------------------------------------------*
*      text
+
*      text
*----------------------------------------------------------------------*
+
*----------------------------------------------------------------------*
FORM select_data.
+
FORM select_data.
+
 
  CALL FUNCTION 'BAPI_EQUI_GETLIST'
+
  CALL FUNCTION 'BAPI_EQUI_GETLIST'
    TABLES
+
    TABLES
      equipment_ra  = s_equnr
+
      equipment_ra  = s_equnr
      maintplant_ra  = s_swerk
+
      maintplant_ra  = s_swerk
      equipment_list = gt_equipos.
+
      equipment_list = gt_equipos.
+
 
  DATA: ls_data_general_exp  LIKE  bapi_itob,
+
  DATA: ls_data_general_exp  LIKE  bapi_itob,
        ls_data_specific_exp LIKE  bapi_itob_eq_only.
+
        ls_data_specific_exp LIKE  bapi_itob_eq_only.
  DATA ld_monto TYPE  bapicurr-bapicurr.
+
  DATA ld_monto TYPE  bapicurr-bapicurr.
+
 
  LOOP AT  gt_equipos INTO gs_equipos.
+
  LOOP AT  gt_equipos INTO gs_equipos.
    CALL FUNCTION 'BAPI_EQUI_GETDETAIL'
+
    CALL FUNCTION 'BAPI_EQUI_GETDETAIL'
      EXPORTING
+
      EXPORTING
        equipment        = gs_equipos-equipment
+
        equipment        = gs_equipos-equipment
      IMPORTING
+
      IMPORTING
        data_general_exp  = ls_data_general_exp
+
        data_general_exp  = ls_data_general_exp
        data_specific_exp = ls_data_specific_exp
+
        data_specific_exp = ls_data_specific_exp
*      DATA_FLEET_EXP    =
+
*      DATA_FLEET_EXP    =
*      RETURN            =
+
*      RETURN            =
      .
+
      .
+
 
    MOVE-CORRESPONDING ls_data_general_exp TO gs_data.
+
    MOVE-CORRESPONDING ls_data_general_exp TO gs_data.
    CALL FUNCTION 'BAPI_CURRENCY_CONV_TO_EXTERNAL'
+
    CALL FUNCTION 'BAPI_CURRENCY_CONV_TO_EXTERNAL'
      EXPORTING
+
      EXPORTING
        currency        = ls_data_general_exp-currency
+
        currency        = ls_data_general_exp-currency
        amount_internal = ls_data_general_exp-acquisval
+
        amount_internal = ls_data_general_exp-acquisval
      IMPORTING
+
      IMPORTING
        amount_external = ld_monto.
+
        amount_external = ld_monto.
+
 
    MOVE ld_monto TO gs_data-acquisval.
+
    MOVE ld_monto TO gs_data-acquisval.
    gs_data-read_supeq  = ls_data_specific_exp-read_supeq.
+
    gs_data-read_supeq  = ls_data_specific_exp-read_supeq.
    gs_data-read_floc = ls_data_specific_exp-read_floc.
+
    gs_data-read_floc = ls_data_specific_exp-read_floc.
    gs_data-inst_pos  = ls_data_specific_exp-inst_pos.
+
    gs_data-inst_pos  = ls_data_specific_exp-inst_pos.
    gs_data-equicatgry =  ls_data_specific_exp-equicatgry.
+
    gs_data-equicatgry =  ls_data_specific_exp-equicatgry.
    gs_data-equipment = gs_equipos-equipment.
+
    gs_data-equipment = gs_equipos-equipment.
+
 
    APPEND gs_data TO gt_data.
+
    APPEND gs_data TO gt_data.
  ENDLOOP.
+
  ENDLOOP.
+
 
ENDFORM.                    "select_data
+
ENDFORM.                    "select_data
*&---------------------------------------------------------------------*
+
*&---------------------------------------------------------------------*
*&      Form  download
+
*&      Form  download
*&---------------------------------------------------------------------*
+
*&---------------------------------------------------------------------*
*      text
+
*      text
*----------------------------------------------------------------------*
+
*----------------------------------------------------------------------*
FORM download.
+
FORM download.
+
 
  PERFORM crear_header_2 USING gs_data CHANGING gt_header[].
+
  PERFORM crear_header_2 USING gs_data CHANGING gt_header[].
+
 
  CALL FUNCTION 'GUI_DOWNLOAD'
+
  CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
+
    EXPORTING
      filename                = p_file
+
      filename                = p_file
      filetype                = 'DAT'
+
      filetype                = 'DAT'
    TABLES
+
    TABLES
      data_tab                = gt_data
+
      data_tab                = gt_data
      fieldnames              = gt_header
+
      fieldnames              = gt_header
    EXCEPTIONS
+
    EXCEPTIONS
      file_write_error        = 1
+
      file_write_error        = 1
      no_batch                = 2
+
      no_batch                = 2
      gui_refuse_filetransfer = 3
+
      gui_refuse_filetransfer = 3
      invalid_type            = 4
+
      invalid_type            = 4
      no_authority            = 5
+
      no_authority            = 5
      unknown_error          = 6
+
      unknown_error          = 6
      header_not_allowed      = 7
+
      header_not_allowed      = 7
      separator_not_allowed  = 8
+
      separator_not_allowed  = 8
      filesize_not_allowed    = 9
+
      filesize_not_allowed    = 9
      header_too_long        = 10
+
      header_too_long        = 10
      dp_error_create        = 11
+
      dp_error_create        = 11
      dp_error_send          = 12
+
      dp_error_send          = 12
      dp_error_write          = 13
+
      dp_error_write          = 13
      unknown_dp_error        = 14
+
      unknown_dp_error        = 14
      access_denied          = 15
+
      access_denied          = 15
      dp_out_of_memory        = 16
+
      dp_out_of_memory        = 16
      disk_full              = 17
+
      disk_full              = 17
      dp_timeout              = 18
+
      dp_timeout              = 18
      file_not_found          = 19
+
      file_not_found          = 19
      dataprovider_exception  = 20
+
      dataprovider_exception  = 20
      control_flush_error    = 21
+
      control_flush_error    = 21
      OTHERS                  = 22.
+
      OTHERS                  = 22.
  IF sy-subrc <> 0.
+
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
+
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
+
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ELSE.
+
  ELSE.
    MESSAGE i000(fb) WITH 'Se genero archivo'
+
    MESSAGE i000(fb) WITH 'Se genero archivo'
                          p_file.
+
                          p_file.
  ENDIF.
+
  ENDIF.
ENDFORM.                    "download
+
ENDFORM.                    "download
+
 
*&---------------------------------------------------------------------*
+
*&---------------------------------------------------------------------*
*&      Form  crear_header
+
*&      Form  crear_header
*&---------------------------------------------------------------------*
+
*&---------------------------------------------------------------------*
*      text
+
*      text
*----------------------------------------------------------------------*
+
*----------------------------------------------------------------------*
FORM crear_header.
+
FORM crear_header.
+
 
  CLEAR gt_header[].
+
  CLEAR gt_header[].
+
 
  DATA: l_index(2) TYPE n,
+
  DATA: l_index(2) TYPE n,
        l_string  TYPE string,
+
        l_string  TYPE string,
        l_0033    TYPE p0033.
+
        l_0033    TYPE p0033.
  FIELD-SYMBOLS <fs> TYPE any.
+
  FIELD-SYMBOLS <fs> TYPE any.
  DATA: descr_struc_ref TYPE REF TO cl_abap_structdescr,
+
  DATA: descr_struc_ref TYPE REF TO cl_abap_structdescr,
        lt_components  TYPE abap_compdescr_tab,
+
        lt_components  TYPE abap_compdescr_tab,
        ls_components  LIKE LINE OF lt_components.
+
        ls_components  LIKE LINE OF lt_components.
*descr_struc_ref ?= cl_abap_typedescr=>describe_by_name( gs_data ).
+
*descr_struc_ref ?= cl_abap_typedescr=>describe_by_name( gs_data ).
*lt_components = descr_struc_ref->components.
+
*lt_components = descr_struc_ref->components.
  DATA comp_tab TYPE abap_compdescr_tab.
+
  DATA comp_tab TYPE abap_compdescr_tab.
  DATA stru_ref TYPE REF TO cl_abap_structdescr.
+
  DATA stru_ref TYPE REF TO cl_abap_structdescr.
  DATA type_ref TYPE REF TO cl_abap_typedescr.
+
  DATA type_ref TYPE REF TO cl_abap_typedescr.
  DATA is_ddic TYPE abap_bool.
+
  DATA is_ddic TYPE abap_bool.
  DATA: lt_ddic TYPE dd_x031l_table,
+
  DATA: lt_ddic TYPE dd_x031l_table,
        wa_ddic TYPE x031l,
+
        wa_ddic TYPE x031l,
        lt_fcat TYPE slis_t_fieldcat_alv,
+
        lt_fcat TYPE slis_t_fieldcat_alv,
        wa_fcat TYPE slis_fieldcat_alv,
+
        wa_fcat TYPE slis_fieldcat_alv,
        ls_layo TYPE slis_layout_alv,
+
        ls_layo TYPE slis_layout_alv,
        l_alv  TYPE REF TO cl_gui_alv_grid.
+
        l_alv  TYPE REF TO cl_gui_alv_grid.
+
 
  DATA: one_comp TYPE abap_compdescr,
+
  DATA: one_comp TYPE abap_compdescr,
        one_name TYPE string.
+
        one_name TYPE string.
+
 
  stru_ref ?= cl_abap_structdescr=>describe_by_data( gs_data ).
+
  stru_ref ?= cl_abap_structdescr=>describe_by_data( gs_data ).
+
 
  comp_tab = stru_ref->components.
+
  comp_tab = stru_ref->components.
+
 
  FIELD-SYMBOLS <f3> TYPE any.
+
  FIELD-SYMBOLS <f3> TYPE any.
  DATA gd_field TYPE string.
+
  DATA gd_field TYPE string.
+
 
  LOOP AT comp_tab INTO one_comp.
+
  LOOP AT comp_tab INTO one_comp.
    CONCATENATE 'GS_DATA-' one_comp-name INTO gd_field.
+
    CONCATENATE 'GS_DATA-' one_comp-name INTO gd_field.
+
 
    ASSIGN (gd_field) TO <f3>.
+
    ASSIGN (gd_field) TO <f3>.
+
 
    type_ref ?= cl_abap_typedescr=>describe_by_data( <f3> ).
+
    type_ref ?= cl_abap_typedescr=>describe_by_data( <f3> ).
    is_ddic = type_ref->is_ddic_type( ).
+
    is_ddic = type_ref->is_ddic_type( ).
+
 
    IF is_ddic = abap_true.
+
    IF is_ddic = abap_true.
      lt_ddic = type_ref->get_ddic_object( ).
+
      lt_ddic = type_ref->get_ddic_object( ).
+
 
      LOOP AT lt_ddic INTO wa_ddic.
+
      LOOP AT lt_ddic INTO wa_ddic.
        CLEAR wa_ddic-tabname.
+
        CLEAR wa_ddic-tabname.
*        SELECT SINGLE
+
*        SELECT SINGLE
*        dd03l~tabname
+
*        dd03l~tabname
*        INTO wa_ddic-tabname
+
*        INTO wa_ddic-tabname
*        FROM dd03l
+
*        FROM dd03l
*        WHERE dd03l~fieldname = wa_ddic-fieldname
+
*        WHERE dd03l~fieldname = wa_ddic-fieldname
*        AND dd03l~tabname NOT LIKE '/%'.
+
*        AND dd03l~tabname NOT LIKE '/%'.
+
 
        SELECT SINGLE dd04t~scrtext_s
+
        SELECT SINGLE dd04t~scrtext_s
                      dd04t~scrtext_m
+
                      dd04t~scrtext_m
                      dd04t~scrtext_l
+
                      dd04t~scrtext_l
        INTO (wa_fcat-seltext_s, wa_fcat-seltext_m, wa_fcat-seltext_l) FROM dd04t
+
        INTO (wa_fcat-seltext_s, wa_fcat-seltext_m, wa_fcat-seltext_l) FROM dd04t
        WHERE dd04t~rollname = wa_ddic-fieldname
+
        WHERE dd04t~rollname = wa_ddic-fieldname
          AND dd04t~ddlanguage = sy-langu.
+
          AND dd04t~ddlanguage = sy-langu.
+
 
        APPEND wa_fcat TO lt_fcat.
+
        APPEND wa_fcat TO lt_fcat.
        CONCATENATE wa_fcat-seltext_l wa_ddic-fieldname INTO gd_field  SEPARATED BY space.
+
        CONCATENATE wa_fcat-seltext_l wa_ddic-fieldname INTO gd_field  SEPARATED BY space.
        APPEND gd_field TO gt_header.
+
        APPEND gd_field TO gt_header.
      ENDLOOP.
+
      ENDLOOP.
    ELSE.
+
    ELSE.
      APPEND one_comp-name TO gt_header.
+
      APPEND one_comp-name TO gt_header.
    ENDIF.
+
    ENDIF.
+
 
  ENDLOOP.
+
  ENDLOOP.
+
 
ENDFORM.                    "crear_header
+
ENDFORM.                    "crear_header
+
 
+
 
*&---------------------------------------------------------------------*
+
*&---------------------------------------------------------------------*
*&      Form  read_text
+
*&      Form  read_text
*&---------------------------------------------------------------------*
+
*&---------------------------------------------------------------------*
*      text
+
*      text
*----------------------------------------------------------------------*
+
*----------------------------------------------------------------------*
FORM read_text.
+
FORM read_text.
+
 
  DATA l_v_name TYPE thead-tdname.  " Declare l_v_name as this type
+
  DATA l_v_name TYPE thead-tdname.  " Declare l_v_name as this type
  DATA l_fs_line TYPE tline.
+
  DATA l_fs_line TYPE tline.
  DATA l_it_line LIKE TABLE OF l_fs_line.
+
  DATA l_it_line LIKE TABLE OF l_fs_line.
+
 
  CONCATENATE gs_qpmk-mandt
+
  CONCATENATE gs_qpmk-mandt
              gs_qpmk-zaehler
+
              gs_qpmk-zaehler
              gs_qpmk-mkmnr
+
              gs_qpmk-mkmnr
              gs_qpmk-version
+
              gs_qpmk-version
              sy-langu INTO l_v_name RESPECTING BLANKS.
+
              sy-langu INTO l_v_name RESPECTING BLANKS.
+
 
  REFRESH l_it_line.
+
  REFRESH l_it_line.
  CALL FUNCTION 'READ_TEXT'    "get long text
+
  CALL FUNCTION 'READ_TEXT'    "get long text
    EXPORTING
+
    EXPORTING
      client  = sy-mandt
+
      client  = sy-mandt
      id      = 'QPMT'
+
      id      = 'QPMT'
      language = sy-langu
+
      language = sy-langu
      name    = l_v_name
+
      name    = l_v_name
      object  = 'QPMERKAL'
+
      object  = 'QPMERKAL'
    TABLES
+
    TABLES
      lines    = l_it_line.
+
      lines    = l_it_line.
+
 
ENDFORM.                    "read_text
+
ENDFORM.                    "read_text
+
 
FORM crear_header_2 USING  VALUE(i_data)
+
FORM crear_header_2 USING  VALUE(i_data)
                  CHANGING i_header TYPE ANY TABLE.
+
                CHANGING i_header TYPE ANY TABLE.
  DATA lt_text TYPE pt_t_text.
+
  DATA lt_text TYPE pt_t_text.
  DATA ls_text LIKE LINE OF lt_text.
+
  DATA ls_text LIKE LINE OF lt_text.
+
 
  FIELD-SYMBOLS <wa>.
+
  FIELD-SYMBOLS <wa>.
  ASSIGN i_data TO <wa>.
+
  ASSIGN i_data TO <wa>.
+
 
  DATA: l_index(2) TYPE n,
+
  DATA: l_index(2) TYPE n,
        l_string  TYPE string,
+
        l_string  TYPE string,
        l_0033    TYPE p0033.
+
        l_0033    TYPE p0033.
  FIELD-SYMBOLS <fs> TYPE any.
+
  FIELD-SYMBOLS <fs> TYPE any.
  DATA: descr_struc_ref TYPE REF TO cl_abap_structdescr,
+
  DATA: descr_struc_ref TYPE REF TO cl_abap_structdescr,
        lt_components  TYPE abap_compdescr_tab,
+
        lt_components  TYPE abap_compdescr_tab,
        ls_components  LIKE LINE OF lt_components.
+
        ls_components  LIKE LINE OF lt_components.
*descr_struc_ref ?= cl_abap_typedescr=>describe_by_name( gs_data ).
+
*descr_struc_ref ?= cl_abap_typedescr=>describe_by_name( gs_data ).
*lt_components = descr_struc_ref->components.
+
*lt_components = descr_struc_ref->components.
  DATA comp_tab TYPE abap_compdescr_tab.
+
  DATA comp_tab TYPE abap_compdescr_tab.
  DATA stru_ref TYPE REF TO cl_abap_structdescr.
+
  DATA stru_ref TYPE REF TO cl_abap_structdescr.
  DATA type_ref TYPE REF TO cl_abap_typedescr.
+
  DATA type_ref TYPE REF TO cl_abap_typedescr.
  DATA is_ddic TYPE abap_bool.
+
  DATA is_ddic TYPE abap_bool.
  DATA: lt_ddic TYPE dd_x031l_table,
+
  DATA: lt_ddic TYPE dd_x031l_table,
        wa_ddic TYPE x031l,
+
        wa_ddic TYPE x031l,
        lt_fcat TYPE slis_t_fieldcat_alv,
+
        lt_fcat TYPE slis_t_fieldcat_alv,
        wa_fcat TYPE slis_fieldcat_alv,
+
        wa_fcat TYPE slis_fieldcat_alv,
        ls_layo TYPE slis_layout_alv,
+
        ls_layo TYPE slis_layout_alv,
        l_alv  TYPE REF TO cl_gui_alv_grid.
+
        l_alv  TYPE REF TO cl_gui_alv_grid.
+
 
  DATA: one_comp TYPE abap_compdescr,
+
  DATA: one_comp TYPE abap_compdescr,
        one_name TYPE string.
+
        one_name TYPE string.
+
 
  stru_ref ?= cl_abap_structdescr=>describe_by_data( <wa> ).
+
  stru_ref ?= cl_abap_structdescr=>describe_by_data( <wa> ).
+
 
  comp_tab = stru_ref->components.
+
  comp_tab = stru_ref->components.
+
 
  FIELD-SYMBOLS <f3> TYPE any.
+
  FIELD-SYMBOLS <f3> TYPE any.
  DATA gd_field TYPE string.
+
  DATA gd_field TYPE string.
+
 
  LOOP AT comp_tab INTO one_comp.
+
  LOOP AT comp_tab INTO one_comp.
    CONCATENATE '<WA>-' one_comp-name INTO gd_field.
+
    CONCATENATE '<WA>-' one_comp-name INTO gd_field.
+
 
    ASSIGN (gd_field) TO <f3>.
+
    ASSIGN (gd_field) TO <f3>.
+
 
    type_ref ?= cl_abap_typedescr=>describe_by_data( <f3> ).
+
    type_ref ?= cl_abap_typedescr=>describe_by_data( <f3> ).
    is_ddic = type_ref->is_ddic_type( ).
+
    is_ddic = type_ref->is_ddic_type( ).
+
 
    IF is_ddic = abap_true.
+
    IF is_ddic = abap_true.
      lt_ddic = type_ref->get_ddic_object( ).
+
      lt_ddic = type_ref->get_ddic_object( ).
+
 
      LOOP AT lt_ddic INTO wa_ddic.
+
      LOOP AT lt_ddic INTO wa_ddic.
        CLEAR wa_ddic-tabname.
+
        CLEAR wa_ddic-tabname.
+
 
        SELECT SINGLE dd04t~scrtext_s
+
        SELECT SINGLE dd04t~scrtext_s
                      dd04t~scrtext_m
+
                      dd04t~scrtext_m
                      dd04t~scrtext_l
+
                      dd04t~scrtext_l
                INTO (wa_fcat-seltext_s, wa_fcat-seltext_m, wa_fcat-seltext_l) FROM dd04t
+
                INTO (wa_fcat-seltext_s, wa_fcat-seltext_m, wa_fcat-seltext_l) FROM dd04t
                WHERE dd04t~rollname = wa_ddic-fieldname
+
              WHERE dd04t~rollname = wa_ddic-fieldname
                  AND dd04t~ddlanguage = sy-langu.
+
                AND dd04t~ddlanguage = sy-langu.
+
 
        APPEND wa_fcat TO lt_fcat.
+
        APPEND wa_fcat TO lt_fcat.
        CONCATENATE wa_fcat-seltext_l wa_ddic-fieldname INTO gd_field  SEPARATED BY space.
+
        CONCATENATE wa_fcat-seltext_l wa_ddic-fieldname INTO gd_field  SEPARATED BY space.
        APPEND gd_field TO lt_text.
+
        APPEND gd_field TO lt_text.
      ENDLOOP.
+
      ENDLOOP.
    ELSE.
+
    ELSE.
      APPEND one_comp-name TO lt_text.
+
      APPEND one_comp-name TO lt_text.
    ENDIF.
+
    ENDIF.
+
 
  ENDLOOP.
+
  ENDLOOP.
+
 
  i_header[] = lt_text[].
+
  i_header[] = lt_text[].
ENDFORM.                    "crear_header</nowiki>
+
ENDFORM.                    "crear_header</nowiki>

Latest revision as of 22:15, 4 April 2020

*&---------------------------------------------------------------------*
*& Report  ZQM_EXTDAT_equi
*&
*&---------------------------------------------------------------------*
*& Descripcion   : Extractor de Datos Equipos
*&
*&---------------------------------------------------------------------*

REPORT  zqm_extdat_equi.
*--------------------------------------------------------------------*
TYPE-POOLS : slis.

DATA decstel(2) TYPE c.
DATA: BEGIN OF gs_data,
*        FUNCTLOCATION type bapi_itob_fl_sel_result-FUNCTLOCATION, "
        equipment  TYPE equnr,           "N° de equipo
*        EQUICATGRY type BAPI_ITOB_EQ_ONLY-EQUICATGRY, "Tipo de equipo
*STRIND type BAPI_ITOB-STRIND, " Indicador de estructura de ubicación técnica
        equicatgry TYPE bapi_itob_eq_only-equicatgry, " Tipo de equipo
        descript   TYPE bapi_itob-descript, " Denominación de la ubicación técnic
        authgrp    TYPE bapi_itob-authgrp , " Grupo de autorizaciones para objeto técnico
        obj_weight TYPE bapi_itob-obj_weight , " Peso del objeto
        unit_of_wt TYPE bapi_itob-unit_of_wt, " Unidad de peso
        obj_size   TYPE bapi_itob-obj_size , " Tamaño/Dimensión
        inventory  TYPE bapi_itob-inventory, " Número de inventario
        start_from TYPE bapi_itob-start_from, " Fecha de puesta en servicio de objeto técnico
        objecttype TYPE bapi_itob-objecttype, " Clase de objeto técnico
*       descript    type bapi_itob-descript,   "denominación   "!!!
        acquisval  TYPE bapi_itob-acquisval , " valor de adquisición
        currency   TYPE bapi_itob-currency ,  " clave de moneda
        acqdate    TYPE bapi_itob-acqdate ,   " fecha de adquisición
        manfacture TYPE bapi_itob-manfacture, " fabricante del activo fijo
        mancountry TYPE bapi_itob-mancountry, " país de fabricación
        manmodel   TYPE bapi_itob-manmodel,   " denominación de tipo del fabricante
        constyear  TYPE bapi_itob-constyear,  " año de construcción
        constmonth TYPE bapi_itob-constmonth, " mes de construcción
        manparno   TYPE bapi_itob-manparno,   " número de pieza de fabricante
        manserno   TYPE bapi_itob-manserno,   " número de serie según el fabricante
        maintplant TYPE bapi_itob-maintplant, " centro de emplazamiento
        maintloc   TYPE bapi_itob-maintloc  , "  emplazamiento del objeto de mantenimiento
        maintroom  TYPE bapi_itob-maintroom,  " local
        plsectn    TYPE bapi_itob-plsectn,    "  Área de empresa
        work_ctr   TYPE bapi_itob-work_ctr,   " puesto de trabajo
        abcindic   TYPE bapi_itob-abcindic,   " indicador abc para objeto técnico
        sortfield  TYPE bapi_itob-sortfield,  " campo de clasificación
        comp_code  TYPE bapi_itob-comp_code,  " sociedad
        bus_area   TYPE bapi_itob-bus_area,   " división
        asset_no   TYPE bapi_itob-asset_no ,  " número principal de activo fijo
        sub_number TYPE bapi_itob-sub_number, " subnúmero de activo fijo
        costcenter TYPE bapi_itob-costcenter, " centro de coste
        wbs_elem   TYPE bapi_itob-wbs_elem,   " elemento del plan de estructura de proyecto (elemento pep)
        standorder TYPE bapi_itob-standorder, " número de orden permanente
        settlorder TYPE bapi_itob-settlorder, " orden de liquidación
        planplant  TYPE bapi_itob-planplant , " centro de planificación del mantenimiento
        plangroup  TYPE bapi_itob-plangroup , " grupo planificador p.servicio cliente y mantenimiento
        pp_wkctr   TYPE bapi_itob-pp_wkctr,   " puesto de trabajo responsable en medidas de mantenimiento
        catprofile TYPE bapi_itob-catprofile, "  perfil de catálogo
*        eqinstall   type bapi_itob_fl_only-eqinstall, " montaje de equipos permitido en ubicación técnica
        read_supeq TYPE bapi_itob_eq_only-read_supeq,  "equipo superior
        read_floc  TYPE bapi_itob_eq_only-read_floc,   "Identificación de ubicación técnica
        inst_pos   TYPE bapi_itob_eq_only-inst_pos, "Posición de equipo en lugar de montaje (eq.sup./ubic.técn.)
      END OF gs_data.
DATA gt_data LIKE TABLE OF gs_data.

DATA: BEGIN OF gs_header,
        colname TYPE scrtext_l,
      END OF gs_header.
DATA gt_header LIKE TABLE OF gs_header.


DATA gt_equipos LIKE TABLE OF bapi_itob_eq_sel_result.
DATA gs_equipos LIKE LINE OF gt_equipos.


DATA: gt_qpmk LIKE TABLE OF qpmk,
      gs_qpmk LIKE LINE OF gt_qpmk.

DATA gd_tfile TYPE ibipparms-path.

DATA: ls_itob_sel_maintplant LIKE TABLE OF  bapi_itob_sel_maintplant WITH HEADER LINE.
DATA: ls_bapiret2  LIKE TABLE OF bapiret2 WITH HEADER LINE.
DATA: ls_itob_fl_sel_result LIKE TABLE OF  bapi_itob_fl_sel_result WITH HEADER LINE.
DATA:  es_bapi_itob LIKE TABLE OF bapi_itob WITH HEADER LINE.
*--------------------------------------------------------------------*
*--------------------------------------------------------------------*
SELECT-OPTIONS: s_equnr FOR gs_data-equipment,
                s_swerk FOR gs_data-maintplant.
PARAMETERS: p_file TYPE string LOWER CASE OBLIGATORY.

*--------------------------------------------------------------------*
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 select_data.

*--------------------------------------------------------------------*
END-OF-SELECTION.
*--------------------------------------------------------------------*
*  PERFORM process_data.
  IF gt_data[] IS INITIAL.
    WRITE:/ 'No se seleccionaron datos'.
    RETURN.
  ENDIF.

  PERFORM download.

*&---------------------------------------------------------------------*
*&      Form  select_data
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM select_data.

  CALL FUNCTION 'BAPI_EQUI_GETLIST'
    TABLES
      equipment_ra   = s_equnr
      maintplant_ra  = s_swerk
      equipment_list = gt_equipos.

  DATA: ls_data_general_exp  LIKE  bapi_itob,
        ls_data_specific_exp LIKE  bapi_itob_eq_only.
  DATA ld_monto TYPE  bapicurr-bapicurr.

  LOOP AT  gt_equipos INTO gs_equipos.
    CALL FUNCTION 'BAPI_EQUI_GETDETAIL'
      EXPORTING
        equipment         = gs_equipos-equipment
      IMPORTING
        data_general_exp  = ls_data_general_exp
        data_specific_exp = ls_data_specific_exp
*       DATA_FLEET_EXP    =
*       RETURN            =
      .

    MOVE-CORRESPONDING ls_data_general_exp TO gs_data.
    CALL FUNCTION 'BAPI_CURRENCY_CONV_TO_EXTERNAL'
      EXPORTING
        currency        = ls_data_general_exp-currency
        amount_internal = ls_data_general_exp-acquisval
      IMPORTING
        amount_external = ld_monto.

    MOVE ld_monto TO gs_data-acquisval.
    gs_data-read_supeq  = ls_data_specific_exp-read_supeq.
    gs_data-read_floc = ls_data_specific_exp-read_floc.
    gs_data-inst_pos  = ls_data_specific_exp-inst_pos.
    gs_data-equicatgry =   ls_data_specific_exp-equicatgry.
    gs_data-equipment = gs_equipos-equipment.

    APPEND gs_data TO gt_data.
  ENDLOOP.

ENDFORM.                    "select_data
*&---------------------------------------------------------------------*
*&      Form  download
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM download.

  PERFORM crear_header_2 USING gs_data CHANGING gt_header[].

  CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
      filename                = p_file
      filetype                = 'DAT'
    TABLES
      data_tab                = gt_data
      fieldnames              = gt_header
    EXCEPTIONS
      file_write_error        = 1
      no_batch                = 2
      gui_refuse_filetransfer = 3
      invalid_type            = 4
      no_authority            = 5
      unknown_error           = 6
      header_not_allowed      = 7
      separator_not_allowed   = 8
      filesize_not_allowed    = 9
      header_too_long         = 10
      dp_error_create         = 11
      dp_error_send           = 12
      dp_error_write          = 13
      unknown_dp_error        = 14
      access_denied           = 15
      dp_out_of_memory        = 16
      disk_full               = 17
      dp_timeout              = 18
      file_not_found          = 19
      dataprovider_exception  = 20
      control_flush_error     = 21
      OTHERS                  = 22.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ELSE.
    MESSAGE i000(fb) WITH 'Se genero archivo'
                          p_file.
  ENDIF.
ENDFORM.                    "download

*&---------------------------------------------------------------------*
*&      Form  crear_header
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM crear_header.

  CLEAR gt_header[].

  DATA: l_index(2) TYPE n,
        l_string   TYPE string,
        l_0033     TYPE p0033.
  FIELD-SYMBOLS <fs> TYPE any.
  DATA: descr_struc_ref TYPE REF TO cl_abap_structdescr,
        lt_components   TYPE abap_compdescr_tab,
        ls_components   LIKE LINE OF lt_components.
*descr_struc_ref ?= cl_abap_typedescr=>describe_by_name( gs_data ).
*lt_components = descr_struc_ref->components.
  DATA comp_tab TYPE abap_compdescr_tab.
  DATA stru_ref TYPE REF TO cl_abap_structdescr.
  DATA type_ref TYPE REF TO cl_abap_typedescr.
  DATA is_ddic TYPE abap_bool.
  DATA: lt_ddic TYPE dd_x031l_table,
        wa_ddic TYPE x031l,
        lt_fcat TYPE slis_t_fieldcat_alv,
        wa_fcat TYPE slis_fieldcat_alv,
        ls_layo TYPE slis_layout_alv,
        l_alv   TYPE REF TO cl_gui_alv_grid.

  DATA: one_comp TYPE abap_compdescr,
        one_name TYPE string.

  stru_ref ?= cl_abap_structdescr=>describe_by_data( gs_data ).

  comp_tab = stru_ref->components.

  FIELD-SYMBOLS <f3> TYPE any.
  DATA gd_field TYPE string.

  LOOP AT comp_tab INTO one_comp.
    CONCATENATE 'GS_DATA-' one_comp-name INTO gd_field.

    ASSIGN (gd_field) TO <f3>.

    type_ref ?= cl_abap_typedescr=>describe_by_data( <f3> ).
    is_ddic = type_ref->is_ddic_type( ).

    IF is_ddic = abap_true.
      lt_ddic = type_ref->get_ddic_object( ).

      LOOP AT lt_ddic INTO wa_ddic.
        CLEAR wa_ddic-tabname.
*        SELECT SINGLE
*        dd03l~tabname
*        INTO wa_ddic-tabname
*        FROM dd03l
*        WHERE dd03l~fieldname = wa_ddic-fieldname
*        AND dd03l~tabname NOT LIKE '/%'.

        SELECT SINGLE dd04t~scrtext_s
                      dd04t~scrtext_m
                      dd04t~scrtext_l
        INTO (wa_fcat-seltext_s, wa_fcat-seltext_m, wa_fcat-seltext_l) FROM dd04t
        WHERE dd04t~rollname = wa_ddic-fieldname
          AND dd04t~ddlanguage = sy-langu.

        APPEND wa_fcat TO lt_fcat.
        CONCATENATE wa_fcat-seltext_l wa_ddic-fieldname INTO gd_field  SEPARATED BY space.
        APPEND gd_field TO gt_header.
      ENDLOOP.
    ELSE.
      APPEND one_comp-name TO gt_header.
    ENDIF.

  ENDLOOP.

ENDFORM.                    "crear_header


*&---------------------------------------------------------------------*
*&      Form  read_text
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM read_text.

  DATA l_v_name TYPE thead-tdname.   " Declare l_v_name as this type
  DATA l_fs_line TYPE tline.
  DATA l_it_line LIKE TABLE OF l_fs_line.

  CONCATENATE gs_qpmk-mandt
              gs_qpmk-zaehler
              gs_qpmk-mkmnr
              gs_qpmk-version
              sy-langu INTO l_v_name RESPECTING BLANKS.

  REFRESH l_it_line.
  CALL FUNCTION 'READ_TEXT'     "get long text
    EXPORTING
      client   = sy-mandt
      id       = 'QPMT'
      language = sy-langu
      name     = l_v_name
      object   = 'QPMERKAL'
    TABLES
      lines    = l_it_line.

ENDFORM.                    "read_text

FORM crear_header_2 USING  VALUE(i_data)
                 CHANGING i_header TYPE ANY TABLE.
  DATA lt_text TYPE pt_t_text.
  DATA ls_text LIKE LINE OF lt_text.

  FIELD-SYMBOLS <wa>.
  ASSIGN i_data TO <wa>.

  DATA: l_index(2) TYPE n,
        l_string   TYPE string,
        l_0033     TYPE p0033.
  FIELD-SYMBOLS <fs> TYPE any.
  DATA: descr_struc_ref TYPE REF TO cl_abap_structdescr,
        lt_components   TYPE abap_compdescr_tab,
        ls_components   LIKE LINE OF lt_components.
*descr_struc_ref ?= cl_abap_typedescr=>describe_by_name( gs_data ).
*lt_components = descr_struc_ref->components.
  DATA comp_tab TYPE abap_compdescr_tab.
  DATA stru_ref TYPE REF TO cl_abap_structdescr.
  DATA type_ref TYPE REF TO cl_abap_typedescr.
  DATA is_ddic TYPE abap_bool.
  DATA: lt_ddic TYPE dd_x031l_table,
        wa_ddic TYPE x031l,
        lt_fcat TYPE slis_t_fieldcat_alv,
        wa_fcat TYPE slis_fieldcat_alv,
        ls_layo TYPE slis_layout_alv,
        l_alv   TYPE REF TO cl_gui_alv_grid.

  DATA: one_comp TYPE abap_compdescr,
        one_name TYPE string.

  stru_ref ?= cl_abap_structdescr=>describe_by_data( <wa> ).

  comp_tab = stru_ref->components.

  FIELD-SYMBOLS <f3> TYPE any.
  DATA gd_field TYPE string.

  LOOP AT comp_tab INTO one_comp.
    CONCATENATE '<WA>-' one_comp-name INTO gd_field.

    ASSIGN (gd_field) TO <f3>.

    type_ref ?= cl_abap_typedescr=>describe_by_data( <f3> ).
    is_ddic = type_ref->is_ddic_type( ).

    IF is_ddic = abap_true.
      lt_ddic = type_ref->get_ddic_object( ).

      LOOP AT lt_ddic INTO wa_ddic.
        CLEAR wa_ddic-tabname.

        SELECT SINGLE dd04t~scrtext_s
                      dd04t~scrtext_m
                      dd04t~scrtext_l
                INTO (wa_fcat-seltext_s, wa_fcat-seltext_m, wa_fcat-seltext_l) FROM dd04t
               WHERE dd04t~rollname = wa_ddic-fieldname
                 AND dd04t~ddlanguage = sy-langu.

        APPEND wa_fcat TO lt_fcat.
        CONCATENATE wa_fcat-seltext_l wa_ddic-fieldname INTO gd_field  SEPARATED BY space.
        APPEND gd_field TO lt_text.
      ENDLOOP.
    ELSE.
      APPEND one_comp-name TO lt_text.
    ENDIF.

  ENDLOOP.

  i_header[] = lt_text[].
ENDFORM.                    "crear_header