Online Tutorials & Training Materials | STechies.com
Register Login

How to display WBS elements in hierrarchial order

|| 1

How to display WBS elements in hierrarchial order
Stechies

Hi,

I have a program that extracts the project related data Excel.

The program fetches the correct data but i want to displsy it in hierarchial order based on WBS element.

How can i display it.

There is a function module CALL
FUNCTION 'AIPR_GET_HIERARCHY _TO_WBSELEM' used for this How can i use
it in my program.

pls Help.

The Abap Code is as follows.

TABLES: COSP, " Primary CO data by Cost Element
COSS, " Secondary CO data by Cost Element
COSB, " Total Variances/Results Analyses
PROJ, " Project Definition
PRPS, " WBS element
PRHI,
AFVC, " Network operations
AFVU, " Network user fields
COBK, " CO header
CEPC, " Costcenter Names
BPGE, " CO Awards
AUFK, " Networks
COOI, " Commitments management: Line items
AFKO, " Network Header
crco,
crhd,
JEST. " Project Status

Internal table for projects
DATA:BEGIN OF ITAB_TEST OCCURS 0,
PSPID LIKE PROJ-PSPID,
UP LIKE PROJ-PSPID,
STUFE LIKE PRPS-STUFE,
POSID LIKE PRPS-POSID,
POST1 LIKE PRPS-POST1,
OBJNR LIKE PRPS-OBJNR,
PSPHI LIKE PRPS-PSPHI,
PRCTR LIKE PRPS-PRCTR,
FAKKZ LIKE PRPS-FAKKZ,
PSPNR LIKE PRPS-PSPNR,
PRART LIKE PRPS-PRART,
VERNA LIKE PROJ-VERNA,
END OF ITAB_TEST.

Internal table for final extract records
TYPES: BEGIN OF EXTRACTREC,
COL_01(40) TYPE C,
COL_02(40) TYPE C,
COL_03(40) TYPE C,
COL_04(40) TYPE C,
COL_05(40) TYPE C,
COL_06(40) TYPE C,
COL_07(40) TYPE C,
COL_08(40) TYPE C,
COL_09(40) TYPE C,
COL_10(40) TYPE C,
COL_11(40) TYPE C,
COL_12(40) TYPE C,
COL_13(40) TYPE C,
COL_14(40) TYPE C,
COL_15(40) TYPE C,
COL_16(40) TYPE C,
COL_17(40) TYPE C,
COL_18(40) TYPE C,
COL_19(40) TYPE C,
COL_20(40) TYPE C,
COL_21(40) TYPE C,
COL_22(40) TYPE C,
COL_23(40) TYPE C,
COL_24(40) TYPE C,
COL_25(40) TYPE C,
COL_26(40) TYPE C,
COL_27(40) TYPE C,
X_P20C(14) TYPE C, "Auth Cost (Plan 20 @ Cost)
X_ITDC(14) TYPE C, "ITD Costs
END OF EXTRACTREC.

Accumulators
DATA : JAN_TOT(14) TYPE C.
DATA : FEB_TOT(14) TYPE C.
DATA : MAR_TOT(14) TYPE C.
DATA : APR_TOT(14) TYPE C.
DATA : MAY_TOT(14) TYPE C.
DATA : JUN_TOT(14) TYPE C.
DATA : JUL_TOT(14) TYPE C.
DATA : AUG_TOT(14) TYPE C.
DATA : SEP_TOT(14) TYPE C.
DATA : OCT_TOT(14) TYPE C.
DATA : NOV_TOT(14) TYPE C.
DATA : DEC_TOT(14) TYPE C.

Miscellaneous
DATA: X1_PROJ-PRCTR( 40) TYPE C.
DATA: COM_TOT(14) TYPE C.
DATA: EXTRACTDATA TYPE EXTRACTREC.
DATA: H_PROJMGR LIKE PRPS-VERNA, "project manager
H_PROJMGRCC LIKE CRCO-KOSTL. "PM costcenter
DATA: ITAB_EXT TYPE EXTRACTREC OCCURS 10 WITH HEADER LINE.
FIELD-SYMBOLS <MNT> .

Internal table of wbs line items for summarization
TYPES: BEGIN OF ZREC_WBS,
PERIOD LIKE RFSDO-BILABMON,
YEAR LIKE COSS-GJAHR,
PROJECT LIKE PRPS-POSID,
SALES LIKE BPGE-WTGES,
PLNDOLLARS LIKE BPGE-WTGES,
ACTDOLLARS LIKE BPGE-WTGES,
COMMIT LIKE BPGE-WTGES,
PLNHOURS LIKE BPGE-WTGES,
ACTHOURS LIKE BPGE-WTGES,
END OF ZREC_WBS.

