Shared Top Border

Enterprise Resource
Planning Portal

 

Advertise | Founder BLOG

ERPGenie.COM ABAP Tips and Tricks Database

THE ultimate
ERP website

 

Forums | Vote for us |

Google    Other Search Options

Login

Login to view more content!!!





Lost Password?
No account yet? Register

Registered Access

Poll

What area of ABAP are you interested in?
 
Home arrow Utilities arrow ABAP Utilities arrow Auto Import program
Auto Import program PDF Print E-mail
User Rating: / 0
PoorBest 
Written by Shawn Franks   
Wednesday, 25 July 2007

Performs automated forwarding and import of transports.Gets last run value from database index, gets delta from last import, forwards those to the buffer of the target system specified, and imports them.

 Schedule this report to run in the background in your Quality environment.

report z_auto_import message-id z01.

*---------------------------------------------------------------------*

* Program Z_AUTO_IMPORT

*---------------------------------------------------------------------*

* Performs automated forwarding and import of transports

*  Gets last run value from database index, gets delta from last import,

*   forwards those to the buffer of the target system specified, and

*   imports them.

*---------------------------------------------------------------------*

 

include ZU_AUTO_IMPORT_TOP.     "Global data

 

selection-screen begin of block whr with frame title text-s01.

parameters: p_tpsys  like  tmscsys-sysnam default 'DV' obligatory,

            p_tgtsys like  tmscsys-sysnam default 'QA' obligatory,

            p_tarcli like  tmsbuffer-tarcli default '300'.

selection-screen end of block whr.

 

selection-screen begin of block wht with frame title text-s02.

parameters: p_forwrd as checkbox,

            p_import as checkbox,

            p_setlst as checkbox.

selection-screen end of block wht.

 

selection-screen begin of block how with frame title text-s03.

parameters:  p_doit   as checkbox,

            p_ignore as checkbox,

            p_force as checkbox,

            p_again as checkbox. "TYPE  STMS_FLAG.

selection-screen end of block how.

 

include ZU_AUTO_IMPORT_F01.     "Forms

include ZU_AUTO_IMPORT_M01.     "Modules.

 

 

*-----------------------------------------------------------------------

* Start-of-selection

*-----------------------------------------------------------------------

start-of-selection.

 

* Build id for last_run parameter

  concatenate c_buffer_pre p_tpsys p_tgtsys into v_buffer.

  clear okcode.

  perform get_last_buffer_no.

  perform read_transport_queue.

 

end-of-selection.

*-----------------------------------------------------------------------

 

  if p_doit = 'X'.

    perform forward_new_requests.

    perform import_requests.

  endif.


*----------------------------------------------------------------------*

*   INCLUDE ZU_AUTO_IMPORT_TOP                                         *

*----------------------------------------------------------------------*

 

tables: indx.

 

type-pools:   stms.                         " TMS types

 

data: yt_buffer   like tmsbuffer   occurs 0 with header line.

data: xt_buffer   type stms_tr_requests.

data: xt_counter  like tmsbufcnt   occurs 0 with header line.

data: xt_requests type stms_tr_requests.

data: yt_requests like tmsbuffer   occurs 0 with header line.

data: xt_request like tmsbuffer-trkorr.

 

data: curr_buff like yt_buffer-bufpos.

data: p_cntnly.

data: collect_date like sy-datum,

      collect_time like sy-uzeit,

      collect_flag,

      cnt_only_flag.

 

data: begin of last_buffer,

       date    like sy-datum,

       counter like tmsbufcnt-counter,

       time like sy-uzeit,

      end of last_buffer.

 

data: new_buffer like last_buffer.

data: v_buffer(25).

data  okcode like sy-ucomm.

 

data: xv_tp_ret_code      like      stpa-retcode      ,

      xv_tp_alog          like      stpa-file         ,

      xv_tp_slog          like      stpa-file         ,

      xv_tp_pid           like      stpa-pid          ,

      xv_tpstat_key       type      tmstpkey          ,

      xs_exception        like      stmscalert        ,

      xt_tp_imports       type      stms_tp_imports   ,

 

begin of  yt_tp_imports occurs 0,

         request        type stms_tr_request,

         tp_ret_code    like stpa-retcode,

         tp_alog        like stpa-file,

         tp_slog        like stpa-file,

         tp_pid         like stpa-pid,

         tp_stdout      like tpstdout occurs 0,

         tp_logptr      like tplogptr occurs 0,

         alert          like stmscalert,

       end   of yt_tp_imports.

 

