Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

regd : ALV

Former Member
0 Likes
547

hi,

I have pasted the code below .when i click on revenue it is giving revenue details .but when i press back .and then again press revenue for the second time.Profit center group data is not coming only Total value is coming.please help me out in finding the solution.

&----


*& Report ZINTORD3

*&

&----


*&

*&

&----


REPORT ZINTORD3 message-id zerror .

*&----


*& Table declaration

&----


TABLES : coep,

coas,

tkv11,

cepc,

cskb,

tka01,

cska,

aufk,

setleaf.

*

*&----


*& type-pool declaration

&----


TYPE-POOLS : slis.

*&----


*& Internal tables declaration

&----


DATA : BEGIN OF itab_coep OCCURS 0,

kokrs LIKE coep-kokrs, " Controlling Area

gjahr LIKE coep-gjahr, " FiscalYear

perio LIKE coep-perio, " Period

kstar LIKE coep-kstar, " CostElement

bukrs LIKE coep-bukrs, " CompanyCode

wogbtr LIKE coep-wogbtr, " Amount in Object Currency

mbgbtr LIKE coep-mbgbtr, " Total quantity entered

meinh LIKE coep-meinh, " unit

objnr like coep-objnr,

OWAER like coep-owaer,

line_color(4) TYPE c,

END OF itab_coep.

DATA :BEGIN OF itab_cepc OCCURS 0,

kokrs LIKE cepc-kokrs,

prctr LIKE cepc-prctr,

khinr LIKE cepc-khinr, " Profit Center Group

bukrs like cepc-bukrs,

END OF itab_cepc.

DATA : BEGIN OF itab_aufk OCCURS 0,

kokrs LIKE aufk-kokrs,

aufnr LIKE aufk-aufnr, " Order Number

bukrs LIKE aufk-bukrs,

prctr LIKE aufk-prctr, " ProfitCenter

auart LIKE aufk-auart, " OrderType

autyp LIKE aufk-autyp, " Order Category

objnr like aufk-objnr,

END OF itab_aufk.

DATA : BEGIN OF itab_cskb OCCURS 0,

kokrs LIKE cskb-kokrs,

kstar LIKE cskb-kstar,

katyp LIKE cskb-katyp, " Cost Element Type

aufnr LIKE cskb-aufnr,

END OF itab_cskb.

data : begin of itab_setleaf occurs 0,

setclass like setleaf-setclass,

subclass like setleaf-subclass,

setname like setleaf-setname, " CostElementGroup

valfrom like setleaf-valfrom,

valto like setleaf-valto,

end of itab_setleaf.

data : begin of itab_setleaf1 occurs 0,

setclass like setleaf-setclass,

subclass like setleaf-subclass,

setname like setleaf-setname, "InternalOrderGroupName

valfrom like setleaf-valfrom,

valto like setleaf-valto,

end of itab_setleaf1.

DATA : BEGIN OF itab_final OCCURS 0,

kokrs LIKE coep-kokrs,

gjahr like coep-gjahr,

perio LIKE coep-perio,

kstar LIKE coep-kstar,

bukrs LIKE coep-bukrs,

wogbtr LIKE coep-wogbtr,

wogbtr1(100) type C,

mbgbtr LIKE coep-mbgbtr,

meinh LIKE coep-meinh,

OWAER like coep-owaer,

aufnr LIKE aufk-aufnr,

auart LIKE aufk-auart,

katyp LIKE cskb-katyp,

prctr LIKE aufk-prctr,

khinr LIKE cepc-khinr,

kagru LIKE tkv11-kagru,

periol like coep-perio,

perioh like coep-perio,

gjahrl like coep-gjahr,

gjahrh like coep-gjahr,

objnr like coep-objnr,

setclass like setleaf-setclass,

subclass like setleaf-subclass,

setname like setleaf-setname, " CostelementGroup

setname1 like setleaf-setname, " InternalOrderGroup

valfrom like setleaf-valfrom,

valto like setleaf-valto,

ca like coep-kokrs,

ccl like coep-bukrs,

cch like coep-bukrs,

pgl like cepc-khinr,

pgh like cepc-khinr,

pcl like cepc-prctr,

pch like cepc-prctr,

kul like coep-kstar,

kuh like coep-kstar,

kgl like setheader-setname,

kgh like setheader-setname,

orl like cskb-aufnr,

orh like cskb-aufnr,

orgl like setleaf-setname,

orgh like setleaf-setname,

line_color(4) TYPE c,

END OF itab_final.

DATA : ifinal like itab_final occurs 0 with header line.

DATA : BEGIN OF itab1 OCCURS 0,

katyp1(100) type c ,

katyp like cskb-katyp,

gjahr like coep-gjahr,

bukrs like coep-bukrs,

  • wogbtr LIKE coep-wogbtr,

wogbtr(100) type C,

OWAER like coep-owaer,

kstar like coep-kstar,

perio1(100) type C,

gjahr1(100) type c,

prctr11 like aufk-prctr,

perio LIKE coep-perio,

periol like coep-perio,

perioh like coep-perio,

gjahrl like coep-gjahr,

gjahrh like coep-gjahr,

prctr like aufk-prctr,

prctr1 like aufk-prctr,

khinr1 like cepc-khinr,

prctr2 like aufk-prctr,

khinr2 like cepc-khinr,

aufnr1 like aufk-aufnr,

setname like setleaf-setname, " CostelementGroup

setname1 like setleaf-setname, " InternalOrderGroup

ca like coep-kokrs,

ccl like coep-bukrs,

cch like coep-bukrs,

pgl like cepc-khinr,

pgh like cepc-khinr,

pcl like cepc-prctr,

pch like cepc-prctr,

kul like coep-kstar,

kuh like coep-kstar,

kgl like setheader-setname,

kgh like setheader-setname,

orl like cskb-aufnr,

orh like cskb-aufnr,

orgl like setleaf-setname,

orgh like setleaf-setname,

line_color(4) TYPE c,

END OF itab1.

DATA : BEGIN OF itab2 OCCURS 0,

katyp1(100) type c ,

katyp like cskb-katyp,

gjahr like coep-gjahr,

bukrs like coep-bukrs,

  • wogbtr LIKE coep-wogbtr,

wogbtr(100) type C,

OWAER like coep-owaer,

kstar like coep-kstar,

perio1(100) type C,

gjahr1(100) type c,

perio LIKE coep-perio,

periol like coep-perio,

perioh like coep-perio,

gjahrl like coep-gjahr,

gjahrh like coep-gjahr,

prctr like aufk-prctr,

prctr2 like aufk-prctr,

khinr2 like cepc-khinr,

aufnr2 like aufk-aufnr,

setname2 like setleaf-setname, " CostelementGroup

setname21 like setleaf-setname, " InternalOrderGroup

ca like coep-kokrs,

ccl like coep-bukrs,

cch like coep-bukrs,

pgl like cepc-khinr,

pgh like cepc-khinr,

pcl like cepc-prctr,

pch like cepc-prctr,

kul like coep-kstar,

kuh like coep-kstar,

kgl like setheader-setname,

kgh like setheader-setname,

orl like cskb-aufnr,

orh like cskb-aufnr,

orgl like setleaf-setname,

orgh like setleaf-setname,

line_color(4) TYPE c,

END OF itab2.

DATA : BEGIN OF itab3 OCCURS 0,

katyp1(100) type c ,

katyp like cskb-katyp,

gjahr like coep-gjahr,

bukrs like coep-bukrs,

  • wogbtr LIKE coep-wogbtr,

wogbtr(100) type C,

OWAER like coep-owaer,

perio1(100) type C,

gjahr1(100) type c,

perio LIKE coep-perio,

periol like coep-perio,

perioh like coep-perio,

gjahrl like coep-gjahr,

gjahrh like coep-gjahr,

prctr3 like aufk-prctr,

khinr3 like cepc-khinr,

kstar like coep-kstar,

aufnr3 like aufk-aufnr,

setname3 like setleaf-setname, " CostelementGroup

setname31 like setleaf-setname, " InternalOrderGroup

ca like coep-kokrs,

ccl like coep-bukrs,

cch like coep-bukrs,

pgl like cepc-khinr,

pgh like cepc-khinr,

pcl like cepc-prctr,

pch like cepc-prctr,

kul like coep-kstar,

kuh like coep-kstar,

kgl like setheader-setname,

kgh like setheader-setname,

orl like cskb-aufnr,

orh like cskb-aufnr,

orgl like setleaf-setname,

orgh like setleaf-setname,

line_color(4) TYPE c,

END OF itab3.

DATA : lin type i.

*&----


*& fieldcatalog declaration

&----


DATA : t_fcat TYPE slis_t_fieldcat_alv,

t_fcat1 TYPE slis_t_fieldcat_alv,

t_fcat2 TYPE slis_t_fieldcat_alv,

t_fcat3 TYPE slis_t_fieldcat_alv,

t_fcat4 TYPE slis_t_fieldcat_alv,

t_fcat5 TYPE slis_t_fieldcat_alv,

t_fcat6 TYPE slis_t_fieldcat_alv,

t_fcat7 TYPE slis_t_fieldcat_alv,

t_fcat8 TYPE slis_t_fieldcat_alv,

t_fcat9 TYPE slis_t_fieldcat_alv,

t_eve TYPE slis_t_event,

t_subtot TYPE slis_t_sortinfo_alv,

t_subtot1 TYPE slis_t_sortinfo_alv,

t_subtot2 type slis_t_sortinfo_alv,

t_subtot3 type slis_t_sortinfo_alv,

t_subtot4 type slis_t_sortinfo_alv,

t_subtot5 type slis_t_sortinfo_alv,

t_subtot6 type slis_t_sortinfo_alv,

t_subtot7 type slis_t_sortinfo_alv,

t_subtot8 type slis_t_sortinfo_alv,

t_subtot9 type slis_t_sortinfo_alv,

subtot LIKE LINE OF t_subtot,

d_fieldcat_wa LIKE LINE OF t_fcat,

gd_layout TYPE slis_layout_alv.

DATA : t_header type slis_t_listheader,

wa_header type slis_listheader.

*&----


*& variables declaration

&----


DATA : gt_gross LIKE coep-wogbtr,

st_rev LIKE coep-wogbtr,

st_rev1 LIKE coep-wogbtr,

st_pc1 LIKE coep-wogbtr,

st_pc LIKE coep-wogbtr,

st_all1 LIKE coep-wogbtr,

st_all LIKE coep-wogbtr,

st_gross LIKE coep-wogbtr,

st_gross1 LIKE coep-wogbtr,

st_net1 LIKE coep-wogbtr,

st_net LIKE coep-wogbtr,

st_pt1 LIKE coep-wogbtr,

st_pt LIKE coep-wogbtr,

st_nt1 LIKE coep-wogbtr,

st_nt LIKE coep-wogbtr.

DATA : gd_repid LIKE sy-repid.

gd_repid = sy-repid.

data : ok_code like sy-ucomm.

data : DC like ok_code.

DC = ok_code.

*&----


*& Selection-Screen declaration

&----


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

PARAMETERS : p_ca LIKE coep-kokrs obligatory .

SELECT-OPTIONS : s_year FOR coep-gjahr obligatory." matchcode object zyear."default 2007 to 9999.

SELECT-OPTIONS : s_pd FOR coep-perio obligatory .

SELECT-OPTIONS : s_code FOR coep-bukrs.

SELECT-OPTIONS : s_pg FOR cepc-khinr MATCHCODE OBJECT zprofitcentergroup.

SELECT-OPTIONS : s_pc FOR aufk-prctr.

SELECT-OPTIONS : s_ku FOR coep-kstar no-display matchcode object zcost.

select-options : s_kg for setleaf-setname matchcode object zsetname.

SELECT-OPTIONS : s_or FOR aufk-aufnr.

select-options : s_org for setleaf-setname matchcode object ZSETNAME1.

SELECTION-SCREEN : END OF BLOCK blk1.

*&----


*& Selection-Screen Validation

&----


at selection-screen on p_ca.

select kokrs gjahr perio bukrs from coep

into corresponding fields of table itab_coep

where kokrs = p_ca.

if sy-subrc <> 0.

message e001(zerror) .

endif.

at selection-screen on s_year.

select kokrs gjahr perio bukrs from coep

into corresponding fields of table itab_coep

where gjahr in s_year.

if sy-subrc <> 0.

  • message e005(zerror) with s_year-low .

Message e000(zash) with 'For' s_year-low 'Entries not Available' .

endif.

at selection-screen on s_code.

select kokrs gjahr perio bukrs from coep

into corresponding fields of table itab_coep

where bukrs in s_code.

if sy-subrc <> 0.

message e006(zerror) .

endif.

at selection-screen on s_pd.

select kokrs gjahr perio bukrs from coep

into corresponding fields of table itab_coep

where perio in s_pd.

if sy-subrc <> 0.

message e001(zash) with 'for' s_pd-low 'No Entries Available'.

endif.

at selection-screen on s_pg.

select kokrs khinr prctr from cepc

into corresponding fields of table itab_cepc

where khinr in s_pg.

if sy-subrc <> 0.

message e002(zerror).

endif.

at selection-screen on s_pc.

select prctr from aufk

into corresponding fields of table itab_cepc

where prctr in s_pc.

if sy-subrc <> 0.

message e008(zerror).

endif.

at selection-screen on s_or.

select single * from aufk where aufnr in s_or.

if sy-subrc <> 0.

message e003(Zerror).

endif.

at selection-screen on s_kg.

select single * from setleaf where setname in s_kg.

if sy-subrc <> 0.

message e017(zerror).

endif.

*&----


*& Start-Of-Selection

&----


START-OF-SELECTION.

clear itab1[].

PERFORM get_data.

  • perform sel.

PERFORM build_cat USING t_fcat.

PERFORM build_layout.

PERFORM display.

&----


*& Form build_cat

&----


  • text

----


  • -->TEMP_FCAT text

----


FORM build_cat USING temp_fcat TYPE slis_t_fieldcat_alv.

d_fieldcat_wa-fieldname = 'KATYP1'.

d_fieldcat_wa-seltext_m = 'CostelementType'.

d_fieldcat_wa-hotspot = 'X'.

d_fieldcat_wa-col_pos = 1.

APPEND d_fieldcat_wa TO temp_fcat.

CLEAR d_fieldcat_wa.

d_fieldcat_wa-fieldname = 'PERIO1'. " Amount For 'To Period'

d_fieldcat_wa-seltext_m = 'For The Period'.

d_fieldcat_wa-key = 'X'.

d_fieldcat_wa-col_pos = 3.

APPEND d_fieldcat_wa TO temp_fcat.

CLEAR d_fieldcat_wa.

d_fieldcat_wa-fieldname = 'GJAHR1'. " Amount For 'From to To period '

d_fieldcat_wa-seltext_m = 'Year to Date'.

d_fieldcat_wa-key = 'X'.

d_fieldcat_wa-col_pos = 4.

APPEND d_fieldcat_wa TO temp_fcat.

CLEAR d_fieldcat_wa.

ENDFORM. "build_cat

&----


*& Form build_eve

&----


  • text

----


FORM build_eve.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 0

IMPORTING

et_events = t_eve

EXCEPTIONS

list_type_wrong = 1

OTHERS = 2.

IF sy-subrc EQ 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

endform.

&----


*& Form get_data

&----


  • text

----


FORM get_data.

--


To fetch Amount, Period ,Year, CompanyCode--

SELECT kokrs gjahr perio kstar bukrs wogbtr objnr owaer

FROM coep INTO CORRESPONDING FIELDS OF TABLE itab_coep

WHERE kokrs = p_ca

AND perio IN s_pd

AND bukrs IN s_code

AND gjahr IN s_year.

LOOP AT itab_coep.

itab_final-kokrs = itab_coep-kokrs.

itab_final-gjahr = itab_coep-gjahr.

itab_final-perio = itab_coep-perio.

itab_final-kstar = itab_coep-kstar.

itab_final-bukrs = itab_coep-bukrs.

itab_final-wogbtr = itab_coep-wogbtr.

itab_final-objnr = itab_coep-objnr.

itab_final-owaer = itab_coep-owaer.

APPEND itab_final.

CLEAR itab_final.

ENDLOOP.

IF NOT itab_coep[] IS INITIAL.

--


To fetch Amount,ProfitCenter,InternalOrder--

SELECT kokrs aufnr prctr bukrs auart objnr

FROM aufk INTO CORRESPONDING FIELDS OF TABLE itab_aufk

WHERE aufnr IN s_or

and prctr in s_pc.

loop at itab_final.

READ TABLE itab_aufk WITH KEY kokrs = itab_final-kokrs

objnr = itab_final-objnr.

IF sy-subrc = 0.

itab_final-aufnr = itab_aufk-aufnr.

itab_final-prctr = itab_aufk-prctr.

MODIFY itab_final TRANSPORTING aufnr prctr.

else.

delete itab_final.

ENDIF.

endloop.

IF NOT itab_aufk[] IS INITIAL.

--


To fetch ProfitCenter ,ProfitCenterGroup--

SELECT kokrs khinr prctr

FROM cepc INTO CORRESPONDING FIELDS OF TABLE itab_cepc

WHERE kokrs = itab_aufk-kokrs

and khinr in s_pg.

LOOP AT itab_final.

READ TABLE itab_cepc WITH KEY kokrs = itab_final-kokrs

prctr = itab_final-prctr.

IF sy-subrc = 0.

itab_final-khinr = itab_cepc-khinr.

MODIFY itab_final TRANSPORTING khinr.

else.

delete itab_final.

ENDIF.

endloop.

if not itab_coep[] is initial.

--


To fetch InternalOrderGroup--

clear itab_final-setname.

select setclass subclass setname valfrom valto

from setleaf into corresponding fields of table itab_setleaf

where setclass = '0102'

and subclass = 'VMIN'

and setname in s_kg

and valfrom in s_ku

and valto in s_ku.

loop at itab_final.

read table itab_setleaf with key valfrom = itab_final-kstar.

if sy-subrc = 0.

itab_final-setname = itab_setleaf-setname.

modify itab_final transporting setname.

else.

delete itab_final.

endif.

endloop.

if not itab_aufk[] is initial.

--


To fetch CostElementGroup--

clear itab_final-setname.

select setclass subclass setname valfrom valto

from setleaf into corresponding fields of table itab_setleaf1

where setclass = '0103'

and setname in s_org

and valfrom in s_or

and valto in s_or.

loop at itab_final .

read table itab_setleaf1 with key valfrom = itab_final-aufnr.

if sy-subrc = 0.

itab_final-setname1 = itab_setleaf1-setname.

modify itab_final transporting setname1.

else.

delete itab_final.

