Cerca nel blog

lunedì 5 ottobre 2015

Programma Custom per Batch Input (ABMA)

Programma Custom per Batch Input (ABMA)

Questo è un programma custom che consente di elaborare la transazione ABMA con un batch input.

REPORT zf15_aa_carica_amm_cespiti.


TYPE-POOLS: slis, icon.

**---------- Dichiarazione Dati Globali ------------**
TYPES : BEGIN OF type_abma,
          societa           TYPE bukrs,
          cespite              TYPE anln1,
          dt_doc_char(10)   TYPE c,
          dt_doc            TYPE bldat,
          dt_reg_char(10)   TYPE c,
          dt_reg            TYPE budat,
          dt_rif            TYPE bzdat,
          dt_rif_char(10)   TYPE c,
          tipo_mov          TYPE bwasl,
          importo01_char(16)  TYPE c,
          importo01           TYPE btrab,
          importo02_char(16)  TYPE c,
          importo02           TYPE btrab,
          importo20_char(16)  TYPE c,
          importo20           TYPE btrab,
        END OF type_abma.

TYPES : BEGIN OF type_errori,
          id                LIKE icon-id,
          cespite(12)          TYPE c,
          descrizione(255)  TYPE c,
        END OF type_errori.

DATA: gv_dir             TYPE string,
      gv_error(1)        TYPE c,
      gv_file            LIKE rlgrap-filename,
      gv_nomefile(125)   TYPE c,
      gv_pathname        TYPE rstxtlg,
      gv_filename        TYPE rsawbnobjnm,
      gv_tab_interna     TYPE STANDARD TABLE OF type_abma,
      wa_dati_batch      TYPE type_abma,
      gt_elaborazione    TYPE STANDARD TABLE OF type_errori,
      gwa_elaborazione   TYPE type_errori.

data: BEGIN OF gt_tabin OCCURS 0,
        record TYPE string.
DATA: END OF gt_tabin.

*     Variabili Batch Input
DATA: bdcdata LIKE bdcdata    OCCURS 0 WITH HEADER LINE,
      messtab LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE,
      v_descr(255).

data: id_red    type icon-id,
      id_green  type icon-id.

PARAMETER: nodata DEFAULT '/' LOWER CASE NO-DISPLAY.          "nodata
*DATA ctumode LIKE ctu_params-dismode VALUE 'N'. "N
"A: show all dynpros
"E: show dynpro on error only
"N: do not display dynpro
DATA: cupdate LIKE ctu_params-updmode VALUE 'A',
"A: asincrono
"S: sincrono
      opt TYPE ctu_params.

**---------- Dichiarazione Costanti ------------**
CONSTANTS: gc_x(1)     TYPE c VALUE 'X'.

*======================================================================*
*                                DATA ALV                              *
*======================================================================*
DATA: gt_fieldcat TYPE slis_t_fieldcat_alv,
      alv_layout  TYPE slis_layout_alv.
     

**---------- Dichiarazione Parametri di Selezione ------------**
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: pfile_se LIKE rlgrap-filename MODIF ID ser DEFAULT '/',
            pfile_lo LIKE rlgrap-filename MODIF ID cli DEFAULT 'C:\'.

SELECTION-SCREEN: SKIP.

SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 40(10) text-003 FOR FIELD rb_loc.
PARAMETERS: rb_loc RADIOBUTTON GROUP rd1
            USER-COMMAND moda MODIF ID rd1
            DEFAULT 'X'.
SELECTION-SCREEN COMMENT 60(10) text-004 FOR FIELD rb_ser.
PARAMETERS: rb_ser RADIOBUTTON GROUP rd1
            MODIF ID rd1.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b2.

SELECTION-SCREEN: SKIP.

SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME.
PARAMETERS: p_mode(1) DEFAULT 'N'.
SELECTION-SCREEN END OF BLOCK b3.
SELECTION-SCREEN END OF BLOCK b1.





**---------- AT SELECTION SCREEN  ------------**
* Caricamento file locale
AT SELECTION-SCREEN ON VALUE-REQUEST FOR pfile_lo.
  PERFORM ricerca_file_locale.

* Caricamento file server
AT SELECTION-SCREEN ON VALUE-REQUEST FOR pfile_se.
  PERFORM ricerca_file_server.

**---------- AT SELECTION SCREEN OUTPUT  ------------**
AT SELECTION-SCREEN OUTPUT.
  PERFORM nascondi_campi.

