Skip to Content

Fetch Document Flow of a TOR

Hi Experts,

Need your help in fetching the document flow of multiple FOs.

Presently I am fethcing document flow for single FO at a time, and calling the same method inside a loop as shown below to fetch document flow for multiple FOs obtained from Query method.

But fetching the document flow for each FO in a loop has degraded the performance of the report.

Please suggest how can I get the document flow for all the FOs  by calling the method only once, outside loop.

Also when I will fetch all the document flow at same time by passing all the FOs in the method 'Get_Doc_flow', how will I distinguish between the documents obtained in table 'lt_df_root' ?? (ie. which document corresponds to which FO )  

   *** Fetching TOR Root Data
  CALL METHOD lo_srvmgr->query
    EXPORTING
      iv_query_key            = /scmtms/if_tor_c=>sc_query-root-root_elements
      it_selection_parameters = lt_sel_par
      iv_fill_data            = abap_true
    IMPORTING
      et_data                 = lt_root
      et_key                  = lt_key.


* Document Flow Factory Instance
  CALL METHOD /scmtms/cl_doc_flow_factory=>get_instance
    EXPORTING
      iv_bo_key   = /scmtms/if_tor_c=>sc_bo_key
    RECEIVING
      ro_doc_flow = lw_doc_flow.

  LOOP AT lt_root INTO ls_root.
    REFRESH:  lt_frw_key, lt_trq_fr_tor.
    ls_frw_key-key = ls_root-key.
    APPEND ls_frw_key TO lt_frw_key.

    REFRESH: lt_df_root, lt_df_root_relation.

    CALL METHOD lw_doc_flow->get_doc_flow
      EXPORTING
        iv_direction         = 'A'
        iv_node_key          = /scmtms/if_tor_c=>sc_node-root
        it_key               = lt_frw_key

      CHANGING
        ct_doc_flow          = lt_df_root
        ct_doc_flow_relation = lt_df_root_relation.

ENDLOOP.

Thanks and regards,

Ashish

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Jun 25, 2014 at 01:43 PM

    Hi Ashish,

    The technical answer to your questions is:

    Move the two REFRESH statements above the LOOP statement, and the CALL METHOD below the ENDLOOP ;-)

    For any FO and a document in its docflow, lt_df_root_relation will then contain an entry with the FO key as the source key and a key of lt_df_root as the target key. The corresponding entry in lt_df_root contains the related document.

    But the more important answer is:

    If you know which documents you're interested in before calling the docflow (and I'm quite sure that's the case...), then it's more efficient to retrieve the related documents by using the corresponding reference fields or associations directly, or make use of a standard helper method.

    Just check the implementation of /SCMTMS/CL_TOR_DOC_FLOW->GET_DOC_FLOW_TOR to see how that works for different kinds of documents in the docflow.

    Regards, Thomas

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 15, 2014 at 02:55 AM

    Hi Ashish,

    What do you want to do with the document flow? I saw that you call the section of logic above in your report, so I am curious about it. If you want get the relations between the FO and its related document, you can use association provided by standard.

    BR, Dawson

    Add comment
    10|10000 characters needed characters exceeded