endif.

ENDLOOP.

IF NOT itab_coep[] IS INITIAL.

SELECT kokrs katyp aufnr kstar

FROM cskb INTO CORRESPONDING FIELDS OF TABLE itab_cskb

FOR ALL ENTRIES IN itab_coep

WHERE kokrs = itab_coep-kokrs.

loop at itab_final.

READ TABLE itab_cskb WITH KEY kstar = itab_final-kstar

kokrs = itab_final-kokrs.

IF sy-subrc = 0.

itab_final-katyp = itab_cskb-katyp.

MODIFY itab_final TRANSPORTING katyp.

ENDIF.

ENDLOOP.

endif.

endif.

ENDIF.

ENDIF.

ENDIF.

loop at itab_final where katyp = '11' or katyp = '12'.

move-corresponding itab_final to ifinal.

append ifinal.

clear ifinal.

endloop.

--


calculation for revenue--

SORT ifinal BY katyp.

loop at ifinal where perio = s_pd-high.

st_rev1 = st_rev1 + ifinal-wogbtr.

endloop.

st_rev1 = ( st_rev1 * ( -1 ) ).

LOOP AT ifinal .

st_rev = st_rev + ifinal-wogbtr.

ENDLOOP.

st_rev = ( st_rev * ( -1 ) ).

itab1-katyp1 = ' '.

itab1-wogbtr = st_rev .

concatenate s_pd-high ' ' into itab1-perio1 separated by space.

Concatenate s_pd-low '-' s_pd-high into itab1-gjahr1 separated by space.

itab1-line_color = 'C710'.

APPEND itab1.

itab1-line_color = ' '.

CLEAR : itab1,ifinal.

itab1-katyp1 = 'Revenue '.

itab1-perio1 = st_rev1 .

itab1-gjahr1 = st_rev .

APPEND itab1.

CLEAR : itab1,ifinal.

---calculation for DirectExpense--


clear : ifinal[].

loop at itab_final where katyp = '01'.

move-corresponding itab_final to ifinal.

append ifinal.

endloop.

SORT ifinal BY katyp .

LOOP AT ifinal.

st_pc = st_pc + ifinal-wogbtr.

ENDLOOP.

loop at ifinal where perio = s_pd-high.

st_pc1 = st_pc1 + ifinal-wogbtr.

endloop.

itab1-katyp1 = 'DirectExpense'.

itab1-wogbtr = st_pc.

itab1-perio1 = st_pc1.

itab1-gjahr1 = st_pc.

APPEND itab1.

CLEAR : itab1,ifinal.

---calculation for Gross Margin--


st_gross1 = st_rev1 - st_pc1.

if st_pc1 > st_rev1.

st_gross1 = ( st_gross1 * ( -1 ) ).

endif.

itab1-katyp1 = 'GrossMargin '.

st_gross = ( st_rev - st_pc ).

if st_pc > st_rev.

st_gross = ( st_gross * ( -1 ) ).

endif.

itab1-wogbtr = st_gross.

itab1-perio1 = st_gross1.

itab1-gjahr1 = st_gross.

itab1-line_color = 'C500'.

APPEND itab1.

CLEAR: itab1,ifinal.

itab1-katyp1 = ' Percentage (%)'.

if st_rev1 = 0. " Handle Divide by Zero exception

st_pt1 = 0.

endif.

if st_rev = 0.

st_pt = 0.

else.

st_pt1 = ( st_gross1 / st_rev1 ) * 100.

st_pt = ( st_gross / st_rev ) * 100.

endif.

itab1-perio1 = st_pt1.

itab1-gjahr1 = st_pt.

itab1-line_color = 'C710'.

APPEND itab1.

CLEAR: itab1,ifinal.

---Calculation for Allocated cost--


clear : ifinal[].

loop at itab_final where katyp <> '01'

and katyp <> '11'

and katyp <> '12'.

move-corresponding itab_final to ifinal.

append ifinal.

endloop.

SORT ifinal BY katyp .

LOOP AT ifinal.

st_all = st_all + ifinal-wogbtr.

ENDLOOP.

loop at ifinal where perio = s_pd-high.

st_all1 = st_all1 + ifinal-wogbtr.

endloop.

itab1-katyp1 = 'AllocatedExpenses'.

itab1-wogbtr = st_all.

itab1-perio1 = st_all1.

itab1-gjahr1 = st_all.

APPEND itab1.

CLEAR: itab1, ifinal.

--


calculation for Net Margin--

st_net1 = st_gross1 - st_all1.

itab1-katyp1 = 'NetMargin'.

st_net = ( st_gross - st_all ).

itab1-wogbtr = st_net.

itab1-perio1 = st_net1.

itab1-gjahr1 = st_net.

itab1-line_color = 'C500'.

APPEND itab1.

CLEAR: itab1, ifinal .

itab1-katyp1 = ' Percentage (%)'.

if st_rev1 = 0. " Handle Divide by Zero exception

st_nt1 = 0.

endif.

if st_rev = 0.

st_nt = 0.

else.

st_nt1 = ( st_net1 / st_rev1 ) * 100.

st_nt = ( st_net / st_rev ) * 100.

endif.

itab1-perio1 = st_pt1.

itab1-gjahr1 = st_pt.

itab1-line_color = 'C710'.

APPEND itab1.

CLEAR: itab1,ifinal.

ENDFORM. "get_data

&----


*& Form build_layout

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM build_layout .

gd_layout-zebra = 'X'.

gd_layout-colwidth_optimize = 'X'.

gd_layout-info_fieldname = 'LINE_COLOR'.

ENDFORM. " build_layout

&----


*& Form display

&----


  • text

----


FORM display.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = gd_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

I_GRID_TITLE = 'Internal Order Analysis Report'

  • I_GRID_SETTINGS =

IS_LAYOUT = gd_layout

IT_FIELDCAT = t_fcat

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT = t_subtot

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS = t_eve[]

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • I_HTML_HEIGHT_TOP = 0

  • I_HTML_HEIGHT_END = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • IR_SALV_FULLSCREEN_ADAPTER =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = itab1

EXCEPTIONS

PROGRAM_ERROR = 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. "display

&----


*& Form For UserCommand

&----


  • text

----


FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM

RS_SELFIELD TYPE SLIS_SELFIELD.

data : &IC1 like ok_code,

&IC2 like ok_code.

&IC1 = ok_code.

&IC2 = ok_code.

CASE R_UCOMM.

WHEN '&IC1'.

clear ok_code.

refresh t_fcat2.

refresh t_subtot2.

refresh t_fcat3.

refresh t_subtot3.

refresh t_fcat1.

refresh t_subtot1.

if rs_selfield-tabindex = 2.

clear itab_final[].

perform secondarylist.

elseIF rs_selfield-tabindex = 3.

refresh t_fcat2.

refresh t_subtot2.

clear itab_final[].

perform secondarylist1.

elseIF rs_selfield-tabindex = 6.

refresh t_fcat3.

refresh t_subtot3.

clear itab_final[].

perform secondarylist11.

ENDIF.

WHEN 'BACK'.

LEAVE TO SCREEN 0.

ENDCASE.

ENDFORM.

&----


*& Form secondarylist

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM secondarylist .

clear itab1[].

*clear ifinal[].

*clear itab_final[].

perform get_data1.

*perform sel.

PERFORM build_layout.

PERFORM build_cat1 USING t_fcat1.

*perform build_sort1.

PERFORM display1.

ENDFORM. " secondarylist

&----


*& Form get_data1

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM get_data1 .

--


To fetch Amount, Period ,Year, CompanyCode--

SELECT kokrs gjahr perio kstar bukrs wogbtr objnr owaer

FROM coep INTO CORRESPONDING FIELDS OF TABLE itab_coep

WHERE kokrs = p_ca

AND perio IN s_pd

AND bukrs IN s_code

AND gjahr IN s_year.

LOOP AT itab_coep.

itab_final-kokrs = itab_coep-kokrs.

itab_final-gjahr = itab_coep-gjahr.

itab_final-perio = itab_coep-perio.

itab_final-kstar = itab_coep-kstar.

itab_final-bukrs = itab_coep-bukrs.

itab_final-wogbtr = itab_coep-wogbtr.

itab_final-objnr = itab_coep-objnr.

itab_final-owaer = itab_coep-owaer.

APPEND itab_final.

CLEAR itab_final.

ENDLOOP.

IF NOT itab_coep[] IS INITIAL.

--


To fetch Amount,ProfitCenter,InternalOrder--

SELECT kokrs aufnr prctr bukrs auart objnr

FROM aufk INTO CORRESPONDING FIELDS OF TABLE itab_aufk

WHERE aufnr IN s_or

and prctr in s_pc.

loop at itab_final.

READ TABLE itab_aufk WITH KEY kokrs = itab_final-kokrs

objnr = itab_final-objnr.

IF sy-subrc = 0.

itab_final-aufnr = itab_aufk-aufnr.

itab_final-prctr = itab_aufk-prctr.

MODIFY itab_final TRANSPORTING aufnr prctr.

else.

delete itab_final.

ENDIF.

endloop.

IF NOT itab_aufk[] IS INITIAL.

--


To fetch ProfitCenter ,ProfitCenterGroup--

SELECT kokrs khinr prctr

FROM cepc INTO CORRESPONDING FIELDS OF TABLE itab_cepc

WHERE kokrs = itab_aufk-kokrs

and khinr in s_pg.

LOOP AT itab_final.

READ TABLE itab_cepc WITH KEY kokrs = itab_final-kokrs

prctr = itab_final-prctr.

IF sy-subrc = 0.

itab_final-khinr = itab_cepc-khinr.

MODIFY itab_final TRANSPORTING khinr.

else.

delete itab_final.

ENDIF.

endloop.

if not itab_coep[] is initial.

--


To fetch InternalOrderGroup--

clear itab_final-setname.

select setclass subclass setname valfrom valto

from setleaf into corresponding fields of table itab_setleaf

where setclass = '0102'

and subclass = 'VMIN'

and setname in s_kg

and valfrom in s_ku

and valto in s_ku.

loop at itab_final.

read table itab_setleaf with key valfrom = itab_final-kstar.

if sy-subrc = 0.

itab_final-setname = itab_setleaf-setname.

modify itab_final transporting setname.

else.

delete itab_final.

endif.

endloop.

if not itab_aufk[] is initial.

--


To fetch CostElementGroup--

clear itab_final-setname.

select setclass subclass setname valfrom valto

from setleaf into corresponding fields of table itab_setleaf1

where setclass = '0103'

and setname in s_org

and valfrom in s_or

and valto in s_or.

loop at itab_final .

read table itab_setleaf1 with key valfrom = itab_final-aufnr.

if sy-subrc = 0.

itab_final-setname1 = itab_setleaf1-setname.

modify itab_final transporting setname1.

else.

delete itab_final.

endif.

ENDLOOP.

IF NOT itab_coep[] IS INITIAL.

SELECT kokrs katyp aufnr kstar

FROM cskb INTO CORRESPONDING FIELDS OF TABLE itab_cskb

FOR ALL ENTRIES IN itab_coep

WHERE kokrs = itab_coep-kokrs.

loop at itab_final.

READ TABLE itab_cskb WITH KEY kstar = itab_final-kstar

kokrs = itab_final-kokrs.

IF sy-subrc = 0.

itab_final-katyp = itab_cskb-katyp.

MODIFY itab_final TRANSPORTING katyp.

ENDIF.

ENDLOOP.

endif.

endif.

ENDIF.

ENDIF.

ENDIF.

clear ifinal[].

loop at itab_final where katyp = '11' or katyp = '12'.

move-corresponding itab_final to ifinal.

append ifinal.

clear ifinal.

endloop.

--


calculation for revenue--

  • SORT ifinal BY katyp.

clear st_rev.

Sort ifinal by khinr.

LOOP AT ifinal.

AT NEW khinr.

LOOP AT ifinal WHERE khinr = ifinal-khinr.

st_rev = st_rev + ifinal-wogbtr.

ENDLOOP.

on change of ifinal-khinr.

itab1-khinr1 = ifinal-khinr.

itab1-wogbtr = st_rev.

itab1-line_color = 'C710'.

APPEND itab1.

clear itab1.

endon.

ENDAT.

ENDLOOP.

*APPEND itab1.

*itab1-line_color = ''.

CLEAR st_rev.

LOOP AT ifinal.

st_rev = st_rev + ifinal-wogbtr.

ENDLOOP.

itab1-khinr1 = 'Total'.

itab1-wogbtr = ( st_rev * ( -1 ) ).

itab1-line_color = 'C310'.

APPEND itab1.

clear itab1.

ENDFORM. " get_data1

&----


*& Form build_cat1

&----


  • text

----


  • -->P_T_FCAT1 text

----


FORM build_cat1 USING temp_fcat type slis_t_fieldcat_alv.

d_fieldcat_wa-fieldname = 'KHINR1'.

d_fieldcat_wa-seltext_m = 'ProfitCenterGroup'.

d_fieldcat_wa-col_pos = 1.

d_fieldcat_wa-hotspot = 'X'.

APPEND d_fieldcat_wa TO temp_fcat.

CLEAR d_fieldcat_wa.

  • d_fieldcat_wa-fieldname = 'PRCTR1'.

  • d_fieldcat_wa-seltext_m = 'ProfitCenter'.

  • d_fieldcat_wa-hotspot = 'X'.

  • d_fieldcat_wa-col_pos = 3.

  • APPEND d_fieldcat_wa TO temp_fcat.

  • CLEAR d_fieldcat_wa.

*

*

d_fieldcat_wa-fieldname = 'WOGBTR'.

d_fieldcat_wa-seltext_m = 'Amount'.

d_fieldcat_wa-key = 'X'.

d_fieldcat_wa-col_pos = 2.

APPEND d_fieldcat_wa TO temp_fcat.

CLEAR d_fieldcat_wa.

ENDFORM. " build_cat1

&----


*& Form build_sort1

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM build_sort1 .

subtot-spos = 1.

subtot-fieldname = 'KHINR1'.

subtot-subtot = 'X'.

subtot-down = 'X'.

subtot-expa = 'X'.

append subtot to t_subtot1.

clear subtot.

*subtot-spos = 3.

*

*subtot-fieldname = 'PRCTR1'.

*subtot-subtot = 'X'.

*subtot-down = 'X'.

*subtot-expa = 'X'.

*

*append subtot to t_subtot1.

*clear subtot.

ENDFORM. " build_sort1

&----


*& Form display1

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM display1 .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = gd_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

I_CALLBACK_USER_COMMAND = 'USER_COMMAND1'

I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

I_GRID_TITLE = 'ProfitCenterGroupDetails'

  • I_GRID_SETTINGS =

IS_LAYOUT = gd_layout

IT_FIELDCAT = t_fcat1

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

IT_SORT = t_subtot1

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS = t_eve[]

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • I_HTML_HEIGHT_TOP = 0

  • I_HTML_HEIGHT_END = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • IR_SALV_FULLSCREEN_ADAPTER =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = itab1

EXCEPTIONS

PROGRAM_ERROR = 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. " display1

&----


*& Form For UserCommand

&----


  • text

----


FORM USER_COMMAND1 USING R_UCOMM LIKE SY-UCOMM

RS_SELFIELD TYPE SLIS_SELFIELD.

data : &IC1 like ok_code,

&IC2 like ok_code.

&IC1 = ok_code.

&IC2 = ok_code.

CASE R_UCOMM.

WHEN '&IC1'.

clear ok_code.

refresh t_fcat4.

refresh t_subtot4.

refresh t_fcat5.

refresh t_subtot5.

refresh t_fcat2.

refresh t_subtot2.

refresh t_fcat3.

refresh t_subtot3.

refresh t_fcat1.

refresh t_subtot1.

IF RS_SELFIELD-FIELDNAME = 'KHINR1'.

READ TABLE itab1 INDEX rs_selfield-tabindex.

clear itab_final[].

perform secondarylist2.

ENDIF.

*WHEN 'BACK'.

*

*LEAVE TO SCREEN 0.

ENDCASE.

endform.

&----


*& Form secondarylist1

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM secondarylist1 .

clear itab2[].

clear ifinal[].

*clear itab1[].

clear itab_final[].

perform get_data2.

*perform sel.

PERFORM build_cat2 USING t_fcat2.

PERFORM build_layout.

perform build_sort2.

PERFORM display2.

ENDFORM. " secondarylist1

&----


*& Form get_data2

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM get_data2 .

--


To fetch Amount, Period ,Year, CompanyCode--

SELECT kokrs gjahr perio kstar bukrs wogbtr objnr owaer

FROM coep INTO CORRESPONDING FIELDS OF TABLE itab_coep

WHERE kokrs = p_ca

AND perio IN s_pd

AND bukrs IN s_code

AND gjahr IN s_year.

LOOP AT itab_coep.

itab_final-kokrs = itab_coep-kokrs.

itab_final-gjahr = itab_coep-gjahr.

itab_final-perio = itab_coep-perio.

itab_final-kstar = itab_coep-kstar.

itab_final-bukrs = itab_coep-bukrs.

itab_final-wogbtr = itab_coep-wogbtr.

itab_final-objnr = itab_coep-objnr.

itab_final-owaer = itab_coep-owaer.

APPEND itab_final.

CLEAR itab_final.

ENDLOOP.

IF NOT itab_coep[] IS INITIAL.

--


To fetch Amount,ProfitCenter,InternalOrder--

SELECT kokrs aufnr prctr bukrs auart objnr

FROM aufk INTO CORRESPONDING FIELDS OF TABLE itab_aufk

WHERE aufnr IN s_or

and prctr in s_pc.

loop at itab_final.

READ TABLE itab_aufk WITH KEY kokrs = itab_final-kokrs

objnr = itab_final-objnr.

IF sy-subrc = 0.

itab_final-aufnr = itab_aufk-aufnr.

itab_final-prctr = itab_aufk-prctr.

MODIFY itab_final TRANSPORTING aufnr prctr.

else.

delete itab_final.

ENDIF.

endloop.

IF NOT itab_aufk[] IS INITIAL.

--


To fetch ProfitCenter ,ProfitCenterGroup--

SELECT kokrs khinr prctr

FROM cepc INTO CORRESPONDING FIELDS OF TABLE itab_cepc

WHERE kokrs = itab_aufk-kokrs

and khinr in s_pg.

LOOP AT itab_final.

READ TABLE itab_cepc WITH KEY kokrs = itab_final-kokrs

prctr = itab_final-prctr.

IF sy-subrc = 0.

itab_final-khinr = itab_cepc-khinr.

MODIFY itab_final TRANSPORTING khinr.

else.

delete itab_final.

ENDIF.

endloop.