**---------- START SELECTION SCREEN ------------**
START-OF-SELECTION.
  PERFORM clear.
  PERFORM carica_file.
  IF gv_error NE gc_x AND NOT gt_tabin[] IS INITIAL.
    PERFORM estrai_dati.
  ENDIF.

  IF NOT gv_tab_interna[] IS INITIAL.
    CLEAR: wa_dati_batch.
    LOOP AT gv_tab_interna INTO wa_dati_batch.
      PERFORM elabora_batch USING wa_dati_batch.
    ENDLOOP.
  ENDIF.

  IF NOT gt_elaborazione[] IS INITIAL.
    SORT gt_elaborazione BY id.
    perform visualizza_output.
  ENDIF.


*&---------------------------------------------------------------------*
*&      Form  RICERCA_FILE_LOCALE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_PFILE_LO  text
*----------------------------------------------------------------------*
FORM ricerca_file_locale.
  DATA: va_window_title     TYPE string,
        initial_dir_path    TYPE string,
        l_filetab           TYPE filetable,
        l_rc                TYPE i,
        wa_filetable        TYPE LINE OF filetable.
  va_window_title = 'Seleziona file'.
  initial_dir_path = 'C:\'.
  CLEAR: wa_filetable.
  REFRESH l_filetab.
  CALL METHOD cl_gui_frontend_services=>file_open_dialog
    EXPORTING
      window_title            = va_window_title
      file_filter             = '*.*'
      initial_directory       = initial_dir_path
      multiselection          = space
    CHANGING
      file_table              = l_filetab
      rc                      = l_rc
      EXCEPTIONS
        file_open_dialog_failed = 1
        cntl_error              = 2
        error_no_gui            = 3
        not_supported_by_gui    = 4
        OTHERS                  = 5.
  IF sy-subrc = 0.
    READ  TABLE l_filetab INDEX 1 INTO wa_filetable.
    pfile_lo = wa_filetable-filename.
  ENDIF.


ENDFORM.                    " RICERCA_FILE_LOCALE

*&---------------------------------------------------------------------*
*&      Form  RICERCA_FILE_SERVER
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_PFILE_SE  text
*----------------------------------------------------------------------*
FORM ricerca_file_server.

  CALL FUNCTION '/SAPDMC/LSM_F4_SERVER_FILE'
   EXPORTING
     directory              = gv_dir
     filemask               = '*.*'
   IMPORTING
     serverfile             = pfile_se
   EXCEPTIONS
     canceled_by_user       = 1
     OTHERS                 = 2.

  IF sy-subrc <> 0.
  ENDIF.
ENDFORM.                    " RICERCA_FILE_SRVER
*&---------------------------------------------------------------------*
*&      Form  NASCONDI_CAMPI
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM nascondi_campi .
  LOOP AT SCREEN.
    IF NOT rb_ser IS INITIAL.
      CASE screen-group1.
        WHEN 'SER'.
          IF pfile_se IS INITIAL.
            pfile_se = '/'.
          ENDIF.
          screen-active = '1'.
        WHEN 'CLI'.
          screen-active = '0'.
      ENDCASE.
      MODIFY SCREEN.
    ENDIF.

    IF NOT rb_loc IS INITIAL.
      CASE screen-group1.
        WHEN 'SER'.
          screen-active = '0'.
        WHEN 'CLI'.
          IF pfile_lo IS INITIAL.
            pfile_lo = 'C:\'.
          ENDIF.
          screen-active = '1'.
      ENDCASE.
      MODIFY SCREEN.
    ENDIF.
  ENDLOOP.
ENDFORM.                    " NASCONDI_CAMPI
*&---------------------------------------------------------------------*
*&      Form  CARICA_FILE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM carica_file .
  DATA: upload_file TYPE string,
        lv_exit,
        lv_importo(20).

  CLEAR: upload_file, lv_exit, lv_importo.

*Se il caricamento del file avviene da PC locale
  IF rb_loc = gc_x.
    IF NOT pfile_lo  IS INITIAL.
      upload_file = pfile_lo.

      CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        filename                = upload_file
        filetype                = 'ASC'
      TABLES
        data_tab                = gt_tabin
      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 'S' NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        gv_error = gc_x.
      ENDIF.

      gv_file = pfile_lo.
    ELSE.
      gv_error = gc_x.
      MESSAGE s002(zf15_aa_cespiti).
    ENDIF.

  ELSE.
