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

help with report

Former Member
0 Likes
505

hello guru's

pls help this querry..

am giving prgm code pls explained th logic and from where the data is fetching and how its working. i want all the details of program. pls help. <b><REMOVED BY MODERATOR></b>

arjun

report zrvp2222 message-id zz line-size 132 line-count 36

no standard page heading.

  • zrvp2222 - OTDB Report, WeekToDate [Z_ONTIME_WK]

  • co.qt 1595(0982).794 devk925285/318/391 11oct04 jcr initial install

  • cp.qt 0217.0887 devk926914 04may05 - simplify operations; fy06

include zrvp2222_00. " top

initialization.

perform init_screen.

at selection-screen.

if sscrfields-ucomm = 'FC01'.

call function 'Z_OTDB_POPUP_LOAD_DATES'.

endif.

at selection-screen output.

perform set_screen_fields.

top-of-page.

perform hof.

start-of-selection. " MAIN

perform hskp.

  • get and total data

perform bld_dy_tables.

perform bld_fp_tables.

perform bld_qt_tables. commit work.

perform output_summary.

perform output_bu.

eject----


*& Form init_screen

&----


  • load: button description, standard business units;

  • setup screen depending on user: Operator|R3admin or not

----


form init_screen.

move 'OTDB Date Info' to sscrfields-functxt_01.

s_bu-sign = 'I'.

s_bu-option = 'EQ'.

select bunit

from z145

into (s_bu-low)

where bunit between '01' and '05'

order by bunit.

append s_bu.

endselect."z145

if sy-subrc <> 0.

message x022 with 'z145 load fail:' sy-subrc.

endif."subrc

perform set_screen_fields.

endform. " init_screen

eject----


*& Form hof

&----


  • head of form.

----


form hof.

write: 001 text-h10.

write: 009 sy-datum,

094 sy-uzeit.

write:/001 text-h20.

write:/001 text-h30,

046 'Fiscal Week',

g_wknbr.

write:/001 text-h40.

skip 1.

endform. " hof

eject----


*& Form hskp

&----


  • lock otdb (shared); get z135 and edit screen date; load date

  • ranges for week, fiscal period, fiscal quarter

----


form hskp.

data: ls_chrdate type z170. " date in character format

data: l_tgtdate type sy-datum. " target date for report

data: l_date type sy-datum. " initially, sy-datum; allow for

"testing

data: l_dow type langt. " weekday name

call function 'Z_OTDB_LOCK_DB'

exporting

i_mode = 'S'

exceptions

lock_fail = 1

others = 2.

if sy-subrc <> 0.

message e001 with sy-msgv1 'has OTDB locked!'.

endif."subrc

select single *

from z135

into gs_dcon

where funcid = 'LOAD'.

if sy-subrc <> 0.

message x002 with 'z135 not found'.

endif."subrc

*

if pa_std = 'X'.

l_date = sy-datum.

write l_date to ls_chrdate. " use for testing special dates

perform get_dow using l_date changing l_dow.

case l_dow.

when 'Monday'.

case ls_chrdate-dd.

when '01'. " yesterday (sunday) is monthend

l_tgtdate = l_date - 2.

perform load_ra using l_tgtdate.

perform inc_wkend.

when '03'. " previous friday is monthend

l_tgtdate = l_date - 3.

perform load_ra using l_tgtdate.

when others. " no monthend; normal saturday week end

l_tgtdate = l_date - 2.

perform load_ra using l_tgtdate.

endcase."chrdate

when others. " use yesterday; adjust week begin for

" sunday = 02

l_tgtdate = l_date - 1.

perform load_ra using l_tgtdate.

write l_tgtdate to ls_chrdate.

if ls_chrdate-dd = '02'

and l_dow = 'Sunday'.

perform dec_wkbeg.

endif."day, date

endcase."dow

else. " use whatever date user entered

l_tgtdate = m_vdatu.

perform load_ra using l_tgtdate.

endif."std

endform. " hskp

eject----


*& Form do_over

&----


  • date from screen not found; if online, leave (does not return!)

  • program and re-execute; if batch, abort.

  • user entered a bad date or there's a system problem

----


form do_over.

if sy-batch is initial.

message i003 with 'Date not found on OTDB; <cr> then'

'click OTDB DATE INFO button'.

leave to transaction 'Z_ONTIME_WK'.

else.

message x004 with 'Date not found on OTDB' m_vdatu.

endif.

endform. " do_over

eject----


*& Form bld_dy_tables

