Event in not triggered in parallel processing

Hello ABAP community,
i am playing around with ABAP OO and doing my first lessons in parallel processing. I am trying to comibine parallel processing (CALL FUNCTION STARTING NEW TASK) with the ABAP OO concept of events.
The idea is to create many instances of a class (RECEIVER_CLASS) and call them in parallel. I want to catch the result of each CALL with the RECEIVE statement and trigger an event to inform the caller class about the finished function/class. In this case a method RESULT is called. I want to access the data of the event via the implicit parameter SENDER (according to online documentation).
Here you can find a simple report. The event seems to be triggerd but the method RESULT will never be called.
REPORT  zcra_parallel2.
*       CLASS receiver_class DEFINITION
CLASS receiver_class DEFINITION.
  PUBLIC SECTION.
    METHODS:
      start IMPORTING value(i_taskname) TYPE char8,
      receiver1 IMPORTING value(p_task) TYPE clike.
    <b>EVENTS:
      finished.</b>
ENDCLASS.                    "receiver_class DEFINITION
*       CLASS receiver_class IMPLEMENTATION
CLASS receiver_class IMPLEMENTATION.
  METHOD start.
    CALL FUNCTION 'ZZ_CRA1' STARTING NEW TASK i_taskname
      CALLING me->receiver1 ON END OF TASK
      EXPORTING
        mytask = i_taskname.
    IF sy-subrc = 0.
      WRITE: /, i_taskname, ' TASK started...'.
    ENDIF.
  ENDMETHOD.   "start
  METHOD receiver1.
    DATA:
      myinfo TYPE TABLE OF zcra1.
    RECEIVE RESULTS FROM FUNCTION 'ZZ_CRA1'
      TABLES my_itab = myinfo.
    <b>RAISE EVENT finished.</b>
  ENDMETHOD.                                                "receiver1
ENDCLASS.                    "receiver_class IMPLEMENTATION
*       CLASS x DEFINITION
CLASS caller DEFINITION.
  PUBLIC SECTION.
    DATA:
      y_ref TYPE REF TO receiver_class,
      z_ref TYPE REF TO receiver_class.
    METHODS:
      constructor,
      <b>result FOR EVENT finished OF receiver_class.</b>
ENDCLASS.                    "callerx DEFINITION
*       CLASS callerx IMPLEMENTATION
CLASS caller IMPLEMENTATION.
  METHOD constructor.
    SET HANDLER: me->result FOR ALL INSTANCES.
    CREATE OBJECT: y_ref, z_ref.
    CALL METHOD y_ref->start( 'WAIT1' ).
    CALL METHOD z_ref->start( 'WAIT2' ).
  ENDMETHOD.                    "constructor
  <b>METHOD result.
    WRITE: /, 'EVENT TRIGGERD!'.
  ENDMETHOD.</b>                    "result
ENDCLASS.                    "callerx IMPLEMENTATION
DATA:
  mycaller TYPE REF TO caller.
START-OF-SELECTION.
  CREATE OBJECT mycaller.
Thanks for any help!

Here is the sample program that I'm working with.  I took your code and changed some things in order to get it working on my system(46c).   Maybe this will help you.
report zrich_0003 .
data:    session(1) type c.
data:    event_fired(1) type c.
*       CLASS receiver_class DEFINITION
class receiver_class definition.
  public section.
    methods:     trigger_event,
                 start importing value(i_taskname) type char8,
                 receiver1 importing value(p_task) type c .
    events:      finished.
endclass.
*       CLASS receiver_class IMPLEMENTATION
class receiver_class implementation.
  method start.
    data: messtab type table of bdcmsgcoll,
          bdcdata type table of bdcdata .
    call function 'ABAP4_CALL_TRANSACTION' starting new task i_taskname
*      calling me->receiver1 on end of task
       performing reciever on end of task
        exporting        mytask = i_taskname
                 tcode                         = 'SM50'
                 mode_val                      = 'N'
                 update_val                    = 'S'
               tables
                 using_tab                     = bdcdata
                 mess_tab                      = messtab.
    wait until session = 'X'.
*    if sy-subrc = 0.
*      write: / i_taskname, ' TASK started...'.
*    endif.
  endmethod.   "start
  method receiver1.
*    data: myinfo type table of zcra1.
*    receive results from function 'ABAP4_CALL_TRANSACTION'
*   tables
*      mess_tab              = messtab.
*    raise event finished.
  endmethod.
  method trigger_event.
    raise event finished.
  endmethod.
endclass.
*       CLASS caller DEFINITION
class caller definition.
  public section.
*    data: y_ref type ref to receiver_class,
*          z_ref type ref to receiver_class.
    methods:
    constructor,
    result for event finished of  receiver_class.
endclass.
*       CLASS caller IMPLEMENTATION
class caller implementation.
  method constructor.
    set  handler: me->result for all instances.
*    create object: y_ref, z_ref.
*    call method y_ref->start( 'WAIT1' ).
*    call method z_ref->start( 'WAIT2' ).
  endmethod.
  method result.
    event_fired = 'X'.
  endmethod.
endclass.
data: y_ref type ref to receiver_class,
      z_ref type ref to receiver_class.
data: mycaller type ref to caller.
start-of-selection.
  create object mycaller.
  create object: y_ref, z_ref.
  call method y_ref->start( 'ZRICH2' ).
  write:/ 'Event Fired:', event_fired.
*       FORM reciever                                                 *
*  -->  TASKNAME                                                      *
form reciever using taskname.
  data: messtab type table of bdcmsgcoll.
  receive results from function 'ABAP4_CALL_TRANSACTION'
       tables
          mess_tab              = messtab.
  session = 'X'.
  call method y_ref->trigger_event.
endform.
Regards,
Rich Heilman