*Se il caricamento del file avviene da Server
    OPEN DATASET pfile_se FOR INPUT IN TEXT MODE
                                 ENCODING NON-UNICODE.

    IF sy-subrc = 0.
      WHILE lv_exit IS INITIAL.
        READ DATASET pfile_se INTO gt_tabin-record.
        IF gt_tabin IS INITIAL.
          lv_exit = gc_x.
        ELSE.
          APPEND gt_tabin.
        ENDIF.
      ENDWHILE.
      CLOSE DATASET pfile_se.
      gv_file = pfile_se.
    ELSE.
      MESSAGE s001(zf15_aa_cespiti).
      gv_error = gc_x.
    ENDIF.
  ENDIF.

  IF gv_error NE gc_x.

    CALL FUNCTION 'RSDS_SPLIT_PATH_TO_FILENAME'
      EXPORTING
        i_filepath = gv_file
      IMPORTING
        e_pathname = gv_pathname
        e_filename = gv_filename.

    gv_nomefile = gv_filename.
    TRANSLATE gv_nomefile TO UPPER CASE.
  ENDIF.

ENDFORM.                    " CARICA_FILE
*&---------------------------------------------------------------------*
*&      Form  CLEAR
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM clear .
  CLEAR: gv_dir, gv_error, gv_file,
         gt_tabin, gv_error, gv_pathname,
         gv_filename, gv_nomefile,
         gt_elaborazione, gwa_elaborazione,
         gt_fieldcat, alv_layout.
  REFRESH: gt_tabin, gv_tab_interna,
           gt_elaborazione,
           gt_fieldcat.

  SELECT SINGLE id FROM icon INTO id_red
   WHERE name = 'ICON_RED_LIGHT' .

  SELECT SINGLE id FROM icon INTO id_green
   WHERE name = 'ICON_GREEN_LIGHT' .

ENDFORM.                    " CLEAR
*&---------------------------------------------------------------------*
*&      Form  ESTRAI_DATI
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM estrai_dati.
  DATA: wa_tab_interna TYPE type_abma.

  LOOP AT gt_tabin.
* La prima riga del file excel, cioè l'intestazione non la considero.
    IF sy-tabix > 1.
      CLEAR: wa_tab_interna.
      SPLIT gt_tabin-record AT ';'
            INTO  wa_tab_interna-societa
                  wa_tab_interna-cespite
                  wa_tab_interna-dt_doc_char
                  wa_tab_interna-dt_reg_char
                  wa_tab_interna-dt_rif_char
                  wa_tab_interna-tipo_mov
                  wa_tab_interna-importo01_char
                  wa_tab_interna-importo02_char
                  wa_tab_interna-importo20_char.

      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
        EXPORTING
          input  = wa_tab_interna-cespite
        IMPORTING
          output = wa_tab_interna-cespite.

      PERFORM converti_data USING wa_tab_interna-dt_doc_char
                            CHANGING wa_tab_interna-dt_doc.

      PERFORM converti_data USING wa_tab_interna-dt_reg_char
                            CHANGING wa_tab_interna-dt_reg.

      PERFORM converti_data USING wa_tab_interna-dt_rif_char
                            CHANGING wa_tab_interna-dt_rif.

      PERFORM converti_importo USING  wa_tab_interna-importo01_char
                               CHANGING  wa_tab_interna-importo01.
      wa_tab_interna-importo01_char = wa_tab_interna-importo01.
      REPLACE '.' WITH ',' INTO wa_tab_interna-importo01_char.
      CONDENSE wa_tab_interna-importo01_char NO-GAPS.

      PERFORM converti_importo USING  wa_tab_interna-importo02_char
                               CHANGING  wa_tab_interna-importo02.
      wa_tab_interna-importo02_char = wa_tab_interna-importo02.
      REPLACE '.' WITH ',' INTO wa_tab_interna-importo02_char.
      WRITE wa_tab_interna-importo02_char
         TO wa_tab_interna-importo02_char
         RIGHT-JUSTIFIED.

      PERFORM converti_importo USING  wa_tab_interna-importo20_char
                               CHANGING  wa_tab_interna-importo20.
      wa_tab_interna-importo20_char = wa_tab_interna-importo20.
      REPLACE '.' WITH ',' INTO wa_tab_interna-importo20_char.
      WRITE wa_tab_interna-importo20_char
         TO wa_tab_interna-importo20_char
         RIGHT-JUSTIFIED.

      APPEND wa_tab_interna TO gv_tab_interna.
    ENDIF.
  ENDLOOP.

  CLEAR:gt_tabin.
  FREE: gt_tabin.
ENDFORM.                    " ESTRAI_DATI