constants: c_some like tmsbuffer-trkorr value 'SOME'.

constants: c_buffer_pre(20) value 'TMS_BUFFER_LV_'.

constants: c_save like sy-ucomm value 'SAVE'.


*----------------------------------------------------------------------*

*   INCLUDE ZU_AUTO_IMPORT_M01                                         *

*----------------------------------------------------------------------*

 

*&---------------------------------------------------------------------*

*&      Module  STATUS_0101  OUTPUT

*&---------------------------------------------------------------------*

module status_0101 output.

  set pf-status '0101'.

  clear okcode.

  if last_buffer is initial.

    get time field last_buffer-time.

    move sy-datum to last_buffer-date.

  endif.

 

 

endmodule.                 " STATUS_0101  OUTPUT

 

 

*&---------------------------------------------------------------------*

*&      Module  USER_COMMAND_0101  INPUT

*&---------------------------------------------------------------------*

module user_command_0101 input.

 

  okcode = sy-ucomm.

  case okcode.

    when 'BACK'.

      set screen 0.

      leave screen.

    when 'SAVE'.

      perform set_last_buffer_no.

      set screen 0.

      leave screen.

    when others.

      message i007.

  endcase.

 

endmodule.                 " USER_COMMAND_0101  INPUT


*----------------------------------------------------------------------*

*   INCLUDE ZU_AUTO_IMPORT_F01                                         *

*----------------------------------------------------------------------*

 

*&---------------------------------------------------------------------*

*&      Form  set_last_buffer_no

*&---------------------------------------------------------------------*

form set_last_buffer_no.

 

  if p_setlst is initial and okcode = c_save.

    get time field last_buffer-time.

    last_buffer-date = sy-datum.

    last_buffer-counter = xt_counter-total.

  endif.

 

  if okcode = c_save.

    export last_buffer to database indx(zu) id v_buffer.

    if sy-subrc = 0.

      message i008 with

              last_buffer-counter

              last_buffer-date

              last_buffer-time.

    endif.

  endif.

 

endform.                    " set_last_buffer_no

 

*&---------------------------------------------------------------------*

*&      Form  read_transport_queue

*&---------------------------------------------------------------------*

form read_transport_queue.

 

  call function 'TMS_MGR_READ_TRANSPORT_QUEUE'

    exporting

      iv_system                = p_tpsys

    iv_collect_data          = 'X'

      iv_count_only            = p_cntnly

      iv_verbose               = 'X'

    tables

      tt_buffer                = yt_buffer

      tt_counter               = xt_counter

    exceptions

      read_config_failed       = 1

      others                   = 2

            .

  if sy-subrc <> 0.

    message id sy-msgid type 'I' number sy-msgno

            with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

  else.

 

  endif.

 

endform.                    " read_transport_queue

 

*&---------------------------------------------------------------------*

*&      Form  forward_new_requests

*&---------------------------------------------------------------------*

form forward_new_requests.

 

  sort yt_buffer by bufpos.

 

  xt_buffer[] = yt_buffer[].

  read table yt_buffer with key bufpos = last_buffer-counter.

 

  if sy-subrc = 0.

    curr_buff = yt_buffer-bufpos + 1.

  else.

    message w007 with last_buffer-counter.

  endif.

 

  append lines of xt_buffer from curr_buff to xt_requests.

  yt_requests[] = xt_requests[].

 

  if p_forwrd = 'X'.

 

    call function 'TMS_MGR_FORWARD_TR_REQUEST'

      exporting

        iv_request                       = c_some

        iv_target                        = p_tgtsys

      iv_tarcli                        = p_tarcli

        it_requests                      = xt_requests

      exceptions

        read_config_failed               = 1

        table_of_requests_is_empty       = 2

        others                           = 3

              .

    if sy-subrc <> 0.

      message id sy-msgid type 'I' number sy-msgno

              with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    endif.

  endif.

 

endform.                    " forward_new_requests

 

*&---------------------------------------------------------------------*

*&      Form  import_requests

*&---------------------------------------------------------------------*