DATA ITAB_WBS TYPE ZREC_WBS OCCURS 10 WITH HEADER LINE.

Accumulators
DATA HOLD_AWARD LIKE BPGE-WTGES.
DATA HOLD_PLAN13_ SALES LIKE BPGE-WTGES.
DATA HOLD_PLAN13_ COST LIKE BPGE-WTGES.
DATA HOLD_PLAN12_ SALES LIKE BPGE-WTGES.
DATA HOLD_PLAN12_ COST LIKE BPGE-WTGES.
DATA HOLD_COMM LIKE COOI-WTGBTR.
DATA ITAB_OBJLIST LIKE OBJLIST_PS OCCURS 10 WITH HEADER LINE.

Miscellaneous
DATA COUNT_RECORDS TYPE I.
DATA PROJ_STATUS( 10) TYPE C.
DATA NET_STATUS(10) TYPE C.
DATA NETFLAG VALUE 'N'.
DATA HOLDDATE(10) .
DATA HOLDDATE1(10) .
DATA HOLDPERIOD(10) .
DATA HOLDAMOUNT(15) TYPE C.
DATA JAMIS_END_DATE LIKE SY-DATUM.

DATA: BEGIN OF PLANDESC1,
FILLER1(5) TYPE C VALUE 'Plan ',
PLANVERSN(3) ,
FILLER2(6) TYPE C VALUE ' Hours',
END OF PLANDESC1.

DATA: BEGIN OF PLANDESC2,
FILLER1(5) TYPE C VALUE 'Plan ',
PLANVERSN(3) ,
FILLER2(2) TYPE C VALUE ' $',
END OF PLANDESC2.

DATA: MNT_INDX(20) TYPE C,
HLD_INDX(3) TYPE N,
YYYY_MM(10) TYPE C.

Selection screen
SELECTION-SCREEN SKIP 3.
SELECTION-SCREEN BEGIN OF BLOCK XEXTRPRJ WITH FRAME TITLE TEXT-001.
SELECTION-SCREEN SKIP 2.
*PARAMETERS: SELPROJ LIKE PROJ-PSPID MATCHCODE OBJECT
PRSM ."OBLIGATORY.
SELECT-OPTIONS: SELPROJ FOR PROJ-PSPID MATCHCODE OBJECT PRSM .
SELECTION-SCREEN SKIP 1.
PARAMETERS MONTH(2) TYPE N OBLIGATORY.
PARAMETERS YEAR(4) TYPE N OBLIGATORY.
*PARAMETER: SELVERSN LIKE COSS-VERSN DEFAULT '000'.
SELECT-OPTIONS: PRJTYP FOR PRPS-PRART. "Project Types (CO,GV,etc.)
SELECT-OPTIONS: PRFCTR for PROJ-PRCTR. "Range of Profit centers
SELECTION-SCREEN END OF BLOCK XEXTRPRJ.

Start of selection
START-OF-SELECTION.

Get Project Definition
SELECT * FROM PROJ WHERE PSPID IN SELPROJ
AND PRCTR IN PRFCTR.

Get WBS element
SELECT * FROM PRPS WHERE PRART IN PRJTYP
AND PSPHI EQ PROJ-PSPNR
AND STUFE GT '1'. .
MOVE-CORRESPONDING PRPS TO ITAB_TEST.
MOVE PROJ-PSPID TO ITAB_TEST-PSPID.

SELECT SINGLE * FROM PRHI WHERE POSNR EQ PRPS-PSPNR.
IF SY-SUBRC EQ '0'.
MOVE PRHI-UP TO ITAB_TEST-UP.
ENDIF.
APPEND ITAB_TEST.
CLEAR ITAB_TEST.
ENDSELECT.

ENDSELECT.

fetch higher wbs levels
LOOP AT ITAB_TEST.
SELECT SINGLE * FROM PRPS WHERE PSPNR EQ ITAB_TEST-UP.
IF PRPS-STUFE NE '2'.
SELECT SINGLE * FROM PRHI WHERE POSNR EQ PRPS-PSPNR.
IF SY-SUBRC EQ '0'.
MOVE PRHI-UP TO ITAB_TEST-UP.
ENDIF.
MODIFY ITAB_TEST.
ENDIF.
ENDLOOP.