if not itab_coep[] is initial.

--


To fetch InternalOrderGroup--

clear itab_final-setname.

select setclass subclass setname valfrom valto

from setleaf into corresponding fields of table itab_setleaf

where setclass = '0102'

and subclass = 'VMIN'

and setname in s_kg

and valfrom in s_ku

and valto in s_ku.

loop at itab_final.

read table itab_setleaf with key valfrom = itab_final-kstar.

if sy-subrc = 0.

itab_final-setname = itab_setleaf-setname.

modify itab_final transporting setname.

else.

delete itab_final.

endif.

endloop.

if not itab_aufk[] is initial.

--


To fetch CostElementGroup--

clear itab_final-setname.

select setclass subclass setname valfrom valto

from setleaf into corresponding fields of table itab_setleaf1

where setclass = '0103'

and setname in s_org

and valfrom in s_or

and valto in s_or.

loop at itab_final .

read table itab_setleaf1 with key valfrom = itab_final-aufnr.

if sy-subrc = 0.

itab_final-setname1 = itab_setleaf1-setname.

modify itab_final transporting setname1.

else.

delete itab_final.

endif.

ENDLOOP.

IF NOT itab_coep[] IS INITIAL.

SELECT kokrs katyp aufnr kstar

FROM cskb INTO CORRESPONDING FIELDS OF TABLE itab_cskb

FOR ALL ENTRIES IN itab_coep

WHERE kokrs = itab_coep-kokrs.

loop at itab_final.

READ TABLE itab_cskb WITH KEY kstar = itab_final-kstar

kokrs = itab_final-kokrs.

IF sy-subrc = 0.

itab_final-katyp = itab_cskb-katyp.

MODIFY itab_final TRANSPORTING katyp.

ENDIF.

ENDLOOP.

endif.

endif.

ENDIF.

ENDIF.

ENDIF.

---calculation for DirectExpense--


clear ifinal[].

loop at itab_final where katyp = '01'.

move-corresponding itab_final to ifinal.

append ifinal.

endloop.

*SORT ifinal BY khinr .

clear st_pc.

sort ifinal by khinr.

LOOP AT ifinal.

AT NEW khinr.

LOOP AT ifinal WHERE khinr = ifinal-khinr.

st_pc = st_pc + ifinal-wogbtr.

ENDLOOP.

on change of ifinal-khinr.

itab2-khinr2 = ifinal-khinr.

itab2-wogbtr = st_pc.

itab2-line_color = 'C710'.

APPEND itab2.

clear itab2.

endon.

*APPEND itab1.

*itab1-line_color = ''.

CLEAR st_pc.

ENDAT.

ENDLOOP.

LOOP AT ifinal.

st_pc = st_pc + ifinal-wogbtr.

ENDLOOP.

itab2-khinr2 = 'Total'.

itab2-wogbtr = ( st_pc * ( -1 ) ).

itab2-line_color = 'C310'.

APPEND itab2.

ENDFORM. " get_data2

&----


*& Form build_cat2

&----


  • text

----


  • -->P_T_FCAT2 text

----


FORM build_cat2 USING temp_fcat type slis_t_fieldcat_alv.

d_fieldcat_wa-fieldname = 'KHINR2'.

d_fieldcat_wa-seltext_m = 'ProfitCenterGroup'.

d_fieldcat_wa-hotspot = 'X'.

d_fieldcat_wa-col_pos = 1.

APPEND d_fieldcat_wa TO temp_fcat.

CLEAR d_fieldcat_wa.

d_fieldcat_wa-fieldname = 'WOGBTR'.

d_fieldcat_wa-seltext_m = 'Amount'.

d_fieldcat_wa-key = 'X'.

d_fieldcat_wa-col_pos = 2.

APPEND d_fieldcat_wa TO temp_fcat.

CLEAR d_fieldcat_wa.

  • d_fieldcat_wa-fieldname = 'PRCTR2'.

  • d_fieldcat_wa-seltext_m = 'ProfitCenter'.

  • d_fieldcat_wa-hotspot = 'X'.

  • d_fieldcat_wa-col_pos = 3.

  • APPEND d_fieldcat_wa TO temp_fcat.

  • CLEAR d_fieldcat_wa.

ENDFORM. " build_cat2

&----


*& Form build_sort2

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM build_sort2 .

subtot-spos = 1.

subtot-fieldname = 'KHINR2'.

subtot-subtot = 'X'.

subtot-down = 'X'.

subtot-expa = 'X'.

append subtot to t_subtot2.

clear subtot.

*subtot-spos = 3.

*

*subtot-fieldname = 'PRCTR2'.

*subtot-subtot = 'X'.

*subtot-down = 'X'.

*subtot-expa = 'X'.

*

*append subtot to t_subtot2.

*clear subtot.

*

ENDFORM. " build_sort2

&----


*& Form display2

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM display2 .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = gd_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

I_CALLBACK_USER_COMMAND = 'USER_COMMAND12'

I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

I_GRID_TITLE = 'ProfitCenterGroupDetails'

  • I_GRID_SETTINGS =

IS_LAYOUT = gd_layout

IT_FIELDCAT = t_fcat2

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

IT_SORT = t_subtot2

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS = t_eve[]

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • I_HTML_HEIGHT_TOP = 0

  • I_HTML_HEIGHT_END = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • IR_SALV_FULLSCREEN_ADAPTER =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = itab2

EXCEPTIONS

PROGRAM_ERROR = 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. " display2

&----


*& Form For UserCommand

&----


  • text

----


FORM USER_COMMAND12 USING R_UCOMM LIKE SY-UCOMM

RS_SELFIELD TYPE SLIS_SELFIELD.

data : &IC1 like ok_code,

&IC2 like ok_code.

&IC1 = ok_code.

&IC2 = ok_code.

CASE R_UCOMM.

WHEN '&IC1'.

clear ok_code.

refresh t_fcat7.

refresh t_subtot7.

refresh t_fcat7.

refresh t_subtot7.

refresh t_fcat6.

refresh t_subtot6.

refresh t_fcat4.

refresh t_subtot4.

refresh t_fcat2.

refresh t_subtot2.

refresh t_fcat3.

refresh t_subtot3.

refresh t_fcat1.

refresh t_subtot1.

IF RS_SELFIELD-FIELDNAME = 'KHINR2'.

clear itab_final[].

perform secondarylist21.

ENDIF.

WHEN 'BACK'.

LEAVE TO SCREEN 0.

ENDCASE.

endform.

&----


*& Form secondarylist11

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM secondarylist11 .

perform get_data3.

*perform sel.

PERFORM build_cat3 USING t_fcat3.

perform build_sort3.

PERFORM build_layout.

PERFORM display3.

ENDFORM. " secondarylist11

&----


*& Form get_data3

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM get_data3 .

--


To fetch Amount, Period ,Year, CompanyCode--

SELECT kokrs gjahr perio kstar bukrs wogbtr objnr owaer

FROM coep INTO CORRESPONDING FIELDS OF TABLE itab_coep

WHERE kokrs = p_ca

AND perio IN s_pd

AND bukrs IN s_code

AND gjahr IN s_year.

LOOP AT itab_coep.

itab_final-kokrs = itab_coep-kokrs.

itab_final-gjahr = itab_coep-gjahr.

itab_final-perio = itab_coep-perio.

itab_final-kstar = itab_coep-kstar.

itab_final-bukrs = itab_coep-bukrs.

itab_final-wogbtr = itab_coep-wogbtr.

itab_final-objnr = itab_coep-objnr.

itab_final-owaer = itab_coep-owaer.

APPEND itab_final.

CLEAR itab_final.

ENDLOOP.

IF NOT itab_coep[] IS INITIAL.

--


To fetch Amount,ProfitCenter,InternalOrder--

SELECT kokrs aufnr prctr bukrs auart objnr

FROM aufk INTO CORRESPONDING FIELDS OF TABLE itab_aufk

WHERE aufnr IN s_or

and prctr in s_pc.

loop at itab_final.

READ TABLE itab_aufk WITH KEY kokrs = itab_final-kokrs

objnr = itab_final-objnr.

IF sy-subrc = 0.

itab_final-aufnr = itab_aufk-aufnr.

itab_final-prctr = itab_aufk-prctr.

MODIFY itab_final TRANSPORTING aufnr prctr.

else.

delete itab_final.

ENDIF.

endloop.

IF NOT itab_aufk[] IS INITIAL.

--


To fetch ProfitCenter ,ProfitCenterGroup--

SELECT kokrs khinr prctr

FROM cepc INTO CORRESPONDING FIELDS OF TABLE itab_cepc

WHERE kokrs = itab_aufk-kokrs

and khinr in s_pg.

LOOP AT itab_final.

READ TABLE itab_cepc WITH KEY kokrs = itab_final-kokrs

prctr = itab_final-prctr.

IF sy-subrc = 0.

itab_final-khinr = itab_cepc-khinr.

MODIFY itab_final TRANSPORTING khinr.

else.

delete itab_final.

ENDIF.

endloop.

if not itab_coep[] is initial.

--


To fetch InternalOrderGroup--

clear itab_final-setname.

select setclass subclass setname valfrom valto

from setleaf into corresponding fields of table itab_setleaf

where setclass = '0102'

and subclass = 'VMIN'

and setname in s_kg

and valfrom in s_ku

and valto in s_ku.

loop at itab_final.

read table itab_setleaf with key valfrom = itab_final-kstar.

if sy-subrc = 0.

itab_final-setname = itab_setleaf-setname.

modify itab_final transporting setname.

else.

delete itab_final.

endif.

endloop.

if not itab_aufk[] is initial.

--


To fetch CostElementGroup--

clear itab_final-setname.

select setclass subclass setname valfrom valto

from setleaf into corresponding fields of table itab_setleaf1

where setclass = '0103'

and setname in s_org

and valfrom in s_or

and valto in s_or.

loop at itab_final .

read table itab_setleaf1 with key valfrom = itab_final-aufnr.

if sy-subrc = 0.

itab_final-setname1 = itab_setleaf1-setname.

modify itab_final transporting setname1.

else.

delete itab_final.

endif.

ENDLOOP.

IF NOT itab_coep[] IS INITIAL.

SELECT kokrs katyp aufnr kstar

FROM cskb INTO CORRESPONDING FIELDS OF TABLE itab_cskb

FOR ALL ENTRIES IN itab_coep

WHERE kokrs = itab_coep-kokrs.

loop at itab_final.

READ TABLE itab_cskb WITH KEY kstar = itab_final-kstar

kokrs = itab_final-kokrs.

IF sy-subrc = 0.

itab_final-katyp = itab_cskb-katyp.

MODIFY itab_final TRANSPORTING katyp.

ENDIF.

ENDLOOP.

endif.

endif.

ENDIF.

ENDIF.

ENDIF.

---Calculation for Allocated cost--


clear : ifinal[].

loop at itab_final where katyp <> '01'

and katyp <> '11'

and katyp <> '12'.

move-corresponding itab_final to ifinal.

append ifinal.

endloop.

SORT ifinal BY katyp .

clear st_all.

LOOP AT ifinal.

st_all = st_all + ifinal-wogbtr.

itab3-khinr3 = ifinal-khinr.

itab3-prctr3 = ifinal-prctr.

itab3-aufnr3 = ifinal-aufnr.

itab3-setname31 = ifinal-setname1.

itab3-setname3 = ifinal-setname.

itab3-kstar = ifinal-kstar.

itab3-wogbtr = ifinal-wogbtr.

if itab2-wogbtr ca '.'.

replace '.' in itab1-wogbtr with ',' .

if itab2-wogbtr ca ','.

replace ',' in itab1-wogbtr with '.' .

endif.

endif.

append itab3.

clear : itab3, ifinal.

ENDLOOP.

itab3-wogbtr = st_all.

itab3-khinr3 = ' '.

itab3-prctr3 = ' '.

itab3-aufnr3 = ' '.

itab3-setname3 = ' '.

itab3-line_color = 'C710'.

APPEND itab3.

CLEAR : itab3,ifinal.

ENDFORM. " get_data3

&----


*& Form build_cat3

&----


  • text

----


  • -->P_T_FCAT3 text

----


FORM build_cat3 USING temp_fcat type slis_t_fieldcat_alv.

d_fieldcat_wa-fieldname = 'KHINR3'.

d_fieldcat_wa-seltext_m = 'ProfitCenterGroup'.

d_fieldcat_wa-hotspot = 'X'.

d_fieldcat_wa-col_pos = 1.

APPEND d_fieldcat_wa TO temp_fcat.

CLEAR d_fieldcat_wa.

d_fieldcat_wa-fieldname = 'WOGBTR'.

d_fieldcat_wa-seltext_m = 'Amount'.

d_fieldcat_wa-key = 'X'.

d_fieldcat_wa-col_pos = 2.

APPEND d_fieldcat_wa TO temp_fcat.

CLEAR d_fieldcat_wa.

d_fieldcat_wa-fieldname = 'PRCTR3'.

d_fieldcat_wa-seltext_m = 'ProfitCenter'.

d_fieldcat_wa-hotspot = 'X'.

d_fieldcat_wa-col_pos = 3.

APPEND d_fieldcat_wa TO temp_fcat.

CLEAR d_fieldcat_wa.

ENDFORM. " build_cat3

&----


*& Form build_sort3

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM build_sort3 .

subtot-spos = 1.

subtot-fieldname = 'KHINR3'.

subtot-subtot = 'X'.

subtot-down = 'X'.

subtot-expa = 'X'.

append subtot to t_subtot3.

clear subtot.

subtot-spos = 3.

subtot-fieldname = 'PRCTR3'.

subtot-subtot = 'X'.

subtot-down = 'X'.

subtot-expa = 'X'.

append subtot to t_subtot3.

clear subtot.

ENDFORM. " build_sort3

&----


*& Form display3

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM display3 .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = gd_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

I_CALLBACK_USER_COMMAND = 'USER_COMMAND22'

I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

I_GRID_TITLE = 'ProfitCenterGroupDetails'

  • I_GRID_SETTINGS =

IS_LAYOUT = gd_layout

IT_FIELDCAT = t_fcat3

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

IT_SORT = t_subtot3

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS = t_eve[]

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • I_HTML_HEIGHT_TOP = 0

  • I_HTML_HEIGHT_END = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • IR_SALV_FULLSCREEN_ADAPTER =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = itab3

EXCEPTIONS

PROGRAM_ERROR = 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. " display3

&----


*& Form For UserCommand

&----


  • text

----


FORM USER_COMMAND22 USING R_UCOMM LIKE SY-UCOMM

RS_SELFIELD TYPE SLIS_SELFIELD.

data : &IC1 like ok_code,

&IC2 like ok_code.

&IC1 = ok_code.

&IC2 = ok_code.

CASE R_UCOMM.

WHEN '&IC1'.

clear ok_code.

refresh t_fcat9.

refresh t_subtot9.

refresh t_fcat7.

refresh t_subtot7.

refresh t_fcat8.

refresh t_subtot8.

refresh t_fcat7.

refresh t_subtot7.

refresh t_fcat6.

refresh t_subtot6.

refresh t_fcat4.

refresh t_subtot4.

refresh t_fcat2.

refresh t_subtot2.

refresh t_fcat3.

refresh t_subtot3.

refresh t_fcat1.

refresh t_subtot1.

IF RS_SELFIELD-FIELDNAME = 'KHINR3'.

clear itab_final[].

perform secondarylist31.

ENDIF.

WHEN 'BACK'.

LEAVE TO SCREEN 0.

ENDCASE.

endform.

&----


*& Form secondarylist2

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM secondarylist2 .

clear itab1[].

clear itab2[].

clear ifinal[].

clear itab_final[].

perform get_data1.

*perform sel.

PERFORM build_cat4 USING t_fcat4.

perform build_sort4.

PERFORM build_layout.

PERFORM display4.

ENDFORM. " secondarylist2

&----


*& Form build_cat4

&----


  • text

----


  • -->P_T_FCAT4 text

----


FORM build_cat4 USING temp_fcat type slis_t_fieldcat_alv.

d_fieldcat_wa-fieldname = 'PRCTR1'.

d_fieldcat_wa-seltext_m = 'ProfitCenter'.

d_fieldcat_wa-col_pos = 1.

APPEND d_fieldcat_wa TO temp_fcat.

CLEAR d_fieldcat_wa.

d_fieldcat_wa-fieldname = 'WOGBTR'.

d_fieldcat_wa-seltext_m = 'Amount'.

d_fieldcat_wa-key = 'X'.

d_fieldcat_wa-col_pos = 2.

APPEND d_fieldcat_wa TO temp_fcat.

CLEAR d_fieldcat_wa.

  • d_fieldcat_wa-fieldname = 'SETNAME1'.

  • d_fieldcat_wa-seltext_m = 'Internal Order Group'.

  • d_fieldcat_wa-hotspot = 'X'.

  • d_fieldcat_wa-col_pos = 3.

  • APPEND d_fieldcat_wa TO temp_fcat.

  • CLEAR d_fieldcat_wa.

*

ENDFORM. " build_cat4

&----


*& Form build_sort4

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM build_sort4 .

subtot-spos = 1.

subtot-fieldname = 'PRCTR1'.

subtot-subtot = 'X'.

subtot-down = 'X'.

subtot-expa = 'X'.

append subtot to t_subtot4.

clear subtot.

ENDFORM. " build_sort4

&----


*& Form display4

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM display4 .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = gd_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

I_CALLBACK_USER_COMMAND = 'USER_COMMAND11'

I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

I_GRID_TITLE = 'InternalOrderDetails'

  • I_GRID_SETTINGS =

IS_LAYOUT = gd_layout

IT_FIELDCAT = t_fcat4

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

IT_SORT = t_subtot4

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS = t_eve[]

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • I_HTML_HEIGHT_TOP = 0

  • I_HTML_HEIGHT_END = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • IR_SALV_FULLSCREEN_ADAPTER =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = itab1

EXCEPTIONS

PROGRAM_ERROR = 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. " display4

&----


*& Form For UserCommand

&----


  • text

----


FORM USER_COMMAND11 USING R_UCOMM LIKE SY-UCOMM

RS_SELFIELD TYPE SLIS_SELFIELD.

data : &IC1 like ok_code,

&IC2 like ok_code.

&IC1 = ok_code.

&IC2 = ok_code.

CASE R_UCOMM.

WHEN '&IC1'.

clear ok_code.

refresh t_fcat2.

refresh t_subtot2.

refresh t_fcat5.

refresh t_subtot5.

refresh t_fcat4.

refresh t_subtot4.

refresh t_fcat3.

refresh t_subtot3.

refresh t_fcat1.

refresh t_subtot1.