&----


  • build day tables for week: week summed on date, summed on bu,

  • grand total; calc percents for each.

----


form bld_dy_tables.

data: lt_sum type z140 occurs 0. " summarized on date

  • get data summarized on date for the week

call function 'Z_OTDB_SUMMARIZE_HEADER'

exporting

i_get_header = 'X'

i_summarize_date = 'X'

tables

it_bu = s_bu

it_vdatu = gr_dy

et_op = lt_sum

exceptions

syserr_level = 1

nothing_found = 2

no_date_range = 3

fisc_cal_fail = 4

others = 5.

if sy-subrc <> 0.

if sy-subrc = 2.

perform do_over.

else.

message x005 with 'syserr' sy-subrc.

endif.

endif."subrc

  • summarize data on bu, all bu's

call function 'Z_OTDB_ROLLUP_BU_GRAND'

exporting

i_bu = 'X'

i_grand = 'X'

tables

it_ip = lt_sum

et_bu = gt_dybu

et_grand = gt_dygr.

  • summarize bu and date

call function 'Z_OTDB_ROLLUP_BU_GRAND'

exporting

i_date = 'X'

tables

it_ip = lt_sum

et_bu = gt_budy.

  • summarize all bu's on date

call function 'Z_OTDB_ROLLUP_BU_GRAND'

exporting

i_budate = 'X'

tables

it_ip = lt_sum

et_bu = gt_bugr.

  • calc percents

call function 'Z_OTDB_CALC_PERCENTS'

tables

iet_tgt = lt_sum.

call function 'Z_OTDB_CALC_PERCENTS'

tables

iet_tgt = gt_dybu.

call function 'Z_OTDB_CALC_PERCENTS'

tables

iet_tgt = gt_dygr.

call function 'Z_OTDB_CALC_PERCENTS'

tables

iet_tgt = gt_budy.

call function 'Z_OTDB_CALC_PERCENTS'

tables

iet_tgt = gt_bugr.

  • save the day detail; sort tables

gt_dy = lt_sum.

sort gt_dy by bunit vdatu.

sort gt_dybu by bunit.

sort gt_budy by bunit vdatu.

sort gt_bugr by vdatu.

endform. " bld_dy_tables

eject----


*& Form bld_fp_tables

&----


  • build fiscal period tables: summed on bu, grand total;

  • calc percents for each.

  • note date detail not needed: date info in day tables is used

----


form bld_fp_tables.

data: lt_sum type z140 occurs 0. " summarized on fiscal period

  • get data summarized on date for the week

call function 'Z_OTDB_SUMMARIZE_HEADER'

exporting

i_get_header = 'X'

i_summarize_fp = 'X'

tables

it_bu = s_bu

it_vdatu = gr_fp

et_op = lt_sum

exceptions

syserr_level = 1

nothing_found = 2

no_date_range = 3

fisc_cal_fail = 4

others = 5.

if sy-subrc <> 0.

if sy-subrc = 2.

perform do_over.

else.

message x014 with 'syserr' sy-subrc.

endif.

endif."subrc

  • summarize data on bu, all bu's

call function 'Z_OTDB_ROLLUP_BU_GRAND'

exporting

i_bu = 'X'

i_grand = 'X'

tables

it_ip = lt_sum

et_bu = gt_fpbu

et_grand = gt_fpgr.

call function 'Z_OTDB_CALC_PERCENTS'

tables

iet_tgt = gt_fpbu.

call function 'Z_OTDB_CALC_PERCENTS'

tables

iet_tgt = gt_fpgr.

  • save the fp detail; sort tables

sort gt_fpbu by bunit.

endform. " bld_fp_tables

eject----


*& Form bld_qt_tables

&----


  • build fiscal quarter tables: summed on bu, grand total;

  • calc percents for each.

  • note date detail not needed: date info in day tables is used

----


form bld_qt_tables.

data: lt_sum type z140 occurs 0. " summarized on fiscal quarter

  • get data summarized on date for the week

call function 'Z_OTDB_SUMMARIZE_HEADER'

exporting

i_get_header = 'X'

i_summarize_quarter = 'X'

tables

it_bu = s_bu

it_vdatu = gr_qt

et_op = lt_sum

exceptions

syserr_level = 1

nothing_found = 2

no_date_range = 3

fisc_cal_fail = 4

others = 5.

if sy-subrc <> 0.

if sy-subrc = 2.

perform do_over.

else.

message x018 with 'syserr' sy-subrc.

endif.

endif."subrc

  • summarize data on bu, all bu's