LOOP AT ITAB_TEST.
SELECT SINGLE * FROM PRPS WHERE PSPNR EQ ITAB_TEST-UP.
MOVE PRPS-POSID TO ITAB_TEST-UP.
MODIFY ITAB_TEST.
ENDLOOP.

SORT ITAB_TEST BY PSPID.

Get Top level WBS element to determine hierarchy
SELECT * UP TO 1 ROWS FROM PRPS CLIENT SPECIFIED
WHERE MANDT = SY-MANDT
AND PSPHI = PROJ-PSPNR
AND STUFE = '1'.
ENDSELECT.

Get all object numbers of related elements in the hierarchy
CALL FUNCTION 'AIPR_GET_HIERARCHY _TO_WBSELEM'
EXPORTING
I_PR_TOP_OBJECT = PRPS-OBJNR
I_WITH_HIERARCHY = 'X'
I_WITH_NETWORK = 'X'
I_WITH_ORDERS = 'X'
TABLES
ET_OBJLIST_PS = ITAB_OBJLIST
EXCEPTIONS
OTHERS = 1.

************ ********* ********* ********* ********* ********* ********* ****
**

Section 1. Project Data.
************ ********* ********* ********* ********* ********* ********* ****
**

Get Group Head name from Profit Center from level 1
SELECT * FROM CEPC
WHERE KOKRS = 'DSRC'
AND DATBI GE SY-DATUM
AND PRCTR = PRPS-PRCTR.

CHECK CEPC-DATAB LE SY-DATUM.
ENDSELECT.

Load Project Data to internal table with headings
MOVE 'ProjectDef' TO ITAB_EXT-COL_ 01.
MOVE 'WBS Title' TO ITAB_EXT-COL_ 02.
MOVE 'WBS Element' TO ITAB_EXT-COL_ 03.
MOVE 'TY' TO ITAB_EXT-COL_ 04.
MOVE 'Prft Cntr' TO ITAB_EXT-COL_ 05.
MOVE 'Project open' TO ITAB_EXT-COL_ 06.
MOVE 'Project close' TO ITAB_EXT-COL_ 07.
MOVE 'Network open' TO ITAB_EXT-COL_ 08.
MOVE 'Network close' TO ITAB_EXT-COL_ 09.
MOVE 'Status' TO ITAB_EXT-COL_ 10.
MOVE 'ProjectMgr' TO ITAB_EXT-COL_ 11.
MOVE 'ProjectMgr_ CC' TO ITAB_EXT-COL_ 12.
MOVE 'Auth20costs' TO ITAB_EXT-COL_ 13.
MOVE 'ITD Costs ' TO ITAB_EXT-COL_ 14.
MOVE 'Jan_costs' TO ITAB_EXT-COL_ 15.
MOVE 'Feb_costs' TO ITAB_EXT-COL_ 16.
MOVE 'Mar_costs' TO ITAB_EXT-COL_ 17.
MOVE 'Apr_costs' TO ITAB_EXT-COL_ 18.
MOVE 'May_costs' TO ITAB_EXT-COL_ 19.
MOVE 'Jun_costs' TO ITAB_EXT-COL_ 20.
MOVE 'Jul_costs' TO ITAB_EXT-COL_ 21.
MOVE 'Aug_costs' TO ITAB_EXT-COL_ 22.
MOVE 'Sep_costs' TO ITAB_EXT-COL_ 23.
MOVE 'Oct_costs' TO ITAB_EXT-COL_ 24.
MOVE 'Nov_costs' TO ITAB_EXT-COL_ 25.
MOVE 'Dec_costs' TO ITAB_EXT-COL_ 26.
MOVE 'Open_commits' TO ITAB_EXT-COL_ 27.

APPEND ITAB_EXT.
CLEAR ITAB_EXT.

Fetching values
LOOP AT ITAB_TEST.

Getting records for every new project
AT NEW PSPID.
select single * from proj where pspid eq itab_test-pspid.
MOVE PROJ-PSPID TO ITAB_EXT-COL_ 01.
MOVE PROJ-POST1 TO ITAB_EXT-COL_ 02.
MOVE PROJ-PSPID TO ITAB_EXT-COL_ 03.

SELECT SINGLE * FROM PRPS WHERE PSPHI EQ PROJ-PSPNR.
CLEAR EXTRACTDATA- COL_04.
EXTRACTDATA- COL_04 = PRPS-PRART.
MOVE EXTRACTDATA- COL_04 TO ITAB_EXT-COL_ 04.