*&---------------------------------------------------------------------*
*&      Form  CONVERTI_IMPORTO
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_WA_TAB_INTERNA_IMPORTO01_CHAR  text
*      <--P_WA_TAB_INTERNA_IMPORTO01  text
*----------------------------------------------------------------------*
FORM converti_importo  USING    p_importo01_char
                       CHANGING p_importo01.

  DATA: lv_char_importo  TYPE type_abma-importo01_char.
  CLEAR: p_importo01.
  lv_char_importo = p_importo01_char.
  IF NOT lv_char_importo IS INITIAL.
    REPLACE '.' WITH ' ' INTO lv_char_importo.
    CONDENSE lv_char_importo NO-GAPS.
    REPLACE ',' WITH '.' INTO lv_char_importo.
    CONDENSE lv_char_importo NO-GAPS.
    MOVE lv_char_importo TO p_importo01.
  ENDIF.

ENDFORM.                    " CONVERTI_IMPORTO

*&---------------------------------------------------------------------*
*&      Form  CONVERTI_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_WA_TAB_INTERNA_DT_DOC_CHAR  text
*      <--P_WA_TAB_INTERNA_DT_DOC  text
*----------------------------------------------------------------------*
FORM converti_data  USING    p_dt_doc_char
                    CHANGING p_dt_doc.

  DATA: lv_dt_doc_char(10) TYPE c. "Formato DD.MM.YYYY

  lv_dt_doc_char = p_dt_doc_char.
  CLEAR p_dt_doc.
  IF NOT p_dt_doc_char IS INITIAL.
    CONCATENATE lv_dt_doc_char+6(4)
                lv_dt_doc_char+3(2)
                lv_dt_doc_char(2)
           INTO p_dt_doc.
  ENDIF.

ENDFORM.                    " CONVERTI_DATA

*&---------------------------------------------------------------------*
*&      Form  ELABORA_BATCH
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM elabora_batch USING pwa_dati_batch.
  DATA: lv_bukrs          TYPE type_abma-societa,
        lv_anln1          TYPE type_abma-cespite,
        lv_anln2          TYPE anbz-anln2,
        lv_doc_char       TYPE type_abma-dt_doc_char,
        lv_rif_char       TYPE type_abma-dt_rif_char,
        lv_reg_char       TYPE type_abma-dt_reg_char,
        lv_tipo_mov       TYPE anbz-bwasl,
        lv_periodo        TYPE anbz-perid,
        lv_importo01      TYPE type_abma-importo01_char,
        lv_importo02      TYPE type_abma-importo02_char,
        lv_importo20      TYPE type_abma-importo20_char,
        lv_dati_batch     TYPE type_abma.

  CLEAR: bdcdata.
  REFRESH: bdcdata.
  lv_dati_batch = pwa_dati_batch.
  lv_bukrs    = lv_dati_batch-societa.
  lv_anln1    = lv_dati_batch-cespite.
  lv_anln2    = 0.
  lv_doc_char = lv_dati_batch-dt_doc_char.
  lv_reg_char = lv_dati_batch-dt_reg_char.
  lv_rif_char = lv_dati_batch-dt_rif_char.
  lv_tipo_mov = lv_dati_batch-tipo_mov.
  lv_importo01 = lv_dati_batch-importo01_char.
  lv_importo02 = lv_dati_batch-importo02_char.
  lv_importo20 = lv_dati_batch-importo20_char.

  CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
    EXPORTING
      input  = lv_tipo_mov
    IMPORTING
      output = lv_tipo_mov.

  WRITE lv_tipo_mov TO lv_tipo_mov RIGHT-JUSTIFIED.
  lv_periodo  = lv_dati_batch-dt_doc_char+3(2).

  CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
    EXPORTING
      input  = lv_periodo
    IMPORTING
      output = lv_periodo.

  PERFORM bdc_dynpro      USING 'SAPMA01B' '0100'.
  PERFORM bdc_field       USING 'BDC_CURSOR'
                                'ANBZ-BWASL'.
  PERFORM bdc_field       USING 'BDC_OKCODE'
                                '/00'.
  PERFORM bdc_field       USING 'ANBZ-BUKRS'
                                lv_bukrs.
  PERFORM bdc_field       USING 'ANBZ-ANLN1'
                                lv_anln1.
  PERFORM bdc_field       USING 'ANBZ-ANLN2'
                                lv_anln2.
  PERFORM bdc_field       USING 'ANEK-BLDAT'
                                lv_doc_char.
  PERFORM bdc_field       USING 'ANEK-BUDAT'
                                lv_reg_char.
  PERFORM bdc_field       USING 'ANBZ-PERID'
                                lv_periodo.
  PERFORM bdc_field       USING 'ANBZ-BWASL'
                                lv_tipo_mov.
  PERFORM bdc_dynpro      USING 'SAPMA01B' '0110'.
  PERFORM bdc_field       USING 'BDC_CURSOR'
                                'ANBZ-DMBTR'.
  PERFORM bdc_field       USING 'BDC_OKCODE'
                                '/00'.
  PERFORM bdc_field       USING 'ANBZ-DMBTR'
                                lv_importo01.
  PERFORM bdc_field       USING 'ANBZ-BZDAT'
                                lv_rif_char.
  PERFORM bdc_dynpro      USING 'SAPMA01B' '0285'.
  PERFORM bdc_field       USING 'BDC_CURSOR'
                                'ANEP-ANBTR'.
  PERFORM bdc_field      USING 'BDC_OKCODE'
                                '=AUSF'.
  PERFORM bdc_field       USING 'ANEP-ANBTR'
                                lv_importo02.
  PERFORM bdc_dynpro      USING 'SAPMA01B' '0285'.
  PERFORM bdc_field       USING 'BDC_CURSOR'
                                'ANEP-ANBTR'.
  PERFORM bdc_field       USING 'BDC_OKCODE'
                                '=AUSF'.
  PERFORM bdc_field       USING 'ANEP-ANBTR'
                                lv_importo20.
  PERFORM bdc_dynpro      USING 'SAPMA01B' '0110'.
  PERFORM bdc_field       USING 'BDC_CURSOR'
                                'ANBZ-DMBTR'.
  PERFORM bdc_field       USING 'BDC_OKCODE'
                                '=UPDA'.

  PERFORM richiamo_transazione USING 'ABMA' lv_anln1.