call function 'Z_OTDB_ROLLUP_BU_GRAND'

exporting

i_bu = 'X'

i_grand = 'X'

tables

it_ip = lt_sum

et_bu = gt_qtbu

et_grand = gt_qtgr.

call function 'Z_OTDB_CALC_PERCENTS'

tables

iet_tgt = gt_qtbu.

call function 'Z_OTDB_CALC_PERCENTS'

tables

iet_tgt = gt_qtgr.

  • save the quarter detail; sort tables

sort gt_qtbu by bunit.

endform. " bld_qt_tables

eject----


*& Form output_summary

&----


  • otifne section: wtd, mtd, qtd on page 1

----


form output_summary.

  • WTD

write:/023 'Fiscal Week',

g_wknbr,

'(' no-gap,

gr_dy-low mm/dd/yy no-gap, '-' no-gap,

gr_dy-high mm/dd/yy no-gap,

')'.

if gr_dy-high > gs_dcon-erdat.

write: 'thru', gs_dcon-erdat mm/dd/yy.

endif."dy-high

write:/022(58) sy-uline.

write:/023 text-i10.

write:/022(58) sy-uline.

perform print_summary tables s_bu gt_dygr gt_dybu.

skip 4.

  • FP

write:/023 'Fiscal Period',

g_fpnbr,

'(' no-gap,

gr_fp-low mm/dd/yy no-gap, '-' no-gap,

gr_fp-high mm/dd/yy no-gap,

')'.

if gr_fp-high > gs_dcon-erdat.

write: 'thru', gs_dcon-erdat mm/dd/yy.

endif."dy-high

write:/022(58) sy-uline.

write:/023 text-i10.

write:/022(58) sy-uline.

perform print_summary tables s_bu gt_fpgr gt_fpbu.

skip 4.

  • QTR

write:/023 'Fiscal Qtr.',

g_qtnbr,

'(' no-gap,

gr_qt-low mm/dd/yy no-gap, '-' no-gap,

gr_qt-high mm/dd/yy no-gap,

')'.

if gr_qt-high > gs_dcon-erdat.

write: 'thru', gs_dcon-erdat mm/dd/yy.

endif."dy-high

write:/022(58) sy-uline.

write:/023 text-i10.

write:/022(58) sy-uline.

perform print_summary tables s_bu gt_qtgr gt_qtbu.

new-page.

endform. " output_summary

eject----


*& Form output_bu

&----


  • detail section: wtd for all bu's then each in turn

----


form output_bu.

  • all bu's

write:/015 'All Business Units'.

write:/014(118) sy-uline.

write:/015 text-s05.

write:/015 text-s10.

write:/015 text-s20.

write:/015 text-s30.

write:/014(118) sy-uline.

perform print_bu tables gt_bugr gt_dygr using space.

new-page.

  • 01: USA

write:/015 '01: USA'.

write:/014(118) sy-uline.

write:/015 text-s05.

write:/015 text-s10.

write:/015 text-s20.

write:/015 text-s30.

write:/014(118) sy-uline.

perform print_bu tables gt_budy gt_dybu using '01'.

new-page.

  • 02: Asia

write:/015 '02: Asia'.

write:/014(118) sy-uline.

write:/015 text-s05.

write:/015 text-s10.

write:/015 text-s20.

write:/015 text-s30.

write:/014(118) sy-uline.

perform print_bu tables gt_budy gt_dybu using '02'.

new-page.

  • 03: PA

write:/015 '03: PA'.

write:/014(118) sy-uline.

write:/015 text-s05.

write:/015 text-s10.

write:/015 text-s20.

write:/015 text-s30.

write:/014(118) sy-uline.

perform print_bu tables gt_budy gt_dybu using '03'.

new-page.

  • 04: EMEA

write:/015 '04: EMEA'.

write:/014(118) sy-uline.

write:/015 text-s05.

write:/015 text-s10.

write:/015 text-s20.

write:/015 text-s30.

write:/014(118) sy-uline.

perform print_bu tables gt_budy gt_dybu using '04'.

new-page.

  • 05: IA

write:/015 '05: IA'.

write:/014(118) sy-uline.

write:/015 text-s05.

write:/015 text-s10.

write:/015 text-s20.

write:/015 text-s30.

write:/014(118) sy-uline.

perform print_bu tables gt_budy gt_dybu using '05'.

endform. " output_bu

eject----


*& Form print_summary

&----


  • first page of report is the summary (ontime and infull lines)

  • aka otifne

