cancel
Showing results for 
Search instead for 
Did you mean: 

How to get Hierarchy of a project till checklist line item leval

Former Member
0 Kudos

I am using BAPI 'BAPI_BUS2172_GET_TREE' to get the Hierarchy of a project

Such as Phase, task but however I am not able to get the check list, Checklist Item and Checklist Reference.

Is there any BAPI which gives me hierarchy till checklist Item and Checklist reference by taking Project GUID?

If not, could you tell me if there are any tables or other methods of fetching the check list, checklist Item and Checklist reference?

Thanking you.

-Ravi

Accepted Solutions (1)

Accepted Solutions (1)

thomas_berndt
Active Participant
0 Kudos

Hi Ravi,

please have a look at the sample program I attached, maybe it provides the answer you seek... or parts of this answer...

The output of this report looks like this


Get Tree

( DPO ) TB-013
   [GUID =  330738469B42137BE10000000A114EC4 ]
( PPO ) P-1
   [GUID =  780838469B42137BE10000000A114EC4 ]
( TTO ) T-1
   [GUID =  7A0838469B42137BE10000000A114EC4 ]
( TTO ) T-1/1
   [GUID =  7C0838469B42137BE10000000A114EC4 ]
( TTO ) T-1/2
   [GUID =  7E0838469B42137BE10000000A114EC4 ]
( PPO ) P-2
   [GUID =  764040464935D86EE10000000A114EC4 ]
( RAG ) Reference to SNES-SORT-0001 C1
   [GUID =  F6954546ED67D86EE10000000A114EC4 ]
( TTO ) T-2
   [GUID =  784040464935D86EE10000000A114EC4 ]
( TTO ) T-2/1
   [GUID =  7A4040464935D86EE10000000A114EC4 ]
( TTO ) T-2/2
   [GUID =  7C4040464935D86EE10000000A114EC4 ]
( CTO ) CL-1
   [GUID =  974040464935D86EE10000000A114EC4 ]
( ITO ) CLI-1
   [GUID =  994040464935D86EE10000000A114EC4 ]
( ITO ) CLI-2
   [GUID =  9B4040464935D86EE10000000A114EC4 ]
( ITO ) CLI-3
   [GUID =  A54040464935D86EE10000000A114EC4 ]
( PPO ) P-3
   [GUID =  29CC484605C3203EE10000000A114EC4 ]
( YTO ) mirror
   [GUID =  2CCC484605C3203EE10000000A114EC4 ]

and here both Checklist and Checklist-Items are shown.

Best regards,

Thomas

former_member184588
Active Participant
0 Kudos

Hello,

please have a look at the sample program I attached

how is it possible to see the sample program?

Thx, Vanessa

EDIT: Now I can see it... but it is empty

Edited by: Vanessa Martinez on Oct 29, 2008 1:53 PM

thomas_berndt
Active Participant
0 Kudos

Hi Vanessa,

that's strange?! Benath the header data of my post I do see the attachment... Well, this seems to be one of the wonders you experience in a forum.

For completeness I alos paste the source code below.

Best regards,

Thomas


*&---------------------------------------------------------------------*
*& Report  ZZ_GET_TREE
*&
*&---------------------------------------------------------------------*
*&
*& Copyright (c) 2007 SAP
*&
*&---------------------------------------------------------------------*

REPORT  zz_get_tree.

TYPES:
  BEGIN OF ts_bapi_detail,
    object_type         TYPE dpr_tv_bapi_object_type,
    bapi_name           TYPE funcname,
  END OF ts_bapi_detail.

DATA:
  lv_guid_project       TYPE guid_32,
  lt_tree               TYPE TABLE OF bapi_ts_tree,
  lt_bapiret            TYPE TABLE OF bapiret2,
  ls_bapi_detail        TYPE          ts_bapi_detail,
  lt_bapi_detail        TYPE TABLE OF ts_bapi_detail,
  lv_subrc              TYPE sy-subrc.

FIELD-SYMBOLS:
  <fs_tree>             TYPE bapi_ts_tree.

PARAMETERS:
  p_id                  TYPE dpr_project-project_id DEFAULT 'TB-013'.
* 'nother nice, big project is RAV_TEST_PERF
* W_0702_002

*--- Select project guid from project id
PERFORM get_project_guid USING p_id
                      CHANGING lv_guid_project
                               lv_subrc.
CHECK lv_subrc IS INITIAL.

*--- Get tree by means of the BAPI
CALL FUNCTION 'BAPI_BUS2172_GET_TREE'
  EXPORTING
    project_definition_guid = lv_guid_project
  TABLES
    et_tree                 = lt_tree
    return                  = lt_bapiret.

READ TABLE lt_bapiret WITH KEY number = '076' TRANSPORTING NO FIELDS.

IF sy-subrc <> 0.
  WRITE:/ 'Error in BAPI'.
  EXIT.
ENDIF.