IF RS_SELFIELD-FIELDNAME = 'AUFNR1'.

clear itab_final[].

perform secondarylist3.

ENDIF.

WHEN 'BACK'.

LEAVE TO SCREEN 0.

ENDCASE.

ENDFORM.

&----


*& Form secondarylist3

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM secondarylist3 .

clear itab1[].

clear itab2[].

clear ifinal[].

clear itab_final[].

perform get_data1.

*perform sel.

PERFORM build_cat5 USING t_fcat5.

perform build_sort5.

PERFORM build_layout.

PERFORM display5.

ENDFORM. " secondarylist3

&----


*& Form build_cat5

&----


  • text

----


  • -->P_T_FCAT5 text

----


FORM build_cat5 USING temp_fcat type slis_t_fieldcat_alv.

d_fieldcat_wa-fieldname = 'SETNAME'.

d_fieldcat_wa-seltext_m = 'Cost Element Group'.

d_fieldcat_wa-hotspot = 'X'.

d_fieldcat_wa-col_pos = 1.

APPEND d_fieldcat_wa TO temp_fcat.

CLEAR d_fieldcat_wa.

d_fieldcat_wa-fieldname = 'KSTAR'.

d_fieldcat_wa-seltext_m = 'CostElement'.

d_fieldcat_wa-col_pos = 2.

APPEND d_fieldcat_wa TO temp_fcat.

CLEAR d_fieldcat_wa.

d_fieldcat_wa-fieldname = 'WOGBTR'.

d_fieldcat_wa-seltext_m = 'Amount'.

d_fieldcat_wa-key = 'X'.

d_fieldcat_wa-col_pos = 3.

APPEND d_fieldcat_wa TO temp_fcat.

CLEAR d_fieldcat_wa.

ENDFORM. " build_cat5

&----


*& Form build_sort5

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM build_sort5 .

subtot-spos = 1.

subtot-fieldname = 'SETNAME'.

subtot-subtot = 'X'.

subtot-down = 'X'.

subtot-expa = 'X'.

append subtot to t_subtot5.

clear subtot.

ENDFORM. " build_sort5

&----


*& Form display5

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM display5 .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = gd_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ''

I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

I_GRID_TITLE = 'CostElementGroupDetails'

  • I_GRID_SETTINGS =

IS_LAYOUT = gd_layout

IT_FIELDCAT = t_fcat5

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

IT_SORT = t_subtot5

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS = t_eve[]

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • I_HTML_HEIGHT_TOP = 0

  • I_HTML_HEIGHT_END = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • IR_SALV_FULLSCREEN_ADAPTER =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = itab1

EXCEPTIONS

PROGRAM_ERROR = 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. " display5

&----


*& Form secondarylist21

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM secondarylist21 .

clear itab1[].

clear itab2[].

clear ifinal[].

clear itab_final[].

perform get_data2.

*perform sel.

PERFORM build_cat6 USING t_fcat6.

perform build_sort6.

PERFORM build_layout.

PERFORM display6.

ENDFORM. " secondarylist21

&----


*& Form build_cat6

&----


  • text

----


  • -->P_T_FCAT6 text

----


FORM build_cat6 USING temp_fcat type slis_t_fieldcat_alv.

d_fieldcat_wa-fieldname = 'AUFNR2'.

d_fieldcat_wa-seltext_m = 'Internal Order'.

d_fieldcat_wa-hotspot = 'X'.

d_fieldcat_wa-col_pos = 1.

APPEND d_fieldcat_wa TO temp_fcat.

CLEAR d_fieldcat_wa.

d_fieldcat_wa-fieldname = 'WOGBTR'.

d_fieldcat_wa-seltext_m = 'Amount'.

d_fieldcat_wa-key = 'X'.

d_fieldcat_wa-col_pos = 2.

APPEND d_fieldcat_wa TO temp_fcat.

CLEAR d_fieldcat_wa.

d_fieldcat_wa-fieldname = 'SETNAME21'.

d_fieldcat_wa-seltext_m = 'Internal Order Group'.

d_fieldcat_wa-hotspot = 'X'.

d_fieldcat_wa-col_pos = 3.

APPEND d_fieldcat_wa TO temp_fcat.

CLEAR d_fieldcat_wa.

ENDFORM. " build_cat6

&----


*& Form build_sort6

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM build_sort6 .

subtot-spos = 1.

subtot-fieldname = 'AUFNR2'.

subtot-subtot = 'X'.

subtot-down = 'X'.

subtot-expa = 'X'.

append subtot to t_subtot6.

clear subtot.

ENDFORM. " build_sort6

&----


*& Form display6

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM display6 .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = gd_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

I_CALLBACK_USER_COMMAND = 'USER_COMMAND13'

I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

I_GRID_TITLE = 'InternalOrderDetails'

  • I_GRID_SETTINGS =

IS_LAYOUT = gd_layout

IT_FIELDCAT = t_fcat6

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

IT_SORT = t_subtot6

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS = t_eve[]

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • I_HTML_HEIGHT_TOP = 0

  • I_HTML_HEIGHT_END = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • IR_SALV_FULLSCREEN_ADAPTER =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = itab2

EXCEPTIONS

PROGRAM_ERROR = 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. " display6

&----


*& Form For UserCommand

&----


  • text

----


FORM USER_COMMAND13 USING R_UCOMM LIKE SY-UCOMM

RS_SELFIELD TYPE SLIS_SELFIELD.

data : &IC1 like ok_code,

&IC2 like ok_code.

&IC1 = ok_code.

&IC2 = ok_code.

CASE R_UCOMM.

WHEN '&IC1'.

clear ok_code.

refresh t_fcat7.

refresh t_subtot7.

refresh t_fcat6.

refresh t_subtot6.

refresh t_fcat2.

refresh t_subtot2.

refresh t_fcat4.

refresh t_subtot4.

refresh t_fcat3.

refresh t_subtot3.

refresh t_fcat1.

refresh t_subtot1.

IF RS_SELFIELD-FIELDNAME = 'AUFNR2'.

clear itab_final[].

perform secondarylist23.

ENDIF.

WHEN 'BACK'.

LEAVE TO SCREEN 0.

ENDCASE.

ENDFORM.

&----


*& Form secondarylist23

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM secondarylist23 .

clear itab1[].

clear itab2[].

clear ifinal[].

clear itab_final[].

perform get_data2.

*perform sel.

PERFORM build_cat7 USING t_fcat7.

perform build_sort7.

PERFORM build_layout.

PERFORM display7.

ENDFORM. " secondarylist23

&----


*& Form build_cat7

&----


  • text

----


  • -->P_T_FCAT7 text

----


FORM build_cat7 USING temp_fcat type slis_t_fieldcat_alv.

d_fieldcat_wa-fieldname = 'SETNAME2'.

d_fieldcat_wa-seltext_m = 'CostElementGroup'.

d_fieldcat_wa-hotspot = 'X'.

d_fieldcat_wa-col_pos = 1.

APPEND d_fieldcat_wa TO temp_fcat.

CLEAR d_fieldcat_wa.

d_fieldcat_wa-fieldname = 'WOGBTR'.

d_fieldcat_wa-seltext_m = 'Amount'.

d_fieldcat_wa-key = 'X'.

d_fieldcat_wa-col_pos = 2.

APPEND d_fieldcat_wa TO temp_fcat.

CLEAR d_fieldcat_wa.

d_fieldcat_wa-fieldname = 'KSTAR'.

d_fieldcat_wa-seltext_m = 'CostElement'.

d_fieldcat_wa-hotspot = 'X'.

d_fieldcat_wa-col_pos = 3.

APPEND d_fieldcat_wa TO temp_fcat.

CLEAR d_fieldcat_wa.

ENDFORM. " build_cat7

&----


*& Form build_sort7

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM build_sort7 .

subtot-spos = 1.

subtot-fieldname = 'SETNAME2'.

subtot-subtot = 'X'.

subtot-down = 'X'.

subtot-expa = 'X'.

append subtot to t_subtot6.

clear subtot.

ENDFORM. " build_sort7

&----


*& Form display7

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM display7 .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = gd_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = 'USER_COMMAND13'

I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

I_GRID_TITLE = 'CostElementGroupDetails'

  • I_GRID_SETTINGS =

IS_LAYOUT = gd_layout

IT_FIELDCAT = t_fcat7

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

IT_SORT = t_subtot7

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS = t_eve[]

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • I_HTML_HEIGHT_TOP = 0

  • I_HTML_HEIGHT_END = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • IR_SALV_FULLSCREEN_ADAPTER =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = itab2

EXCEPTIONS

PROGRAM_ERROR = 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. " display7

&----


*& Form secondarylist31

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM secondarylist31 .

clear itab1[].

clear itab3[].

clear ifinal[].

clear itab_final[].

perform get_data3.

*perform sel.

PERFORM build_cat8 USING t_fcat8.

perform build_sort8.

PERFORM build_layout.

PERFORM display8.

ENDFORM. " secondarylist31

&----


*& Form build_cat8

&----


  • text

----


  • -->P_T_FCAT8 text

----


FORM build_cat8 USING temp_fcat type slis_t_fieldcat_alv.

d_fieldcat_wa-fieldname = 'AUFNR3'.

d_fieldcat_wa-seltext_m = 'Internal Order'.

d_fieldcat_wa-hotspot = 'X'.

d_fieldcat_wa-col_pos = 1.

APPEND d_fieldcat_wa TO temp_fcat.

CLEAR d_fieldcat_wa.

d_fieldcat_wa-fieldname = 'WOGBTR'.

d_fieldcat_wa-seltext_m = 'Amount'.

d_fieldcat_wa-key = 'X'.

d_fieldcat_wa-col_pos = 2.

APPEND d_fieldcat_wa TO temp_fcat.

CLEAR d_fieldcat_wa.

d_fieldcat_wa-fieldname = 'SETNAME31'.

d_fieldcat_wa-seltext_m = 'Internal Order Group'.

d_fieldcat_wa-hotspot = 'X'.

d_fieldcat_wa-col_pos = 3.

APPEND d_fieldcat_wa TO temp_fcat.

CLEAR d_fieldcat_wa.

ENDFORM. " build_cat8

&----


*& Form build_sort8

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM build_sort8 .

subtot-spos = 1.

subtot-fieldname = 'AUFNR3'.

subtot-subtot = 'X'.

subtot-down = 'X'.

subtot-expa = 'X'.

append subtot to t_subtot8.

clear subtot.

ENDFORM. " build_sort8

&----


*& Form display8

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM display8 .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = gd_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

I_CALLBACK_USER_COMMAND = 'USER_COMMAND23'

I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

I_GRID_TITLE = 'InternalOrderDetails'

  • I_GRID_SETTINGS =

IS_LAYOUT = gd_layout

IT_FIELDCAT = t_fcat8

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

IT_SORT = t_subtot8

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS = t_eve[]

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • I_HTML_HEIGHT_TOP = 0

  • I_HTML_HEIGHT_END = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • IR_SALV_FULLSCREEN_ADAPTER =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = itab3

EXCEPTIONS

PROGRAM_ERROR = 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. " display8

&----


*& Form For UserCommand

&----


  • text

----


FORM USER_COMMAND23 USING R_UCOMM LIKE SY-UCOMM

RS_SELFIELD TYPE SLIS_SELFIELD.

data : &IC1 like ok_code,

&IC2 like ok_code.

&IC1 = ok_code.

&IC2 = ok_code.

CASE R_UCOMM.

WHEN '&IC1'.

clear ok_code.

refresh t_fcat9.

refresh t_subtot9.

refresh t_fcat8.

refresh t_subtot8.

refresh t_fcat7.

refresh t_subtot7.

refresh t_fcat6.

refresh t_subtot6.

refresh t_fcat2.

refresh t_subtot2.

refresh t_fcat4.

refresh t_subtot4.

refresh t_fcat3.

refresh t_subtot3.

refresh t_fcat1.

refresh t_subtot1.

IF RS_SELFIELD-FIELDNAME = 'AUFNR3'.

clear itab_final[].

perform secondarylist33.

ENDIF.

WHEN 'BACK'.

LEAVE TO SCREEN 0.

ENDCASE.

ENDFORM.

&----


*& Form secondarylist33

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM secondarylist33 .

clear itab1[].

clear itab3[].

clear ifinal[].

clear itab_final[].

perform get_data3.

*perform sel.

PERFORM build_cat9 USING t_fcat9.

perform build_sort9.

PERFORM build_layout.

PERFORM display9.

ENDFORM. " secondarylist33

&----


*& Form build_cat9

&----


  • text

----


  • -->P_T_FCAT9 text

----


FORM build_cat9 USING temp_fcat type slis_t_fieldcat_alv.

d_fieldcat_wa-fieldname = 'SETNAME3'.

d_fieldcat_wa-seltext_m = 'CostElement Group'.

d_fieldcat_wa-hotspot = 'X'.

d_fieldcat_wa-col_pos = 1.

APPEND d_fieldcat_wa TO temp_fcat.

CLEAR d_fieldcat_wa.

d_fieldcat_wa-fieldname = 'WOGBTR'.

d_fieldcat_wa-seltext_m = 'Amount'.

d_fieldcat_wa-key = 'X'.

d_fieldcat_wa-col_pos = 2.

APPEND d_fieldcat_wa TO temp_fcat.

CLEAR d_fieldcat_wa.

d_fieldcat_wa-fieldname = 'KSTAR'.

d_fieldcat_wa-seltext_m = 'CostElement'.

d_fieldcat_wa-hotspot = 'X'.

d_fieldcat_wa-col_pos = 3.

APPEND d_fieldcat_wa TO temp_fcat.

CLEAR d_fieldcat_wa.

ENDFORM. " build_cat9

&----


*& Form build_sort9

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM build_sort9 .

subtot-spos = 1.

subtot-fieldname = 'SETNAME3'.

subtot-subtot = 'X'.

subtot-down = 'X'.

subtot-expa = 'X'.

append subtot to t_subtot9.

clear subtot.

ENDFORM. " build_sort9

&----


*& Form display9

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM display9 .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = gd_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

I_CALLBACK_USER_COMMAND = 'USER_COMMAND23'

I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

I_GRID_TITLE = 'CostElementGroupDetails'

  • I_GRID_SETTINGS =

IS_LAYOUT = gd_layout

IT_FIELDCAT = t_fcat9

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

IT_SORT = t_subtot9

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS = t_eve[]

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • I_HTML_HEIGHT_TOP = 0

  • I_HTML_HEIGHT_END = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • IR_SALV_FULLSCREEN_ADAPTER =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = itab3

EXCEPTIONS

PROGRAM_ERROR = 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. " display9

&----


*& Form Top_of_page

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form top_of_page.

data : uline like sy-uline.

data : wa_header1 type slis_listheader.

uline = sy-uline.

wa_header-typ = 'S'.

wa_header-info = 'Inputs'.

append wa_header to t_header.

clear wa_header.

wa_header-typ = 'S'.

wa_header-info = uline.

append wa_header to t_header.

clear wa_header.

wa_header-typ = 'S'.

wa_header-key = 'Controlling Area:'.

wa_header-info = p_ca.

append wa_header to t_header.

clear wa_header.

wa_header-typ = 'S'.

wa_header-key = ' Year '.

if s_year-high = ''.

wa_header-info = s_year-low.

append wa_header to t_header.

clear wa_header.

else.

concatenate s_year-low 'to' s_year-high

into wa_header-info separated by space.

append wa_header to t_header.

clear wa_header.

endif.

wa_header-typ = 'S'.

wa_header-key = 'Company Code '.

if s_code-high = ''.

wa_header-info = s_code-low.

append wa_header to t_header.

clear wa_header.

else.

concatenate s_code-low 'to' s_code-high

into wa_header-info separated by space.

append wa_header to t_header.

clear wa_header.

endif.

wa_header-typ = 'S'.

wa_header-key = ' Profit Center Group '.

if s_pg-high = ''.

wa_header-info = s_pg-low.

append wa_header to t_header.

clear wa_header.

else.

concatenate s_pg-low 'to' s_pg-high

into wa_header-info separated by space.

append wa_header to t_header.

clear wa_header.

endif.

wa_header-typ = 'S'.

wa_header-key = 'Profit Center'.

if s_pc-high = ''.

wa_header-info = s_pc-low.

append wa_header to t_header.

clear wa_header.

else.

concatenate s_pc-low 'to' s_pc-high

into wa_header-info separated by space.

append wa_header to t_header.

clear wa_header.

endif.

wa_header-typ = 'S'.

wa_header-key = 'Cost Element Group '.

if s_kg-high = ''.

wa_header-info = s_kg-low.

append wa_header to t_header.

clear wa_header.

else.

concatenate s_kg-low 'to' s_kg-high

into wa_header-info separated by space.

append wa_header to t_header.

clear wa_header.

endif.

wa_header-typ = 'S'.

wa_header-key = ' Internal Order '.

if s_or-high = ''.

wa_header-info = s_or-low.

append wa_header to t_header.

clear wa_header.

else.

concatenate s_or-low 'to' s_or-high

into wa_header-info separated by space.

append wa_header to t_header.

clear wa_header.

endif.

wa_header-typ = 'S'.

wa_header-key = ' InternalOrderGroup '.

if s_org-high = ''.

wa_header-info = s_org-low.

append wa_header to t_header.

clear wa_header.

else.

concatenate s_org-low 'to' s_org-high

into wa_header-info separated by space.

append wa_header to t_header.

clear wa_header.

endif.

wa_header-typ = 'S'.

wa_header-key = 'Currency'.

wa_header-info = itab_final-owaer.

append wa_header to t_header.

clear wa_header.

wa_header-typ = 'S'.

wa_header-info = uline.

append wa_header to t_header.

clear wa_header.

wa_header1-key = 'TillPeriod '.

concatenate s_pd-low 'To'

s_pd-high into wa_header1-info separated by space.

wa_header-typ = 'S'.

concatenate 'From Period ' s_pd-low

space wa_header1 into wa_header-info separated by space.

append wa_header to t_header.

clear wa_header.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = t_header

I_LOGO = 'ZVMLOGO'

  • I_END_OF_LIST_GRID =

  • I_ALV_FORM =

.

refresh t_header.

endform. "top_of_page

hi,

I have pasted the code below .when i click on revenue it is giving revenue details .but when i press back .and then again press revenue for the second time.Profit center group data is not coming only Total value is coming.please help me out in finding the solution.

&----


*& Report ZINTORD3

*&

&----


*&

*&

&----


REPORT ZINTORD3 message-id zerror .

*&----


*& Table declaration

&----


TABLES : coep,

coas,

tkv11,

cepc,

cskb,

tka01,

cska,

aufk,