*PROFIT CENTRE CORRECTION

IF PROJ-PRCTR(2) = '01'.
X1_PROJ-PRCTR = PROJ-PRCTR.
CONCATENATE SPACE PROJ-PRCTR INTO X1_PROJ-PRCTR
SEPARATED BY SPACE.

MOVE X1_PROJ-PRCTR TO ITAB_EXT-COL_ 05. "Employee's Cost Center
ELSE.
MOVE PROJ-PRCTR TO ITAB_EXT-COL_ 05. "Employee's Cost Center
ENDIF.

PERFORM CONVERT-DATE USING PROJ-PLFAZ.
MOVE HOLDDATE1 TO ITAB_EXT-COL_ 06.
PERFORM CONVERT-DATE USING PROJ-PLSEZ.
MOVE HOLDDATE1 TO ITAB_EXT-COL_ 07.
MOVE '00/00/0000' TO ITAB_EXT-COL_ 08.
MOVE '00/00/0000' TO ITAB_EXT-COL_ 09.
perform CHECK-PROJSTATUS.
move PROJ_STATUS to ITAB_EXT-COL_ 10.
CLEAR EXTRACTDATA- COL_11.
EXTRACTDATA- COL_11 = PROJ-VERNA .
MOVE EXTRACTDATA- COL_11 TO ITAB_EXT-COL_ 11.

manager CC
MOVE PROJ-VERNR+3( 5) TO H_PROJMGR.
SELECT SINGLE * FROM CRHD
WHERE ARBPL = H_PROJMGR. "employee number

Assignment of Work Center to Cost Center
SELECT * FROM CRCO
WHERE OBJTY = CRHD-OBJTY
AND OBJID = CRHD-OBJID
AND LASET = 1
AND LANUM = '0001'.

IF CRCO-ENDDA > SY-DATUM.
EXIT.
ENDIF.
ENDSELECT.

insert space if cost center starts with 01
IF CRCO-KOSTL(2) = '01'.
H_PROJMGRCC = CRCO-KOSTL.
CONCATENATE SPACE H_PROJMGRCC
INTO H_PROJMGRCC SEPARATED BY SPACE.
ELSE.
H_PROJMGRCC = CRCO-KOSTL.
ENDIF.

MOVE H_PROJMGRCC TO ITAB_EXT-COL_ 12.

Award and Authorization (Revenue & Cost)

SELECT SINGLE * FROM PRPS
WHERE PSPHI EQ PROJ-PSPNR
AND STUFE EQ 1.

SELECT * FROM BPGE
WHERE OBJNR = PRPS-OBJNR
AND LEDNR = '0001' "Budget / Planning Ledger
AND TRGKZ = 'N' "Object indicator
AND WRTTP = '01' "Value Type
AND VERSN = '020' . "020 = Award

IF BPGE-VERSN = '020'. "Plan 20 = RA Authorization
CASE BPGE-VORGA.
WHEN 'KSTP'. "KSTP = Cost level
EXTRACTDATA- X_P20C = BPGE-WTGES.
move EXTRACTDATA- X_P20C to ITAB_EXT-COL_ 13.
ENDCASE.
ENDIF.

ENDSELECT. "BPGE

APPEND ITAB_EXT.
CLEAR ITAB_EXT.
ENDAT.

PERFORM GET-WBS-DATA.

ENDLOOP.

************ ********* ********* ********* ********* ********* ********* ****
**

Dump Out to Excel.
************ ********* ********* ********* ********* ********* ********* ****
**

Call a function for data download to an EXCEL file.
CALL FUNCTION 'Z_RH_START_ EXCEL_DATA_ OLE'
EXPORTING
DATA_NAME = 'ZCOSTS.XLS'
DATA_PATH_FLAG = 'W'
DATA_TYPE = 'DAT'
DATA_BIN_FILE_ SIZE = 'ZCOSTS'
CHART_TITLE = 'ZCOSTS'
CHART_TYPE = 2
CATEGORY_TITLE = 'ZCOSTS'
VALUE_TITLE = 'ZCOSTS'
DATA_XTOP_COR = 0
DATA_YTOP_COR = 0
DATA_XBOT_COR = 0
DATA_YBOT_COR = 0
CATEGORY_XTOP_ COR = 0
CATEGORY_YTOP_ COR = 0
CATEGORY_XBOT_ COR = 0
CATEGORY_YBOT_ COR = 0
TABLES
DATA_TAB = ITAB_EXT
EXCEPTIONS
NO_BATCH = 1
DOWNLOAD_ERROR = 2
INVALID_TYPE = 3
INTERNAL_ERROR = 4
NO_OLE_SUPPORT = 5
OLE_FILE_ERROR = 6
OLE_ERROR = 7
NO_DATA = 8
COORDINATE_ERROR = 9
OTHERS = 10.

