Posted: Sat Sep 15, 2007 9:26 pm Post subject: Using Week Day
Code:
report z.
include <LIST>.
*======================================================================*
selection-screen: begin of line,
comment (5) ps_cycle.
parameters: p_cycle(2) type n,
p_from like sy-datum.
selection-screen: position 30,
comment (4) ps_from.
parameter p_today like sy-datum.
selection-screen end of line.
*----------------------------------------------------------------------*
data: w_delta type i,
w_start like sy-datum,
w_start_d like sy-datum,
w_day like sy-datum,
w_end_d like sy-datum,
ws_month(20) type c,
it_day(10) type c occurs 0 with header line,
begin of it_days occurs 0,
day like sy-datum,
flag like icon-id,
end of it_days.
*----------------------------------------------------------------------*
define get_day_name.
select single varvalue from ttdtg into it_day
where spras = sy-langu and varname = &1.
if sy-subrc <> 0.
select single varvalue from ttdtg into it_day
where spras = 'EN' and varname = &1.
if sy-subrc <> 0.
select varvalue from ttdtg into it_day up to 1 rows
where varname = &1.
endselect.
if sy-subrc <> 0.
it_day = &2.
endif.
endif.
endif.
append it_day.
end-of-definition.
*======================================================================*
AT SELECTION-SCREEN.
*----------------------------------------------------------------------*
if p_today < p_from.
message e899(mm) with 'Select from > cycle'.
endif.
*======================================================================*
AT SELECTION-SCREEN OUTPUT.
*----------------------------------------------------------------------*
loop at screen.
if screen-name = 'P_CYCLE' or screen-name = 'P_FROM'.
screen-input = 0.
modify screen.
endif.
endloop.
*======================================================================*
END-OF-SELECTION.
*----------------------------------------------------------------------*
constants: c_cell type i value 10,
c_varmon like ttdtg-varname value '%%SAPSCRIPT_MMMM_'.
data: w_len type i,
w_len_m type i,
w_len_d type i,
w_pos type i,
w_pos2 type i,
w____(200) type c,
w_weekday type i,
w_varmon like ttdtg-varname.
w_pos = 1.
format intensified off.
write at /(w_len) w____ color col_heading.
loop at it_day.
if sy-tabix = 1.
write: at /w_pos sy-vline, at (w_len_d) it_day color col_heading.
else.
if sy-tabix = 6.
format intensified on.
endif.
write: at w_pos sy-vline, at (w_len_d) it_day color col_heading.
endif.
add c_cell to w_pos.
endloop.
format intensified off.
write: at (w_len) sy-vline, at /(w_len) w____ color col_heading.
sort it_days by day ascending.
w_weekday = 1.
loop at it_days.
* ws_month
if it_days-day >= w_start_d.
if ws_month is initial or it_days-day+6(2) = '01'.
if not ws_month is initial.
w_pos2 = ( w_weekday - 1 ) * c_cell + 1.
if w_pos2 <> w_len.
write at w_pos2 sy-vline.
endif.
write: at w_len sy-vline, at /(w_len) w____.
endif.
concatenate c_varmon it_days-day+4(2) into w_varmon.
select single varvalue from ttdtg into ws_month
where spras = sy-langu and varname = w_varmon.
if sy-subrc <> 0.
select single varvalue from ttdtg into ws_month
where spras = 'EN' and varname = w_varmon.
if sy-subrc <> 0.
select varvalue from ttdtg into ws_month up to 1 rows
where varname = w_varmon.
endselect.
if sy-subrc <> 0.
ws_month = it_days-day+4(2).
endif.
endif.
endif.
concatenate ws_month it_days-day(4) into ws_month
separated by space.
write: / sy-vline, at (w_len_m) ws_month color col_key,
at w_len sy-vline, at /(w_len) w____ color col_key.
endif.
w_pos = ( w_weekday - 1 ) * c_cell + 1.
if w_weekday = 6.
format intensified on.
endif.
if w_pos = 1.
write: at /w_pos sy-vline.
elseif it_days-day+6(2) = '01'.
write: / sy-vline, at w_pos sy-vline.
else.
write: at w_pos sy-vline.
endif.
if it_days-day = sy-datum.
format color col_total on.
write: it_days-day+6(2), it_days-flag as icon.
format color col_total off.
else.
write: it_days-day+6(2), it_days-flag as icon.
endif.
add 1 to w_weekday.
if w_weekday = 8.
write at w_len sy-vline.
format intensified off.
write at /(w_len) w____.
w_weekday = 1.
endif.
endif.
endloop.
*--- End Of Code ---
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.