Skip to Content
author's profile photo Former Member
Former Member

use of export and import in oo abap

Hello experts,

We are new to oo abap and using process controlled workflow for BRF.

There are 3 methods which we are using. /SAPSRM/IF_EX_WF_RESP_RESOLVERGET_AREA_TO_ITEM_MAP, /SAPSRM/IF_WF_AREAGET_RESPONSIBLE_APPROVERS and /SAPSRM/IF_EX_WF_RESP_RESOLVER~GET_APPROVERS_BY_AREA_GUID.

In a situation we want to use document_id which is created in item_map into get_responsible_approvers method.

Therefore, we used export and import in these two methods like the following.

zgc_mock_pdo_guid =  is_document-document_guid. "uncomment later
    export zgc_mock_pdo_guid from zgc_mock_pdo_guid to memory id 'Z_MOCK_PDO_GUID' . "uncomment later

and

import zgc_mock_pdo_guid  = zgc_mock_pdo_guid  from  memory id 'Z_MOCK_PDO_GUID' . "uncomment this later

               CALL METHOD /SAPSRM/CL_WF_APV_FACADE=>RETRIEVE_PROCESS_HISTORY
                 EXPORTING
                   IV_DOCUMENT_GUID = zgc_mock_pdo_guid "ins_guid
                   IV_AGENT_ID      = lv_agent
                   IV_LANGUAGE      = sy-langu
                 IMPORTING
                   ES_PROCESS       = ls_process
                   .

Now we are getting the results as per our requirements. But I want to know whether or not it is supposed to be used in oo abap context or not otherwise I will find another method to do so. Please advise/suggest about the same.

Thank you.

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Posted on Feb 07, 2012 at 10:39 AM

    Cant we make zgc_mock_pdo_guid as a read only attribute in class and access it in the other?

    [READ-ONLY|http://help.sap.com/abapdocu_70/en/ABAPDATA_OPTIONS.htm#&ABAP_ADDITION_2@2@]

    Kesav

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Feb 07, 2012 at 10:50 AM

    Hello Abhijit,

    .... we used export and import in these two methods .... But I want to know whether or not it is supposed to be used in oo abap context or not otherwise I will find another method to do so

    It's good to know that you are concerned about using EXPORT/IMPORT in OOP. To the purists it has to be a big NO-NO, by doing so you are violating one of the basic principles of OOP - Encapsulation.

    Imho one of the major advantages of OOP over procedural programming is the ability of the former to protect the data it handles. Only the required data is exposed by the class to the external agents via the PUBLIC visibility section.

    Keshav has already provided you one way of achieving this(read: encapsulation) by declaring a Public read-only attribute. But if this data is manipulated inside the class only & you don't foresee any external agent ever accessing this data you can safely define it as Private.

    Hope i'm clear.

    BR,

    Suhas

    PS: The visibility of this data completely depends on your class framework.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hello Keshav, Suhas.

      Thank you vary much for your reply. I was definitely a great help to understand the concept.

      This ZGC_MOCK_PDO_GUID attribute was already made private. Instead of defining under public section I defined it under attributes tab.

      Thank you for your help though.

      Right now I am trying to explore another way to do so.

      I am trying to get factory instance for tack container using /SAPSRM/IF_CLL_TASKCON_FACTORY interface with method GET_INSTANCE from class /SAPSRM/CL_CH_WD_TASKCONT_FACT.

      Later I am trying to get task container from this interface. Then after I am interested to get SC GUID using GET_BO_GUID method.

      I have been trying to achieve this in following way. But somehow i am getting this GUID empty.

      data : 
      temp_task_container_factory type REF TO /SAPSRM/IF_CLL_TASKCON_FACTORY, 
      temp_instance type REF TO /SAPSRM/IF_PDO_BO_SC_ADV, 
      ins_guid type BBP_GUID, "/SAPSRM/WF_DOCUMENT_GUID, 
      ls_process_info TYPE /SAPSRM/S_PDO_WF_PROCESS_INFO, 
      temp_handler TYPE REF TO /SAPSRM/IF_PDO_STATIC_META, 
      temp_task_container type REF TO /SAPSRM/IF_CLL_TASK_CONTAINER, 
      lo_task TYPE REF TO /SAPSRM/IF_CLL_TASKCON_FACTORY. 
      
      CALL METHOD /SAPSRM/CL_CH_WD_TASKCONT_FACT=>GET_INSTANCE 
      RECEIVING 
      RO_TASK_CONTAINER_FACTORY = temp_task_container_factory " 
      . 
      
      CALL METHOD TEMP_TASK_CONTAINER_FACTORY->GET_TASK_CONTAINER 
      * EXPORTING 
      * IV_TRANS_MODE = 
      * IO_MESSAGE_HANDLER = 
      * IV_BO_TYPE = 
      RECEIVING 
      RO_TASK_CONTAINER = temp_task_container 
      
      CALL METHOD TEMP_TASK_CONTAINER->GET_BO_GUID 
      RECEIVING 
      RV_BO_GUID = ins_guid . 
      
      TRY. 
      CALL METHOD /SAPSRM/CL_PDO_FACTORY_SC_ADV=>GET_BUFFERED_INSTANCE 
      EXPORTING 
      IV_HEADER_GUID = ins_guid 
      RECEIVING 
      RO_INSTANCE = temp_instance 
      . 
      ENDTRY. 
      
      CALL METHOD ZCL_WF_APV_FACADE=>RETRIEVE_PROCESS_HISTORY 
      EXPORTING 
      IV_DOCUMENT_GUID = ins_guid " we are passing ins_guid instead of zGC_MOCK_PDO_GUID this should have area_guid now. 
      IV_AGENT_ID = lv_agent 
      IV_LANGUAGE = sy-langu 
      IMPORTING 
      ES_PROCESS = ls_process.

      But the ins_guid ( returned by RV_BO_GUID ) is empty ( The Bold fonted line of code)

      I want to know whether I am doing this instantiation correctly or not or do I have to create class and object here only ?

      Right now I am calling the class, getting get_instance and using its instance temp_task_container_factory i am calling interface /SAPSRM/IF_CLL_TASKCON_FACTORY. Is it correct way? PLease advise. Thank you once again.

      Edited by: abhijitkamatkar on Feb 7, 2012 1:38 PM

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.