----


  • -->PR_BU range of bu's from selection screen

  • -->PT_XXGR detail, grand totals

  • -->PT_XXBU detail, bu by date

----


form print_summary tables pr_bu structure s_bu

pt_xxgr structure z140

pt_xxbu structure z140.

  • OnTime and InFull field tables

data: lt_otd type z140-pc_ot occurs 0 with header line.

data: lt_if type z140-pc_ot occurs 0 with header line.

data: ls_ip type z140. " work area for grand/bu detail

data: l_pp type p. " print position

loop at pt_xxgr into ls_ip.

lt_otd = ls_ip-pc_ot. append lt_otd.

lt_if = ls_ip-pc_if. append lt_if.

endloop."xxgr

loop at pr_bu.

clear: lt_otd, lt_if, ls_ip.

loop at pt_xxbu into ls_ip where bunit = pr_bu-low.

lt_otd = ls_ip-pc_ot.

lt_if = ls_ip-pc_if.

endloop."xxgr

append: lt_otd, lt_if.

endloop."bu

write:/011 '% On Time'.

l_pp = 21.

loop at lt_otd.

write: at l_pp lt_otd no-gap no-sign no-zero.

l_pp = l_pp + 10.

endloop."otd

write:/011 '% In Full'.

l_pp = 21.

loop at lt_if.

write: at l_pp lt_if no-gap no-sign no-zero.

l_pp = l_pp + 10.

endloop."if.

endform. " print_summary

eject----


*& Form print_bu

&----


  • write wtd bu detail

----


  • -->PT_DTL bu detail

  • -->PT_GR grand total for detail

  • -->P_BU bu number or blank

----


form print_bu tables pt_dtl structure z140

pt_gr structure z140

using p_bu type z140-bunit.

data: ls_dtl type z140. " work area

data: lr_bu type zbunit_range_tab " bu range of

with header line. " one value

data: l_dyname type hrvsched-daytxt.

lr_bu-sign = 'I'.

if p_bu is initial.

lr_bu-low = '*'.

lr_bu-option = 'CP'.

else.

lr_bu-low = p_bu.

lr_bu-option = 'EQ'.

endif."p_bu

append lr_bu.

loop at pt_dtl into ls_dtl where bunit = p_bu.

call function 'RH_GET_DATE_DAYNAME'

exporting

langu = sy-langu

date = ls_dtl-vdatu

importing

daytxt = l_dyname

exceptions

no_langu = 1

no_date = 2

no_daytxt_for_langu = 3

invalid_date = 4

others = 5.

if sy-subrc <> 0.

message x006 with 'rhgetdayname fail:'

sy-subrc ls_dtl-vdatu.

endif."subrc

write:/ l_dyname+0(3),

ls_dtl-vdatu mm/dd/yy,

016 ls_dtl-pc_ot no-sign no-zero,

025(007) ls_dtl-cnt_tl no-sign no-zero,

036(007) ls_dtl-cnt_ot no-sign no-zero,

049 ls_dtl-pv_ot no-sign no-zero,

059(012) ls_dtl-val_tl no-sign no-zero decimals 0,

072(012) ls_dtl-val_ot no-sign no-zero decimals 0,

086(007) ls_dtl-cnt_cr no-sign no-zero,

096(012) ls_dtl-val_cr no-sign no-zero decimals 0,

114 ls_dtl-pc_cr no-sign no-zero,

124 ls_dtl-pv_cr no-sign no-zero.

endloop."ls_dtl

loop at pt_gr into ls_dtl where bunit = p_bu.

write:/001 'WTD',

013 '=>',

016 ls_dtl-pc_ot no-sign no-zero,

025(007) ls_dtl-cnt_tl no-sign no-zero,

036(007) ls_dtl-cnt_ot no-sign no-zero,

049 ls_dtl-pv_ot no-sign no-zero,

059(012) ls_dtl-val_tl no-sign no-zero decimals 0,

072(012) ls_dtl-val_ot no-sign no-zero decimals 0,

086(007) ls_dtl-cnt_cr no-sign no-zero,

096(012) ls_dtl-val_cr no-sign no-zero decimals 0,

114 ls_dtl-pc_cr no-sign no-zero,

124 ls_dtl-pv_cr no-sign no-zero.

endloop."lt_gr

check sy-subrc <> 0.

write:/001 'WTD',

013 '=> No Sales'.

endform. " print_bu

eject----


*& Form get_dow

&----


  • get the day of week for input date

----


  • -->U_DATE input date

  • <--C_DOW returned day of week

----


