cancel
Showing results for 
Search instead for 
Did you mean: 

Revenue of trucks

Former Member
0 Kudos
59

Hi Guys

I would be thankful if you please help me in getting my

Revenue after seeing this formulae column.

Our companies generally a cement company and I am find out the revenue for trucks by each employees.

I am not getting the value in Truck rev.Please see the attachment in word and help me in modifying my report .

Regards

Piroz

REPORT Z_ESLP_ZFCR1 LINE-SIZE 160 LINE-COUNT 75

NO STANDARD PAGE HEADING.

TABLES : PA2002,USER_ADDR,

ASSOB_HR,CSKS,

PA0002,S901,S903.

TYPES: BEGIN OF ty_data ,

pernr type pa2002-pernr,

begda type pa2002-begda,

endda type pa2002-endda,

abrtg type pa2002-abrtg,

abrst type pa2002-abrst,

kostl type csks-kostl,

prctr type csks-prctr,

traid type s901-traid,

sptag type s901-sptag,

END OF ty_data.

TYPES: BEGIN OF ty_final,

pernr type pa2002-pernr,

begda type pa2002-begda,

endda type pa2002-endda,

abrtg type pa2002-abrtg,

abrst type pa2002-abrst,

kostl type csks-kostl,

prctr type csks-prctr,

traid type s901-traid,

sptag type s901-sptag,

kzwi4 type s903-kzwi4,

t_phrs type pa2002-abrst,

t_days type pa2002-abrtg,

t_rev type s903-kzwi4,

t_rd type p decimals 2,

END OF ty_final.

TYPES: BEGIN OF ty_final2,

traid type s901-traid,

sptag type s901-sptag,

" kzwi4 type s903-kzwi4,

t_rev type s903-kzwi4,

END OF ty_final2.

DATA: i_data TYPE TABLE OF ty_data, " internal table

wa_data TYPE ty_data, " work area

i_final TYPE TABLE OF ty_final, " internal table

wa_final TYPE ty_final, " work area

i_final2 TYPE TABLE OF ty_final2, " internal table

wa_final2 TYPE ty_final2. " work area

SELECTION-SCREEN BEGIN OF BLOCK blk WITH FRAME.

SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.

SELECT-OPTIONS: p_pernr FOR pa2002-pernr matchcode OBJECT prem ,

p_kostl FOR assob_hr-kostl,

p_begda FOR pa2002-begda ,

p_werks FOR s903-werks.

SELECTION-SCREEN END OF BLOCK blk1.

SELECTION-SCREEN BEGIN OF BLOCK blk2 WITH FRAME TITLE text-002.

SELECTION-SCREEN BEGIN OF BLOCK radio WITH FRAME.

PARAMETERS :TK RADIOBUTTON GROUP rbg1 , " trucks with cost center

CPT RADIOBUTTON GROUP rbg1 , " trucks without cost center

"ALL RADIOBUTTON GROUP rbg1 ,

Printer RADIOBUTTON GROUP rbg1 .

SELECTION-SCREEN END OF BLOCK radio.

SELECTION-SCREEN END OF BLOCK blk2.

SELECTION-SCREEN END OF BLOCK blk.

TOP-OF-PAGE.

FORMAT INTENSIFIED ON.

WRITE:/55(40) ' TRUCK REVENUE '.

WRITE:/50(40) ' TRUCK REVENUE BY EACH EMPLOYEE /DAY ' CENTERED ,

2 'Page', sy-pagno.

FORMAT INTENSIFIED OFF.

WRITE:/50(40) '----


' CENTERED .

FORMAT INTENSIFIED ON.

WRITE:/2 sy-datum COLOR 3, sy-uzeit .

"WRITE:/1 S903-SPMON ."p_yearf.

ULINE.

"CENTERED.

write: /2 'Truck No :'left-justified,p_kostl-low color 2 , ' to ' , p_kostl-high color 2.

write: /2 'Date From :', p_begda-low color 2 , ' to ' , p_begda-high color 2.

SKIP.

ULINE.

WRITE:/1 sy-vline,

2 ' TRUCK NO#', 15 sy-vline ,

16 ' COST CENTER', 40 sy-vline,

41 ' PER NO', 60 sy-vline,

61 ' BEGIN DATE', 74 sy-vline,

75 ' END DATE', 87 sy-vline,

88 'TOTAL HRS' , 100 sy-vline,

101 ' DAYS ', 110 sy-vline,

111 ' TRUCK REV ' , 130 sy-vline,

131' REV/DAY ', 148 sy-vline.

FORMAT COLOR 3 ON.

ULINE.

END-OF-PAGE.

START-OF-SELECTION.

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

select distinct apernr abegda aendda ekostl e~prctr

into corresponding fields of table i_data

FROM ( PA2002 AS A

INNER JOIN assob_hr AS B

on BBEGDA = ABEGDA

and BENDDA = AENDDA

and BPERNR = APERNR

and BSEQNR = ASEQNR

and BSUBTY = ASUBTY

inner join CSKS AS E

on EKOKRS = BKOKRS

and EBUKRS = BBUKRS

and EKOSTL = BKOSTL

)

where

A~PERNR in p_pernr

and A~BEGDA in p_begda

and B~KOSTL in p_kostl

and