*--- Prepare table with bapi-names for getting the details
ls_bapi_detail-object_type = 'DPO'.                     "Project
ls_bapi_detail-bapi_name   = 'BAPI_BUS2172_GET_DETAIL'.
APPEND ls_bapi_detail TO lt_bapi_detail.
ls_bapi_detail-object_type = 'PPO'.                     "Phase
ls_bapi_detail-bapi_name   = 'BAPI_BUS2173_GET_DETAIL'.
APPEND ls_bapi_detail TO lt_bapi_detail.
ls_bapi_detail-object_type = 'TTO'.                     "Task
ls_bapi_detail-bapi_name   = 'BAPI_BUS2175_GET_DETAIL'.
APPEND ls_bapi_detail TO lt_bapi_detail.
ls_bapi_detail-object_type = 'CTO'.                     "Checklist-header
ls_bapi_detail-bapi_name   = 'BAPI_BUS2176_GET_DETAIL'.
APPEND ls_bapi_detail TO lt_bapi_detail.
ls_bapi_detail-object_type = 'ITO'.                     "Checklist-item
ls_bapi_detail-bapi_name   = 'BAPI_BUS2174_GET_DETAIL'.
APPEND ls_bapi_detail TO lt_bapi_detail.
ls_bapi_detail-object_type = 'YTO'.                     "Mirror-task
ls_bapi_detail-bapi_name   = 'BAPI_BUS2175_GET_DETAIL'.
APPEND ls_bapi_detail TO lt_bapi_detail.
ls_bapi_detail-object_type = 'RAG'.                     "Checklist-ref
ls_bapi_detail-bapi_name   = 'BAPI_BUS2164_GET_DETAIL'.
APPEND ls_bapi_detail TO lt_bapi_detail.

DATA:
  ls_proj_detail      TYPE          bapi_ts_project_def_detail,
  ls_phase_detail     TYPE          bapi_ts_phase_detail,
  ls_task_detail      TYPE          bapi_ts_task_detail,
  ls_clh_detail       TYPE          bapi_ts_checklist_detail,
  ls_cli_detail       TYPE          bapi_ts_chkl_item_detail,
  ls_clr_detail       TYPE          bapi_ts_chkl_reference_detail,
  lt_name             TYPE TABLE OF bapi_ts_name,
  lt_desc             TYPE TABLE OF bapi_ts_description,
  lt_status           TYPE TABLE OF bapi_ts_status,
  lt_auth             TYPE TABLE OF bapi_ts_authorization_out.

LOOP AT lt_tree ASSIGNING <fs_tree>.
*--- Get details for the given object
  READ TABLE lt_bapi_detail WITH KEY <fs_tree>-object_type INTO ls_bapi_detail.
  CHECK sy-subrc IS INITIAL.
  WRITE:/ '(', <fs_tree>-object_type, ')',  <fs_tree>-explanation.
  WRITE:/ '   [GUID = ' , <fs_tree>-guid, ']'.

  CALL FUNCTION ls_bapi_detail-bapi_name
    EXPORTING
      project_definition_guid       = <fs_tree>-guid
      phase_guid                    = <fs_tree>-guid
      task_guid                     = <fs_tree>-guid
      checklist_guid                = <fs_tree>-guid
      checklist_item_guid           = <fs_tree>-guid
      checklist_reference_guid      = <fs_tree>-guid
    IMPORTING
      es_project_definition_detail  = ls_proj_detail
      es_phase_detail               = ls_phase_detail
      es_task_detail                = ls_task_detail
      es_checklist_detail           = ls_clh_detail
      es_checklist_item_detail      = ls_cli_detail
      es_checklist_reference_detail = ls_clr_detail
    TABLES
      et_name                       = lt_name
      et_description                = lt_desc
      et_status                     = lt_status
      et_authorization              = lt_auth
      return                        = lt_bapiret.

*  IF <fs_tree>-object_type = 'PPO'.
*    EXIT.
*  ENDIF.
ENDLOOP.

clear <fs_tree>-guid.
write:/ <fs_tree>-guid.

*------------------------------------------------------------------------------
*--- get_project_guid 
*------------------------------------------------------------------------------
FORM get_project_guid USING    iv_id            TYPE dpr_project-project_id
                      CHANGING cv_guid_project  TYPE guid_32
                               cv_subrc         TYPE sy-subrc.

  CALL FUNCTION 'CONVERSION_EXIT_CGPLE_INPUT'
    EXPORTING
      input                = iv_id
*   IV_VERSION           =
      iv_application       = 'DPR'
*   IV_OBJECT_TYPE       =
    IMPORTING
      output               = cv_guid_project
   EXCEPTIONS
     not_unique           = 1
     OTHERS               = 2.

  cv_subrc = sy-subrc.
  IF cv_subrc IS NOT INITIAL.
    WRITE: / 'no conversion possible:', cv_subrc.
    EXIT.
  ELSE.
    IF cv_guid_project IS INITIAL.
      WRITE: / 'project does not exist:', iv_id.
      cv_subrc = 4.
    ENDIF.
  ENDIF.

ENDFORM.                    "get_project_guid
*------------------------------------------------------------------------------

former_member184588
Active Participant
0 Kudos

Hello Thomas,

thanks for this code. I have never seen a source code that is so extraordinary good.

The only thing I can say is: wow...

Thx, Vanessa

Former Member
0 Kudos

Dear Thomas,

This FM served my purpose. Thanks a lot

CALL FUNCTION 'CONVERSION_EXIT_CGPLE_INPUT'

    EXPORTING

      input                = iv_id

*   IV_VERSION           =

      iv_application       = 'DPR'

*   IV_OBJECT_TYPE       =

    IMPORTING

      output               = cv_guid_project

   EXCEPTIONS

     not_unique           = 1

     OTHERS               = 2.

Thanks .

Answers (1)

Answers (1)

former_member201206
Active Contributor
0 Kudos

Hi Ravi,

Please use the database table CGPL_HIERARCHY, you get the Guid of the related objects(project, phase, checklist, checklistiem, task etc.). Then the cgpl_project & cgpl_task table can be searched with the GUIDS, the field 'OBJECT_TYPE' of both table indicate, which type of object it is. e.g. DPO for the project header.

The you can either use corresponding Bapi method or the database table (e.g. DPR_PROJECT) to get the detailed information of the object.

Kind regards,

Zhenbo