setleaf.

*

*&----


*& type-pool declaration

&----


TYPE-POOLS : slis.

*&----


*& Internal tables declaration

&----


DATA : BEGIN OF itab_coep OCCURS 0,

kokrs LIKE coep-kokrs, " Controlling Area

gjahr LIKE coep-gjahr, " FiscalYear

perio LIKE coep-perio, " Period

kstar LIKE coep-kstar, " CostElement

bukrs LIKE coep-bukrs, " CompanyCode

wogbtr LIKE coep-wogbtr, " Amount in Object Currency

mbgbtr LIKE coep-mbgbtr, " Total quantity entered

meinh LIKE coep-meinh, " unit

objnr like coep-objnr,

OWAER like coep-owaer,

line_color(4) TYPE c,

END OF itab_coep.

DATA :BEGIN OF itab_cepc OCCURS 0,

kokrs LIKE cepc-kokrs,

prctr LIKE cepc-prctr,

khinr LIKE cepc-khinr, " Profit Center Group

bukrs like cepc-bukrs,

END OF itab_cepc.

DATA : BEGIN OF itab_aufk OCCURS 0,

kokrs LIKE aufk-kokrs,

aufnr LIKE aufk-aufnr, " Order Number

bukrs LIKE aufk-bukrs,

prctr LIKE aufk-prctr, " ProfitCenter

auart LIKE aufk-auart, " OrderType

autyp LIKE aufk-autyp, " Order Category

objnr like aufk-objnr,

END OF itab_aufk.

DATA : BEGIN OF itab_cskb OCCURS 0,

kokrs LIKE cskb-kokrs,

kstar LIKE cskb-kstar,

katyp LIKE cskb-katyp, " Cost Element Type

aufnr LIKE cskb-aufnr,

END OF itab_cskb.

data : begin of itab_setleaf occurs 0,

setclass like setleaf-setclass,

subclass like setleaf-subclass,

setname like setleaf-setname, " CostElementGroup

valfrom like setleaf-valfrom,

valto like setleaf-valto,

end of itab_setleaf.

data : begin of itab_setleaf1 occurs 0,

setclass like setleaf-setclass,

subclass like setleaf-subclass,

setname like setleaf-setname, "InternalOrderGroupName

valfrom like setleaf-valfrom,

valto like setleaf-valto,

end of itab_setleaf1.

DATA : BEGIN OF itab_final OCCURS 0,

kokrs LIKE coep-kokrs,

gjahr like coep-gjahr,

perio LIKE coep-perio,

kstar LIKE coep-kstar,

bukrs LIKE coep-bukrs,

wogbtr LIKE coep-wogbtr,

wogbtr1(100) type C,

mbgbtr LIKE coep-mbgbtr,

meinh LIKE coep-meinh,

OWAER like coep-owaer,

aufnr LIKE aufk-aufnr,

auart LIKE aufk-auart,

katyp LIKE cskb-katyp,

prctr LIKE aufk-prctr,

khinr LIKE cepc-khinr,

kagru LIKE tkv11-kagru,

periol like coep-perio,

perioh like coep-perio,

gjahrl like coep-gjahr,

gjahrh like coep-gjahr,

objnr like coep-objnr,

setclass like setleaf-setclass,

subclass like setleaf-subclass,

setname like setleaf-setname, " CostelementGroup

setname1 like setleaf-setname, " InternalOrderGroup

valfrom like setleaf-valfrom,

valto like setleaf-valto,

ca like coep-kokrs,

ccl like coep-bukrs,

cch like coep-bukrs,

pgl like cepc-khinr,

pgh like cepc-khinr,

pcl like cepc-prctr,

pch like cepc-prctr,

kul like coep-kstar,

kuh like coep-kstar,

kgl like setheader-setname,

kgh like setheader-setname,

orl like cskb-aufnr,

orh like cskb-aufnr,

orgl like setleaf-setname,

orgh like setleaf-setname,

line_color(4) TYPE c,

END OF itab_final.

DATA : ifinal like itab_final occurs 0 with header line.

DATA : BEGIN OF itab1 OCCURS 0,

katyp1(100) type c ,

katyp like cskb-katyp,

gjahr like coep-gjahr,

bukrs like coep-bukrs,

  • wogbtr LIKE coep-wogbtr,

wogbtr(100) type C,

OWAER like coep-owaer,

kstar like coep-kstar,

perio1(100) type C,

gjahr1(100) type c,

prctr11 like aufk-prctr,

perio LIKE coep-perio,

periol like coep-perio,

perioh like coep-perio,

gjahrl like coep-gjahr,

gjahrh like coep-gjahr,

prctr like aufk-prctr,

prctr1 like aufk-prctr,

khinr1 like cepc-khinr,

prctr2 like aufk-prctr,

khinr2 like cepc-khinr,

aufnr1 like aufk-aufnr,

setname like setleaf-setname, " CostelementGroup

setname1 like setleaf-setname, " InternalOrderGroup

ca like coep-kokrs,

ccl like coep-bukrs,

cch like coep-bukrs,

pgl like cepc-khinr,

pgh like cepc-khinr,

pcl like cepc-prctr,

pch like cepc-prctr,

kul like coep-kstar,

kuh like coep-kstar,

kgl like setheader-setname,

kgh like setheader-setname,

orl like cskb-aufnr,

orh like cskb-aufnr,

orgl like setleaf-setname,

orgh like setleaf-setname,

line_color(4) TYPE c,

END OF itab1.

DATA : BEGIN OF itab2 OCCURS 0,

katyp1(100) type c ,

katyp like cskb-katyp,

gjahr like coep-gjahr,

bukrs like coep-bukrs,

  • wogbtr LIKE coep-wogbtr,

wogbtr(100) type C,

OWAER like coep-owaer,

kstar like coep-kstar,

perio1(100) type C,

gjahr1(100) type c,

perio LIKE coep-perio,

periol like coep-perio,

perioh like coep-perio,

gjahrl like coep-gjahr,

gjahrh like coep-gjahr,

prctr like aufk-prctr,

prctr2 like aufk-prctr,

khinr2 like cepc-khinr,

aufnr2 like aufk-aufnr,

setname2 like setleaf-setname, " CostelementGroup

setname21 like setleaf-setname, " InternalOrderGroup

ca like coep-kokrs,

ccl like coep-bukrs,

cch like coep-bukrs,

pgl like cepc-khinr,

pgh like cepc-khinr,

pcl like cepc-prctr,

pch like cepc-prctr,

kul like coep-kstar,

kuh like coep-kstar,

kgl like setheader-setname,

kgh like setheader-setname,

orl like cskb-aufnr,

orh like cskb-aufnr,

orgl like setleaf-setname,

orgh like setleaf-setname,

line_color(4) TYPE c,

END OF itab2.

DATA : BEGIN OF itab3 OCCURS 0,

katyp1(100) type c ,

katyp like cskb-katyp,

gjahr like coep-gjahr,

bukrs like coep-bukrs,

  • wogbtr LIKE coep-wogbtr,

wogbtr(100) type C,

OWAER like coep-owaer,

perio1(100) type C,

gjahr1(100) type c,

perio LIKE coep-perio,

periol like coep-perio,

perioh like coep-perio,

gjahrl like coep-gjahr,

gjahrh like coep-gjahr,

prctr3 like aufk-prctr,

khinr3 like cepc-khinr,

kstar like coep-kstar,

aufnr3 like aufk-aufnr,

setname3 like setleaf-setname, " CostelementGroup

setname31 like setleaf-setname, " InternalOrderGroup

ca like coep-kokrs,

ccl like coep-bukrs,

cch like coep-bukrs,

pgl like cepc-khinr,

pgh like cepc-khinr,

pcl like cepc-prctr,

pch like cepc-prctr,

kul like coep-kstar,

kuh like coep-kstar,

kgl like setheader-setname,

kgh like setheader-setname,

orl like cskb-aufnr,

orh like cskb-aufnr,

orgl like setleaf-setname,

orgh like setleaf-setname,

line_color(4) TYPE c,

END OF itab3.

DATA : lin type i.

*&----


*& fieldcatalog declaration

&----


DATA : t_fcat TYPE slis_t_fieldcat_alv,

t_fcat1 TYPE slis_t_fieldcat_alv,

t_fcat2 TYPE slis_t_fieldcat_alv,

t_fcat3 TYPE slis_t_fieldcat_alv,

t_fcat4 TYPE slis_t_fieldcat_alv,

t_fcat5 TYPE slis_t_fieldcat_alv,

t_fcat6 TYPE slis_t_fieldcat_alv,

t_fcat7 TYPE slis_t_fieldcat_alv,

t_fcat8 TYPE slis_t_fieldcat_alv,

t_fcat9 TYPE slis_t_fieldcat_alv,

t_eve TYPE slis_t_event,

t_subtot TYPE slis_t_sortinfo_alv,

t_subtot1 TYPE slis_t_sortinfo_alv,

t_subtot2 type slis_t_sortinfo_alv,

t_subtot3 type slis_t_sortinfo_alv,

t_subtot4 type slis_t_sortinfo_alv,

t_subtot5 type slis_t_sortinfo_alv,

t_subtot6 type slis_t_sortinfo_alv,

t_subtot7 type slis_t_sortinfo_alv,

t_subtot8 type slis_t_sortinfo_alv,

t_subtot9 type slis_t_sortinfo_alv,

subtot LIKE LINE OF t_subtot,

d_fieldcat_wa LIKE LINE OF t_fcat,

gd_layout TYPE slis_layout_alv.

DATA : t_header type slis_t_listheader,

wa_header type slis_listheader.

*&----


*& variables declaration

&----


DATA : gt_gross LIKE coep-wogbtr,

st_rev LIKE coep-wogbtr,

st_rev1 LIKE coep-wogbtr,

st_pc1 LIKE coep-wogbtr,

st_pc LIKE coep-wogbtr,

st_all1 LIKE coep-wogbtr,

st_all LIKE coep-wogbtr,

st_gross LIKE coep-wogbtr,

st_gross1 LIKE coep-wogbtr,

st_net1 LIKE coep-wogbtr,

st_net LIKE coep-wogbtr,

st_pt1 LIKE coep-wogbtr,

st_pt LIKE coep-wogbtr,

st_nt1 LIKE coep-wogbtr,

st_nt LIKE coep-wogbtr.

DATA : gd_repid LIKE sy-repid.

gd_repid = sy-repid.

data : ok_code like sy-ucomm.

data : DC like ok_code.

DC = ok_code.

*&----


*& Selection-Screen declaration

&----


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

PARAMETERS : p_ca LIKE coep-kokrs obligatory .

SELECT-OPTIONS : s_year FOR coep-gjahr obligatory." matchcode object zyear."default 2007 to 9999.

SELECT-OPTIONS : s_pd FOR coep-perio obligatory .

SELECT-OPTIONS : s_code FOR coep-bukrs.

SELECT-OPTIONS : s_pg FOR cepc-khinr MATCHCODE OBJECT zprofitcentergroup.

SELECT-OPTIONS : s_pc FOR aufk-prctr.

SELECT-OPTIONS : s_ku FOR coep-kstar no-display matchcode object zcost.

select-options : s_kg for setleaf-setname matchcode object zsetname.

SELECT-OPTIONS : s_or FOR aufk-aufnr.

select-options : s_org for setleaf-setname matchcode object ZSETNAME1.

SELECTION-SCREEN : END OF BLOCK blk1.

*&----


*& Selection-Screen Validation

&----


at selection-screen on p_ca.

select kokrs gjahr perio bukrs from coep

into corresponding fields of table itab_coep

where kokrs = p_ca.

if sy-subrc <> 0.

message e001(zerror) .

endif.

at selection-screen on s_year.

select kokrs gjahr perio bukrs from coep

into corresponding fields of table itab_coep

where gjahr in s_year.

if sy-subrc <> 0.

  • message e005(zerror) with s_year-low .

Message e000(zash) with 'For' s_year-low 'Entries not Available' .

endif.

at selection-screen on s_code.

select kokrs gjahr perio bukrs from coep

into corresponding fields of table itab_coep

where bukrs in s_code.

if sy-subrc <> 0.

message e006(zerror) .

endif.

at selection-screen on s_pd.

select kokrs gjahr perio bukrs from coep

into corresponding fields of table itab_coep

where perio in s_pd.

if sy-subrc <> 0.

message e001(zash) with 'for' s_pd-low 'No Entries Available'.

endif.

at selection-screen on s_pg.

select kokrs khinr prctr from cepc

into corresponding fields of table itab_cepc

where khinr in s_pg.

if sy-subrc <> 0.

message e002(zerror).

endif.

at selection-screen on s_pc.

select prctr from aufk

into corresponding fields of table itab_cepc

where prctr in s_pc.

if sy-subrc <> 0.

message e008(zerror).

endif.

at selection-screen on s_or.

select single * from aufk where aufnr in s_or.

if sy-subrc <> 0.

message e003(Zerror).

endif.

at selection-screen on s_kg.

select single * from setleaf where setname in s_kg.

if sy-subrc <> 0.

message e017(zerror).

endif.

*&----


*& Start-Of-Selection

&----


START-OF-SELECTION.

clear itab1[].

PERFORM get_data.

  • perform sel.

PERFORM build_cat USING t_fcat.

PERFORM build_layout.

PERFORM display.

&----


*& Form build_cat

&----


  • text

----


  • -->TEMP_FCAT text

----


FORM build_cat USING temp_fcat TYPE slis_t_fieldcat_alv.

d_fieldcat_wa-fieldname = 'KATYP1'.

d_fieldcat_wa-seltext_m = 'CostelementType'.

d_fieldcat_wa-hotspot = 'X'.

d_fieldcat_wa-col_pos = 1.

APPEND d_fieldcat_wa TO temp_fcat.

CLEAR d_fieldcat_wa.

d_fieldcat_wa-fieldname = 'PERIO1'. " Amount For 'To Period'

d_fieldcat_wa-seltext_m = 'For The Period'.

d_fieldcat_wa-key = 'X'.

d_fieldcat_wa-col_pos = 3.

APPEND d_fieldcat_wa TO temp_fcat.

CLEAR d_fieldcat_wa.

d_fieldcat_wa-fieldname = 'GJAHR1'. " Amount For 'From to To period '

d_fieldcat_wa-seltext_m = 'Year to Date'.

d_fieldcat_wa-key = 'X'.

d_fieldcat_wa-col_pos = 4.

APPEND d_fieldcat_wa TO temp_fcat.

CLEAR d_fieldcat_wa.

ENDFORM. "build_cat

&----


*& Form build_eve

&----


  • text

----


FORM build_eve.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 0

IMPORTING

et_events = t_eve

EXCEPTIONS

list_type_wrong = 1

OTHERS = 2.

IF sy-subrc EQ 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

endform.

&----


*& Form get_data

&----


  • text

----


FORM get_data.

--


To fetch Amount, Period ,Year, CompanyCode--

SELECT kokrs gjahr perio kstar bukrs wogbtr objnr owaer

FROM coep INTO CORRESPONDING FIELDS OF TABLE itab_coep

WHERE kokrs = p_ca

AND perio IN s_pd

AND bukrs IN s_code

AND gjahr IN s_year.

LOOP AT itab_coep.

itab_final-kokrs = itab_coep-kokrs.

itab_final-gjahr = itab_coep-gjahr.

itab_final-perio = itab_coep-perio.

itab_final-kstar = itab_coep-kstar.

itab_final-bukrs = itab_coep-bukrs.

itab_final-wogbtr = itab_coep-wogbtr.

itab_final-objnr = itab_coep-objnr.

itab_final-owaer = itab_coep-owaer.

APPEND itab_final.

CLEAR itab_final.

ENDLOOP.

IF NOT itab_coep[] IS INITIAL.

--


To fetch Amount,ProfitCenter,InternalOrder--

SELECT kokrs aufnr prctr bukrs auart objnr

FROM aufk INTO CORRESPONDING FIELDS OF TABLE itab_aufk

WHERE aufnr IN s_or

and prctr in s_pc.

loop at itab_final.

READ TABLE itab_aufk WITH KEY kokrs = itab_final-kokrs

objnr = itab_final-objnr.

IF sy-subrc = 0.

itab_final-aufnr = itab_aufk-aufnr.

itab_final-prctr = itab_aufk-prctr.

MODIFY itab_final TRANSPORTING aufnr prctr.

else.

delete itab_final.

ENDIF.

endloop.

IF NOT itab_aufk[] IS INITIAL.

--


To fetch ProfitCenter ,ProfitCenterGroup--

SELECT kokrs khinr prctr

FROM cepc INTO CORRESPONDING FIELDS OF TABLE itab_cepc

WHERE kokrs = itab_aufk-kokrs

and khinr in s_pg.

LOOP AT itab_final.

READ TABLE itab_cepc WITH KEY kokrs = itab_final-kokrs

prctr = itab_final-prctr.

IF sy-subrc = 0.

itab_final-khinr = itab_cepc-khinr.

MODIFY itab_final TRANSPORTING khinr.

else.

delete itab_final.

ENDIF.

endloop.

if not itab_coep[] is initial.

--


To fetch InternalOrderGroup--

clear itab_final-setname.

select setclass subclass setname valfrom valto

from setleaf into corresponding fields of table itab_setleaf

where setclass = '0102'

and subclass = 'VMIN'

and setname in s_kg

and valfrom in s_ku

and valto in s_ku.

loop at itab_final.

read table itab_setleaf with key valfrom = itab_final-kstar.

if sy-subrc = 0.

itab_final-setname = itab_setleaf-setname.

modify itab_final transporting setname.

else.

delete itab_final.

endif.

endloop.

if not itab_aufk[] is initial.

--


To fetch CostElementGroup--

clear itab_final-setname.

select setclass subclass setname valfrom valto

from setleaf into corresponding fields of table itab_setleaf1

where setclass = '0103'

and setname in s_org

and valfrom in s_or

and valto in s_or.

loop at itab_final .

read table itab_setleaf1 with key valfrom = itab_final-aufnr.

if sy-subrc = 0.

itab_final-setname1 = itab_setleaf1-setname.

modify itab_final transporting setname1.

else.

delete itab_final.

endif.

ENDLOOP.

IF NOT itab_coep[] IS INITIAL.

SELECT kokrs katyp aufnr kstar

FROM cskb INTO CORRESPONDING FIELDS OF TABLE itab_cskb

FOR ALL ENTRIES IN itab_coep

WHERE kokrs = itab_coep-kokrs.

loop at itab_final.

READ TABLE itab_cskb WITH KEY kstar = itab_final-kstar

kokrs = itab_final-kokrs.

IF sy-subrc = 0.

itab_final-katyp = itab_cskb-katyp.