Similar Messages

  • Top-of-page event is not triggered

    Hi,
    I have a problem with top-of-page event. I have a report that shows the results in ALV grid display. But I use "REUSE_ALV_GRID_DISPLAY" not OO alv and there is only one screen with number 1000. On the menu toolbar there is a button that prints the data of ALV in a list using "write" statement. While writing , "top of page" event is not triggered. I expect that it is triggered at the first "write" statement but isn't. Is there anyone who knows the cause of this problem?
    The code is below.
    Thanks.
    Tables ...
    TABLES : mara , makt , ekko , ekpo , zzith_yukh , lfa1 , t001w  , lips ,
             eket .
    global variables
    DATA : BEGIN OF list OCCURS 1,
           zztahsk LIKE ekko-zztahsk ,
           zterm LIKE ekko-zterm ,
           txz01 LIKE ekpo-txz01 ,
           name1 LIKE lfa1-name1 ,
           menge LIKE ekpo-menge ,
           meins LIKE ekpo-meins ,
           fyukl LIKE zzith_yukh-zzdel_flag ,
                             " Yüklenmi&#351; miktar var göstergesi ...
           inco1 LIKE ekko-inco1 ,
           netwr LIKE ekpo-netwr ,
           waers LIKE ekko-waers ,
           bedat LIKE ekko-bedat ,
           zzontar LIKE ekko-zzontar ,
           slfdt LIKE eket-slfdt ,
           tname1 LIKE t001w-name1 ,
           banfn LIKE ekpo-banfn ,
           ebeln LIKE ekko-ebeln ,
           ebelp LIKE ekpo-ebelp ,
           lifnr LIKE ekko-lifnr ,
           mtart LIKE mara-mtart ,
           matkl LIKE mara-matkl ,
           ekgrp LIKE ekko-ekgrp ,
           matnr LIKE mara-matnr ,
           eknam  LIKE t024-eknam,
           bukrs  LIKE ekko-bukrs,
           zzbltur LIKE ekko-zzbltur,
           END   OF list         .
    DATA temp  LIKE list OCCURS 1 WITH HEADER LINE .
    DATA total LIKE list OCCURS 1 WITH HEADER LINE .
    ALV fields
    TYPE-POOLS : slis.
    DATA : gt_fields TYPE  slis_fieldcat_alv OCCURS 1 WITH HEADER LINE .
    DATA : gt_events TYPE  slis_t_event.
    DATA : gs_layout TYPE  slis_layout_alv.
    DATA : gv_title  TYPE lvc_title VALUE 'Günlük Depo Say&#305;m Miktarlar&#305;'.
    DATA : gt_top_of_page TYPE slis_t_listheader.
    selection screen
    SELECTION-SCREEN BEGIN OF BLOCK a WITH FRAME TITLE text-001 .
    *Sat&#305;nalma organizasyonu
    *Sat&#305;nalma grubu
    *Sat&#305;c&#305;
    *Tarih
    *SAS no
    *Dosya no
    SELECT-OPTIONS:
    s_bukrs FOR ekko-bukrs .
    SELECTION-SCREEN SKIP .
    SELECT-OPTIONS:
    s_ekorg FOR  ekko-ekorg OBLIGATORY MEMORY ID eko ,
    s_ekgrp FOR  ekko-ekgrp ,
    s_lifnr FOR  ekko-lifnr ,
    s_ebeln FOR  ekko-ebeln .
    SELECTION-SCREEN END  OF BLOCK a        .
    Define Katalog
    DEFINE fill_catalog .
      gt_fields-fieldname  = &1.
      gt_fields-tabname    = &2.
      gt_fields-seltext_l  = &3.
      gt_fields-seltext_m  = &3.
      gt_fields-seltext_s  = &3.
      gt_fields-checkbox   = &4.
      gt_fields-cfieldname = &5.
      gt_fields-ref_tabname  = &6.
      gt_fields-ref_fieldname  = &7.
      gt_fields-edit       = &8.
      append gt_fields .
      clear gt_fields .
    END-OF-DEFINITION.
    Modify Catalog
    DEFINE modify_catalog .
      gt_fields-seltext_m = &1 .
      modify gt_fields  transporting seltext_m where fieldname = &2 .
    END-OF-DEFINITION     .
    TOP-OF-PAGE.
      write 'top of page'.
      PERFORM top-of-page.
    start-of-selection
    START-OF-SELECTION .
      PERFORM get_data.
      PERFORM listele .
    *&      Form  listele .
    FORM listele .
      PERFORM get_events .
      PERFORM alv_list_header.
      PERFORM get_field_catalog USING 'LIST' .
      PERFORM display_alv    .
    ENDFORM.                    " listele.
    *&      Form  getfield_Catalog
    FORM get_field_catalog  USING p_tabname .
      fill_catalog :
    'EBELN'   'LIST' '' '' '' 'EKPO' 'EBELN'   '' ,
    'ZZTAHSK' 'LIST' '' '' '' 'EKKO' 'ZZTAHSK' '' ,
    'ZZBLTUR' 'LIST' '' '' '' 'EKKO' 'ZZBLTUR' '' ,
    'MATNR'   'LIST' '' '' '' 'MARA' 'MATNR'   '' ,
    'MATKL'   'LIST' '' '' '' 'MARA' 'MATKL'   '' ,
    'TXZ01'   'LIST' '' '' '' 'EKPO' 'TXZ01'   '' ,
    'NAME1'   'LIST' '' '' '' 'LFA1' 'NAME1'   '' ,
    'MENGE'   'LIST' '' '' '' 'EKPO' 'MENGE'   '' ,
    'MEINS'   'LIST' '' '' '' 'EKPO' 'MENGE'   '' ,
    'FYUKL'   'LIST' '' '' '' 'ZZITH_YUKH' 'ZZDEL_FLAG'   '' ,
    'INCO1'   'LIST' '' '' '' 'EKKO' 'INCO1'   '' ,
    'NETWR'   'LIST' '' '' '' 'EKPO' 'NETWR'   '' ,
    'WAERS'   'LIST' '' '' '' 'EKKO' 'WAERS'   '' ,
    'BEDAT'   'LIST' '' '' '' 'EKKO' 'BEDAT'   '' ,
    'ZZONTAR' 'LIST' '' '' '' 'EKKO' 'ZZONTAR' '' ,
    'SLFDT'   'LIST' '' '' '' 'EKET' 'SLFDT'   '' ,
    'TNAME1'  'LIST' '' '' '' 'T001W' 'NAME1'  '' ,
    'BANFN'   'LIST' '' '' '' 'EKPO' 'BANFN'   '' ,
    'EKNAM'   'LIST' '' '' '' 'T024' 'EKNAM'   '' .
      gt_fields-ddictxt = 'M' .
      MODIFY gt_fields  TRANSPORTING ddictxt WHERE fieldname NE space.
      modify_catalog 'Yükleme No'            'VBELN'   .
      modify_catalog 'Malzeme Türü'          'ZZBLTUR' .
      modify_catalog 'Malzeme Tan&#305;m&#305;'        'TXZ01'   .
      modify_catalog 'Sat&#305;c&#305;'                'NAME1'   .
      modify_catalog 'Teslim &#350;ekli'          'INCO1'   .
      modify_catalog 'Döviz Tutar&#305;'          'ZZTOPLAM'.
      modify_catalog 'Döviz Kodu'            'WAERS'   .
      modify_catalog 'Sipari&#351;i Veren'        'TNAME1'  .
      modify_catalog 'Tahmini &#304;thalat Trh.'  'SLFDT'   .
      modify_catalog '&#304;thalata &#304;ntikal Trh.' 'BEDAT'   .
      modify_catalog 'Dosya Onay Tarihi'     'ZZONTAR' .
      modify_catalog 'Talep No'              'BANFN'   .
      modify_catalog 'Dosya Sorumlusu'       'EKNAM'   .
      modify_catalog 'Yük.Göstergesi'        'FYUKL'   .
    ENDFORM.                    " getfield_Catalog
    *&      Form  display_alv
          text
    -->  p1        text
    <--  p2        text
    FORM display_alv .
      DATA lv_repid LIKE sy-repid .
      lv_repid = sy-repid .
      CLEAR gs_layout.
      gs_layout-zebra                 = 'X'.
      gs_layout-colwidth_optimize     = 'X'.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program       = lv_repid
          i_callback_pf_status_set = 'SET_PF_STATUS'
          i_callback_user_command  = 'USER_COMMAND'
          is_layout                = gs_layout
          it_fieldcat              = gt_fields[]
          it_events                = gt_events[]
        TABLES
          t_outtab                 = list[].
    ENDFORM.                    " display_alv
    FORM set_pf_status USING  iv_nodisplay TYPE slis_t_extab.
      SET PF-STATUS 'STANDARD' ."excluding iv_nodisplay.
    ENDFORM.                    " SET_PF_STATUS
    FORM user_command  USING iv_ucomm LIKE sy-ucomm
                      rs_selfield TYPE slis_selfield.
      CASE iv_ucomm .
        WHEN 'PRINT'  . PERFORM print_data .
      ENDCASE       .
    ENDFORM.                    "USER_COMMAND
    FORM get_events .
      DATA: ls_event TYPE slis_alv_event.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type = 0
        IMPORTING
          et_events   = gt_events.
      READ TABLE gt_events WITH KEY name = slis_ev_top_of_page
                               INTO ls_event.
      IF sy-subrc = 0.
        MOVE 'ALV_TOP_OF_PAGE' TO ls_event-form.
        APPEND ls_event TO gt_events.
      ENDIF.
    ENDFORM.                    " getevents
    FORM alv_list_header .
      DATA: ls_line TYPE slis_listheader.
      CLEAR ls_line.
      ls_line-typ  = 'S'.
      ls_line-key  = 'Sat&#305;nalma Org.:'.
      CONCATENATE s_ekorg-low s_ekorg-high
      INTO ls_line-info SEPARATED BY '/'.
      APPEND ls_line TO gt_top_of_page.
      ls_line-key  = 'Sat&#305;nalma Grubu.:'.
      CONCATENATE s_ekgrp-low s_ekgrp-high
      INTO ls_line-info SEPARATED BY '/'.
      APPEND ls_line TO gt_top_of_page.
      ls_line-key  = 'Sat&#305;c&#305;.:'.
      CONCATENATE s_lifnr-low s_lifnr-high
      INTO ls_line-info SEPARATED BY '/'.
      APPEND ls_line TO gt_top_of_page.
      ls_line-key  = 'SAS No.:'.
      CONCATENATE s_ebeln-low s_ebeln-high
      INTO ls_line-info SEPARATED BY '/'.
      APPEND ls_line TO gt_top_of_page.
    ENDFORM.                    " alv_list_header
    FORM alv_top_of_page.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary = gt_top_of_page.
    ENDFORM.                    "TOP_OF_PAGE
    FORM get_data .
      DATA : BEGIN OF tr ,
              menge LIKE eket-menge ,
              dabmg LIKE eket-dabmg ,
             END OF tr ,
             zzfiilytar LIKE zzith_yukh-zzfiilytar  .
    *- Get data ...
      SELECT *
        INTO CORRESPONDING FIELDS OF TABLE list
        FROM ekpo AS a
       INNER JOIN ekko AS b ON bebeln = aebeln
      WHERE b~ebeln IN s_ebeln AND
            b~bukrs IN s_bukrs AND
            b~loekz EQ space   AND
            b~lifnr IN s_lifnr AND
            b~ekorg IN s_ekorg AND
            b~ekgrp IN s_ekgrp AND
            a~loekz EQ space   AND
            a~elikz EQ space .
      LOOP AT list .
        CLEAR tr .
        SELECT menge dabmg
          INTO tr
          FROM eket
         WHERE ebeln = list-ebeln AND
               ebelp = list-ebelp.
          tr-menge = tr-menge - tr-dabmg .
        ENDSELECT.
        IF tr-menge LE 0 .
          DELETE list .
        ELSE .
          list-menge = tr-menge .
          IF tr-dabmg GT 0 .
            list-fyukl = '*' .
          ENDIF .
          SELECT SINGLE butxt INTO list-tname1 FROM t001
            WHERE bukrs = list-bukrs .
          SELECT SINGLE slfdt INTO list-slfdt FROM eket
          WHERE ebeln = list-ebeln AND
                ebelp = list-ebelp .
          SELECT SINGLE name1 INTO list-name1 FROM lfa1 WHERE lifnr = list-lifnr.
          SELECT SINGLE mtart matkl INTO (list-mtart,list-matkl)
          FROM mara WHERE matnr = list-matnr .
          SELECT SINGLE eknam INTO list-eknam FROM t024 WHERE ekgrp = list-ekgrp .
          MODIFY list .
        ENDIF .
      ENDLOOP      .
    ENDFORM.                    " get_data
    FORM print_data .
      LEAVE TO LIST-PROCESSING .
      NEW-PAGE NO-HEADING NO-TITLE LINE-SIZE 229 .
      SET PF-STATUS SPACE .
    PERFORM top-of-page .
    malzeme türü 1005 ler yazd&#305;r&#305;l&#305;r
      PERFORM yazdir_1005 .
    malzeme türü 1005 olmayanlar yazd&#305;r&#305;l&#305;r
      PERFORM yazdir_ne_1005 .
    Sat&#305;nalama gruplar&#305; bilgisi yazd&#305;r&#305;l&#305;r
      PERFORM yazdir_ekgrp .
    ENDFORM.                    " print_data
    FORM top-of-page .
      WRITE : 'ÜLKER GRUBU KONSOL&#304;DE' .
      WRITE AT 40 'Sevkiyat Bekleyen Malzemeler' COLOR COL_HEADING .
      WRITE :  180 sy-uname , sy-datum , sy-uzeit.
      NEW-LINE .
      ULINE 0(229) .
      WRITE :/2 'Rapor Kodu..............:' , (10) sy-tcode .
      WRITE :/2 'Sat&#305;nalma Organizasyonu.:' , (10) s_ekorg-low, '/', (10) s_ekorg-high .
      WRITE :/2 'Sat&#305;nalma Grubu.........:' , (10) s_ekgrp-low, '/', (10) s_ekgrp-high .
      WRITE :/2 'Sat&#305;c&#305;..................:' , (10) s_lifnr-low, '/', (10) s_lifnr-high .
      WRITE :/2 'Sat&#305;nalma Sipari&#351; No....:' , (10) s_ebeln-low, '/', (10) s_ebeln-high .
      NEW-LINE .
      ULINE 0(229) .
    Ba&#351;l&#305;klar yaz&#305;l&#305;r
      FORMAT COLOR COL_HEADING .
      WRITE :
      /(10) 'SAS NO.' CENTERED,
      (6)  'TAHS&#304;S'  CENTERED,
      (5)  'ÖDEME'   CENTERED,
      (5)  'Bel.T'   CENTERED,
      (25) 'MALZEME' CENTERED,
      (25) 'SATICI' CENTERED,
      (12) 'M&#304;KTAR' CENTERED,
      (3)  'BRM' CENTERED,
      (3)  'G' ,
      (7) 'TES.&#350;K.' CENTERED,
      (16) 'DÖV&#304;Z TUTARI' CENTERED,
      (3)  'DB.' CENTERED,
      (13) '&#304;TH.&#304;NTK.TRH.' CENTERED,
      (13) 'DOSYA ON.TRH.' CENTERED,
      (10) 'TAHM&#304;N.&#304;TH.TRH.' CENTERED,
      (20) 'S&#304;PAR&#304;&#350; VEREN' CENTERED,
      (10) 'TALEP NO.' CENTERED,
      (18) 'DOSYA SORUMLUSU' CENTERED.
      ULINE 0(229) .
      FORMAT RESET .
    ENDFORM.                    " top-of-page
    FORM yazdir_1005 .
      DATA ebeln LIKE list-ebeln  .
      SORT list BY zzbltur matnr .
      temp[] = list[] .
      DELETE temp WHERE mtart <> '1005' .
      LOOP AT list WHERE mtart = '1005' .
        CLEAR list-netwr .
        IF ebeln NE list-ebeln OR ebeln EQ space .
          REFRESH total . CLEAR total .
          ebeln = list-ebeln .
          LOOP AT temp WHERE ebeln = list-ebeln .
            list-netwr = list-netwr + temp-netwr  .
            CLEAR total .
            total-txz01 = '*** TKNK.MLZ. TOPLAMI ****' .
            total-meins = temp-meins .
            total-menge = temp-menge .
            COLLECT total .
          ENDLOOP                               .
          PERFORM write_list USING '1'  .
          LOOP AT total .
            PERFORM write_list USING '2'  .
          ENDLOOP .
          AT END OF zzbltur .
            ULINE 0(229) .
          ENDAT .
        ENDIF .
      ENDLOOP .
    ENDFORM.                    " yazdir_1005
    FORM write_list  USING    flag .
    flag 1 1005 için yazd&#305;rma
    flag 2 ise ara toplam
      IF flag = '1' .
       FORMAT COLOR COL_NORMAL .
        WRITE :
        /(10) list-ebeln ,
         (6)  list-zztahsk,
         (5)  list-zterm,
         (5)  list-zzbltur ,
         (25) list-txz01,
         (25) list-name1,
         (12) list-menge,
         (3)  list-meins,
         (3)  list-fyukl,
         (7)  list-inco1,
         (16) list-netwr,
         (3)  list-waers,
         (13) list-bedat,
         (13) list-zzontar,
         (10) list-slfdt ,
         (20) list-tname1,
         (10) list-banfn ,
         (18) list-eknam .
        FORMAT RESET .
      ELSEIF flag = '2'  .
       FORMAT COLOR COL_TOTAL .
        WRITE :
        /(10) '' ,
         (6)  '' ,
         (5)  '' ,
         (5)  '' ,
         (25) total-txz01,
         (25) '' ,
         (12) total-menge,
         (3)  total-meins,
         (3)  '' ,
         (7)  '' ,
         (16) '' ,
         (3)  '' ,
         (13) '' ,
         (13) '' ,
         (10) '' ,
         (20) '' ,
         (10) '' ,
         (18) '' .
        FORMAT RESET .
      ELSEIF flag = '3'  .
       FORMAT COLOR COL_TOTAL .
        WRITE :
       /(10) '' ,
        (6)  '' ,
        (5)  '' ,
        (5)  '' ,
        (25) total-txz01,
        (25) '' ,
        (12) total-menge,
        (3)  '' ,
        (3)  '' ,
        (7)  '' ,
        (16) total-netwr ,
        (3)  '' ,
        (13) '' ,
        (13) '' ,
        (10) '' ,
        (20) '' ,
        (10) '' ,
        (18) '' .
        FORMAT RESET .
      ENDIF .
    ENDFORM.                    " write_list
    FORM yazdir_ne_1005 .
      DATA matnr LIKE list-matnr .
      SORT list BY zzbltur matkl matnr .
      temp[] = list[] .
      DELETE temp WHERE mtart = '1005' .
      LOOP AT list WHERE mtart <> '1005' .
    Her yeni Malzeme için ara toplam yaz&#305;l&#305;r
        IF matnr NE list-matnr AND matnr NE space .
           REFRESH total . CLEAR total .
    Toplamlar al&#305;n&#305;r
          LOOP AT temp WHERE matnr = matnr .
            CLEAR total .
            total-netwr = temp-netwr  .
            total-menge = temp-menge  .
            total-txz01 =  '***     TOPLAM        ****' .
            COLLECT total .
          ENDLOOP                          .
          LOOP AT total .               .
            PERFORM write_list USING '3'  .
          ENDLOOP                       .
          ULINE 0(229) .
        ENDIF                      .
        PERFORM write_list USING '1'  .
        matnr = list-matnr            .
      ENDLOOP                           .
    Toplamlar al&#305;n&#305;r
      LOOP AT temp WHERE matnr = matnr .
        REFRESH total . CLEAR total .
        total-netwr = temp-netwr  .
        total-menge = temp-menge  .
        total-txz01 =  '***     TOPLAM        ****' .
        COLLECT total .
      ENDLOOP .
      LOOP AT total .
        PERFORM write_list USING '3'  .
      ENDLOOP       .
      ULINE 0(229)  .
    ENDFORM.                    " yazdir_ne_1005
    FORM yazdir_ekgrp .
      DATA: BEGIN OF total OCCURS 1 ,
            eknam LIKE list-eknam   ,
            zzbltur LIKE list-zzbltur ,
            sayi TYPE i ,
            END  OF  total          .
      DATA: BEGIN OF gtotal OCCURS 1 ,
            eknam LIKE list-eknam   ,
            zzbltur LIKE list-zzbltur ,
            sayi TYPE i ,
            END  OF  gtotal          .
      DATA: bltur LIKE zzith_bltur OCCURS 1 WITH HEADER LINE .
      DATA: len TYPE i  .
      DATA: wa LIKE total.
      REFRESH temp .
      SELECT * INTO TABLE bltur FROM zzith_bltur .
      CLEAR bltur .
      MOVE : 'ZZZZ'   TO bltur-zzbltur ,  " Sat&#305;r toplam&#305; için ...
             text-002 TO bltur-zztanim .
      APPEND bltur .
      CLEAR list   .
      SORT list BY eknam ebeln .
      DELETE ADJACENT DUPLICATES FROM list COMPARING eknam ebeln .
      LOOP AT list .
        CLEAR : total, gtotal .
        total-eknam = list-eknam .
        total-zzbltur = list-zzbltur .
        total-sayi  = 1 .
        COLLECT total   .
        total-eknam   = list-eknam .
        total-zzbltur = 'ZZZZ' .
        total-sayi  = 1 .
        COLLECT total   .
        gtotal-eknam = text-001 .
        gtotal-zzbltur = list-zzbltur .
        gtotal-sayi  = 1 .
        COLLECT gtotal   .
        gtotal-eknam = text-001 .
        gtotal-zzbltur = 'ZZZZ' .
        gtotal-sayi  = 1 .
        COLLECT gtotal   .
      ENDLOOP      .
      FORMAT COLOR COL_HEADING.
      ULINE AT /1(145).
      WRITE :/
      sy-vline , (15) 'Dosya Sorumlusu' , sy-vline .
      LOOP AT bltur .
        WRITE :(15) bltur-zztanim  , sy-vline .
      ENDLOOP  .
      ULINE AT /1(145).
      FORMAT RESET   .
      total-zzbltur = '0001' .
      MODIFY total TRANSPORTING zzbltur WHERE zzbltur = space .
      gtotal-zzbltur = '0001' .
      MODIFY gtotal TRANSPORTING zzbltur WHERE zzbltur = space .
      SORT total BY eknam .
      LOOP AT total  .
        AT NEW eknam .
          WRITE :/
          sy-vline , (15) total-eknam COLOR COL_HEADING ,
          sy-vline .
          LOOP AT bltur   .
            len = sy-tabix * 18 .
            len = len + 3 .
            CLEAR wa .
            READ TABLE total INTO wa WITH KEY zzbltur = bltur-zzbltur
                                              eknam   = total-eknam .
            WRITE AT len(15) wa-sayi NO-ZERO.
            WRITE sy-vline .
          ENDLOOP    .
        ENDAT      .
      ENDLOOP .
      LOOP AT gtotal  .
        AT NEW eknam .
          FORMAT COLOR COL_TOTAL .
          WRITE :/
          sy-vline , (15) gtotal-eknam ,
          sy-vline .
          LOOP AT bltur   .
            len = sy-tabix * 18 .
            len = len + 3 .
            CLEAR wa .
            READ TABLE gtotal INTO wa WITH KEY zzbltur = bltur-zzbltur
                                               eknam   = text-001    .
            WRITE AT len(15) wa-sayi NO-ZERO.
            WRITE sy-vline .
          ENDLOOP    .
        ENDAT      .
      ENDLOOP .
      ULINE AT /1(145).
      FORMAT RESET .
    ENDFORM.                    " yazdir_ekgrp

    Hi,
    In the function  use the top-of-page event as follows:
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
            EXPORTING
                    I_BYPASSING_BUFFER          =
                    I_BUFFER_ACTIVE             =
                    I_INTERFACE_CHECK           = ' '
                 I_CALLBACK_PROGRAM          = 'ZRPMSLM'
                    I_CALLBACK_PF_STATUS_SET    = ' '
                    I_CALLBACK_USER_COMMAND     = ' '
               <b>  I_CALLBACK_TOP_OF_PAGE      = 'TOP'</b>
    Define whatever to appear in top-of page in a subroutine named TOP.
    Hope this helps.
    Reward if helpful.
    Regards,
    Sipra

  • User exit U935 in Mod. Pool RGGBS000 not executing in Parallel Processing

    Hi,
    Settlement of IO (KO88) is not successful in parallel processing mode.
    While doing Settlement of IOs (KO88) in parallel processing mode, I am getting an error on account assignment object. CO account assignment in OKC9, an user exit U935 is maintained and this user exit is used in Mod.Pool RGGBS000.
    When running the settlement in normal mode, the program is running through this user exit and settlement is successful. But in prallel processing mode, looks like the settlement program is not executing / by passing the user exit and errs out with CO object assignment.
    How can we make the settlement execute through the user exit in parallel processing mode?
    Thanks

    Hi,
    If the user exit supposed to trigger thru substitution (GGB1), then check whether active status is 1 in OKC9.  Just a wild guess....
    Best Regards,
    Madhu

  • Interactive Form - button SubmitToSap - OnSubmit event is not triggered

    Please help to resolve triggering OnSubmit event problem.
    I created a test Webdynpro with UI element InteractiveForm.
    The InteractiveForm properties are:
    - displayType = native
    - enabled is checked.
    OnSubmit event  a method is called. The method contains very simple code so I could debug and see if the event is triggered.
    The form was created in SFP with  Layout type = Native.
    The form properies are:
    Default Lang = Javascript.
    Default run =  at client
    Preserve scripting changes to form when saved = Manually
    I have inserted Webdynpro script thru SAP Utilities menu.
    The form has SubmitToSap button and Textfield.
    So now i am trying to debug WDA.
    At runtime WDA opens Adobe form.
    If I enter data into Textfield and then click SubmitToSap button  -  OnSubmit event is triggered. I am happy.
    Then I run WDA again. This time I click  SubmitToSap button  right away without entering data into Textfield. OnSubmit event is NOT triggered this time.
    Is something wrong with my form properties?
    Thank you very much,
    Tatyana.

    Manas, you are right.
    OnSubmit event was not triggered unless U enter value into Textfield because the Textfield property was "Requiered".
    Also just for clarification the form Layout type  is ZCI Layout (not Native like I said above).
    Thank you!

  • OIM 11gR2 - RoleUser PostProcess Event Handler not triggered

    Hi,
    I'm trying to create a postprocess event-handler for RoleUser entity so that when a role is assigned (or removed) to a user an UDF is populated with the list of its roles.
    I developed my event-handler and registered it following instructions on http://docs.oracle.com/cd/E27559_01/dev.1112/e27150/oper.htm#OMDEV4749 but the event-handler is not triggered.
    I've read and tried a lot of things but nothing seems to work.
    I use System.out.println() and a Logger in the event-handler methods as well as breakpoints debugging via Eclipse, all this indicates the event-handler is not triggered.
    I checked the event-handler is registered by using getEventHandlers(RoleUser,CREATE) method on IAMAppDesignMBean through Enterprise Manager. Result is :
    Postprocess,-2147483648,PostProcessingInitiation,/metadata/iam-features-request/event-definition/EventHandlers.xml,true
    Postprocess,FIRST,MyHandler,Plugin:MyHandler,false
    Postprocess,FIRST,MyHandler,Plugin:MyHandler,false
    Postprocess,FIRST,MyHandler,Plugin:MyHandler,false
    Postprocess,FIRST,MyHandler,Plugin:MyHandler,false
    Postprocess,1020,RoleGrantPostProcessActionHandler,/metadata/iam-features-identity/event-definition/EventHandlers.xml,false
    Postprocess,9988,AsyncHandler,/metadata/iam-features-asyncwsclient/EventHandlers.xml,true
    Postprocess,3000000,CallBackOAACGWithApprove,/metadata/iam-features-rolesod/EventHandlers.xml,true
    Postprocess,2147483647,RequestCompleted,/metadata/iam-features-request/event-definition/EventHandlers.xml,true
    Note that I dont understand why the handler appears four times..
    Also, when I unregister it, it still appears one time.
    Here is my event handler XML file (in META-INF folder of the plugin zip) :
    <?xml version='1.0' encoding='utf-8'?>
    <eventhandlers
      xmlns="http://www.oracle.com/schema/oim/platform/kernel/"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.oracle.com/schema/oim/platform/kernel orchestration-handlers.xsd">
      <action-handler
      class="package.MyHandler"
      entity-type="RoleUser"
      operation="ANY"
      name="MyHandler"
      stage="postprocess"
      order="FIRST"
      sync="TRUE" />
    </eventhandlers>
    plugin.xml file (root of plugin zip) :
    <?xml version="1.0" encoding="UTF-8"?>
    <oimplugins xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <plugins pluginpoint="oracle.iam.platform.kernel.spi.EventHandler">
      <plugin
      pluginclass="package.MyHandler"
      version="1.0"
      name="Myhandler" />
      </plugins>
    </oimplugins>
    Java code (in a JAR in lib folder of plugin zip) :
    public class MyHandler implements PostProcessHandler {
    @Override
    public EventResult execute(long processId, long eventId, Orchestration orchestration) {
      System.out.println("Inside EventResult execute ");
      LOGGER.log(Level.SEVERE, "Inside eventResult execute");
      // Some code
      return new EventResult();
    @Override
    public BulkEventResult execute(long processId, long eventId, BulkOrchestration orchestration) {
      String operation = orchestration.getOperation().trim().toString();
      System.out.println("<---------- Calling " + getClass().getName() + ": Operation[" + operation + "] Execute ---------->");
      LOGGER.log(Level.SEVERE, "Inside BulkEventResult execute");
      // Some code
      return new BulkEventResult();
    Maybe I'm missing something ? Any help would be really appreciated
    Thanks,
    Gael
    EDIT :
    Also note that I see these messages in the logs but I'm not sure it concern my event handler from what I read on some pages :
    XML schema validation failed for XML eventhandlers and it will not be loaded by kernel.
    [CALLBACKMSG] Found 0 possible matches for applicable policies for step POST_PROCESS, entity RoleUser, operation CREATE.
    Related link : Post process event handler when a role is created or modified in OIM

    I eventually got it working but I'm not sure of how.. !
    I changed the name of the handler (it was not "MyHandler" but something very long, I shortened it). I copy and paste exactly what was described here : Post process event handler when a role is created or modified in OIM. I did purge cache. I tried to apply it on another entity (Role), it was triggered, then I applied it back to RoleUser and it still works.
    If it can help someone, my plugin zip contains :
    plugin.xml :
    <?xml version="1.0" encoding="UTF-8"?>
    <oimplugins xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <plugins pluginpoint="oracle.iam.platform.kernel.spi.EventHandler">
      <plugin pluginclass="fr.xxx.RoleUserProcessor"
      version="1.0" name="RoleUserProcessor" />
      </plugins>
    </oimplugins>
    META-INF/EventHandlers.xml :
    <?xml version="1.0" encoding="UTF-8"?>
    <eventhandlers xmlns="http://www.oracle.com/schema/oim/platform/kernel"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.oracle.com/schema/oim/platform/kernel orchestration-handlers.xsd">
      <action-handler class="fr.xxx.RoleUserProcessor"
      entity-type="RoleUser" operation="ANY" name="RoleUserProcessor" order="9999"
      stage="postprocess" sync="TRUE" />
    </eventhandlers>
    lib/xxx.jar/RoleUserProcessor.java :
    @Override
      public EventResult execute(long processId, long eventId, Orchestration orchestration) {
      LOGGER.log(Level.INFO, "Execution RoleUserProcessor EventHandler (mode non bulk)");
      String operation = orchestration.getOperation().trim().toString();
      LOGGER.log(Level.INFO, "Operation : " + operation);
      return new EventResult();
      @Override
      public BulkEventResult execute(long processId, long eventId, BulkOrchestration orchestration) {
      LOGGER.log(Level.INFO, "Execution RoleUserProcessor EventHandler (mode bulk)");
      String operation = orchestration.getOperation().trim().toString();
      LOGGER.log(Level.INFO, "Operation : " + operation);
      return new BulkEventResult();
    Thank you
    Also, a thing that may help some people, I found out that the ORCHEVENTS table in OIM schema contains the history of handlers triggered.

  • Radiobutton during at selection-screen event is not triggered

    Hi experts,
    I have this event:
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file
    perform f_file_sel.
    I want to select a file according to the radiobuttons on the selection screen, but during the f_file_sel form I recognized, that the radiobutton which I selected is not triggered.
    It's only triggered after 'start-of-selection'.
    How can I force the program to trigger it when f_file_sel is processing?

    Hi,
    SELECT-OPTIONS : so_matnr1    FOR  mvke-matnr MODIF ID id1,
                                    so_matnr2   FOR  mara-wrkst MODIF ID id2.
    PARAMETERS : rb_mat TYPE c RADIOBUTTON GROUP rbg DEFAULT 'X' USER-COMMAND hid,
                              rb_var TYPE c RADIOBUTTON GROUP rbg.
    LOOP AT SCREEN.
        IF rb_mat EQ c_x.
          IF screen-group1 EQ  'ID2'.
            screen-input = '0'.
          ENDIF.
        ENDIF.
        IF rb_var EQ c_x.
          IF screen-group1 EQ 'ID1'.
            screen-input = '0'.
          ENDIF.
        ENDIF.
        MODIFY SCREEN.
      ENDLOOP.
    Apply this piece of code to your requirement with files in place of fields.Hope your issue will be resolved.
    Regards,
    Anand.

  • Workflow WS00000038 Purch.Req - Event REJECTED not triggered

    Hi Friends!
    (SAP ECC 6.0)
    (Tcode SWE3 - BUS2009-REJECTED is active)
    When using WS00000038 Purchase requisition we have problem when an item is REJECTED.
    the Event that is triggered is BUS2009-SIGNIFICANTLYCHANGED. This leads to that the Workflow end up with status  COMPLETED and NO further handling of the actual Rejection that were made.
    IF BUS2009-REJECTED were triggered instead, then WS00000038 would have followed another path in the workflow which is to handle the REJECTION via another TASK.
    Why is BUS2009-REJECTED not triggered when button "REJECT" Requisition is pressed (ME54N).
    Best regards
    Henrik

    In this aproval step within WS00000038 it is actually ME54N that is called.
    The result in the task of the workflow is an EXTERNAL EVENT that is triggered.
    In my case it is BUS2009-SIGNIFICANTLYCHANGED that is triggered instead of BUS2009-REJECTED.
    this is what causes my Workflow WS00000038 to choose the wrong path.
    Does anyone have a solution of how to get BUS2009-REJECTED triggered via ME54N when I actually press button to REJECT and then SAVE.
    Best reg
    Henrik

  • 'End Terminate' event does not completely terminate the process instance!

    Hi,
    my process make use of the 'End Terminate' event, this will be used pending on the outcome of a prior task, using the 'Exclusive' gateway. This works quite well but in case of process termination some strange behavior happens.
    The Enterprise Manager tell me that the process instance is in state 'Terminated' but the BPM Workspace in the 'Process Tracking' tab this instance is still in state 'Running' and if I check the WFTASK database table the process instance is still in state 'OPEN' and not 'CANCELED'.
    So my question is, do I use the 'End Terminate' event the wrong way or is this a bug/feature?
    Thanks in advance,
    Daniel
    PS: I use BPM Suite 11.1.1.5 with Feature Pack.

    If we see a human task active even after termination end event is not considered a bug... I'm sorry, but i think that if every task active in the process instance is not terminated or "killed", the terminate end event is not working well. So we are talking about a bug.
    If I'm wrong, what is the expected behavior of teminate end event?
    Thanks in advance.

  • Event OnInputProcessing not triggered ..... please help, it's urgent

    hi all,
    i have a problem in my bsp page.
    in my bsp page, there is a button which is clicked, a new pop up window will appear. after the pop up window closed the caller window will be submitted.
    after submitted, the server side script ( ABAP Code in event OnInputProcessing & OnInitiallization will be run ).
    in order to be able to do this, i used java script. and it's already works well.
    the problem is : there is 1 record that the ABAP code in event OnInputProcessing is not run. I have set break points on one of code in event OnInputProcessing, but it seems event OnInputProcessing is not triggered. if i also put the break point in event OnInitialization, it will stop in the break point in event OnInitialization.
    is there any clue why this happened ?
    please help, it's urgent because it's happened in my production system
    many thanks in advance
    regards
    eddhie

    hi Raja,
    thanks for the respond.
    the code is already works for 2 years and just 1 record of ... perhaps thousands record that used the same code.
    for other record, it go to event OnInputProcessing
    but just this 1 record it won't go to event OnInputProcessing.
    any clue ?
    please help
    regards

  • Custom action event does not triggers

    Hai ,
    i have BAPI which results the data in a table when the screen loads initially .after i will inster one record to this bapi clicks on save the record is going to saved .
    i have a button (refresh ) on the same table when user clicks the refresh button the inserted record has to populate in the table.
    Table form -> create toolbar -> refrsh -> custom action -> self
    in event trigger i have selected refresh .im passing the input values again to same bapi as  date1 , date2 , pernr .
    im not able to see the updated record in the same table .
    when i refresh the browser iam able to see the updated record in the table
    any inputs .
    Regards ,
    venkat p

    Hai Govindhu ,
    timer doesnot works for me .
    signal in & signal out i have taken passed similar parameters , signal out event name is Refresh ,
    wht abt signal in event does not takes as it mask ,
    any inputs for this .
    Regards ,
    venkat p

  • Event Handler not Triggered when user is assigned by Membership Rule

    I have defined a post-processed event handler for RoleUser Entity.
    The handler is triggered normally when a user is manually assigned a role.
    However, it is not trigger, if users are assigned through membership rule.
    I have tried both the single execute method and the bulk execute method.
    OIM version: 11gR2

    Hi,
    Check the list of orchestration handlers triggered for this operation in the Diagnostic Dashboard. Check whether, if your custom event handler is present in the list. If its isn't, then there must be something wrong with your Plugin.
    Thanks,
    RK.

  • RSPPFPROCESS - mail not triggering for incorrectly processed PO

    Hi All,
    I tried executing the RSPPFPROCESS by giving a variant but I am not able to get the details of any incorrectly processed purchase orders in the output.
    The RSPPFPROCESS  program functions in such a way that if a PO is unsuccessfully processed, then on executing the RSPPFPROCESS program with status "Unsuccessfully Processed" a mail will be triggered to the creators whose POs were incorrectly processed.
    But this is not happening in my case, the mail is not getting triggered at all.
    The variant details are:
    Application : BBP_PD
    Action Profile : BBP_PD_PO
    Action Definition : STANDARD_PO
    Promotion status : 2 (ie)incorrectly processed
    Processing type : MET
    Time of Processing : Processing when saving document
    The radio buttons: Ignore "Repeat" flag and Ignore "Generated Manually" flag are checked.
    The check box "Number of Actions Outputted" is checked.
    Please help.
    Thanx in advance.
    Regards,
    Mary Catherine

    Hello Prasath,
    Please check your configuration on ERP/ECC
    side in transaction SWETYPV. Here you can enable or disable the
    event type linkage for BUS2012 and for CL_SE_PUR_PO_WF_OUT or any
    customer-specific business object related to Purchase Orders which might
    be in use. If you disable the event linkage for CREATE and/or change
    event, no message will be triggered upon PO creation.
    If this is not sufficient for your business process the usual logic is
    that all Purchase Order message are being sent out when the event
    linkage is active (e.g. you want to send out only some of the message
    types possible). In this case you might want to make use of BAdI
    PUR_SE_PO_INTERFACE_OUT_SELECT (enhancement spot / BAdI)."
    Enhancement Spot: PUR_SPOT_SE_PURCHASE_ORDER
    BAdI Definition:  PUR_SE_PO_INTERFACE_OUT_SELECT
    Interface:        IF_PUR_SE_PO_IF_OUT_SELECT
    BADI definition   PUR_APPL_SE_POCONF_IN_ASYN
    Also in the standard, for the following messages
       PurchaseOrderChangedInformation_Out
       PurchaseOrderERPRequest_Out_V1
       PurchaseOrderERPConfirmation_Out
    we are sending out these information as soon as a purchase Order is
    created. We do not distinguish between the services all of them will be
    triggered.
    Hope this hepls
    Ray

  • Event is not triggering in swel

    Hello Gurus,
    i have used a subtype business object zbus2009 of bus2009.
    and i have deactivated the event of bus2009 in workflow. now i am using there this subtype zbus2009.
    but in swel while i am checking after creation, no event is triggering here, and showing here in swel "no event is trigger for bus2009" but i have changed bus2009 to zbus2009, so it should show for zbus2009, either its triggering or not.
    please tell me where am i lacking.
    Kind Regards,
    Him Joshi

    HI HIM,
    It seems like you have created a subtype for BUS2009 and you want to use the additional functionality of ZBUS2009 in
    your workflow. You need to do the following:
    1. Delegate your BO ZBUS2009 with BUS2009( you can search for this in this forum).
    2. Activate the event for BUS2009. This will be trigerred for ZBUS2009 as well due to this delegation.
    Hope this helps you.
    Regards
    Gautam

  • WF : Event ReleaseStepCreated not triggered BUS2013/2014

    Hi,
    We have approval WF for PO(BUS2012),SA(BUS2013) and Contracts(BUS2013). We have the following scenario for a PO.
    1. When a PO is changed (Value/new line item) when it's approval is still in process and it is Blocked state event CHANGED is fired.
    2. When a PO is changed when it is in Release state, event 'ReleaseStepCreated' is fired along with 'CHANGED'.
    Now this is not happening for SA and contracts. I checked the release strategy and found all of them had '9' in the workflow column for Release Code.
    Any suggestions what could be missing.
    Regards
    Manish

    Hi,
    the event  .Reset  is not in use anymore (see event definition in transaction SWO1, declaring it as "Not used").
    When cancelling a given release(code), a new event .ReleaseStepCreated will be risen, as that particular release codes is open again.
    During the release procedure and signifcant changes on the purchase order (or requisition), which is customizable, the system may reset all given release codes at once, which results in new events .ReleaseStepCreated and an event .SignificantlyChanged (to close all previous workflows).
    To get an event like .AllReleaseCodesReset or something similar, you'll have to create a new custom event, creating it through change documents that say EKKO-FRGZU_OLD <> space AND EKKO-FRGZU_NEW = space.
    However it could be a good idea to switch on the log (as you already did) and see what events the SAP Standard will created in a certain situation.
    Best wishes,
    Florin

  • PrintJobFailed,printJobCompleted,printJobCanceled events are not triggering

    Hi,
    In my application we are printing some data. For that we are adding PrintStatusTracker listner class which impliments PrintJobListener to DocPrintJob.
    Now the problem is... after print is given i am getting only 2 events triggered in PrintJobListener i.,e printDataTransferCompleted, printJobNoMoreEvents even though it is failed to print. But other events like printJobFailed, printJobCompleted, printJobCanceled are not at all triggering.
    Please help me in this.
    Thanks
    Edited by: Bamgaram on Dec 31, 2009 9:12 AM

    Hi Andrew,
    I dont know how to post an SSCCE. if u want code pls find below.
         import javax.print.*;
         import javax.print.event.*;
         import javax.print.attribute.*;
         import java.awt.print.*;
         import java.awt.*;
         import java.awt.geom.*;
         import java.awt.event.*;
         import javax.swing.*;
    import java.io.*;
         public class PrintJob {
         static class MyComponent extends JPanel
         implements Printable {
         Font theFont = new Font("Serif", Font.ITALIC, 48);
         public void paint(Graphics g) {
         super.paint(g);
         String msg = "Hello, Printer";
         g.setFont(theFont);
         FontMetrics fm = g.getFontMetrics();
         // Center line
         int width = getWidth();
         int stringWidth = fm.stringWidth(msg);
         int x = (width - stringWidth)/2;
         int height = getHeight();
         int stringHeight = fm.getHeight();
         int ascent = fm.getAscent();
         int y = (height - stringHeight)/2 + ascent;
         g.drawString(msg, x, y);
         g.drawRect(x, y-ascent, stringWidth, stringHeight);
         public int print(Graphics g, PageFormat pageFormat, int pageIndex) {
         int x = (int)pageFormat.getImageableX();
         int y = (int)pageFormat.getImageableY();
         g.translate(x, y);
         if (pageIndex == 0) {
         paint(g);
         return Printable.PAGE_EXISTS;
         } else {
         return Printable.NO_SUCH_PAGE;
         public static void main(String args[]) throws Exception {
         final JFrame frame = new JFrame("Printing Graphics");
         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         Container contentPane = frame.getContentPane();
         final Component printIt = new MyComponent();
         contentPane.add(printIt, BorderLayout.CENTER);
         JButton button = new JButton("Print");
         contentPane.add(button, BorderLayout.SOUTH);
         ActionListener listener = new ActionListener() {
         public void actionPerformed(ActionEvent e) {
         DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
         PrintService printService =
         PrintServiceLookup.lookupDefaultPrintService();
         DocPrintJob job = printService.createPrintJob();
         PrintJobListener pjlistener = new PrintJobAdapter() {
         public void printDataTransferCompleted(PrintJobEvent e) {
         System.out.println("DataTransferCompleted");
         public void printJobCompleted(PrintJobEvent objPJEvent) {
              System.out.println("printJobCompleted");
         public void printJobFailed(PrintJobEvent objPJEvent) {
              System.out.println("Failed");
         public void printJobNoMoreEvents(PrintJobEvent objPJEvent) {
              System.out.println("NoMoreEvents");
         job.addPrintJobListener(pjlistener);
         PrintRequestAttributeSet pras =
         new HashPrintRequestAttributeSet();
         DocAttributeSet das = new HashDocAttributeSet();
         Doc doc = new SimpleDoc(printIt, flavor, das);
         try {
         job.print(doc, pras);
         } catch (PrintException pe) {
         pe.printStackTrace();
         button.addActionListener(listener);
         frame.setSize(350, 250);
         frame.show();
         }

Maybe you are looking for

  • I do not have the apple id for the macbook pro which i bought off ebay

    I bought a macbook pro model A1278 off of ebay.  I got the dreaded flashing folder with question mark.  After trying to repair the disk after booting using command r.  I then tried to make a new startup disc with and external hd.  I got to the point

  • DiskWarrior can't fix disk, but I can still mount it?

    My MacBook kernel panicked the other day while I was using it, so I shut it down, and tried to reboot it. Upon rebooting, the Apple logo will appear and the loading wheel starts to spin, but then it just shuts down. I then decided to boot into single

  • Help with the forward delete key code equivalent

    As a follow-up to this post: http://discussions.apple.com/thread.jspa?messageID=702033

  • J2se or j2ee

    which one is better to use provided i am not that good in java.

  • Displayed name in Messages

    I have my wife in my contacts list under two different names, her actual name and "ICE". When I receive messages from here, the name displayed is "ICE". I assume this is because Apple decided that in such situations, the name displayed would be the f