*&---------------------------------------------------------------------*
*& Form ADD_WORKING_DAYS_WORKSCHEDULE
*&---------------------------------------------------------------------*
* Add n number of working days to date, using employees work
* schedule to calculate working days
*----------------------------------------------------------------------*
* <-- P_DAYS Number of days to add
* <-- P_PAYDATE Starting date
*----------------------------------------------------------------------*
FORM add_working_days_workschedule USING p_days
CHANGING p_paydate TYPE sy-datum.
DATA: ld_count TYPE i,
ld_memid(30) TYPE c.
* Copied from rptpsh10
DATA: psp LIKE ptpsp OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF hd OCCURS 0,
pernr LIKE pernr-pernr,
name(40),
inv_menge LIKE pakey-seqnr, "ALV copies only 20 columns!
moabw LIKE t001p-moabw, "
mover LIKE t001p-mover, "ALV copies only 20 columns!
datum LIKE psp-datum,
kurzt LIKE t246-kurzt,
tprog LIKE psp-tprog,
varia LIKE psp-varia,
ttext LIKE t550s-ttext,
vtart LIKE p2003-vtart,
vtext LIKE t556t-vtext,
motpr LIKE psp-motpr,
sobeg(8),
soend(8),
stdaz LIKE ptev_rep_h-stdaz,
ftkla LIKE psp-ftkla,
tagty LIKE psp-tagty,
tatxt LIKE t553t-langt,
zmodn LIKE psp-zmodn,
ptext LIKE t551s-ztext,
mofid LIKE t508a-mofid,
ftext LIKE thoct-ltext,
menge LIKE ptev_rep_h-itanz,
alvmarker TYPE rp_xfeld,
END OF hd.
ld_count = p_days.
CONCATENATE sy-uname sy-uzeit INTO ld_memid.
* Z version of 'personal work schedule' report, created to export data
* to memory rather than display it on screen
SUBMIT zrptpsh10_list_to_memory WITH pnppernr EQ pernr-pernr
WITH pnpbegda EQ p2001-begda
WITH pnpendda EQ p2001-endda
WITH pnpbegps EQ p2001-begda
WITH pnpendps EQ p2001-endda
WITH pnptimed EQ ' '
WITH rdclust EQ 'X'
WITH p_memid EQ ld_memid
AND RETURN.
* import datd from memoory
IMPORT hd FROM MEMORY ID ld_memid.
* Check if days are working days
WHILE ld_count GT 0.
READ TABLE hd WITH KEY datum = p_paydate.
IF hd-tprog NE 'FREE'. "FREE equals non working day
p_paydate = p_paydate + 1.
ld_count = ld_count - 1.
ELSE.
p_paydate = p_paydate + 1.
ENDIF.
ENDWHILE.
ENDFORM. " ADD_WORKING_DAYS_WORKSCHEDULE
|