BKOSTL LIKE 'TK%'. "AND CENDDA = '99991231'

  • group by

  • A~PERNR

  • A~BEGDA

  • A~ENDDA

  • E~KOSTL

  • E~PRCTR .

loop at i_data into wa_data.

CLEAR: wa_final.

READ TABLE i_final into wa_final

with key pernr = wa_data-pernr." BINARY SEARCH.

if sy-subrc EQ 0.

PERFORM F_DATA.

PERFORM F_YCONTBILL.

PERFORM prepare_final_rec USING'M'. " Modify Existing Record

ElSE.

PERFORM prepare_final_rec USING'A'. " Append New Record.

ENDIF.

ENDLOOP.

LOOP AT i_final into wa_final.

on change of wa_final-prctr.

WRITE:/1 sy-vline,

2 wa_final-kostl , 15 sy-vline,

16 wa_final-prctr , 40 sy-vline,

41 wa_final-pernr , 60 sy-vline,

61 wa_final-begda color 2 , 74 sy-vline,

75 wa_final-endda color 2 LEFT-JUSTIFIED , 87 sy-vline,

88 wa_final-t_phrs color 1 , 100 sy-vline,

101 wa_final-t_days color 2 , 110 sy-vline,

111 wa_final2-t_rev color 2 , 130 sy-vline,

131 wa_final-t_rd , 148 sy-vline,

149 wa_final-traid color 7 , 160 sy-vline.

endon.

uline.

endloop.

FORMAT COLOR 2 ON.

"refresh i_final.

"clear i_final.

FORM F_DATA.

select distinct apernr abegda aendda ekostl e~prctr

sum( aabrst ) as t_phrs sum( aabrtg ) as t_days

into corresponding fields of table i_final

"(wa_final-t_phrs,wa_final-t_days)

FROM ( PA2002 AS A

INNER JOIN assob_hr AS B

on BBEGDA = ABEGDA

and BENDDA = AENDDA

and BPERNR = APERNR

and BSEQNR = ASEQNR

and BSUBTY = ASUBTY

inner join CSKS AS E

on EKOKRS = BKOKRS

and EBUKRS = BBUKRS

and EKOSTL = BKOSTL

)

where

A~PERNR in p_pernr

and A~BEGDA in p_begda

and B~KOSTL in p_kostl

and

BKOSTL LIKE 'TK%' "AND CENDDA = '99991231'

group by

A~PERNR

A~BEGDA

A~ENDDA

E~KOSTL

E~PRCTR .

ENDFORM.

FORM F_YCONTBILL.

select single ftraid sum( gkzwi4 ) as t_rev

into corresponding fields of (wa_final2-traid,wa_final2-t_rev)

*(wa_final-traid,wa_final-t_rev)

FROM ( PA2002 AS A

INNER JOIN assob_hr AS B

on BBEGDA = ABEGDA

and BENDDA = AENDDA

and BPERNR = APERNR

and BSEQNR = ASEQNR

and BSUBTY = ASUBTY

and b~seqnr = ' '

inner join CSKS AS E

on EKOKRS = BKOKRS

and EBUKRS = BBUKRS

and EKOSTL = BKOSTL

INNER JOIN s901 as F

ON FTRAID = EPRCTR

AND

FSPTAG = BBEGDA

INNER JOIN S903 AS G

on GSPTAG = FSPTAG

and GVGBEL = FVBELN_01

and GAUPOS = FVGPOS

and GVKORG = FVKORG

)

where

A~PERNR in p_pernr

and A~BEGDA in p_begda

and B~KOSTL in p_kostl

and

BKOSTL LIKE 'TK%' "AND CENDDA = '99991231'

group by

A~PERNR

A~BEGDA

A~ENDDA

E~KOSTL

E~PRCTR

F~TRAID.

*

insert wa_final2 into table i_final2 .

"endselect.

ENDFORM.

FORM prepare_final_rec USING p_mode TYPE char1.

"wa_final-t_rd = ( wa_final-t_phrs ) / ( wa_final2-t_rev ).

if wa_final-t_rev <> 0.

wa_final-t_rd = ( wa_final-t_phrs ) / ( wa_final2-t_rev ).

ELSE.

wa_final-t_phrs = 0.

endif.

if wa_final-t_rd <> 0.

wa_final-t_rd = ( wa_final-t_phrs ) / ( wa_final2-t_rev ).

ELSE.

wa_final-t_rd = 0.

endif.

IF p_mode = 'A'.

wa_final-pernr = wa_data-pernr.

wa_final-begda = wa_data-begda.

wa_final-endda = wa_data-endda.

wa_final-abrtg = wa_data-abrtg.

wa_final-abrst = wa_data-abrst.

wa_final-kostl = wa_data-kostl.

wa_final-prctr = wa_data-prctr.

wa_final-traid = wa_data-traid.

wa_final-sptag = wa_data-sptag.

wa_final-t_rd = ( wa_final-t_phrs ) / ( wa_final2-t_rev ).

APPEND wa_final TO i_final .

ELSE.

MODIFY i_final FROM wa_final

TRANSPORTING

pernr

begda

endda

abrtg

abrst

kostl

prctr

traid

sptag

t_phrs

t_rev

t_rd

where pernr = wa_data-pernr.

ENDIF.

ENDFORM. " PREPARE_FINAL_REC

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

CLOSE