MODIFY itab_final TRANSPORTING katyp.

ENDIF.

ENDLOOP.

endif.

endif.

ENDIF.

ENDIF.

ENDIF.

loop at itab_final where katyp = '11' or katyp = '12'.

move-corresponding itab_final to ifinal.

append ifinal.

clear ifinal.

endloop.

--


calculation for revenue--

SORT ifinal BY katyp.

loop at ifinal where perio = s_pd-high.

st_rev1 = st_rev1 + ifinal-wogbtr.

endloop.

st_rev1 = ( st_rev1 * ( -1 ) ).

LOOP AT ifinal .

st_rev = st_rev + ifinal-wogbtr.

ENDLOOP.

st_rev = ( st_rev * ( -1 ) ).

itab1-katyp1 = ' '.

itab1-wogbtr = st_rev .

concatenate s_pd-high ' ' into itab1-perio1 separated by space.

Concatenate s_pd-low '-' s_pd-high into itab1-gjahr1 separated by space.

itab1-line_color = 'C710'.

APPEND itab1.

itab1-line_color = ' '.

CLEAR : itab1,ifinal.

itab1-katyp1 = 'Revenue '.

itab1-perio1 = st_rev1 .

itab1-gjahr1 = st_rev .

APPEND itab1.

CLEAR : itab1,ifinal.

---calculation for DirectExpense--


clear : ifinal[].

loop at itab_final where katyp = '01'.

move-corresponding itab_final to ifinal.

append ifinal.

endloop.

SORT ifinal BY katyp .

LOOP AT ifinal.

st_pc = st_pc + ifinal-wogbtr.

ENDLOOP.

loop at ifinal where perio = s_pd-high.

st_pc1 = st_pc1 + ifinal-wogbtr.

endloop.

itab1-katyp1 = 'DirectExpense'.

itab1-wogbtr = st_pc.

itab1-perio1 = st_pc1.

itab1-gjahr1 = st_pc.

APPEND itab1.

CLEAR : itab1,ifinal.

---calculation for Gross Margin--


st_gross1 = st_rev1 - st_pc1.

if st_pc1 > st_rev1.

st_gross1 = ( st_gross1 * ( -1 ) ).

endif.

itab1-katyp1 = 'GrossMargin '.

st_gross = ( st_rev - st_pc ).

if st_pc > st_rev.

st_gross = ( st_gross * ( -1 ) ).

endif.

itab1-wogbtr = st_gross.

itab1-perio1 = st_gross1.

itab1-gjahr1 = st_gross.

itab1-line_color = 'C500'.

APPEND itab1.

CLEAR: itab1,ifinal.

itab1-katyp1 = ' Percentage (%)'.

if st_rev1 = 0. " Handle Divide by Zero exception

st_pt1 = 0.

endif.

if st_rev = 0.

st_pt = 0.

else.

st_pt1 = ( st_gross1 / st_rev1 ) * 100.

st_pt = ( st_gross / st_rev ) * 100.

endif.

itab1-perio1 = st_pt1.

itab1-gjahr1 = st_pt.

itab1-line_color = 'C710'.

APPEND itab1.

CLEAR: itab1,ifinal.

---Calculation for Allocated cost--


clear : ifinal[].

loop at itab_final where katyp <> '01'

and katyp <> '11'

and katyp <> '12'.

move-corresponding itab_final to ifinal.

append ifinal.

endloop.

SORT ifinal BY katyp .

LOOP AT ifinal.

st_all = st_all + ifinal-wogbtr.

ENDLOOP.

loop at ifinal where perio = s_pd-high.

st_all1 = st_all1 + ifinal-wogbtr.

endloop.

itab1-katyp1 = 'AllocatedExpenses'.

itab1-wogbtr = st_all.

itab1-perio1 = st_all1.

itab1-gjahr1 = st_all.

APPEND itab1.

CLEAR: itab1, ifinal.

--


calculation for Net Margin--

st_net1 = st_gross1 - st_all1.

itab1-katyp1 = 'NetMargin'.

st_net = ( st_gross - st_all ).

itab1-wogbtr = st_net.

itab1-perio1 = st_net1.

itab1-gjahr1 = st_net.

itab1-line_color = 'C500'.

APPEND itab1.

CLEAR: itab1, ifinal .

itab1-katyp1 = ' Percentage (%)'.

if st_rev1 = 0. " Handle Divide by Zero exception

st_nt1 = 0.

endif.

if st_rev = 0.

st_nt = 0.

else.

st_nt1 = ( st_net1 / st_rev1 ) * 100.

st_nt = ( st_net / st_rev ) * 100.

endif.

itab1-perio1 = st_pt1.

itab1-gjahr1 = st_pt.

itab1-line_color = 'C710'.

APPEND itab1.

CLEAR: itab1,ifinal.

ENDFORM. "get_data

&----


*& Form build_layout

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM build_layout .

gd_layout-zebra = 'X'.

gd_layout-colwidth_optimize = 'X'.

gd_layout-info_fieldname = 'LINE_COLOR'.

ENDFORM. " build_layout

&----


*& Form display

&----


  • text

----


FORM display.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = gd_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

I_GRID_TITLE = 'Internal Order Analysis Report'

  • I_GRID_SETTINGS =

IS_LAYOUT = gd_layout

IT_FIELDCAT = t_fcat

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT = t_subtot

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS = t_eve[]

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • I_HTML_HEIGHT_TOP = 0

  • I_HTML_HEIGHT_END = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • IR_SALV_FULLSCREEN_ADAPTER =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = itab1

EXCEPTIONS

PROGRAM_ERROR = 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. "display

&----


*& Form For UserCommand

&----


  • text

----


FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM

RS_SELFIELD TYPE SLIS_SELFIELD.

data : &IC1 like ok_code,

&IC2 like ok_code.

&IC1 = ok_code.

&IC2 = ok_code.

CASE R_UCOMM.

WHEN '&IC1'.

clear ok_code.

refresh t_fcat2.

refresh t_subtot2.

refresh t_fcat3.

refresh t_subtot3.

refresh t_fcat1.

refresh t_subtot1.

if rs_selfield-tabindex = 2.

clear itab_final[].

perform secondarylist.

elseIF rs_selfield-tabindex = 3.

refresh t_fcat2.

refresh t_subtot2.

clear itab_final[].

perform secondarylist1.

elseIF rs_selfield-tabindex = 6.

refresh t_fcat3.

refresh t_subtot3.

clear itab_final[].

perform secondarylist11.

ENDIF.

WHEN 'BACK'.

LEAVE TO SCREEN 0.

ENDCASE.

ENDFORM.

&----


*& Form secondarylist

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM secondarylist .

clear itab1[].

*clear ifinal[].

*clear itab_final[].

perform get_data1.

*perform sel.

PERFORM build_layout.

PERFORM build_cat1 USING t_fcat1.

*perform build_sort1.

PERFORM display1.

ENDFORM. " secondarylist

&----


*& Form get_data1

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM get_data1 .

--


To fetch Amount, Period ,Year, CompanyCode--

SELECT kokrs gjahr perio kstar bukrs wogbtr objnr owaer

FROM coep INTO CORRESPONDING FIELDS OF TABLE itab_coep

WHERE kokrs = p_ca

AND perio IN s_pd

AND bukrs IN s_code

AND gjahr IN s_year.

LOOP AT itab_coep.

itab_final-kokrs = itab_coep-kokrs.

itab_final-gjahr = itab_coep-gjahr.

itab_final-perio = itab_coep-perio.

itab_final-kstar = itab_coep-kstar.

itab_final-bukrs = itab_coep-bukrs.

itab_final-wogbtr = itab_coep-wogbtr.

itab_final-objnr = itab_coep-objnr.

itab_final-owaer = itab_coep-owaer.

APPEND itab_final.

CLEAR itab_final.

ENDLOOP.

IF NOT itab_coep[] IS INITIAL.

--


To fetch Amount,ProfitCenter,InternalOrder--

SELECT kokrs aufnr prctr bukrs auart objnr

FROM aufk INTO CORRESPONDING FIELDS OF TABLE itab_aufk

WHERE aufnr IN s_or

and prctr in s_pc.

loop at itab_final.

READ TABLE itab_aufk WITH KEY kokrs = itab_final-kokrs

objnr = itab_final-objnr.

IF sy-subrc = 0.

itab_final-aufnr = itab_aufk-aufnr.

itab_final-prctr = itab_aufk-prctr.

MODIFY itab_final TRANSPORTING aufnr prctr.

else.

delete itab_final.

ENDIF.

endloop.

IF NOT itab_aufk[] IS INITIAL.

--


To fetch ProfitCenter ,ProfitCenterGroup--

SELECT kokrs khinr prctr

FROM cepc INTO CORRESPONDING FIELDS OF TABLE itab_cepc

WHERE kokrs = itab_aufk-kokrs

and khinr in s_pg.

LOOP AT itab_final.

READ TABLE itab_cepc WITH KEY kokrs = itab_final-kokrs

prctr = itab_final-prctr.

IF sy-subrc = 0.

itab_final-khinr = itab_cepc-khinr.

MODIFY itab_final TRANSPORTING khinr.

else.

delete itab_final.

ENDIF.

endloop.

if not itab_coep[] is initial.

--


To fetch InternalOrderGroup--

clear itab_final-setname.

select setclass subclass setname valfrom valto

from setleaf into corresponding fields of table itab_setleaf

where setclass = '0102'

and subclass = 'VMIN'

and setname in s_kg

and valfrom in s_ku

and valto in s_ku.

loop at itab_final.

read table itab_setleaf with key valfrom = itab_final-kstar.

if sy-subrc = 0.

itab_final-setname = itab_setleaf-setname.

modify itab_final transporting setname.

else.

delete itab_final.

endif.

endloop.

if not itab_aufk[] is initial.

--


To fetch CostElementGroup--

clear itab_final-setname.

select setclass subclass setname valfrom valto

from setleaf into corresponding fields of table itab_setleaf1

where setclass = '0103'

and setname in s_org

and valfrom in s_or

and valto in s_or.

loop at itab_final .

read table itab_setleaf1 with key valfrom = itab_final-aufnr.

if sy-subrc = 0.

itab_final-setname1 = itab_setleaf1-setname.

modify itab_final transporting setname1.

else.

delete itab_final.

endif.

ENDLOOP.

IF NOT itab_coep[] IS INITIAL.

SELECT kokrs katyp aufnr kstar

FROM cskb INTO CORRESPONDING FIELDS OF TABLE itab_cskb

FOR ALL ENTRIES IN itab_coep

WHERE kokrs = itab_coep-kokrs.

loop at itab_final.

READ TABLE itab_cskb WITH KEY kstar = itab_final-kstar

kokrs = itab_final-kokrs.

IF sy-subrc = 0.

itab_final-katyp = itab_cskb-katyp.

MODIFY itab_final TRANSPORTING katyp.

ENDIF.

ENDLOOP.

endif.

endif.

ENDIF.

ENDIF.

ENDIF.

clear ifinal[].

loop at itab_final where katyp = '11' or katyp = '12'.

move-corresponding itab_final to ifinal.

append ifinal.

clear ifinal.

endloop.

--


calculation for revenue--

  • SORT ifinal BY katyp.

clear st_rev.

Sort ifinal by khinr.

LOOP AT ifinal.

AT NEW khinr.

LOOP AT ifinal WHERE khinr = ifinal-khinr.

st_rev = st_rev + ifinal-wogbtr.

ENDLOOP.

on change of ifinal-khinr.

itab1-khinr1 = ifinal-khinr.

itab1-wogbtr = st_rev.

itab1-line_color = 'C710'.

APPEND itab1.

clear itab1.

endon.

ENDAT.

ENDLOOP.

*APPEND itab1.

*itab1-line_color = ''.

CLEAR st_rev.

LOOP AT ifinal.

st_rev = st_rev + ifinal-wogbtr.

ENDLOOP.

itab1-khinr1 = 'Total'.

itab1-wogbtr = ( st_rev * ( -1 ) ).

itab1-line_color = 'C310'.

APPEND itab1.

clear itab1.

ENDFORM. " get_data1

&----


*& Form build_cat1

&----


  • text

----


  • -->P_T_FCAT1 text

----


FORM build_cat1 USING temp_fcat type slis_t_fieldcat_alv.

d_fieldcat_wa-fieldname = 'KHINR1'.

d_fieldcat_wa-seltext_m = 'ProfitCenterGroup'.

d_fieldcat_wa-col_pos = 1.

d_fieldcat_wa-hotspot = 'X'.

APPEND d_fieldcat_wa TO temp_fcat.

CLEAR d_fieldcat_wa.

  • d_fieldcat_wa-fieldname = 'PRCTR1'.

  • d_fieldcat_wa-seltext_m = 'ProfitCenter'.

  • d_fieldcat_wa-hotspot = 'X'.

  • d_fieldcat_wa-col_pos = 3.

  • APPEND d_fieldcat_wa TO temp_fcat.

  • CLEAR d_fieldcat_wa.

*

*

d_fieldcat_wa-fieldname = 'WOGBTR'.

d_fieldcat_wa-seltext_m = 'Amount'.

d_fieldcat_wa-key = 'X'.

d_fieldcat_wa-col_pos = 2.

APPEND d_fieldcat_wa TO temp_fcat.

CLEAR d_fieldcat_wa.

ENDFORM. " build_cat1

&----


*& Form build_sort1

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM build_sort1 .

subtot-spos = 1.

subtot-fieldname = 'KHINR1'.

subtot-subtot = 'X'.

subtot-down = 'X'.

subtot-expa = 'X'.

append subtot to t_subtot1.

clear subtot.

*subtot-spos = 3.

*

*subtot-fieldname = 'PRCTR1'.

*subtot-subtot = 'X'.

*subtot-down = 'X'.

*subtot-expa = 'X'.

*

*append subtot to t_subtot1.

*clear subtot.

ENDFORM. " build_sort1

&----


*& Form display1

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM display1 .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = gd_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

I_CALLBACK_USER_COMMAND = 'USER_COMMAND1'

I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

I_GRID_TITLE = 'ProfitCenterGroupDetails'

  • I_GRID_SETTINGS =

IS_LAYOUT = gd_layout

IT_FIELDCAT = t_fcat1

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

IT_SORT = t_subtot1

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS = t_eve[]

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • I_HTML_HEIGHT_TOP = 0

  • I_HTML_HEIGHT_END = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • IR_SALV_FULLSCREEN_ADAPTER =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = itab1

EXCEPTIONS

PROGRAM_ERROR = 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. " display1

&----


*& Form For UserCommand

&----


  • text

----


FORM USER_COMMAND1 USING R_UCOMM LIKE SY-UCOMM

RS_SELFIELD TYPE SLIS_SELFIELD.

data : &IC1 like ok_code,

&IC2 like ok_code.

&IC1 = ok_code.

&IC2 = ok_code.

CASE R_UCOMM.

WHEN '&IC1'.

clear ok_code.

refresh t_fcat4.

refresh t_subtot4.

refresh t_fcat5.

refresh t_subtot5.

refresh t_fcat2.

refresh t_subtot2.

refresh t_fcat3.

refresh t_subtot3.

refresh t_fcat1.

refresh t_subtot1.

IF RS_SELFIELD-FIELDNAME = 'KHINR1'.

READ TABLE itab1 INDEX rs_selfield-tabindex.

clear itab_final[].

perform secondarylist2.

ENDIF.

*WHEN 'BACK'.

*

*LEAVE TO SCREEN 0.

ENDCASE.

endform.

&----


*& Form secondarylist1

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM secondarylist1 .

clear itab2[].

clear ifinal[].

*clear itab1[].

clear itab_final[].

perform get_data2.

*perform sel.

PERFORM build_cat2 USING t_fcat2.

PERFORM build_layout.

perform build_sort2.

PERFORM display2.

ENDFORM. " secondarylist1

&----


*& Form get_data2

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM get_data2 .

--


To fetch Amount, Period ,Year, CompanyCode--

SELECT kokrs gjahr perio kstar bukrs wogbtr objnr owaer

FROM coep INTO CORRESPONDING FIELDS OF TABLE itab_coep

WHERE kokrs = p_ca

AND perio IN s_pd

AND bukrs IN s_code

AND gjahr IN s_year.

LOOP AT itab_coep.

itab_final-kokrs = itab_coep-kokrs.

itab_final-gjahr = itab_coep-gjahr.

itab_final-perio = itab_coep-perio.

itab_final-kstar = itab_coep-kstar.

itab_final-bukrs = itab_coep-bukrs.

itab_final-wogbtr = itab_coep-wogbtr.

itab_final-objnr = itab_coep-objnr.

itab_final-owaer = itab_coep-owaer.

APPEND itab_final.

CLEAR itab_final.

ENDLOOP.

IF NOT itab_coep[] IS INITIAL.

--


To fetch Amount,ProfitCenter,InternalOrder--

SELECT kokrs aufnr prctr bukrs auart objnr

FROM aufk INTO CORRESPONDING FIELDS OF TABLE itab_aufk

WHERE aufnr IN s_or

and prctr in s_pc.

loop at itab_final.

READ TABLE itab_aufk WITH KEY kokrs = itab_final-kokrs

objnr = itab_final-objnr.

IF sy-subrc = 0.

itab_final-aufnr = itab_aufk-aufnr.

itab_final-prctr = itab_aufk-prctr.

MODIFY itab_final TRANSPORTING aufnr prctr.

else.

delete itab_final.

ENDIF.

endloop.

IF NOT itab_aufk[] IS INITIAL.

--


To fetch ProfitCenter ,ProfitCenterGroup--

SELECT kokrs khinr prctr

FROM cepc INTO CORRESPONDING FIELDS OF TABLE itab_cepc

WHERE kokrs = itab_aufk-kokrs

and khinr in s_pg.

LOOP AT itab_final.

READ TABLE itab_cepc WITH KEY kokrs = itab_final-kokrs

prctr = itab_final-prctr.

IF sy-subrc = 0.

itab_final-khinr = itab_cepc-khinr.

MODIFY itab_final TRANSPORTING khinr.

else.

delete itab_final.

ENDIF.

endloop.

if not itab_coep[] is initial.

--


To fetch InternalOrderGroup--

clear itab_final-setname.

select setclass subclass setname valfrom valto

from setleaf into corresponding fields of table itab_setleaf

where setclass = '0102'

and subclass = 'VMIN'

and setname in s_kg

and valfrom in s_ku

and valto in s_ku.

loop at itab_final.

read table itab_setleaf with key valfrom = itab_final-kstar.

if sy-subrc = 0.

itab_final-setname = itab_setleaf-setname.

modify itab_final transporting setname.