Function modules used for the program

*&---------- --------- --------- --------- --------- --------- ---
-
*& Form CHECK-PROJSTATUS
*&---------- --------- --------- --------- --------- --------- ---
-
*
FORM CHECK-PROJSTATUS.
CLEAR PROJ_STATUS.

Fetch status
SELECT * FROM JEST "use JEST to determine Status
WHERE OBJNR = PRPS-OBJNR
AND INACT EQ SPACE. "space denotes an active status

Last one found will be reported
CASE JEST-STAT. "find the system status (Ixxx)
WHEN 'I0001'.
PROJ_STATUS = 'CRTD'. "Created
WHEN 'I0002'.
PROJ_STATUS = 'REL'. "Released
WHEN 'I0045'.
PROJ_STATUS = 'TECO'. "Technically Complete
WHEN 'I0046'.
PROJ_STATUS = 'CLSD'. "Closed
WHEN 'I0076'.
PROJ_STATUS = 'DLFL'. "Deleted Flag Activated
ENDCASE.
ENDSELECT.

ENDFORM. " CHECK-PROJSTATUS

*&---------- --------- --------- --------- --------- --------- ---
-
*
*& Form CONVERT-DATE
*&---------- --------- --------- --------- --------- --------- ---
-
*
FORM CONVERT-DATE USING HOLDDATE.
MOVE HOLDDATE+4(2) TO HOLDDATE1+0.
MOVE '/' TO HOLDDATE1+2.
MOVE HOLDDATE+6(2) TO HOLDDATE1+3.
MOVE '/' TO HOLDDATE1+5.
MOVE HOLDDATE+0(4) TO HOLDDATE1+6.

ENDFORM. " CONVERT-DATE

*&---------- --------- --------- --------- --------- --------- ---
-
*
*& Form GET-WBS-DATA
*&---------- --------- --------- --------- --------- --------- ---
-
FORM GET-WBS-DATA.

Fetch Operation within Order for status checking
SELECT SINGLE * FROM AFVC
WHERE OBJNR = ITAB_OBJLIST- OBJNR.

MOVE PROJ-PSPID TO ITAB_EXT-COL_ 01.
MOVE PRPS-POST1 TO ITAB_EXT-COL_ 02.
MOVE PRPS-POSID TO ITAB_EXT-COL_ 03.

Fetch WBS elements by hierarchy
SELECT SINGLE * FROM PRPS
WHERE OBJNR = ITAB_OBJLIST- OBJNR.

Check status of WBS element
PERFORM CHECK-PROJSTATUS.

If item has been deleted, skip
IF PROJ_STATUS = 'DLFL'.
EXIT.
ENDIF.

Fetch Authorization
PERFORM GET-AUTHORIZATION.

Load extract record.
MOVE PRPS-STUFE TO ITAB_EXT-COL_ 01.
MOVE PRPS-POSID TO ITAB_EXT-COL_ 02.
MOVE PRPS-POST1 TO ITAB_EXT-COL_ 03.
MOVE HOLD_PLAN13_ COST TO ITAB_EXT-COL_ 04.
MOVE HOLD_PLAN13_ SALES TO ITAB_EXT-COL_ 05.
MOVE HOLD_PLAN12_ COST TO ITAB_EXT-COL_ 06.
MOVE HOLD_PLAN12_ SALES TO ITAB_EXT-COL_ 07.
MOVE PROJ_STATUS TO ITAB_EXT-COL_ 10.

APPEND ITAB_EXT.
CLEAR ITAB_EXT.

CLEAR EXTRACTDATA- COL_04.
EXTRACTDATA- COL_04 = PRPS-PRART.
MOVE EXTRACTDATA- COL_04 TO ITAB_EXT-COL_ 04.

*PROFIT CENTRE
IF PROJ-PRCTR(2) = '01'.