ENDFORM.                    " ELABORA_BATCH
*&---------------------------------------------------------------------*
*&      Form  RICHIAMO_TRANSAZIONE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_0767   text
*----------------------------------------------------------------------*
FORM richiamo_transazione  USING  p_tcode
                                  p_cespite.
  DATA: wa_t100       TYPE t100,
        lv_descr(255) TYPE c.

* batch input session
  opt-dismode = p_mode.
  opt-defsize = ' '.
  opt-updmode = cupdate.
  opt-racommit = 'X'.

  CLEAR: lv_descr, wa_t100, messtab,
          gwa_elaborazione.

  REFRESH: messtab.
  gwa_elaborazione-id = id_green.

  CALL TRANSACTION p_tcode USING bdcdata
                    OPTIONS FROM opt
                   MESSAGES INTO messtab.

  READ TABLE messtab WITH KEY msgtyp = 'E'.
  IF sy-subrc = 0.
    SELECT SINGLE * FROM t100
         INTO wa_t100
         WHERE sprsl = 'I'
           AND msgnr = messtab-msgnr
           AND arbgb = messtab-msgid.

    IF sy-subrc = 0.
      MESSAGE ID messtab-msgid
              TYPE messtab-msgtyp
              NUMBER messtab-msgnr
              WITH messtab-msgv1 messtab-msgv2
                   messtab-msgv3 messtab-msgv4
              INTO lv_descr.

      gwa_elaborazione-id = id_red.
    ELSE.
      READ TABLE messtab INDEX 1.
      SELECT SINGLE * FROM t100
          INTO wa_t100
          WHERE sprsl = 'I'
            AND msgnr = messtab-msgnr
            AND arbgb = messtab-msgid.
      IF sy-subrc = 0.
        MESSAGE ID messtab-msgid
                TYPE messtab-msgtyp
                NUMBER messtab-msgnr
                WITH messtab-msgv1 messtab-msgv2
                     messtab-msgv3 messtab-msgv4
                INTO lv_descr.
        gwa_elaborazione-id = id_red.
      ENDIF.
    ENDIF.
  ELSE.
    READ TABLE messtab WITH KEY msgtyp = 'S'.
    IF sy-subrc = 0.
      SELECT SINGLE * FROM t100
           INTO wa_t100
          WHERE sprsl = 'I'
            AND msgnr = messtab-msgnr
            AND arbgb = messtab-msgid.

      IF sy-subrc = 0.
        MESSAGE ID messtab-msgid
                TYPE messtab-msgtyp
                NUMBER messtab-msgnr
                WITH messtab-msgv1 messtab-msgv2
                     messtab-msgv3 messtab-msgv4
                INTO lv_descr.
      ENDIF.
    ENDIF.
  ENDIF.