else.

delete itab_final.

endif.

endloop.

if not itab_aufk[] is initial.

--


To fetch CostElementGroup--

clear itab_final-setname.

select setclass subclass setname valfrom valto

from setleaf into corresponding fields of table itab_setleaf1

where setclass = '0103'

and setname in s_org

and valfrom in s_or

and valto in s_or.

loop at itab_final .

read table itab_setleaf1 with key valfrom = itab_final-aufnr.

if sy-subrc = 0.

itab_final-setname1 = itab_setleaf1-setname.

modify itab_final transporting setname1.

else.

delete itab_final.

endif.

ENDLOOP.

IF NOT itab_coep[] IS INITIAL.

SELECT kokrs katyp aufnr kstar

FROM cskb INTO CORRESPONDING FIELDS OF TABLE itab_cskb

FOR ALL ENTRIES IN itab_coep

WHERE kokrs = itab_coep-kokrs.

loop at itab_final.

READ TABLE itab_cskb WITH KEY kstar = itab_final-kstar

kokrs = itab_final-kokrs.

IF sy-subrc = 0.

itab_final-katyp = itab_cskb-katyp.

MODIFY itab_final TRANSPORTING katyp.

ENDIF.

ENDLOOP.

endif.

endif.

ENDIF.

ENDIF.

ENDIF.

---calculation for DirectExpense--


clear ifinal[].

loop at itab_final where katyp = '01'.

move-corresponding itab_final to ifinal.

append ifinal.

endloop.

*SORT ifinal BY khinr .

clear st_pc.

sort ifinal by khinr.

LOOP AT ifinal.

AT NEW khinr.

LOOP AT ifinal WHERE khinr = ifinal-khinr.

st_pc = st_pc + ifinal-wogbtr.

ENDLOOP.

on change of ifinal-khinr.

itab2-khinr2 = ifinal-khinr.

itab2-wogbtr = st_pc.

itab2-line_color = 'C710'.

APPEND itab2.

clear itab2.

endon.

*APPEND itab1.

*itab1-line_color = ''.

CLEAR st_pc.

ENDAT.

ENDLOOP.

LOOP AT ifinal.

st_pc = st_pc + ifinal-wogbtr.

ENDLOOP.

itab2-khinr2 = 'Total'.

itab2-wogbtr = ( st_pc * ( -1 ) ).

itab2-line_color = 'C310'.

APPEND itab2.

ENDFORM. " get_data2

&----


*& Form build_cat2

&----


  • text

----


  • -->P_T_FCAT2 text

----


FORM build_cat2 USING temp_fcat type slis_t_fieldcat_alv.

d_fieldcat_wa-fieldname = 'KHINR2'.

d_fieldcat_wa-seltext_m = 'ProfitCenterGroup'.

d_fieldcat_wa-hotspot = 'X'.

d_fieldcat_wa-col_pos = 1.

APPEND d_fieldcat_wa TO temp_fcat.

CLEAR d_fieldcat_wa.

d_fieldcat_wa-fieldname = 'WOGBTR'.

d_fieldcat_wa-seltext_m = 'Amount'.

d_fieldcat_wa-key = 'X'.

d_fieldcat_wa-col_pos = 2.

APPEND d_fieldcat_wa TO temp_fcat.

CLEAR d_fieldcat_wa.

  • d_fieldcat_wa-fieldname = 'PRCTR2'.

  • d_fieldcat_wa-seltext_m = 'ProfitCenter'.

  • d_fieldcat_wa-hotspot = 'X'.

  • d_fieldcat_wa-col_pos = 3.

  • APPEND d_fieldcat_wa TO temp_fcat.

  • CLEAR d_fieldcat_wa.

ENDFORM. " build_cat2

&----


*& Form build_sort2

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM build_sort2 .

subtot-spos = 1.

subtot-fieldname = 'KHINR2'.

subtot-subtot = 'X'.

subtot-down = 'X'.

subtot-expa = 'X'.

append subtot to t_subtot2.

clear subtot.

*subtot-spos = 3.

*

*subtot-fieldname = 'PRCTR2'.

*subtot-subtot = 'X'.

*subtot-down = 'X'.

*subtot-expa = 'X'.

*

*append subtot to t_subtot2.

*clear subtot.

*

ENDFORM. " build_sort2

&----


*& Form display2

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM display2 .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = gd_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

I_CALLBACK_USER_COMMAND = 'USER_COMMAND12'

I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

I_GRID_TITLE = 'ProfitCenterGroupDetails'

  • I_GRID_SETTINGS =

IS_LAYOUT = gd_layout

IT_FIELDCAT = t_fcat2

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

IT_SORT = t_subtot2

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS = t_eve[]

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • I_HTML_HEIGHT_TOP = 0

  • I_HTML_HEIGHT_END = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • IR_SALV_FULLSCREEN_ADAPTER =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = itab2

EXCEPTIONS

PROGRAM_ERROR = 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. " display2

&----


*& Form For UserCommand

&----


  • text

----


FORM USER_COMMAND12 USING R_UCOMM LIKE SY-UCOMM

RS_SELFIELD TYPE SLIS_SELFIELD.

data : &IC1 like ok_code,

&IC2 like ok_code.

&IC1 = ok_code.

&IC2 = ok_code.

CASE R_UCOMM.

WHEN '&IC1'.

clear ok_code.

refresh t_fcat7.

refresh t_subtot7.

refresh t_fcat7.

refresh t_subtot7.

refresh t_fcat6.

refresh t_subtot6.

refresh t_fcat4.

refresh t_subtot4.

refresh t_fcat2.

refresh t_subtot2.

refresh t_fcat3.

refresh t_subtot3.

refresh t_fcat1.

refresh t_subtot1.

IF RS_SELFIELD-FIELDNAME = 'KHINR2'.

clear itab_final[].

perform secondarylist21.

ENDIF.

WHEN 'BACK'.

LEAVE TO SCREEN 0.

ENDCASE.

endform.

&----


*& Form secondarylist11

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM secondarylist11 .

perform get_data3.

*perform sel.

PERFORM build_cat3 USING t_fcat3.

perform build_sort3.

PERFORM build_layout.

PERFORM display3.

ENDFORM. " secondarylist11

&----


*& Form get_data3

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM get_data3 .

--


To fetch Amount, Period ,Year, CompanyCode--

SELECT kokrs gjahr perio kstar bukrs wogbtr objnr owaer

FROM coep INTO CORRESPONDING FIELDS OF TABLE itab_coep

WHERE kokrs = p_ca

AND perio IN s_pd

AND bukrs IN s_code

AND gjahr IN s_year.

LOOP AT itab_coep.

itab_final-kokrs = itab_coep-kokrs.

itab_final-gjahr = itab_coep-gjahr.

itab_final-perio = itab_coep-perio.

itab_final-kstar = itab_coep-kstar.

itab_final-bukrs = itab_coep-bukrs.

itab_final-wogbtr = itab_coep-wogbtr.

itab_final-objnr = itab_coep-objnr.

itab_final-owaer = itab_coep-owaer.

APPEND itab_final.

CLEAR itab_final.

ENDLOOP.

IF NOT itab_coep[] IS INITIAL.

--


To fetch Amount,ProfitCenter,InternalOrder--

SELECT kokrs aufnr prctr bukrs auart objnr

FROM aufk INTO CORRESPONDING FIELDS OF TABLE itab_aufk

WHERE aufnr IN s_or

and prctr in s_pc.

loop at itab_final.

READ TABLE itab_aufk WITH KEY kokrs = itab_final-kokrs

objnr = itab_final-objnr.

IF sy-subrc = 0.

itab_final-aufnr = itab_aufk-aufnr.

itab_final-prctr = itab_aufk-prctr.

MODIFY itab_final TRANSPORTING aufnr prctr.

else.

delete itab_final.

ENDIF.

endloop.

IF NOT itab_aufk[] IS INITIAL.

--


To fetch ProfitCenter ,ProfitCenterGroup--

SELECT kokrs khinr prctr

FROM cepc INTO CORRESPONDING FIELDS OF TABLE itab_cepc

WHERE kokrs = itab_aufk-kokrs

and khinr in s_pg.

LOOP AT itab_final.

READ TABLE itab_cepc WITH KEY kokrs = itab_final-kokrs

prctr = itab_final-prctr.

IF sy-subrc = 0.

itab_final-khinr = itab_cepc-khinr.

MODIFY itab_final TRANSPORTING khinr.

else.

delete itab_final.

ENDIF.

endloop.

if not itab_coep[] is initial.

--


To fetch InternalOrderGroup--

clear itab_final-setname.

select setclass subclass setname valfrom valto

from setleaf into corresponding fields of table itab_setleaf

where setclass = '0102'

and subclass = 'VMIN'

and setname in s_kg

and valfrom in s_ku

and valto in s_ku.

loop at itab_final.

read table itab_setleaf with key valfrom = itab_final-kstar.

if sy-subrc = 0.

itab_final-setname = itab_setleaf-setname.

modify itab_final transporting setname.

else.

delete itab_final.

endif.

endloop.

if not itab_aufk[] is initial.

--


To fetch CostElementGroup--

clear itab_final-setname.

select setclass subclass setname valfrom valto

from setleaf into corresponding fields of table itab_setleaf1

where setclass = '0103'

and setname in s_org

and valfrom in s_or

and valto in s_or.

loop at itab_final .

read table itab_setleaf1 with key valfrom = itab_final-aufnr.

if sy-subrc = 0.

itab_final-setname1 = itab_setleaf1-setname.

modify itab_final transporting setname1.

else.

delete itab_final.

endif.

ENDLOOP.

IF NOT itab_coep[] IS INITIAL.

SELECT kokrs katyp aufnr kstar

FROM cskb INTO CORRESPONDING FIELDS OF TABLE itab_cskb

FOR ALL ENTRIES IN itab_coep

WHERE kokrs = itab_coep-kokrs.

loop at itab_final.

READ TABLE itab_cskb WITH KEY kstar = itab_final-kstar

kokrs = itab_final-kokrs.

IF sy-subrc = 0.

itab_final-katyp = itab_cskb-katyp.

MODIFY itab_final TRANSPORTING katyp.

ENDIF.

ENDLOOP.

endif.

endif.

ENDIF.

ENDIF.

ENDIF.

---Calculation for Allocated cost--


clear : ifinal[].

loop at itab_final where katyp <> '01'

and katyp <> '11'

and katyp <> '12'.

move-corresponding itab_final to ifinal.

append ifinal.

endloop.

SORT ifinal BY katyp .

clear st_all.

LOOP AT ifinal.

st_all = st_all + ifinal-wogbtr.

itab3-khinr3 = ifinal-khinr.

itab3-prctr3 = ifinal-prctr.

itab3-aufnr3 = ifinal-aufnr.

itab3-setname31 = ifinal-setname1.

itab3-setname3 = ifinal-setname.

itab3-kstar = ifinal-kstar.

itab3-wogbtr = ifinal-wogbtr.

if itab2-wogbtr ca '.'.

replace '.' in itab1-wogbtr with ',' .

if itab2-wogbtr ca ','.

replace ',' in itab1-wogbtr with '.' .

endif.

endif.

append itab3.

clear : itab3, ifinal.

ENDLOOP.

itab3-wogbtr = st_all.

itab3-khinr3 = ' '.

itab3-prctr3 = ' '.

itab3-aufnr3 = ' '.

itab3-setname3 = ' '.

itab3-line_color = 'C710'.

APPEND itab3.

CLEAR : itab3,ifinal.

ENDFORM. " get_data3

&----


*& Form build_cat3

&----


  • text

----


  • -->P_T_FCAT3 text

----


FORM build_cat3 USING temp_fcat type slis_t_fieldcat_alv.

d_fieldcat_wa-fieldname = 'KHINR3'.

d_fieldcat_wa-seltext_m = 'ProfitCenterGroup'.

d_fieldcat_wa-hotspot = 'X'.

d_fieldcat_wa-col_pos = 1.

APPEND d_fieldcat_wa TO temp_fcat.

CLEAR d_fieldcat_wa.

d_fieldcat_wa-fieldname = 'WOGBTR'.

d_fieldcat_wa-seltext_m = 'Amount'.

d_fieldcat_wa-key = 'X'.

d_fieldcat_wa-col_pos = 2.

APPEND d_fieldcat_wa TO temp_fcat.

CLEAR d_fieldcat_wa.

d_fieldcat_wa-fieldname = 'PRCTR3'.

d_fieldcat_wa-seltext_m = 'ProfitCenter'.

d_fieldcat_wa-hotspot = 'X'.

d_fieldcat_wa-col_pos = 3.

APPEND d_fieldcat_wa TO temp_fcat.

CLEAR d_fieldcat_wa.

ENDFORM. " build_cat3

&----


*& Form build_sort3

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM build_sort3 .

subtot-spos = 1.

subtot-fieldname = 'KHINR3'.

subtot-subtot = 'X'.

subtot-down = 'X'.

subtot-expa = 'X'.

append subtot to t_subtot3.

clear subtot.

subtot-spos = 3.

subtot-fieldname = 'PRCTR3'.

subtot-subtot = 'X'.

subtot-down = 'X'.

subtot-expa = 'X'.

append subtot to t_subtot3.

clear subtot.

ENDFORM. " build_sort3

&----


*& Form display3

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM display3 .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = gd_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

I_CALLBACK_USER_COMMAND = 'USER_COMMAND22'

I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

I_GRID_TITLE = 'ProfitCenterGroupDetails'

  • I_GRID_SETTINGS =

IS_LAYOUT = gd_layout

IT_FIELDCAT = t_fcat3

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

IT_SORT = t_subtot3

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS = t_eve[]

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • I_HTML_HEIGHT_TOP = 0

  • I_HTML_HEIGHT_END = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • IR_SALV_FULLSCREEN_ADAPTER =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = itab3

EXCEPTIONS

PROGRAM_ERROR = 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. " display3

&----


*& Form For UserCommand

&----


  • text

----


FORM USER_COMMAND22 USING R_UCOMM LIKE SY-UCOMM

RS_SELFIELD TYPE SLIS_SELFIELD.

data : &IC1 like ok_code,

&IC2 like ok_code.

&IC1 = ok_code.

&IC2 = ok_code.

CASE R_UCOMM.

WHEN '&IC1'.

clear ok_code.

refresh t_fcat9.

refresh t_subtot9.

refresh t_fcat7.

refresh t_subtot7.

refresh t_fcat8.

refresh t_subtot8.

refresh t_fcat7.

refresh t_subtot7.

refresh t_fcat6.

refresh t_subtot6.

refresh t_fcat4.

refresh t_subtot4.

refresh t_fcat2.

refresh t_subtot2.

refresh t_fcat3.

refresh t_subtot3.

refresh t_fcat1.

refresh t_subtot1.

IF RS_SELFIELD-FIELDNAME = 'KHINR3'.

clear itab_final[].

perform secondarylist31.

ENDIF.

WHEN 'BACK'.

LEAVE TO SCREEN 0.

ENDCASE.

endform.

&----


*& Form secondarylist2

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM secondarylist2 .

clear itab1[].

clear itab2[].

clear ifinal[].

clear itab_final[].

perform get_data1.

*perform sel.

PERFORM build_cat4 USING t_fcat4.

perform build_sort4.

PERFORM build_layout.

PERFORM display4.

ENDFORM. " secondarylist2

&----


*& Form build_cat4

&----


  • text

----


  • -->P_T_FCAT4 text

----


FORM build_cat4 USING temp_fcat type slis_t_fieldcat_alv.

d_fieldcat_wa-fieldname = 'PRCTR1'.

d_fieldcat_wa-seltext_m = 'ProfitCenter'.

d_fieldcat_wa-col_pos = 1.

APPEND d_fieldcat_wa TO temp_fcat.

CLEAR d_fieldcat_wa.

d_fieldcat_wa-fieldname = 'WOGBTR'.

d_fieldcat_wa-seltext_m = 'Amount'.

d_fieldcat_wa-key = 'X'.

d_fieldcat_wa-col_pos = 2.

APPEND d_fieldcat_wa TO temp_fcat.

CLEAR d_fieldcat_wa.

  • d_fieldcat_wa-fieldname = 'SETNAME1'.

  • d_fieldcat_wa-seltext_m = 'Internal Order Group'.

  • d_fieldcat_wa-hotspot = 'X'.

  • d_fieldcat_wa-col_pos = 3.

  • APPEND d_fieldcat_wa TO temp_fcat.

  • CLEAR d_fieldcat_wa.

*

ENDFORM. " build_cat4

&----


*& Form build_sort4

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM build_sort4 .

subtot-spos = 1.

subtot-fieldname = 'PRCTR1'.

subtot-subtot = 'X'.

subtot-down = 'X'.

subtot-expa = 'X'.

append subtot to t_subtot4.

clear subtot.

ENDFORM. " build_sort4

&----


*& Form display4

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM display4 .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = gd_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

I_CALLBACK_USER_COMMAND = 'USER_COMMAND11'

I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

I_GRID_TITLE = 'InternalOrderDetails'

  • I_GRID_SETTINGS =

IS_LAYOUT = gd_layout

IT_FIELDCAT = t_fcat4

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

IT_SORT = t_subtot4

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS = t_eve[]

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • I_HTML_HEIGHT_TOP = 0

  • I_HTML_HEIGHT_END = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • IR_SALV_FULLSCREEN_ADAPTER =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = itab1

EXCEPTIONS

PROGRAM_ERROR = 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. " display4

&----


*& Form For UserCommand

&----


  • text

----


FORM USER_COMMAND11 USING R_UCOMM LIKE SY-UCOMM

RS_SELFIELD TYPE SLIS_SELFIELD.

data : &IC1 like ok_code,

&IC2 like ok_code.

&IC1 = ok_code.

&IC2 = ok_code.

CASE R_UCOMM.

WHEN '&IC1'.

clear ok_code.

refresh t_fcat2.

refresh t_subtot2.

refresh t_fcat5.

refresh t_subtot5.

refresh t_fcat4.

refresh t_subtot4.

refresh t_fcat3.

refresh t_subtot3.

refresh t_fcat1.

refresh t_subtot1.

IF RS_SELFIELD-FIELDNAME = 'AUFNR1'.

clear itab_final[].

perform secondarylist3.

ENDIF.

WHEN 'BACK'.

LEAVE TO SCREEN 0.

ENDCASE.

ENDFORM.

&----


*& Form secondarylist3

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM secondarylist3 .

clear itab1[].

clear itab2[].

clear ifinal[].

clear itab_final[].

perform get_data1.

*perform sel.

PERFORM build_cat5 USING t_fcat5.

perform build_sort5.

PERFORM build_layout.

