SAP Bilgi Merkezi
Ana Sayfa  ABAP   FI   CO   MM   SD   PP   QM   HR   BW 
ABAP Destek
Batch Input
Batch Input SAP de var olan standart programlara veri girişi yapabilmek için oluşturulmuş bir otomatik veri giriş sistemidir. Program içerisinden uygun parametreler ile CALL TRANSACTION komutu ile yapılır. 3 farklı mode ile yapılabilir:
  • 'A' - Tum adımları göster.
  • 'E' - Sadece hata mesajlarını göster.
  • 'N' - Hiçbirşey gösterme.
İki farklı update modu ile yapılır:
  • 'S' - Verilerin kaydedilmesini bekle.
  • 'A' - Verilerin kaydedilmesini bekleme.

    Örnek Batch input programı:
*-----------------------------------------------------------------------
* ABAP Name  : ZYAV_BATCHINPUT
* Created by : Yavuz KOMUT
* Created on : 19.04.2006
* Version    : 1.3
*
* Transactions called : ZYAV01
* Modifications       :
* Recorder            : SHDB
*-----------------------------------------------------------------------

REPORT zyav_batchinput .

TYPE-POOLS: slis .

*************************** Constants *****************************

CONSTANTS: gc_alv_item_table TYPE slis_tabname  VALUE 'GT_ALV',
      gc_program_name LIKE sy-repid VALUE 'ZYAV_BATCHINPUT',
      gc_title LIKE sy-title VALUE 'MM: Veri Giriş Ekranı.',
      gc_structure_name LIKE dd02l-tabname VALUE 'ZYAV_BIALV'.

****************************** Data *******************************
DATA: gt_flcat  TYPE slis_t_fieldcat_alv,
      gt_layout TYPE slis_layout_alv,
      gt_event  TYPE slis_t_event.

DATA: gf_flcat LIKE LINE OF gt_flcat,
      gf_event LIKE LINE OF gt_event.

****************************** Data *******************************
DATA: gv_default_folder(128) TYPE c VALUE 'C:\'.

************************* Internal Tables *************************
DATA: BEGIN OF gt_bdctab OCCURS 0.
        INCLUDE STRUCTURE bdcdata.
DATA: END OF gt_bdctab.

DATA: BEGIN OF gt_tab OCCURS 0,
        check(1) TYPE c,
        firmasehir(10) TYPE c,
        firmatarih(8) TYPE c,
        firmatelefon(11) TYPE c,
        firmaadi(10) TYPE c,
        kullaniciadi(10) TYPE c,
        sifre(10) TYPE c,
        email(10) TYPE c,
        telefon(10) TYPE c,
      END OF gt_tab.

************************ Selection Screen *************************
SELECTION-SCREEN BEGIN OF BLOCK m1 WITH FRAME TITLE text-001.
PARAMETERS : p_fname LIKE rlgrap-filename DEFAULT 'C:\deneme.txt'.
SELECTION-SCREEN END OF BLOCK m1.

*********************** At Selection Screen ***********************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fname.
  PERFORM value_request_filename USING p_fname.

*********************** Start of selection ************************
START-OF-SELECTION.
  PERFORM get_data.

END-OF-SELECTION .
  PERFORM show_data .

*&---------------------------------------------------------------------*
*&      Form  get_data
*&---------------------------------------------------------------------*
FORM get_data .

  CALL FUNCTION 'WS_UPLOAD'
    EXPORTING
      filename = p_fname
      filetype = 'DAT'
    TABLES
      data_tab = gt_tab.

  IF sy-subrc <> 0.
    WRITE: / 'Dosya Okunamadı'.
  ENDIF.

ENDFORM.                    " get_data
*&---------------------------------------------------------------------*
*&      Form  value_request_filename
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_P_FNAME  text
*----------------------------------------------------------------------*
FORM value_request_filename  USING    p_p_fname.

  CALL FUNCTION 'WS_FILENAME_GET'
    EXPORTING
      def_filename     = ''
      def_path         = gv_default_folder
      mask             = ',*.*,*.*.'
      mode             = 'O'
      title            = 'Mesaj'
    IMPORTING
      filename         = p_p_fname
    EXCEPTIONS
      inv_winsys       = 01
      no_batch         = 02
      selection_cancel = 03
      selection_error  = 04.