form get_dow using u_date type sy-datum

changing c_dow type langt.

data: lta_casdayattr type table of casdayattr.

data: ls_casdayattr type casdayattr.

data: l_returncode type sy-subrc.

call function 'DAY_ATTRIBUTES_GET'

exporting

date_from = u_date

date_to = u_date

importing

returncode = l_returncode

tables

day_attributes = lta_casdayattr

exceptions

factory_calendar_not_found = 1

holiday_calendar_not_found = 2

date_has_invalid_format = 3

date_inconsistency = 4

others = 5.

if sy-subrc <> 0 or l_returncode <> 0.

message x007 with 'dayattributesget fail:'

u_date l_returncode sy-subrc.

endif.

loop at lta_casdayattr into ls_casdayattr.

c_dow = ls_casdayattr-weekday_l.

exit.

endloop."casdayattr

endform. " get_dow

eject----


*& Form load_ra

&----


  • edit target date; load fiscal week/period/quarter ranges

----


  • -->U_TGTDATE date used to identify fiscal info

----


form load_ra using u_tgtdate type sy-datum.

if not u_tgtdate between gs_dcon-begda and gs_dcon-erdat.

perform do_over.

endif."tgtdaye

call function 'Z_OTDB_BLD_RANGES_FOR_DATE'

exporting

i_date = u_tgtdate

importing

e_week = g_wknbr

e_period = g_fpnbr

e_quarter = g_qtnbr

tables

et_week = gr_dy

et_period = gr_fp

et_quarter = gr_qt

exceptions

syserr = 1

others = 2.

if sy-subrc <> 0.

perform do_over.

endif."subrc

endform. " load_ra

eject----


*& Form inc_wkend

&----


  • increment the end of the week one day

----


form inc_wkend.

loop at gr_dy.

gr_dy-high = gr_dy-high + 1.

modify gr_dy.

endloop."week

endform. " inc_wkend

&----


*& Form dec_wkbeg

&----


  • decrement the beginning of week one day

----


form dec_wkbeg.

loop at gr_dy.

gr_dy-low = gr_dy-low - 1.

modify gr_dy.

endloop."week

endform. " dec_wkbeg

eject----


*& Form set_screen_fields

&----


  • set visible fields on sel scrn depending on login name

----


form set_screen_fields.

case sy-uname.

when 'OPERATOR' or 'R3ADMIN'.

loop at screen.

if screen-name = 'PA_STD'. " show field

screen-active = 1.

screen-input = 1.

screen-output = 1.

screen-invisible = 0.

modify screen.

elseif

screen-name = 'M_VDATU'. " not obligatory

screen-required = 0.

modify screen.

endif."screen

endloop."screen

if m_vdatu is initial.

pa_std = 'X'. " operator default

endif."vdatu

when others.

loop at screen.

if screen-name = 'PA_STD' " hide field

or screen-name = '%C311010_1000'. " hide comments

screen-active = 0.

screen-input = 0.

screen-output = 0.

screen-invisible = 1.

modify screen.

endif."screen

endloop."screen

if m_vdatu is initial.

m_vdatu = sy-datum - 1. " default yesterday

endif."vdatu

endcase."uname

endform. " set_screen_fields

Title and Message were edited by:

Alvaro Tejada Galindo

3 REPLIES 3
Read only

Former Member
0 Likes
463

Hi Arjun,

To really understand ur code is a big problem..

Why ???

a) The include in ur program is not coded here.

b) ur program includes ztables, so without knowing the fields,

one cannot clue it out to find what exactly is going on ur programs.

So next time b careful to code ur includes n giv info bout ur Ztables..

Hope this helps u.

Thanks,

S.Agarwal

Read only

0 Likes
463

hello sapna!

actually wat happen is this is developed 1 year bak. now i get ticket as code review. and it is checking as per require not. i know the flow. but here in this func. mod included some other func.modules. this becomes difficult 2 undersand me how d data fetching. i hav to giv documentation on this code review. really am not able to do this.

bcoz its very difficult to understand the ztables and zfunction modules. and their logics

tell me wat 2 do yaar!

any how thks 4 reply....

<b><REMOVED BY MODERATOR></b>

y indiatimes bcoz no other sites are access here.

Regards,

arjun

Message was edited by:

Alvaro Tejada Galindo

Read only

Former Member
0 Likes
463

Execute the report and debug it...Don't expect us to read the whole code and the documentation work for you...Anyway...If you need help with a particular piece of code...just paste that particular piece of code...and not the whole...

Greetings,

Blag.