Saving Word documents from ABAP

program ytrans.
 
******************************************************************
* TABLE DECLARATIONS.
******************************************************************
tables: e070, e07t.
 
data:  display type c,
       exit type c,
       ok_code like sy-ucomm,
       lo_form type ref to ytform,
       lf_test type ref to ytform,
       l_template type string value 'block',
       l_num type i,
       isource type table of string,
       xsource type t_source.
 
selection-screen begin of block standard.
select-options: p_skorr    for e070-strkorr,
                p_user     for e070-as4user no intervals default sy-uname,
                p_date     for e070-as4date.
selection-screen skip.
 
selection-screen end of block standard.
 
start-of-selection.
  types: begin of t_reqs,
    sel,
    strkorr like e070-strkorr,
    as4text like e07t-as4text,
    as4user like e070-as4user,
    as4date like e070-as4date,
  end of t_reqs.
 
  data: lt_reqs type standard table of t_reqs,
        wa_reqs type t_reqs. "like line of lt_reqs. "work area (header line)"
  select * from e070 inner join e07t on e070~strkorr eq e07t~trkorr
    into corresponding fields of table lt_reqs where e070~trkorr in p_skorr[] and
    e070~as4user in p_user[] and e070~as4date in p_date[] and e070~trstatus eq 'R'.
 
  xsource = '1.'. append xsource to isource.
  xsource = '2.'. append xsource to isource.
  xsource = '3.'. append xsource to isource.
  xsource = '4.'. append xsource to isource.
end-of-selection.
 
  perform alv_grid_display.
 
*&---------------------------------------------------------------------*
*&      Form  alv_grid_display
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
form alv_grid_display.
  type-pools: slis.
  data: it_fieldcat  type slis_t_fieldcat_alv,
        wa_fieldcat  type slis_fieldcat_alv,
        fs_layout type slis_layout_alv.
  fs_layout-box_fieldname = 'SEL'.
  fs_layout-zebra = 'X'.
 
  wa_fieldcat-fieldname  = 'STRKORR'.
  wa_fieldcat-seltext_m  = 'Номер запроса'.
  append wa_fieldcat to it_fieldcat.
  wa_fieldcat-fieldname  = 'AS4TEXT'.
  wa_fieldcat-seltext_m  = 'Описание'.
  append wa_fieldcat to it_fieldcat.
  wa_fieldcat-fieldname  = 'AS4USER'.
  wa_fieldcat-seltext_m  = 'Имя пользователя'.
  append wa_fieldcat to it_fieldcat.
  wa_fieldcat-fieldname  = 'AS4DATE'.
  wa_fieldcat-seltext_m  = 'Дата'.
  append wa_fieldcat to it_fieldcat.
 
  call function 'REUSE_ALV_GRID_DISPLAY'
    exporting
      it_fieldcat              = it_fieldcat
      is_layout                = fs_layout
      i_callback_program       = sy-repid
      i_callback_pf_status_set = 'SET_GUI_STATUS'
      i_callback_user_command  = 'COMMANDS_HANDLER'
    tables
      t_outtab                 = lt_reqs
    exceptions
      program_error            = 1
      others                   = 2.
endform.                    "alv_grid_display
*&---------------------------------------------------------------------*
*&      Form  set_gui_stat
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->RT_EXTAB   text
*----------------------------------------------------------------------*
form set_gui_status using rt_extab type slis_t_extab.
  set pf-status 'YSTATUS' excluding rt_extab.
  set titlebar text-005.
endform.                    "set_gui_status
 
*&---------------------------------------------------------------------*
*&      Form  STAT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->R_UCOMM      text
*      -->RS_SELFIELD  text
*----------------------------------------------------------------------*
form commands_handler using r_ucomm like sy-ucomm
rs_selfield type slis_selfield.
  data selfield type slis_selfield.
  data lt_sel type standard table of t_reqs.
  case r_ucomm.
    when 'QUIT'.
      leave program.
    when 'SELE'.
      delete lt_reqs where sel ne 'X'.
      set pf-status ''.
      call screen 0100.
  endcase.
endform.                    "STAT
 