ENDFORM.                    " value_request_filename
*&---------------------------------------------------------------------*
*&      Form  start_batch
*&---------------------------------------------------------------------*
FORM start_batch.

  PERFORM open_group_bdc USING 'ZYAV001'.

  LOOP AT gt_tab WHERE check = 'X' .
    REFRESH gt_bdctab.
    CLEAR gt_bdctab.
    PERFORM dynpro USING :
                       'X' 'ZYAV_GENELDENEME'         '1000',
                       ' ' 'FIRMASHR'      gt_tab-firmasehir,
                       ' ' 'FIRMATRH'      gt_tab-firmatarih,
                       ' ' 'FIRMATLF'      gt_tab-firmatelefon,
                       ' ' 'FIRMAADI'      gt_tab-firmaadi,
                       ' ' 'KULLAAD'       gt_tab-kullaniciadi,
                       ' ' 'SIFRE'         gt_tab-sifre,
                       ' ' 'EMAIL'         gt_tab-email,
                       ' ' 'TELEFON'       gt_tab-telefon,
                       ' ' 'BDC_OKCODE'       '=ONLI'.

    PERFORM run_bi_session USING 'ZYAV01'.
    CLEAR gt_tab.
  ENDLOOP.

  PERFORM close_group_bdc.

  WRITE : 'Sistem problemsiz çalıştı.' .

ENDFORM.                    " start_batch
*&---------------------------------------------------------------------*
*&      Form  dynpro
*&---------------------------------------------------------------------*
FORM dynpro USING dynbegin name value.

  CLEAR gt_bdctab.
  IF dynbegin = 'X'.
    MOVE:  name  TO gt_bdctab-program,
           value TO gt_bdctab-dynpro,
           'X'   TO gt_bdctab-dynbegin.
  ELSE.
    MOVE:  name  TO gt_bdctab-fnam,
           value TO gt_bdctab-fval.
  ENDIF.
  APPEND gt_bdctab.

ENDFORM.                    " dynpro
*&---------------------------------------------------------------------*
*&      Form  open_group_bdc
*&---------------------------------------------------------------------*
FORM open_group_bdc USING p_group.

  CALL FUNCTION 'BDC_OPEN_GROUP'
    EXPORTING
      group = p_group
      user  = sy-uname.

ENDFORM.                    " open_group_bdc
*&---------------------------------------------------------------------*
*&      Form  insert_bdc
*&---------------------------------------------------------------------*
FORM insert_bdc USING  p_tcode.

  CALL FUNCTION 'BDC_INSERT'
    EXPORTING
      tcode     = p_tcode
    TABLES
      dynprotab = gt_bdctab.

ENDFORM.                    " insert_bdc
*&---------------------------------------------------------------------*
*&      Form  close_group_bdc
*&---------------------------------------------------------------------*
FORM close_group_bdc.

  CALL FUNCTION 'BDC_CLOSE_GROUP'.

ENDFORM.                    " close_group_bdc
*&---------------------------------------------------------------------*
*&      Form  run_bi_session
*&---------------------------------------------------------------------*
FORM run_bi_session USING lv_tcode.

  CALL TRANSACTION lv_tcode USING gt_bdctab
                            MODE 'N'.

ENDFORM.                    " run_session
*&---------------------------------------------------------------------*
*&      Form  show_data
*&---------------------------------------------------------------------*
FORM show_data.

  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
      i_program_name         = gc_program_name
      i_internal_tabname     = gc_alv_item_table
      i_client_never_display = 'X'
      i_inclname             = gc_program_name
      i_structure_name       = gc_structure_name
    CHANGING
      ct_fieldcat            = gt_flcat
    EXCEPTIONS
      inconsistent_interface = 1
      program_error          = 2
      OTHERS                 = 3.

* Görüntüleme Özellikleri.
  gt_layout-zebra                = 'X'.
  gt_layout-window_titlebar      = gc_title.
  gt_layout-colwidth_optimize    = 'X'.
  gt_layout-box_fieldname        = 'CHECK'.
  gt_layout-box_tabname          = 'GT_ALV'.

* Event Tanımları.
  gf_event-name = 'PF_STATUS_SET'.
  gf_event-form = 'ALV_STATUS'.
  APPEND gf_event TO gt_event.

  gf_event-name = 'USER_COMMAND'.
  gf_event-form = 'ALV_COMMAND'.
  APPEND gf_event TO gt_event.


* Listeleme.
  CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
       EXPORTING
            it_fieldcat             = gt_flcat
            i_callback_program      = gc_program_name
*            i_callback_user_command = 'user_command'
            i_save                  = 'A'
            is_layout               = gt_layout
            it_events               = gt_event
       TABLES
            t_outtab                = gt_tab.

ENDFORM.                    " show_data

*&---------------------------------------------------------------------*
*&      Form  ALV_STATUS
*&---------------------------------------------------------------------*
FORM alv_status USING x.

  SET PF-STATUS '0100'.

ENDFORM.                    "alv_status
**&---------------------------------------------------------------------
**&      Form  alv_command
**&---------------------------------------------------------------------
FORM alv_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.

  CASE r_ucomm.
    WHEN 'BBB'.
      PERFORM start_batch .
  ENDCASE.

ENDFORM.                    "alv_status-1
ABAP Destek
SAP Chain
SAP NetWeaver
ticket sistemimize katılın ve ücretsiz
10 adam gün kazanın >>
 Ana Sayfa  |  ABAP  |  FI  |  CO  |  MM  |  SD  |  PP  |  QM  |  HR  |  BW 
ykomut@gmail.com