PERFORM display5.

ENDFORM. " secondarylist3

&----


*& Form build_cat5

&----


  • text

----


  • -->P_T_FCAT5 text

----


FORM build_cat5 USING temp_fcat type slis_t_fieldcat_alv.

d_fieldcat_wa-fieldname = 'SETNAME'.

d_fieldcat_wa-seltext_m = 'Cost Element Group'.

d_fieldcat_wa-hotspot = 'X'.

d_fieldcat_wa-col_pos = 1.

APPEND d_fieldcat_wa TO temp_fcat.

CLEAR d_fieldcat_wa.

d_fieldcat_wa-fieldname = 'KSTAR'.

d_fieldcat_wa-seltext_m = 'CostElement'.

d_fieldcat_wa-col_pos = 2.

APPEND d_fieldcat_wa TO temp_fcat.

CLEAR d_fieldcat_wa.

d_fieldcat_wa-fieldname = 'WOGBTR'.

d_fieldcat_wa-seltext_m = 'Amount'.

d_fieldcat_wa-key = 'X'.

d_fieldcat_wa-col_pos = 3.

APPEND d_fieldcat_wa TO temp_fcat.

CLEAR d_fieldcat_wa.

ENDFORM. " build_cat5

&----


*& Form build_sort5

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM build_sort5 .

subtot-spos = 1.

subtot-fieldname = 'SETNAME'.

subtot-subtot = 'X'.

subtot-down = 'X'.

subtot-expa = 'X'.

append subtot to t_subtot5.

clear subtot.

ENDFORM. " build_sort5

&----


*& Form display5

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM display5 .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = gd_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ''

I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

I_GRID_TITLE = 'CostElementGroupDetails'

  • I_GRID_SETTINGS =

IS_LAYOUT = gd_layout

IT_FIELDCAT = t_fcat5

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

IT_SORT = t_subtot5

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS = t_eve[]

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • I_HTML_HEIGHT_TOP = 0

  • I_HTML_HEIGHT_END = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • IR_SALV_FULLSCREEN_ADAPTER =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = itab1

EXCEPTIONS

PROGRAM_ERROR = 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. " display5

&----


*& Form secondarylist21

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM secondarylist21 .

clear itab1[].

clear itab2[].

clear ifinal[].

clear itab_final[].

perform get_data2.

*perform sel.

PERFORM build_cat6 USING t_fcat6.

perform build_sort6.

PERFORM build_layout.

PERFORM display6.

ENDFORM. " secondarylist21

&----


*& Form build_cat6

&----


  • text

----


  • -->P_T_FCAT6 text

----


FORM build_cat6 USING temp_fcat type slis_t_fieldcat_alv.

d_fieldcat_wa-fieldname = 'AUFNR2'.

d_fieldcat_wa-seltext_m = 'Internal Order'.

d_fieldcat_wa-hotspot = 'X'.

d_fieldcat_wa-col_pos = 1.

APPEND d_fieldcat_wa TO temp_fcat.

CLEAR d_fieldcat_wa.

d_fieldcat_wa-fieldname = 'WOGBTR'.

d_fieldcat_wa-seltext_m = 'Amount'.

d_fieldcat_wa-key = 'X'.

d_fieldcat_wa-col_pos = 2.

APPEND d_fieldcat_wa TO temp_fcat.

CLEAR d_fieldcat_wa.

d_fieldcat_wa-fieldname = 'SETNAME21'.

d_fieldcat_wa-seltext_m = 'Internal Order Group'.

d_fieldcat_wa-hotspot = 'X'.

d_fieldcat_wa-col_pos = 3.

APPEND d_fieldcat_wa TO temp_fcat.

CLEAR d_fieldcat_wa.

ENDFORM. " build_cat6

&----


*& Form build_sort6

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM build_sort6 .

subtot-spos = 1.

subtot-fieldname = 'AUFNR2'.

subtot-subtot = 'X'.

subtot-down = 'X'.

subtot-expa = 'X'.

append subtot to t_subtot6.

clear subtot.

ENDFORM. " build_sort6

&----


*& Form display6

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM display6 .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = gd_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

I_CALLBACK_USER_COMMAND = 'USER_COMMAND13'

I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

I_GRID_TITLE = 'InternalOrderDetails'

  • I_GRID_SETTINGS =

IS_LAYOUT = gd_layout

IT_FIELDCAT = t_fcat6

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

IT_SORT = t_subtot6

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS = t_eve[]

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • I_HTML_HEIGHT_TOP = 0

  • I_HTML_HEIGHT_END = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • IR_SALV_FULLSCREEN_ADAPTER =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = itab2

EXCEPTIONS

PROGRAM_ERROR = 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. " display6

&----


*& Form For UserCommand

&----


  • text

----


FORM USER_COMMAND13 USING R_UCOMM LIKE SY-UCOMM

RS_SELFIELD TYPE SLIS_SELFIELD.

data : &IC1 like ok_code,

&IC2 like ok_code.

&IC1 = ok_code.

&IC2 = ok_code.

CASE R_UCOMM.

WHEN '&IC1'.

clear ok_code.

refresh t_fcat7.

refresh t_subtot7.

refresh t_fcat6.

refresh t_subtot6.

refresh t_fcat2.

refresh t_subtot2.

refresh t_fcat4.

refresh t_subtot4.

refresh t_fcat3.

refresh t_subtot3.

refresh t_fcat1.

refresh t_subtot1.

IF RS_SELFIELD-FIELDNAME = 'AUFNR2'.

clear itab_final[].

perform secondarylist23.

ENDIF.

WHEN 'BACK'.

LEAVE TO SCREEN 0.

ENDCASE.

ENDFORM.

&----


*& Form secondarylist23

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM secondarylist23 .

clear itab1[].

clear itab2[].

clear ifinal[].

clear itab_final[].

perform get_data2.

*perform sel.

PERFORM build_cat7 USING t_fcat7.

perform build_sort7.

PERFORM build_layout.

PERFORM display7.

ENDFORM. " secondarylist23

&----


*& Form build_cat7

&----


  • text

----


  • -->P_T_FCAT7 text

----


FORM build_cat7 USING temp_fcat type slis_t_fieldcat_alv.

d_fieldcat_wa-fieldname = 'SETNAME2'.

d_fieldcat_wa-seltext_m = 'CostElementGroup'.

d_fieldcat_wa-hotspot = 'X'.

d_fieldcat_wa-col_pos = 1.

APPEND d_fieldcat_wa TO temp_fcat.

CLEAR d_fieldcat_wa.

d_fieldcat_wa-fieldname = 'WOGBTR'.

d_fieldcat_wa-seltext_m = 'Amount'.

d_fieldcat_wa-key = 'X'.

d_fieldcat_wa-col_pos = 2.

APPEND d_fieldcat_wa TO temp_fcat.

CLEAR d_fieldcat_wa.

d_fieldcat_wa-fieldname = 'KSTAR'.

d_fieldcat_wa-seltext_m = 'CostElement'.

d_fieldcat_wa-hotspot = 'X'.

d_fieldcat_wa-col_pos = 3.

APPEND d_fieldcat_wa TO temp_fcat.

CLEAR d_fieldcat_wa.

ENDFORM. " build_cat7

&----


*& Form build_sort7

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM build_sort7 .

subtot-spos = 1.

subtot-fieldname = 'SETNAME2'.

subtot-subtot = 'X'.

subtot-down = 'X'.

subtot-expa = 'X'.

append subtot to t_subtot6.

clear subtot.

ENDFORM. " build_sort7

&----


*& Form display7

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM display7 .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = gd_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = 'USER_COMMAND13'

I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

I_GRID_TITLE = 'CostElementGroupDetails'

  • I_GRID_SETTINGS =

IS_LAYOUT = gd_layout

IT_FIELDCAT = t_fcat7

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

IT_SORT = t_subtot7

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS = t_eve[]

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • I_HTML_HEIGHT_TOP = 0

  • I_HTML_HEIGHT_END = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • IR_SALV_FULLSCREEN_ADAPTER =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = itab2

EXCEPTIONS

PROGRAM_ERROR = 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. " display7

&----


*& Form secondarylist31

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM secondarylist31 .

clear itab1[].

clear itab3[].

clear ifinal[].

clear itab_final[].

perform get_data3.

*perform sel.

PERFORM build_cat8 USING t_fcat8.

perform build_sort8.

PERFORM build_layout.

PERFORM display8.

ENDFORM. " secondarylist31

&----


*& Form build_cat8

&----


  • text

----


  • -->P_T_FCAT8 text

----


FORM build_cat8 USING temp_fcat type slis_t_fieldcat_alv.

d_fieldcat_wa-fieldname = 'AUFNR3'.

d_fieldcat_wa-seltext_m = 'Internal Order'.

d_fieldcat_wa-hotspot = 'X'.

d_fieldcat_wa-col_pos = 1.

APPEND d_fieldcat_wa TO temp_fcat.

CLEAR d_fieldcat_wa.

d_fieldcat_wa-fieldname = 'WOGBTR'.

d_fieldcat_wa-seltext_m = 'Amount'.

d_fieldcat_wa-key = 'X'.

d_fieldcat_wa-col_pos = 2.

APPEND d_fieldcat_wa TO temp_fcat.

CLEAR d_fieldcat_wa.

d_fieldcat_wa-fieldname = 'SETNAME31'.

d_fieldcat_wa-seltext_m = 'Internal Order Group'.

d_fieldcat_wa-hotspot = 'X'.

d_fieldcat_wa-col_pos = 3.

APPEND d_fieldcat_wa TO temp_fcat.

CLEAR d_fieldcat_wa.

ENDFORM. " build_cat8

&----


*& Form build_sort8

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM build_sort8 .

subtot-spos = 1.

subtot-fieldname = 'AUFNR3'.

subtot-subtot = 'X'.

subtot-down = 'X'.

subtot-expa = 'X'.

append subtot to t_subtot8.

clear subtot.

ENDFORM. " build_sort8

&----


*& Form display8

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM display8 .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = gd_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

I_CALLBACK_USER_COMMAND = 'USER_COMMAND23'

I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

I_GRID_TITLE = 'InternalOrderDetails'

  • I_GRID_SETTINGS =

IS_LAYOUT = gd_layout

IT_FIELDCAT = t_fcat8

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

IT_SORT = t_subtot8

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS = t_eve[]

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • I_HTML_HEIGHT_TOP = 0

  • I_HTML_HEIGHT_END = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • IR_SALV_FULLSCREEN_ADAPTER =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = itab3

EXCEPTIONS

PROGRAM_ERROR = 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. " display8

&----


*& Form For UserCommand

&----


  • text

----


FORM USER_COMMAND23 USING R_UCOMM LIKE SY-UCOMM

RS_SELFIELD TYPE SLIS_SELFIELD.

data : &IC1 like ok_code,

&IC2 like ok_code.

&IC1 = ok_code.

&IC2 = ok_code.

CASE R_UCOMM.

WHEN '&IC1'.

clear ok_code.

refresh t_fcat9.

refresh t_subtot9.

refresh t_fcat8.

refresh t_subtot8.

refresh t_fcat7.

refresh t_subtot7.

refresh t_fcat6.

refresh t_subtot6.

refresh t_fcat2.

refresh t_subtot2.

refresh t_fcat4.

refresh t_subtot4.

refresh t_fcat3.

refresh t_subtot3.

refresh t_fcat1.

refresh t_subtot1.

IF RS_SELFIELD-FIELDNAME = 'AUFNR3'.

clear itab_final[].

perform secondarylist33.

ENDIF.

WHEN 'BACK'.

LEAVE TO SCREEN 0.

ENDCASE.

ENDFORM.

&----


*& Form secondarylist33

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM secondarylist33 .

clear itab1[].

clear itab3[].

clear ifinal[].

clear itab_final[].

perform get_data3.

*perform sel.

PERFORM build_cat9 USING t_fcat9.

perform build_sort9.

PERFORM build_layout.

PERFORM display9.

ENDFORM. " secondarylist33

&----


*& Form build_cat9

&----


  • text

----


  • -->P_T_FCAT9 text

----


FORM build_cat9 USING temp_fcat type slis_t_fieldcat_alv.

d_fieldcat_wa-fieldname = 'SETNAME3'.

d_fieldcat_wa-seltext_m = 'CostElement Group'.

d_fieldcat_wa-hotspot = 'X'.

d_fieldcat_wa-col_pos = 1.

APPEND d_fieldcat_wa TO temp_fcat.

CLEAR d_fieldcat_wa.

d_fieldcat_wa-fieldname = 'WOGBTR'.

d_fieldcat_wa-seltext_m = 'Amount'.

d_fieldcat_wa-key = 'X'.

d_fieldcat_wa-col_pos = 2.

APPEND d_fieldcat_wa TO temp_fcat.

CLEAR d_fieldcat_wa.

d_fieldcat_wa-fieldname = 'KSTAR'.

d_fieldcat_wa-seltext_m = 'CostElement'.

d_fieldcat_wa-hotspot = 'X'.

d_fieldcat_wa-col_pos = 3.

APPEND d_fieldcat_wa TO temp_fcat.

CLEAR d_fieldcat_wa.

ENDFORM. " build_cat9

&----


*& Form build_sort9

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM build_sort9 .

subtot-spos = 1.

subtot-fieldname = 'SETNAME3'.

subtot-subtot = 'X'.

subtot-down = 'X'.

subtot-expa = 'X'.

append subtot to t_subtot9.

clear subtot.

ENDFORM. " build_sort9

&----


*& Form display9

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM display9 .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = gd_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

I_CALLBACK_USER_COMMAND = 'USER_COMMAND23'

I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

I_GRID_TITLE = 'CostElementGroupDetails'

  • I_GRID_SETTINGS =

IS_LAYOUT = gd_layout

IT_FIELDCAT = t_fcat9

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

IT_SORT = t_subtot9

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS = t_eve[]

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • I_HTML_HEIGHT_TOP = 0

  • I_HTML_HEIGHT_END = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • IR_SALV_FULLSCREEN_ADAPTER =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = itab3

EXCEPTIONS

PROGRAM_ERROR = 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. " display9

&----


*& Form Top_of_page

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form top_of_page.

data : uline like sy-uline.

data : wa_header1 type slis_listheader.

uline = sy-uline.

wa_header-typ = 'S'.

wa_header-info = 'Inputs'.

append wa_header to t_header.

clear wa_header.

wa_header-typ = 'S'.

wa_header-info = uline.

append wa_header to t_header.

clear wa_header.

wa_header-typ = 'S'.

wa_header-key = 'Controlling Area:'.

wa_header-info = p_ca.

append wa_header to t_header.

clear wa_header.

wa_header-typ = 'S'.

wa_header-key = ' Year '.

if s_year-high = ''.

wa_header-info = s_year-low.

append wa_header to t_header.

clear wa_header.

else.

concatenate s_year-low 'to' s_year-high

into wa_header-info separated by space.

append wa_header to t_header.

clear wa_header.

endif.

wa_header-typ = 'S'.

wa_header-key = 'Company Code '.

if s_code-high = ''.

wa_header-info = s_code-low.

append wa_header to t_header.

clear wa_header.

else.

concatenate s_code-low 'to' s_code-high

into wa_header-info separated by space.

append wa_header to t_header.

clear wa_header.

endif.

wa_header-typ = 'S'.

wa_header-key = ' Profit Center Group '.

if s_pg-high = ''.

wa_header-info = s_pg-low.

append wa_header to t_header.

clear wa_header.

else.

concatenate s_pg-low 'to' s_pg-high

into wa_header-info separated by space.

append wa_header to t_header.

clear wa_header.

endif.

wa_header-typ = 'S'.

wa_header-key = 'Profit Center'.

if s_pc-high = ''.

wa_header-info = s_pc-low.

append wa_header to t_header.

clear wa_header.

else.

concatenate s_pc-low 'to' s_pc-high

into wa_header-info separated by space.

append wa_header to t_header.

clear wa_header.

endif.

wa_header-typ = 'S'.

wa_header-key = 'Cost Element Group '.

if s_kg-high = ''.

wa_header-info = s_kg-low.

append wa_header to t_header.

clear wa_header.

else.

concatenate s_kg-low 'to' s_kg-high

into wa_header-info separated by space.

append wa_header to t_header.

clear wa_header.

endif.

wa_header-typ = 'S'.

wa_header-key = ' Internal Order '.

if s_or-high = ''.

wa_header-info = s_or-low.

append wa_header to t_header.

clear wa_header.

else.

concatenate s_or-low 'to' s_or-high

into wa_header-info separated by space.

append wa_header to t_header.

clear wa_header.

endif.

wa_header-typ = 'S'.

wa_header-key = ' InternalOrderGroup '.

if s_org-high = ''.

wa_header-info = s_org-low.

append wa_header to t_header.

clear wa_header.

else.

concatenate s_org-low 'to' s_org-high

into wa_header-info separated by space.

append wa_header to t_header.

clear wa_header.

endif.

wa_header-typ = 'S'.

wa_header-key = 'Currency'.

wa_header-info = itab_final-owaer.

append wa_header to t_header.

clear wa_header.

wa_header-typ = 'S'.

wa_header-info = uline.

append wa_header to t_header.

clear wa_header.

wa_header1-key = 'TillPeriod '.

concatenate s_pd-low 'To'

s_pd-high into wa_header1-info separated by space.

wa_header-typ = 'S'.

concatenate 'From Period ' s_pd-low

space wa_header1 into wa_header-info separated by space.

append wa_header to t_header.

clear wa_header.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = t_header

I_LOGO = 'ZVMLOGO'

  • I_END_OF_LIST_GRID =

  • I_ALV_FORM =

.

refresh t_header.

endform. "top_of_page

3 REPLIES 3
Read only

Former Member
0 Likes
513

Hi Vinutha,

Bulky Code... Gone thru it.. everything seems to be right. You just have to see that you are clearing work area and refreshing Internal tables at the right time and also do see that the fieldcalalog table is populated with all the fields before you are passing it to the FM for ALV.

Rest I believe you have to debug and find the bug.

Jayant Sahu

Read only

Former Member
0 Likes
513

Hello Vinutha,

Its not that much easy t refer nearly 4000 LOC and to tell.

Just confirm the below points. I think you will get out of this problem.

- are you clearing the OK_CODE after its uage

- Make sure the code associated to that button should be under the code of that Button.

Reward If Helpful.

Reagrds

--

Sasidhar Reddy Matli.

Read only

0 Likes
513

hi,

I have use on change of statement.where in

on change of ifinal-khinr i have used.

itab1-khinr1 = ifinal-khinr.

endon.

in the above statement ifinal-khinr is not getting cleared.how to clear each time.