*  CONCATENATE p_cespite ': '  lv_descr INTO lv_descr.
  gwa_elaborazione-cespite = p_cespite.
  gwa_elaborazione-descrizione = lv_descr.
  APPEND gwa_elaborazione TO gt_elaborazione.

*  WRITE: / lv_descr.
ENDFORM.                    " RICHIAMO_TRANSAZIONE

*&---------------------------------------------------------------------*
*&      Form  BDC_DYNPRO
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_0627   text
*      -->P_0628   text
*----------------------------------------------------------------------*
FORM bdc_dynpro USING program dynpro.
  CLEAR bdcdata.
  bdcdata-program  = program.
  bdcdata-dynpro   = dynpro.
  bdcdata-dynbegin = 'X'.
  APPEND bdcdata.
ENDFORM.                    " BDC_DYNPRO
*&---------------------------------------------------------------------*
*&      Form  BDC_FIELD
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_0632   text
*      -->P_0633   text
*----------------------------------------------------------------------*
FORM bdc_field USING fnam fval.
  DATA: cfval(132) TYPE c.
  cfval = fval.
  IF cfval <> nodata.
    CLEAR bdcdata.
    bdcdata-fnam = fnam.
    bdcdata-fval = fval.
    APPEND bdcdata.
  ENDIF.
ENDFORM.                    " BDC_FIELD

*&---------------------------------------------------------------------*
*&      Form  VISUALIZZA_OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM visualizza_output .
  PERFORM fill_fieldcat CHANGING gt_fieldcat.
  PERFORM fill_layout CHANGING alv_layout.
  PERFORM output_list.
ENDFORM.                    " VISUALIZZA_OUTPUT

*&---------------------------------------------------------------------*
*&      Form  FILL_FIELDCAT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      <--P_GT_FIELDCAT  text
*----------------------------------------------------------------------*
FORM fill_fieldcat  CHANGING p_alv_fieldcat TYPE slis_t_fieldcat_alv.

  DATA: ls_fieldcat TYPE slis_fieldcat_alv.
  CLEAR: p_alv_fieldcat.
  refresh: p_alv_fieldcat.

  CLEAR ls_fieldcat.
  ls_fieldcat-fieldname = 'ID'.
  ls_fieldcat-tabname = 'GT_ELABORAZIONE'.
  ls_fieldcat-reptext_ddic = 'Esito'.
  ls_fieldcat-outputlen = '05'.
  APPEND ls_fieldcat TO p_alv_fieldcat.

  CLEAR ls_fieldcat.
  ls_fieldcat-fieldname = 'CESPITE'.
  ls_fieldcat-tabname = 'GT_ELABORAZIONE'.
  ls_fieldcat-reptext_ddic = 'Cespite'.
  ls_fieldcat-outputlen = '12'.
  APPEND ls_fieldcat TO p_alv_fieldcat.

  CLEAR ls_fieldcat.
  ls_fieldcat-fieldname = 'DESCRIZIONE'.
  ls_fieldcat-tabname = 'GT_ELABORAZIONE'.
  ls_fieldcat-reptext_ddic = 'Descrizione.'.
  ls_fieldcat-outputlen = '255'.
  APPEND ls_fieldcat TO p_alv_fieldcat.

ENDFORM.                    " FILL_FIELDCAT

*&---------------------------------------------------------------------*
*&      Form  FILL_LAYOUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      <--P_ALV_LAYOUT  text
*----------------------------------------------------------------------*
FORM fill_layout CHANGING p_alv_layout TYPE  slis_layout_alv.
  p_alv_layout-detail_popup      = 'X'.
  p_alv_layout-detail_initial_lines = 'X'.
  p_alv_layout-get_selinfos         = 'X'.
ENDFORM.                    " FILL_LAYOUT
*&---------------------------------------------------------------------*
*&      Form  OUTPUT_LIST
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM output_list .
data: gv_repid  type sy-repid.

    gv_repid = sy-repid.

  CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
      i_callback_program      = gv_repid
      is_layout               = alv_layout
      it_fieldcat             = gt_fieldcat[]
      i_save                  = 'A'
    TABLES
      t_outtab                = gt_elaborazione
    EXCEPTIONS
      program_error           = 1
      OTHERS                  = 2.
ENDFORM.                    " OUTPUT_LIST

 

Nessun commento:

Posta un commento