‎2007 Nov 07 4:39 AM
Hai I am having some date diff for ex i_diff = 01.01.2007 - 01.05.2006
and in that diff i need to subtract now-work days also i mean sat and sun so how it is possible can anyone pls help me
‎2007 Nov 07 4:51 AM
DATE_CHECK_WORKINGDAY IS THE fucntion modeule for checking that a particular date is a working day or not.
it gives sat and sun as non-working days so it may be helpful to u...
‎2007 Nov 07 4:53 AM
Hi,
You can directly subtract following way.
int days.
Days = date1 - date2.
otherwise you can use FM: Calcuate_days_between* search for this in SE37
Reward points if useful
PRaneeth
‎2007 Nov 07 4:59 AM
TABLES: *MSEG, *T001W.
DATA: BEGIN OF J_1H_VBFA OCCURS 10. "Key Buffer
INCLUDE STRUCTURE VBFA.
DATA: END OF J_1H_VBFA.
DATA: BEGIN OF J_1H_COMWA. "Return table from fn.
INCLUDE STRUCTURE VBCO6.
DATA: END OF J_1H_COMWA.
DATA: J_1H_KONV LIKE KONV,
J_1H_SAVE_KONV LIKE KONV.
DATA: T_VBRK TYPE STANDARD TABLE OF VBRK. "Billing header
DATA: WA_VBRK TYPE VBRK. "Work area for Billing
DATA: BEGIN OF ZUK,
MODUL(3) VALUE '360',
BUPLA LIKE VBRK-BUPLA,
LIFNR LIKE LFA1-LIFNR,
MWSKZ LIKE VBRP-MWSKZ,
END OF ZUK.
DATA: D_KURDT LIKE VBRK-FKDAT. "Currency exch. rate date
STATICS: D_FKDAT LIKE VBRK-FKDAT.
Component check for country - Thailand
CALL FUNCTION 'J_1BSA_COMPONENT_ACTIVE'
EXPORTING
BUKRS = VBRK-BUKRS
COMPONENT = 'TH'
EXCEPTIONS
COMPONENT_NOT_ACTIVE = 1
OTHERS = 2.
CHECK SY-SUBRC = 0.
Determine BUPLA from Plant
SELECT SINGLE * FROM *T001W WHERE WERKS = VBRP-WERKS.
IF SY-SUBRC = 0.
ZUK-BUPLA = *T001W-J_1BBRANCH.
ENDIF.
Determine BUPLA from original invoice if credit/debit note, return
IF NOT VBAK-VGBEL IS INITIAL.
SELECT * FROM VBRK INTO TABLE T_VBRK
WHERE VBELN EQ VBAK-VGBEL
AND BUKRS EQ VBRK-BUKRS.
READ TABLE T_VBRK INTO WA_VBRK INDEX 1.
IF SY-SUBRC EQ 0.
IF NOT WA_VBRK-BUPLA IS INITIAL.
MOVE WA_VBRK-BUPLA TO VBRK-BUPLA.
ENDIF.
ENDIF.
ENDIF.
*------- For Thailand, the business place is required. "596215
*... This will allow the user to enter BUPLA
*... before release billing to accounting.
data: begin of xtemp occurs 1.
include structure sval.
data: end of xtemp.
data returncode(1).
if sy-batch is initial
and vbrk-bupla is initial.
select single PARVA from USR05
into vbrk-bupla
where bname = vbrk-ernam
and parid = 'ID_BUPLA'.
clear xtemp.
move: 'J_1HVAT_OFF_NUM' to xtemp-tabname,
'BUKRS' to xtemp-fieldname,
vbrk-bukrs to xtemp-value,
'02' to xtemp-field_attr.
collect xtemp.
clear xtemp.
move: 'J_1HVAT_OFF_NUM' to xtemp-tabname,
'BRNCH' to xtemp-fieldname,
vbrk-bupla to xtemp-value,
'X' to xtemp-field_obl.
collect xtemp.
call function 'POPUP_GET_VALUES_DB_CHECKED'
exporting
check_existence = 'X'
popup_title = sy-title
importing
returncode = returncode
tables
fields = xtemp
exceptions
error_in_fields = 1
others = 2.
read table xtemp index 2.
if sy-subrc = 0
and returncode is initial.
move xtemp-value to vbrk-bupla.
endif.
if vbrk-bupla is initial.
CALL FUNCTION 'CUSTOMIZED_MESSAGE'
EXPORTING
I_ARBGB = 'F5'
I_DTYPE = 'E'
I_MSGNR = '883'.
endif.
endif.
*----
BoI 415711 -
*------- Vendor Consignment: In Thailand,consignor name&address
*... has to be printed on Tax Invoice, Debit/Credit Note
*... Read document flow for mat.document
data t_konv like konv occurs 0 with header line.
select * from vbfa where vbelv = vbrp-vgbel "Delivery
and vbtyp_n = 'R'.
move: vbfa-vbeln to *mseg-mblnr,
vbfa-posnn to *mseg-zeile.
select * from *mseg where mblnr eq *mseg-mblnr
and zeile eq *mseg-zeile.
move *mseg-lifnr to zuk-lifnr.
exit.
endselect.
exit.
endselect.
*----
Use only taxable tax code
*... if only one taxable, combine non-taxable
select * from konv into table t_konv
where knumv = vbak-knumv
and kappl = 'V'
and koaid = 'D'
and kntyp = 'D'
and kschl = 'MWST'.
loop at t_konv.
select single mwsk1 from konp into t_konv-mwsk1
where knumh = t_konv-knumh
and kopos = t_konv-kopos.
modify t_konv.
endloop.
clear zuk-mwskz.
loop at t_konv into konv
where mwsk1 <> t001-mwska "Non-taxable
and mwsk1 <> t001-mwskv
and mwsk1 <> space.
if zuk-mwskz = space.
move konv-mwsk1 to zuk-mwskz.
elseif konv-mwsk1 <> zuk-mwskz.
move '*' to zuk-mwskz.
endif.
endloop.
*----
if more than one taxable, split for each tax code
*... include non-taxable.
if zuk-mwskz = '*'.
read table t_konv into konv
with key knumv = vbak-knumv
kposn = vbap-posnr.
if sy-subrc = 0.
move konv-mwsk1 to zuk-mwskz.
endif.
endif.
*----
EoI 415711 -
... Pass to VBRK
VBRK-ZUKRI = ZUK.
Set currency exchange rate date by working day before billing date
Only TVCPF-PFKUR = 'C' (Exchange rate from billing date).
'X' assigned after first line item proceed.
CHECK TVCPF-PFKUR CA 'CX'.
Keep billing date in statics varible
IF D_FKDAT IS INITIAL.
D_FKDAT = VBRK-FKDAT.
ENDIF.
Begin from billing date - 1
D_KURDT = D_FKDAT - 1.
Retreive factory calendar
SELECT SINGLE * FROM *T001W WHERE WERKS = VBRP-WERKS.
DO.
CALL FUNCTION 'DATE_CHECK_WORKINGDAY'
EXPORTING
DATE = D_KURDT
FACTORY_CALENDAR_ID = *T001W-FABKL
MESSAGE_TYPE = 'W'
EXCEPTIONS
DATE_AFTER_RANGE = 1
DATE_BEFORE_RANGE = 2
DATE_INVALID = 3
DATE_NO_WORKINGDAY = 4
FACTORY_CALENDAR_NOT_FOUND = 5
MESSAGE_TYPE_INVALID = 6
OTHERS = 7.
IF SY-SUBRC EQ 0.
EXIT.
ENDIF.
D_KURDT = D_KURDT - 1.
ENDDO.
Use exchange rate type that maintain in customer master. - NOTE 22781
IF T001-BUKRS NE VBRK-BUKRS.
SELECT SINGLE * FROM T001 WHERE BUKRS = VBRK-BUKRS.
ENDIF.
get new exchange rate from table TCUR
IF VBRK-WAERK NE T001-WAERS AND VBRK-KURST NE SPACE.
CALL FUNCTION 'READ_EXCHANGE_RATE'
EXPORTING
date = vbrk-fkdat
DATE = D_KURDT
FOREIGN_CURRENCY = VBRK-WAERK
LOCAL_CURRENCY = T001-WAERS
TYPE_OF_RATE = VBRK-KURST
IMPORTING
EXCHANGE_RATE = VBRK-KURRF
EXCEPTIONS
NO_RATE_FOUND = 1.
IF SY-SUBRC NE 0.
VBRK-KURRF = 0.
ELSE.
VBRK-CPKUR = 'X'.
VBRK-KURRF_DAT = D_KURDT.
VBRP-KURSK = VBRK-KURRF.
VBRP-KURSK_DAT = D_KURDT.
TVCPF-PFKUR = 'X'. "Ignore standard re-determine exch.rate
ENDIF.
ENDIF.
ENDFORM.