ETAB-X_CNTR = PROJ-PRCTR. "Profit Center
X1_PROJ-PRCTR = PROJ-PRCTR.
CONCATENATE SPACE PROJ-PRCTR INTO X1_PROJ-PRCTR SEPARATED BY SPACE
.
MOVE X1_PROJ-PRCTR TO ITAB_EXT-COL_ 05. "Employee's Cost Center
ELSE.
MOVE PROJ-PRCTR TO ITAB_EXT-COL_ 05. "Employee's Cost Center
ENDIF.

PERFORM CONVERT-DATE USING PROJ-PLFAZ.
MOVE '00/00/0000' TO ITAB_EXT-COL_ 06.
PERFORM CONVERT-DATE USING PROJ-PLSEZ.
MOVE '00/00/0000' TO ITAB_EXT-COL_ 07.

Fetch order operations
SELECT SINGLE * FROM AFVC
WHERE PROJN = ITAB_TEST-PSPNR.

Fetch Order Master Data
SELECT SINGLE * FROM AUFK
WHERE PSPEL = AFVC-PROJN. " WBS element(external)

Fetch Order Header Data for start and end dates
SELECT SINGLE * FROM AFKO
WHERE AUFNR = AUFK-AUFNR. " Network # (external)

Fetch network user fields for Jamis end date
CLEAR JAMIS_END_DATE.

SELECT SINGLE * FROM AFVU WHERE
AUFPL = AFVC-AUFPL AND
APLZL = AFVC-APLZL.

SELECT SINGLE * FROM AFVC
WHERE OBJNR = ITAB_OBJLIST- OBJNR.

IF SY-SUBRC = 0.
JAMIS_END_DATE = AFVU-USR08.
ENDIF.

CLEAR EXTRACTDATA- COL_11.
EXTRACTDATA- COL_11 = PRPS-VERNA .
MOVE EXTRACTDATA- COL_11 TO ITAB_EXT-COL_ 11.

manager CC
MOVE PRPS-VERNR+3( 5) TO H_PROJMGR.
SELECT SINGLE * FROM CRHD
WHERE ARBPL = H_PROJMGR. "employee number

Assignment of Work Center to Cost Center
SELECT * FROM CRCO
WHERE OBJTY = CRHD-OBJTY
AND OBJID = CRHD-OBJID
AND LASET = 1
AND LANUM = '0001'.
IF CRCO-ENDDA > SY-DATUM.
EXIT.
ENDIF.
ENDSELECT.

Insert space if cost center starts with 01
IF CRCO-KOSTL(2) = '01'.
H_PROJMGRCC = CRCO-KOSTL.
CONCATENATE SPACE H_PROJMGRCC
INTO H_PROJMGRCC SEPARATED BY SPACE.
ELSE.
H_PROJMGRCC = CRCO-KOSTL.
ENDIF.
MOVE H_PROJMGRCC TO ITAB_EXT-COL_ 12.

Auth 20 costs for WBS elements
clear EXTRACTDATA- X_P20C.

SELECT * FROM BPGE
WHERE OBJNR = PRPS-OBJNR
AND LEDNR = '0001' "Budget / Planning Ledger
AND TRGKZ = 'N' "Object indicator
AND WRTTP = '01' "Value Type
AND VERSN = '020' . "020 = Award

IF BPGE-VERSN = '020'. "Plan 20 = RA Authorization
CASE BPGE-VORGA.
WHEN 'KSTP'. "KSTP = Cost level
EXTRACTDATA- X_P20C = BPGE-WTGES.
ENDCASE.
ENDIF.
ENDSELECT.

move EXTRACTDATA- X_P20C to ITAB_EXT-COL_ 13.
PERFORM CONVERT-DATE USING AFKO-GSTRP.
MOVE HOLDDATE1 TO ITAB_EXT-COL_ 08.

IF JAMIS_END_DATE IS INITIAL.
PERFORM CONVERT-DATE USING AFKO-GLTRP.
ELSE.
PERFORM CONVERT-DATE USING JAMIS_END_DATE.
ENDIF.

MOVE HOLDDATE1 TO ITAB_EXT-COL_ 09.
perform CHECK-PROJSTATUS.
MOVE PROJ_STATUS TO ITAB_EXT-COL_ 10.

SELECT SINGLE * FROM PRPS
WHERE OBJNR = ITAB_TEST-OBJNR.
PERFORM GET-ACTUALDOLLARS.

ITD COST MOVED
IF EXTRACTDATA- X_ITDC CA '-'.
SHIFT EXTRACTDATA- X_ITDC RIGHT CIRCULAR.
ENDIF.

