SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Show project hierarchy info



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> CO
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Sat Oct 27, 2007 3:40 pm    Post subject: Show project hierarchy info Reply with quote

Code:
REPORT zpmgmt_rpt_projinfo NO STANDARD PAGE HEADING LINE-SIZE 160.

*&------------------------------------------------------------------- --*
*& Includes
*&------------------------------------------------------------------- --*

INCLUDE <icon>.
INCLUDE zdata_declare_n. " include for data declaration
INCLUDE zsubr_n. " include for both subroutines

DATA: gv_index LIKE sy-tabix,
lv_index LIKE sy-tabix,
date_index TYPE sy-tabix.



*&------------------------------------------------------------------- --*
*& Start of Selection ( Get Data )
*&------------------------------------------------------------------- --*

START-OF-SELECTION.

* For initial display cnt is set to X
IF cnt EQ 'X'.
PERFORM getdata.
CLEAR it_final.
PERFORM hierarchy.
cnt = ''.
ENDIF.

*&------------------------------------------------------------------- --*
*& Form GETDATA
*&------------------------------------------------------------------- --*
* Fetches the data and logic for T1 and T2
*-------------------------------------------------------------------- --*
* --> p1 text
* <-- p2 text
*-------------------------------------------------------------------- --*
FORM getdata.

* Getting project header data

SELECT * FROM proj
INTO CORRESPONDING FIELDS OF TABLE it_proj
WHERE pspid IN so_posid
AND werks IN so_plant
AND stort IN so_loc
AND erdat IN so_date.

IF sy-subrc <0> 1.
PERFORM date_monitor.
ENDIF.
it_final-t1 = '@09@'.
ELSEIF
sy-datum LT it_final-fsavd.
it_final-t1 = '@08@'.
ENDIF.


WHEN '@08@'. " If Green
it_final-t1 = '@08@'.

ENDCASE.


MODIFY it_final INDEX gv_index TRANSPORTING t1.
CLEAR gv_index.

ENDLOOP.
ENDFORM. " GETDATA

*&------------------------------------------------------------------- --*
*& Form hierarchy
*&------------------------------------------------------------------- --*
* Displays the data in ALV hierarchical manner.
*-------------------------------------------------------------------- --*
* In coding 3 tables are used for roll-up functionality.
*
*-------------------------------------------------------------------- --*
FORM hierarchy .

DATA: it_final1 LIKE it_final OCCURS 0 WITH HEADER LINE.
DATA: it_final2 LIKE it_final OCCURS 0 WITH HEADER LINE.
DATA: it_final3 LIKE it_final OCCURS 0 WITH HEADER LINE.

DATA: count TYPE i VALUE 1.
DATA: posid LIKE prps-posid.
DATA: change,
date_mask TYPE c LENGTH 10,
lv_index2 LIKE sy-tabix.
DATA: index TYPE sy-tabix.
DATA: up LIKE prps-posid.

********** Deleting duplicate entries from the it_final.*****************

DELETE ADJACENT DUPLICATES FROM it_final.

LOOP AT it_final WHERE stufe EQ 2.
IF posid NE it_final-posid.
posid = it_final-posid.
ELSE.
DELETE it_final INDEX sy-tabix.
ENDIF.
ENDLOOP.

CLEAR posid.

LOOP AT it_final WHERE stufe EQ 3
AND ltxa1 EQ space.
IF posid NE it_final-posid.
posid = it_final-posid.
ELSE.
DELETE it_final INDEX sy-tabix.
ENDIF.
ENDLOOP.

********** Updating a new intrnal table for roll up functionality. ********

it_final1[] = it_final[].

CLEAR: lv_index2.

LOOP AT it_final1 WHERE stufe = 3
AND ltxa1 IS NOT INITIAL.

READ TABLE it_final WITH KEY stufe = 3
posid = it_final1-posid
post1 = it_final1-post1.
* clear change.
IF sy-subrc = 0.

lv_index = sy-tabix.
IF lv_index2 <> lv_index.
CLEAR: change.
lv_index2 = lv_index.
ENDIF.

IF it_final1-t1 = '@0A@'.
it_final-t1 = '@0A@' .
MODIFY it_final INDEX lv_index TRANSPORTING t1.
DELETE it_final1 WHERE posid = it_final-posid.
CONTINUE.
ENDIF.

IF it_final1-t1 = '@09@'.
it_final-t1 = '@09@'.
change = 'Y'.
MODIFY it_final INDEX lv_index TRANSPORTING t1.
CONTINUE.
ENDIF.

IF it_final1-t1 = '@08@'.
it_final-t1 = '@08@' .
IF change IS INITIAL.
MODIFY it_final INDEX lv_index TRANSPORTING t1.
ENDIF.
CONTINUE.
ENDIF.

ENDIF.

ENDLOOP.

*************************************************************************
it_final2[] = it_final[].

CLEAR: lv_index2.

LOOP AT it_final2 WHERE stufe = 3
AND ltxa1 IS INITIAL.

READ TABLE e_wbs WITH KEY wbs_element = it_final2-posid.
IF sy-subrc = 0.
READ TABLE it_final WITH KEY stufe = 2
posid = e_wbs-up.

IF sy-subrc = 0.
CHECK it_final-t1 <0A> p1 text
* <-- p2 text
*-------------------------------------------------------------------- --*
FORM date_difference .


CALL FUNCTION 'ZDATETIME_DIFFERENCE_N'
EXPORTING
date1 = it_final-fsavd
time1 = '000000'
date2 = it_final-fssad
time2 = '000000'
IMPORTING
datediff = gv_diff
EXCEPTIONS
INVALID_DATETIME = 1
OTHERS = 2
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

ENDFORM. " date_difference

*&------------------------------------------------------------------- --*
*& Form date_monitor
*&------------------------------------------------------------------- --*
* text
*-------------------------------------------------------------------- --*
* --> p1 text
* <p2> 2.

lv_days = con * gv_diff.

CALL FUNCTION 'ZCALC_DATE_N'
EXPORTING
date = lv_date
days = lv_days
months = '00'
sign = '+'
years = '00'
IMPORTING
calc_date = lv_date_final.


IF sy-datum LE lv_date_final.
it_final-t1 = '@08@'.
ELSEIF sy-datum GT lv_date_final AND
sy-datum EQ it_final-fssad.
it_final-t1 = '@09@'.
ENDIF.

ENDIF.
ENDFORM. " date_monitor
******************************************************************
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> CO All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.