form import_requests.

 

  if p_import = 'X'.

    loop at yt_requests.

      xt_request = yt_requests-trkorr.

      call function 'TMS_MGR_IMPORT_TR_REQUEST'

        exporting

      iv_system                        = p_tgtsys

      iv_request                       = xt_request

      iv_client                        = p_tarcli

      iv_import_again                  = p_again

      IV_IGNORE_ORIGINALITY            = p_ignore

      IV_FORCE                         = p_force

       importing

        ev_tp_ret_code                   = xv_tp_ret_code

        ev_tp_alog                       = xv_tp_alog

        ev_tp_slog                       = xv_tp_slog

        ev_tp_pid                        = xv_tp_pid

        ev_tpstat_key                    = xv_tpstat_key

        es_exception                     = xs_exception

        et_tp_imports                    = xt_tp_imports

        exceptions

          read_config_failed               = 1

          table_of_requests_is_empty       = 2

          others                           = 3

                .

      if sy-subrc <> 0.

        message i014 with yt_tp_imports-request-trkorr

                          yt_tp_imports-tp_ret_code

                          sy-subrc.                       .

 

      else.

        yt_tp_imports[] = xt_tp_imports.

        loop at yt_tp_imports.

          case yt_tp_imports-tp_ret_code.

            when 0.

            message i013 with 'Successful'

                            yt_tp_imports-request-trkorr

                            yt_tp_imports-tp_ret_code.

            when 4.

            message i013 with  'Warning'

                            yt_tp_imports-request-trkorr

                            yt_tp_imports-tp_ret_code.

            when others.

            message i013 with   'Error'

                            yt_tp_imports-request-trkorr

                            yt_tp_imports-tp_ret_code.

            endcase.

        endloop.

 

      endif.

 

      write: / yt_tp_imports-request-trkorr,

               yt_tp_imports-tp_ret_code,

               xs_exception-SYSNAM,

               xs_exception-CLIENT,

               xs_exception-FUNCTION,

               xs_exception-ERROR,

               xs_exception-SEVERITY,

               xs_exception-TEXT,

             / yt_tp_imports-request-trkorr,

               xs_exception-MSGID,

               xs_exception-MSGTY,

               xs_exception-MSGNO,

               xs_exception-MSGV1.

 

    endloop.

 

    read table xt_counter index 1.

    okcode = c_save.

    perform set_last_buffer_no.

 

  endif.

endform.                    " import_requests

 

 

*&---------------------------------------------------------------------*

*&      Form  get_last_buffer_no

*&---------------------------------------------------------------------*

form get_last_buffer_no.

  import last_buffer from database indx(zu) id v_buffer.

  if sy-subrc ne 0 or p_setlst = 'X'.

    message i006(zu01) with v_buffer.

    if sy-batch = space.

      perform set_last_run_default.

    else.

      message e012.

      exit.

    endif.

  endif.

 

endform.                    " get_last_buffer_no

 

*&---------------------------------------------------------------------*

*&      Form  set_last_run_default

*&---------------------------------------------------------------------*

form set_last_run_default.

 

  data answer.

 

  call function 'POPUP_TO_DECIDE'

    exporting

      textline1               = text-i01

      text_option1            = 'Yes'

      text_option2            = 'No'

      titel                   = text-t01

    importing

      answer                  = answer.

 

  case answer.

 

    when '1'.

      call screen 101.

    when '2'.

      stop.

    when others.

 

  endcase.

 

endform.                    " set_last_run_default

 


Related Items:

 
< Prev   Next >

Google Search

Statistics

Contribution Activity
Utilities: 38
Tips and Tricks: 333
Sample Code: 164
Total Contributions: 550

Member Activity
Members: 6175 since 2/1/2007!
New: 6 since yesterday!
Visitors: 1008729
We have 2 guests and 1 member online
  • t.veerendra

Newest Members

Welcome our newest members:

Google Ads

Shared Bottom Border

Contact Us | Polls | Add URL | Contribute | Privacy | Terms | Feedback

Discussion Forum | BLOG | Consultants: Post your resume | Companies: Advertise on ERPGenie.COM | Post Job
Financials Consultant | Consultant Review | Gallia Consulting | Supply Chain Project | SAP Financials Forum
GenieHoldings.COM, Inc. | Genie Press | WorkflowGenie | ESAGenie | ERPTopSites | ABAP Tips and Tricks | SAP Solutions Database

EDIGenie | Searching Survivor