move EXTRACTDATA- X_ITDC to ITAB_EXT-COL_ 14.

MONTH BREAK-UP FOR CURRENT YEAR COST MOVED

IF JAN_TOT CA '-'.
SHIFT JAN_TOT RIGHT CIRCULAR.
ENDIF.

move JAN_TOT to ITAB_EXT-COL_ 15.

IF FEB_TOT CA '-'.
SHIFT FEB_TOT RIGHT CIRCULAR.
ENDIF.
move FEB_TOT to ITAB_EXT-COL_ 16.

IF MAR_TOT CA '-'.
SHIFT MAR_TOT RIGHT CIRCULAR.
ENDIF.
move MAR_TOT to ITAB_EXT-COL_ 17.

IF APR_TOT CA '-'.
SHIFT APR_TOT RIGHT CIRCULAR.
ENDIF.
move APR_TOT to ITAB_EXT-COL_ 18.

IF MAY_TOT CA '-'.
SHIFT MAY_TOT RIGHT CIRCULAR.
ENDIF.
move MAY_TOT to ITAB_EXT-COL_ 19.

IF JUN_TOT CA '-'.
SHIFT JUN_TOT RIGHT CIRCULAR.
ENDIF.
move JUN_TOT to ITAB_EXT-COL_ 20.

IF JUL_TOT CA '-'.
SHIFT JUL_TOT RIGHT CIRCULAR.
ENDIF.
move JUL_TOT to ITAB_EXT-COL_ 21.

IF AUG_TOT CA '-'.
SHIFT AUG_TOT RIGHT CIRCULAR.
ENDIF.
move AUG_TOT to ITAB_EXT-COL_ 22.

IF SEP_TOT CA '-'.
SHIFT SEP_TOT RIGHT CIRCULAR.
ENDIF.
move SEP_TOT to ITAB_EXT-COL_ 23.

IF OCT_TOT CA '-'.
SHIFT OCT_TOT RIGHT CIRCULAR.
ENDIF.
move OCT_TOT to ITAB_EXT-COL_ 24.

IF NOV_TOT CA '-'.
SHIFT NOV_TOT RIGHT CIRCULAR.
ENDIF.
move NOV_TOT to ITAB_EXT-COL_ 25.

IF DEC_TOT CA '-'.
SHIFT DEC_TOT RIGHT CIRCULAR.
ENDIF.
move DEC_TOT to ITAB_EXT-COL_ 26.

open commits
COM_TOT = 0.
SELECT * FROM COOI
WHERE OBJNR = PRPS-OBJNR
AND WRTTP = '22'
AND WTGBTR 0.

COM_TOT = COM_TOT + COOI-WTGBTR .
ENDSELECT.

move COM_TOT to ITAB_EXT-COL_ 27.

CLEAR : EXTRACTDATA- X_ITDC,
JAN_TOT,
FEB_TOT,
MAR_TOT,
APR_TOT,
MAY_TOT,
JUN_TOT,
JUL_TOT,
AUG_TOT,
SEP_TOT,
OCT_TOT,
NOV_TOT,
DEC_TOT.

APPEND ITAB_EXT.
CLEAR ITAB_EXT.

ENDFORM. " GET-WBS-DATA

*&---------- --------- --------- --------- --------- --------- ---
-
*& Form GET-ACTUALDOLLARS
*&---------- --------- --------- --------- --------- --------- ---
-
FORM GET-ACTUALDOLLARS.
*BREAK-POINT.

Costs - DPC and legacy load
SELECT * FROM COSP CLIENT SPECIFIED
WHERE MANDT = SY-MANDT
AND OBJNR = PRPS-OBJNR
AND WRTTP = '04'
AND ( BEKNZ = 'S' OR BEKNZ = 'H' )
AND ( KSTAR GE '0000600001' AND KSTAR LE '0000601999' ).

IF YEAR = COSP-GJAHR.
DO.
IF SY-INDEX LE MONTH.
MOVE SY-INDEX TO HLD_INDX.
MNT_INDX = 'COSP-WKGXXX' .
REPLACE 'XXX' WITH HLD_INDX INTO MNT_INDX.
ASSIGN (MNT_INDX) TO <MNT>.

EXTRACTDATA- X_ITDC = EXTRACTDATA- X_ITDC + <MNT>.

if sy-index = 01.
JAN_TOT = JAN_TOT + <MNT>.
endif.

if sy-index = 02.
FEB_TOT = FEB_TOT + <MNT>.
endif.