*----------------------------------------------------------------------*
*  MODULE status_0100 OUTPUT
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
module status_0100 output.
  "class CL_ABAP_CHAR_UTILITIES definition load.
  data: io_text type string,
        lv_username type string,
        header_date type string,
        lv_commalist type string,
        lv_reqlist type string,
        lv_reqtext type string,
        lv_teststeps type string.
 
  field-symbols: <fs> like line of lt_reqs,
                 <fsi> like line of isource.
 
  case sy-ucomm.
    when 'TESTS'.
      editor-call for isource.
    when 'EXIT'.
      leave program.
    when 'GENERATE'.
      loop at lt_reqs assigning <fs> .
        concatenate <fs>-strkorr lv_reqlist into lv_reqlist separated by ';'.
        lv_reqtext = <fs>-strkorr && cl_abap_char_utilities=>horizontal_tab &&
                      <fs>-as4text && cl_abap_char_utilities=>cr_lf && lv_reqtext.
        lv_commalist = |{ <fs>-strkorr }, { lv_commalist }|.
      endloop.
 
      shift lv_reqlist right deleting trailing ';'. shift lv_reqlist left deleting leading space.
      shift lv_commalist right deleting trailing ', '.
 
      select single name_text from user_addrp into lv_username where bname = sy-uname.
      concatenate sy-datum+6(2) sy-datum+4(2) sy-datum(4) into header_date separated by '.'.
 
      sort isource descending.
      loop at isource assigning <fsi> .
        lv_teststeps = <fsi> && cl_abap_char_utilities=>horizontal_tab &&
                      lv_teststeps && cl_abap_char_utilities=>cr_lf.
      endloop.
 
      create object
        lo_form
        exporting
          i_template = 'Y_TRMAIN'.
 
      lo_form->replicate(
       i_template_id = l_template
       i_copy_num = 2
      ).
 
      lo_form->prep_seq_access( ).
      if lo_form->find_variable('header_date') eq abap_true.
        lo_form->set_value( header_date ).
      endif.
      if lo_form->find_variable('header_num') eq abap_true.
        lo_form->set_value( lv_commalist ).
      endif.
      if lo_form->find_variable('source_client') eq abap_true.
        lo_form->set_value( sy-mandt && space && sy-sysid ).
      endif.
      if lo_form->find_variable('dest_client') eq abap_true.
        lo_form->set_value('300 [PEW]').
      endif.
      if lo_form->find_variable('sec_nums') eq abap_true.
        lo_form->set_value( lv_commalist ).
      endif.
      if lo_form->find_variable('trans_list') eq abap_true.
        lo_form->set_value( lv_reqtext ).
      endif.
      if lo_form->find_variable('special') eq abap_true.
        lo_form->set_value( io_text ).
      endif.
      if lo_form->find_variable('owna') eq abap_true.
        lo_form->set_value( lv_username ).
      endif.
      lo_form->finish_seq_access( ).
      lo_form->clean( ).
 
      lo_form->display( sy-datum && '_' && lv_reqlist ).
 
      create object
        lf_test
        exporting
          i_template = 'Y_TESTS'.
 
      lf_test->replicate(
       i_template_id = l_template
       i_copy_num = 2
      ).
 
      lf_test->prep_seq_access( ).
      if lf_test->find_variable('header_date') eq abap_true.
        lf_test->set_value( header_date ).
      endif.
      if lf_test->find_variable('trans_list') eq abap_true.
        lf_test->set_value( lv_reqtext ).
      endif.
      if lf_test->find_variable('sec_nums') eq abap_true.
        lf_test->set_value( lv_commalist ).
      endif.
      if lf_test->find_variable('test_sys') eq abap_true.
        lf_test->set_value( 'TES310' ).
      endif.
      if lf_test->find_variable('test_steps') eq abap_true.
        lf_test->set_value( lv_teststeps ).
      endif.
      if lf_test->find_variable('special') eq abap_true.
        lf_test->set_value( io_text ).
      endif.
      if lf_test->find_variable('owna') eq abap_true.
        lf_test->set_value( lv_username ).
      endif.
      lf_test->finish_seq_access( ).
      lf_test->clean( ).
 
      lf_test->display( sy-datum && '_' && lv_reqlist && '_ПТ').
      leave program.
  endcase.
endmodule.                 " STATUS_0100  OUTPUT

Schreibe einen Kommentar



All fields are required. Your email address will not be published.