Skip to Content
0
Former Member
Jul 30, 2009 at 03:15 PM

Parallel Processing

124 Views

Hi experts,

I'm tryin to implement parallel processing to this code:

EDIT: : Why is my code not structured?

-


METHOD data_select.

    REFRESH gt_ltap.

* Get all relevant TA's
    DATA: lt_zident_ta TYPE TABLE OF zident_ta,
          lt_mara TYPE TABLE OF mara,
          lt_ltap_all TYPE TABLE OF ltap,
          lt_ltak_all TYPE TABLE OF ltak.
    FIELD-SYMBOLS: <ls_ltap> TYPE ltap.


* <RELEVANT TA'S>
    SELECT *
    FROM ltak
    INTO TABLE lt_ltak_all
    WHERE lgnum IN so_lgnum
      AND tanum IN so_tanum
      AND bdatu IN so_bdatu
      AND kquit = 'X'         "Only fully confirmed TO
      AND betyp = 'L'.
* </RELEVANT TA'S>

    CHECK sy-subrc = 0.

    SELECT *
    FROM ltap
    INTO TABLE lt_ltap_all
    FOR ALL ENTRIES IN lt_ltak_all
    WHERE lgnum = lt_ltak_all-lgnum
      AND tanum = lt_ltak_all-tanum
      AND nltyp = '916'.      "Only outgoing for now

* Get all ident registrations
    CHECK sy-subrc = 0.

    SELECT *
    FROM zident_ta
    INTO TABLE lt_zident_ta
    FOR ALL ENTRIES IN lt_ltap_all
    WHERE lgnum = lt_ltap_all-lgnum
      AND tanum = lt_ltap_all-tanum.


    SELECT DISTINCT *
    FROM mara
    INTO TABLE lt_mara
    FOR ALL ENTRIES IN lt_ltap_all
    WHERE matnr = lt_ltap_all-matnr.

ENDMETHOD.

Should I create one FM for parallel processing per Select?

E.g. FM 'Z_GET_LTAK' for LTAK-select, FM 'Z_GET_LTAP' for LTAP-select and so on.

Like this... :

METHOD get_ltak.

CALL METHOD rfc_info_get. "Are there enough free processes
    IF free_tasks LT 5.
      MESSAGE a010(ad) WITH 'less than 5 processes available' .
    ENDIF.

    CALL FUNCTION 'Z_GET_LTAK'
      STARTING NEW TASK 'FUNC1'
      DESTINATION IN GROUP 'parallel_generators'
      CALLING me->on_return ON END OF TASK
      EXPORTING
        ipf_lgnum = so_lgnum
        ipf_tanum = so_tanum
        ipf_bdatu = so_bdatu.

    WAIT UNTIL functioncall1 = done.

  ENDMETHOD.                    "get_ltak

METHOD rfc_info_get .
    CALL FUNCTION 'SPBT_INITIALIZE'
     IMPORTING
       max_pbt_wps                          = max_tasks
       free_pbt_wps                         = free_tasks
     EXCEPTIONS
       invalid_group_name                   = 1
       internal_error                       = 2
       pbt_env_already_initialized          = 3
       currently_no_resources_avail         = 4
       no_pbt_resources_found               = 5
       cant_init_different_pbt_groups       = 6
       OTHERS                               = 7.
    CASE sy-subrc.
      WHEN 0. "ok
      WHEN 3.
        CALL FUNCTION 'SPBT_GET_CURR_RESOURCE_INFO'
          IMPORTING
            max_pbt_wps                 = max_tasks
            free_pbt_wps                = free_tasks
          EXCEPTIONS
            internal_error              = 1
            pbt_env_not_initialized_yet = 2
            OTHERS                      = 3.
        IF sy-subrc <> 0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                  WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
      WHEN OTHERS.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDCASE.
  ENDMETHOD.                    " rfc_info_get

  METHOD on_return.

    RECEIVE RESULTS FROM FUNCTION 'Z_GET_LTAK'
     TABLES
        lt_ltak       = gt_ltak.

    functioncall1 = done.
ENDMETHOD.

Or should I create one big FM.. but how should I do this because every Table has other keys..

Sorry, but I'm very confused...

Greetz,

Zaya

Edited by: Tuncay Zaya on Jul 30, 2009 5:15 PM