if sy-index = 03.
MAR_TOT = MAR_TOT + <MNT>.
endif.

if sy-index = 04.
APR_TOT = APR_TOT + <MNT>.
endif.

if sy-index = 05.
MAY_TOT = MAY_TOT + <MNT>.
endif.

if sy-index = 06.
JUN_TOT = JUN_TOT + <MNT>.
endif.

if sy-index = 07.
JUL_TOT = JUL_TOT + <MNT>.
endif.

if sy-index = 08.
AUG_TOT = AUG_TOT + <MNT>.
endif.

if sy-index = 09.
SEP_TOT = SEP_TOT + <MNT>.
endif.

if sy-index = 10.
OCT_TOT = OCT_TOT + <MNT>.
endif.

if sy-index = 11.
NOV_TOT = NOV_TOT + <MNT>.
endif.

if sy-index = 12.
DEC_TOT = DEC_TOT + <MNT>.
endif.
ELSE.
EXIT.
ENDIF.
ENDDO.
ELSEIF YEAR > COSP-GJAHR.

EXTRACTDATA- X_ITDC = EXTRACTDATA- X_ITDC +
COSP-WKG001 + COSP-WKG002 +
COSP-WKG003 + COSP-WKG004 +
COSP-WKG005 + COSP-WKG006 +
COSP-WKG007 + COSP-WKG008 +
COSP-WKG009 + COSP-WKG010 +
COSP-WKG011 + COSP-WKG012 +
COSP-WKG013 + COSP-WKG014 +
COSP-WKG015 + COSP-WKG016.

ELSE.
EXIT.
ENDIF.
ENDSELECT.

Costs - Shared DPC's
SELECT * FROM COSS CLIENT SPECIFIED
WHERE MANDT = SY-MANDT
AND OBJNR = PRPS-OBJNR
AND WRTTP = '04' AND
BEKNZ = 'S'.

IF YEAR = COSS-GJAHR.
DO.
IF SY-INDEX LE MONTH.
MOVE SY-INDEX TO HLD_INDX.
MNT_INDX = 'COSS-WKGXXX' .
REPLACE 'XXX' WITH HLD_INDX INTO MNT_INDX.
ASSIGN (MNT_INDX) TO <MNT>.

EXTRACTDATA- X_ITDC = EXTRACTDATA- X_ITDC + <MNT>.

if sy-index = 01.
JAN_TOT = JAN_TOT + <MNT>.
endif.

if sy-index = 02.
FEB_TOT = FEB_TOT + <MNT>.
endif.

if sy-index = 03.
MAR_TOT = MAR_TOT + <MNT>.
endif.

if sy-index = 04.
APR_TOT = APR_TOT + <MNT>.
endif.

if sy-index = 05.
MAY_TOT = MAY_TOT + <MNT>.
endif.

if sy-index = 06.
JUN_TOT = JUN_TOT + <MNT>.
endif.

if sy-index = 07.
JUL_TOT = JUL_TOT + <MNT>.
endif.

if sy-index = 08.
AUG_TOT = AUG_TOT + <MNT>.
endif.

if sy-index = 09.
SEP_TOT = SEP_TOT + <MNT>.
endif.

if sy-index = 10.
OCT_TOT = OCT_TOT + <MNT>.
endif.

if sy-index = 11.
NOV_TOT = NOV_TOT + <MNT>.
endif.

if sy-index = 12.
DEC_TOT = DEC_TOT + <MNT>.
endif.

ELSE.
EXIT.
ENDIF.
ENDDO.
ELSEIF YEAR > COSS-GJAHR.

EXTRACTDATA- X_ITDC = EXTRACTDATA- X_ITDC +
COSS-WKG001 + COSS-WKG002 +
COSS-WKG003 + COSS-WKG004 +
COSS-WKG005 + COSS-WKG006 +
COSS-WKG007 + COSS-WKG008 +
COSS-WKG009 + COSS-WKG010 +
COSS-WKG011 + COSS-WKG012 +
COSS-WKG013 + COSS-WKG014 +
COSS-WKG015 + COSS-WKG016.
ELSE.
EXIT.
ENDIF.
ENDSELECT.

ENDFORM.
 


Comments

  • 08 Nov 2011 6:56 am
    hi.
    You can use alv tree for displaying it. you can get code from sap technical (ALV) .

    thanks for this code it is useful for me but i want to display it in alv formate not to hirarchicaly...........but i want detail about wbs element PO,PR,GR............