HR_HK_DIFF_BT_2_DATES
hi friends,
hope all of you doing good.
i am getting dump at years = ( l_date3+0(4) + ( l_total_number_days / days_in_year ) ). in the FM HR_HK_DIFF_BT_2_DATES.
the error message i am getting is Overflow during the arithmetical operation (type P) in program "SAPL3HKC".
can any one give me the suggestion inseted of using this FM HR_HK_DIFF_BT_2_DATES can i use any othere FM for the same purpuse.
thaks
ysr.
Hi,
have u given the data like this ...
DATE1 20.10.2009
DATE2 10.10.2009
OUTPUT_FORMAT 02
Export parameters Value
YEARS 0,0000
MONTHS 0,0000
DAYS 11
you have to first test with the FM, then send the data via program.
date 1 should be greater than date 2
in the program you have to give it like
date1 = 20091020
date2 = 20091010
output_format = '02'
and then see the results.
Results
Venkatesh
Similar Messages
-
Runtime error in FM HR_HK_DIFF_BT_2_DATES
hi experts,
i am getting runtime error at years = ( l_date3+0(4) + ( l_total_number_days / days_in_year ) ). in the FM HR_HK_DIFF_BT_2_DATES.
the runtime error is Overflow during the arithmetical operation (type P) in program "SAPL3HKC".
can any one give me the suggestion to get a solution.
thanks
nagarajHi,
Check what you have passed to the dates. (DATE1 , DATE2)
If the difference is greater than 999 years , then you'll get the below dump.
l_date3 = ( date1 + 1 ) - date2.
Regards,
Srini. -
Dear Experts,
I have to add one field at the last of the of a ALV. THe field name is ebeln.
I have made modifiaction in the structure as well as in the fieldcat.
please go through the complete code below.
Program name : Z_Invoice *
Program Description : The purpose of the report is to: *
Give the details of open invoices for a *
project. *
Give details of cleared invoices for a *
project *
Technical Object No : NA *
Developer : Priyanka Vasudeva,Jasleen Randhawa *
Level2 Analyst/FC : Sanjay Arali *
Company : Satyam Computer Services Limited(SCSL) *
Start Date : 12-05-2005 *
End Date : 18-05-2005 *
Logical Database : NA *
Function Modules : HR_SEN_CALE_DAYS_DATE, *
REUSE_ALV_LIST_DISPLAY, *
HR_HK_DIFF_BT_2_DATES *
Includes : z_invoice_form - For forms *
z_invoice_top - For data Declarations *
C H A N G E H I S T O R Y *
*Version| Developer | Date | Change Description *
V00 |Priyanka ,Jasleen |12/10/2004| New Development
report z_invoice message-id znew.
Include for the data declarations and selection screen
include z_invoice_top.
Include for the forms used
include z_invoice_form.
I N I T I A L I Z A T I O N *
initialization.
Storing the report name
v_repid = sy-repid.
A T S E L E C T I O N - S C R E E N *
at selection-screen.
For validating the Project number entered by the user
perform f_validate_proj_number.
S T A R T - O F - S E L E C T I O N *
start-of-selection.
For creating the field catalog
perform f_fieldcat.
*For checking the project number in lowercse
perform f_projectno_concatenate.
if p_open = 'X'.
*For open invoices
perform f_invoice_open.
elseif p_closed = 'X'.
*For cleared invoices
perform f_invoice_cleared.
endif.
For vendor details
perform f_vendor_details.
Display the Final Output in ALV
perform f_alv_display.
E N D - O F - S E L E C T I O N *
*Free all internal tables
free: i_output1,
i_fieldcat,
i_bsak,
i_bsik.
E N D O F R E P O R T *
Program name : Z_Invoice *
Program Description : The purpose of the report is to: *
Give the details of open invoices for a *
project. *
Give details of cleared invoices for a
project
Technical Object No : NA *
Developer : Priyanka Vasudeva,Jasleen Randhawa
Level2 Analyst/FC : Sanjay Arali *
Company : Satyam Computer Services Limited(SCSL) *
Start Date : 12-05-2005 *
End Date : 17-05-2005 *
Logical Database : NA *
Function Modules : HR_SEN_CALE_DAYS_DATE, *
REUSE_ALV_LIST_DISPLAY, *
HR_HK_DIFF_BT_2_DATES *
Includes : z_invoice_form - For forms *
z_invoice_top - For data Declarations *
C H A N G E H I S T O R Y *
*Version| Developer | Date | Change Description *
V00 |Priyanka ,Jasleen |12/10/2004| New Development *
INCLUDE Z_INVOICE_TOP *
include <icon>.
type-pools: slis.
D A T A B A S E T A B L E S *
tables: bsak, "accounting:secondary index for vendors(cleared items)
bsik, "accounting:secondary index for vendors
lfa1, "vendor master
proj. "project definition
I N T E R N A L T A B L E S ***********************
For the complete details to be shown on the output screen
data: begin of i_output1 occurs 0,
lifnr like lfa1-lifnr, "vendor no
name(70), "vendor name1
belnr like bsak-belnr, "document no
bldat like bsak-bldat, "document date
dmbtr like bsak-dmbtr, "amount in local currency
waers LIKE bsak-waers, "currency
augdt like bsak-augdt, "date paid
zuonr like bsak-zuonr, "assignment number
due_date like bsik-zfbdt, "due date
status(4), "To set color
g_days like p0347-scrdd, "date paid
end of i_output1.
*For open invoices
data: begin of i_bsak occurs 0,
lifnr like bsak-lifnr,
belnr like bsak-belnr, "document no
bldat like bsak-bldat, "document date
dmbtr like bsak-dmbtr, "amount in local currency
waers LIKE bsak-waers, "currency
augdt like bsak-augdt, "date paid
zuonr like bsak-zuonr, "assignment number
bukrs like bsak-bukrs, "company code
blart like bsak-blart, "document type
shkzg like bsak-shkzg, "Type Credit Or Debit
end of i_bsak.
*For vendor details including vendor number and name
data: begin of i_lfa1 occurs 0,
lifnr like lfa1-lifnr, "vendor no
name1 like lfa1-name1, "vendor name1
name2 like lfa1-name2, "vendor name2
end of i_lfa1.
*For closed invoices
data: begin of i_bsik occurs 0,
lifnr like bsik-lifnr, "vendor no
belnr like bsik-belnr, "document no
bldat like bsik-bldat, "document date
dmbtr like bsik-dmbtr, "amount in local currency
waers LIKE bsik-waers, "currency
blart like bsik-blart, "document type
zfbdt like bsik-zfbdt, "baseline date for due date
zbd1t like bsik-zbd1t, "cash discount days1
augdt like bsik-augdt, "date paid
zuonr like bsik-zuonr, "assignment number
bukrs like bsik-bukrs, "company code
shkzg like bsik-shkzg, "Type Credit Or Debit
end of i_bsik.
D A T A D E C L A R A T I O N S *
data: v_repid type sy-repid, "For the report name
v_projno type bsak-zuonr,
v_projno1(25) type c.
T A B L E T Y P E S *****************************
Internal Table for Field Catalog
data i_fieldcat type slis_t_fieldcat_alv.
W O R K A R E A S *************************
Work Area for Field Catalog
data wa_fieldcat type slis_fieldcat_alv.
S E L E C T I O N S C R E E N *
selection-screen skip 1.
selection-screen begin of block input with frame title text-001.
selection-screen skip 1.
parameters: p_projno type proj-pspid obligatory.
selection-screen skip 2.
parameters: p_open radiobutton group inv,
p_closed radiobutton group inv.
selection-screen skip 1.
selection-screen end of block input.
Program name : Z_Invoi ce *
Program Description : The purpose of the report is to: *
Give the details of open invoices for a *
project. *
Give details of cleared invoices for a *
project
Technical Object No : NA *
Developer : Priyanka Vasudeva,Jasleen Randhawa
Level2 Analyst/FC : Sanjay Arali *
Company : Satyam Computer Services Limited(SCSL) *
Start Date : 12-05-2005 *
End Date : 17-05-2005 *
Logical Database : NA *
Function Modules : HR_SEN_CALE_DAYS_DATE, *
REUSE_ALV_LIST_DISPLAY, *
HR_HK_DIFF_BT_2_DATES *
Includes : z_invoice_form - For forms *
z_invoice_top - For data Declarations *
C H A N G E H I S T O R Y *
*Version| Developer | Date | Change Description *
V00 |Priyanka ,Jasleen |12/10/2004| New Development
V01 | | | *
INCLUDE Z_INVOICE_FORM *
Form To Create a FieldCatalog *
form f_fieldcat.
clear wa_fieldcat.
lifnr
wa_fieldcat-ref_fieldname = 'LIFNR'.
wa_fieldcat-fieldname = 'LIFNR'.
wa_fieldcat-tabname = 'I_OUTPUT1'.
wa_fieldcat-seltext_m = 'Vendor No'(004).
append wa_fieldcat to i_fieldcat.
clear wa_fieldcat.
NAME
wa_fieldcat-ref_fieldname = 'NAME'.
wa_fieldcat-fieldname = 'NAME'.
wa_fieldcat-tabname = 'I_OUTPUT1'.
wa_fieldcat-seltext_m = 'Vendor Name'(005).
append wa_fieldcat to i_fieldcat.
clear wa_fieldcat.
BELNR
wa_fieldcat-ref_fieldname = 'BELNR'.
wa_fieldcat-fieldname = 'BELNR'.
wa_fieldcat-tabname = 'I_OUTPUT1'.
wa_fieldcat-seltext_m = 'Document No'(006).
append wa_fieldcat to i_fieldcat.
clear wa_fieldcat.
BLDAT
wa_fieldcat-ref_fieldname = 'BLDAT'.
wa_fieldcat-fieldname = 'BLDAT'.
wa_fieldcat-tabname = 'I_OUTPUT1'.
wa_fieldcat-seltext_m = 'Document Date'(007).
wa_fieldcat-no_zero = 'X'.
append wa_fieldcat to i_fieldcat.
clear wa_fieldcat.
DMBTR
wa_fieldcat-ref_fieldname = 'DMBTR'.
wa_fieldcat-ref_tabname = 'BSIK'.
wa_fieldcat-fieldname = 'DMBTR'.
wa_fieldcat-tabname = 'I_OUTPUT1'.
wa_fieldcat-just = 'R'.
wa_fieldcat-seltext_m = 'Amount in LC'(008).
wa_fieldcat-no_zero = 'X'.
append wa_fieldcat to i_fieldcat.
clear wa_fieldcat.
WAERS
wa_fieldcat-ref_fieldname = 'WAERS'.
wa_fieldcat-fieldname = 'WAERS'.
wa_fieldcat-tabname = 'I_OUTPUT1'.
wa_fieldcat-seltext_m = 'Currency'(009).
wa_fieldcat-no_zero = 'X'.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
if p_open = 'X'.
due date
wa_fieldcat-fieldname = 'DUE_DATE'.
wa_fieldcat-tabname = 'I_OUTPUT1'.
wa_fieldcat-seltext_m = 'Due Date'(010).
wa_fieldcat-no_zero = 'X'.
append wa_fieldcat to i_fieldcat.
clear wa_fieldcat.
Status
wa_fieldcat-fieldname = 'STATUS'.
wa_fieldcat-tabname = 'I_OUTPUT1'.
wa_fieldcat-seltext_m = 'Status'.
wa_fieldcat-just = 'C'.
wa_fieldcat-icon = 'X'.
append wa_fieldcat to i_fieldcat.
clear wa_fieldcat.
G_DAYS
wa_fieldcat-fieldname = 'G_DAYS'.
wa_fieldcat-tabname = 'I_OUTPUT1'.
wa_fieldcat-seltext_m = 'Days Past Due'(011).
append wa_fieldcat to i_fieldcat.
clear wa_fieldcat.
*AUGDT
wa_fieldcat-ref_fieldname = 'AUGDT'.
wa_fieldcat-fieldname = 'AUGDT'.
wa_fieldcat-tabname = 'I_OUTPUT1'.
wa_fieldcat-seltext_m = 'Date Paid'(012).
wa_fieldcat-no_zero = 'X'.
append wa_fieldcat to i_fieldcat.
clear wa_fieldcat.
elseif p_closed = 'X'.
endif.
endform.
*& Form F_VALIDATE_Project_Number
Form to validate the Project number entered by the user
form f_validate_proj_number.
Validation of Project numbers entered on the selection screen
select single pspid
from proj
into proj-pspid
where pspid = p_projno.
if sy-subrc ne 0.
message e100.
endif.
endform.
*& Form F_projectno_conctenate
Form to check for the project number.
form f_projectno_concatenate.
concatenate p_projno(1) '-' p_projno+1(23)
into v_projno.
v_projno1 = v_projno.
translate v_projno1 to lower case.
endform.
*& Form F_invoice_open
Form to get the details for open invoices
form f_invoice_open.
data: l_dat type endda,
l_date type begda,
l_days type psen_duration_dec,
l_outdate like p0347-scrdd,
l_date1 type dats,
l_date2 type dats,
l_days1(6) type c,
l_days2(6) type c.
select lifnr "vendor no
belnr "document no
bldat "document date
dmbtr "amount in LC
waers "currency
blart "document type
zfbdt "baseline date for due date
zbd1t "cash discount days1
augdt "date paid
zuonr "assignment number
bukrs "company code
shkzg "Type Credit or Debit
from bsik
into corresponding fields of table i_bsik
where ( zuonr = v_projno
or zuonr = v_projno1 )
and bukrs = 'AIC'
AND ( blart = 'RE' OR blart = 'KZ' )
and umsks eq space.
loop at i_bsik.
i_output1-lifnr = i_bsik-lifnr.
i_output1-belnr = i_bsik-belnr.
i_output1-dmbtr = i_bsik-dmbtr.
i_output1-bldat = i_bsik-bldat.
i_output1-waers = i_bsik-waers.
i_output1-zuonr = i_bsik-zuonr.
l_days-caldd = i_bsik-zbd1t.
l_date = i_bsik-zfbdt.
*Modification for Account Payable
if i_bsik-BLART = 'KZ' .
if i_bsik-shkzg = 'H' .
i_output1-dmbtr = 0 - i_bsik-dmbtr .
endif.
to add baseline date and accounts recievable days1
call function 'HR_SEN_CALE_DAYS_DATE'
exporting
id_date = l_date
id_operator = '+'
is_duration = l_days
importing
ed_date = l_dat
exceptions
conversion_not_specified = 1
conversion_not_possible = 2
others = 3.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
i_output1-due_date = l_dat.
if sy-datum > l_dat.
l_date1 = sy-datum.
l_date2 = l_dat.
else.
l_date1 = l_dat.
l_date2 = sy-datum.
endif.
*to calculate difference between the due date and currrent date
call function 'HR_HK_DIFF_BT_2_DATES'
exporting
date1 = l_date1
date2 = l_date2
output_format = '02'
importing
days = l_outdate
exceptions
invalid_dates_specified = 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.
l_days2 = l_outdate.
if sy-datum le l_dat.
i_output1-status = icon_green_light.
concatenate '-' l_days2 into l_days1.
i_output1-g_days = l_days1.
elseif sy-datum gt l_dat.
i_output1-status = icon_red_light.
concatenate '+' l_days2 into l_days1.
i_output1-g_days = l_days1.
endif.
append i_output1.
endloop.
endform.
*& Form F_vendor_details
Form to get the details of vendors
form f_vendor_details.
*to get vendor details
loop at i_output1.
select single lifnr "vendor no
name1 " vendor name1
name2 " vendor name2
from lfa1
into i_lfa1
where lifnr = i_output1-lifnr.
if sy-subrc = 0.
i_output1-lifnr = i_lfa1-lifnr.
concatenate i_lfa1-name1 i_lfa1-name2
into i_output1-name
separated by space.
modify i_output1.
endif.
endloop.
endform.
*& Form F_invoice_cleared
Form to get the details for cleared invoices
form f_invoice_cleared.
select lifnr "vendor no
belnr "document no
bldat "document date
dmbtr "amount in LC
waers "currency
augdt "date paid
zuonr "assignment number
bukrs "company code
blart "document type
*Added for
shkzg "Type Credit or Debit
from bsak
into table i_bsak
where ( zuonr = v_projno
or zuonr = v_projno1 )
and bukrs = 'AIC'
AND ( blart = 'RE'
OR blart = 'KZ' )
and umsks eq space.
loop at i_bsak.
i_output1-lifnr = i_bsak-lifnr.
i_output1-belnr = i_bsak-belnr.
i_output1-dmbtr = i_bsak-dmbtr.
i_output1-bldat = i_bsak-bldat.
i_output1-waers = i_bsak-waers.
i_output1-augdt = i_bsak-augdt.
i_output1-zuonr = i_bsak-zuonr.
*Modification for Account Payable
If i_BSAK-BLART = 'KZ' .
if i_bsak-shkzg = 'H' .
i_output1-dmbtr = 0 - i_bsak-dmbtr.
endif.
append i_output1.
endloop.
endform.
FORM f_alv_display *
form f_alv_display.
data:wa_layout type slis_layout_alv,
v_title type lvc_title,
wa_variant like disvariant. "For default variant
if p_open = 'X'.
concatenate 'Open Invoices for Project:'(003) v_projno into
v_title separated by space.
wa_variant-variant = '/DEFAULT1'.
else.
concatenate 'Cleared Invoices for Project:'(002) v_projno into
v_title separated by space.
wa_variant-variant = '/DEFAULT'.
endif.
wa_layout-colwidth_optimize = 'X'.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = v_repid
is_layout = wa_layout
i_grid_title = v_title
it_fieldcat = i_fieldcat[]
i_save = 'A'
is_variant = wa_variant
tables
t_outtab = i_output1
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.
But after doing these changes as i mentioned above , i am not able to get the
catalog in the ALV.
Please help!!!
i wanted to send you all the picture of ALV, But i am not able to paste it,
can i post picture inthis , if possible pl tell.
Thanks
NeerajHello,
to get it in ALV , there needs to be an append of EBELN to the field catalogue
ebeln
wa_fieldcat-fieldname = 'EBELN''.
wa_fieldcat-tabname = 'I_OUTPUT1'.
wa_fieldcat-seltext_m = 'EBELN'(009).
append wa_fieldcat to i_fieldcat.
clear wa_fieldcat.
Please check if you have added it to the field catalog.......
In addition to it,before calling the reuse_ALV function put a breakpoint and see if the internal table 'I_OUTPUT1' contains EBELN and all relevant data....
Reward if useful and pls reply if you rectified the problem
Regards
Byju -
Manager not able to approve leave of the employee on the MSS
Hi There,
When the manager execute the work item on the portal, a run time error occurs on SAP and as discribed on ST22, is caused by function module HR_HK_DIFF_BT_2_DATES which returns a CX_SY_ARITHMETIC_OVERFLOW exception. I Think that this function is supposed to return the difference between the start date of the leave and the end date of the leave. but on the trace, it looks like it is not receiving the end date of the leave. I cannot manage to simmulate the problem in development.
Some managers are able to approve and some can't however they have the same roles and their recored are same on HR.
Can you help me to track the real cause of this problem?
Best regards,
FlubertThe oss note that you recomended was applied as we are runing ECC6.
I addition, the problem is pointing at the following statment:
years = ( l_date3+0(4) + ( l_total_number_days / days_in_year ) ).
I want to think that the end date2 is not supplied to the function, that is the reason why it is failling.
But why would date2 not be passed to the function???
Even if it is one day leave, date2 is supposed to be passed to the function with the same value as date1 !!!
What can be the next point of investigation????
Thanks a millon!
Flubert. -
Using the FM SO_NEW_DOCUMENT_ATT_SEND_API1
Hi Gurus,
I am using the FM SO_NEW_DOCUMENT_ATT_SEND_API1.
My requirement needs me to email an attachment.
Why is it that when I input
A
B
C
in my table, the value I am getting is
A B C
wherein I should get an attachment that should look like this one
A
B
C
My output file is a TXT file. I understand that this is using the CONTENT_BIN that uses the binary format.
What I need is an attachment that is using the ASCII format. But when I use the ASCII format, I am getting an error: "error occurred during sending !".
Do I need to make enhacements on the FM?
Thanks in advance.
BenedictHi Benedict,
Please refer to the below code.
Program: ZRAT Creation Date: 12.04.2007 *
Program Title : Retirement Age Trigger *
Program Author: Puneet Jhari *
Program Type : Executable *
Object ID : *
Technical Specification Version: *
Technical Specification Author: *
Code Quality Reviewer : *
Transport No. : SRDK906499 *
Program Description: *
Inputs *
Tables: *
Parameters *
External files: *
Outputs *
Reports: *
Tables: *
Databases: *
Screens: *
Parameters *
External files: *
Other objects: *
Return codes set by ABAP: *
Modification Informaion *
Program Version: *
Date : DD-MMM-YYYY *
Author : *
Description : *
Transport No.: *
REPORT zrat NO STANDARD PAGE HEADING.
*DATA DECLARATION
DATA : BEGIN OF wa_ccode,
bukrs TYPE t001-bukrs,
END OF wa_ccode.
DATA : itab_ccode LIKE TABLE OF wa_ccode.
DATA : BEGIN OF wa_emp,
pernr TYPE pa0001-pernr,
sachp TYPE pa0001-sachp,
sname TYPE pa0001-sname,
END OF wa_emp.
DATA : itab_emp LIKE TABLE OF wa_emp.
DATA : BEGIN OF wa_bdate,
nachn LIKE pa0002-nachn,
vorna LIKE pa0002-vorna,
pernr TYPE pa0002-pernr,
gbdat TYPE pa0002-gbdat,
END OF wa_bdate.
DATA : itab_bdate LIKE TABLE OF wa_bdate.
DATA : new_date LIKE sy-datum.
DATA : diff TYPE i.
DATA : years LIKE p0347-scryy,
months LIKE p0347-scrmm,
days LIKE p0347-scrdd.
DATA : sup_code LIKE pa0001-sachp,
itab_usrid LIKE t526-usrid,
sup_pernr LIKE pa0105-pernr.
DATA : BEGIN OF wa_email,
usrid_long LIKE pa0105-usrid_long,
END OF wa_email.
DATA : sup_email LIKE TABLE OF wa_email.
DATA : gwa_document_data LIKE sodocchgi1,
gc_name TYPE so_obj_nam VALUE 'RETIREMENT',
gc_senst TYPE so_obj_sns VALUE 'P',
gc_size TYPE so_doc_siz VALUE '510',
gi_obj_cnt LIKE TABLE OF solisti1 WITH HEADER LINE,
gi_recievers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
gwa_obj_cnt LIKE LINE OF gi_obj_cnt.
DATA : smtp_addr LIKE adr6-smtp_addr.
DATA : wa_date LIKE sy-datum,
entries LIKE sy-tabix,
name(15),
line1(18) TYPE c,
line2(20) TYPE c,
line3(20) TYPE c,
line4(23) TYPE c,
line5(10) TYPE c,
line6(45) type c,
date(2) TYPE c,
month(2) TYPE c,
year(4) TYPE c.
*START OF SELECTION
SELECT bukrs
FROM t001
INTO TABLE itab_ccode
WHERE land1 EQ 'GB'.
SORT itab_ccode.
DELETE ADJACENT DUPLICATES FROM itab_ccode.
SELECT pernr sachp sname
FROM pa0001
INTO TABLE itab_emp
FOR ALL ENTRIES IN itab_ccode
WHERE bukrs EQ itab_ccode-bukrs AND begda LE sy-datum AND
endda GE sy-datum and persg eq '1'.
SELECT nachn vorna pernr gbdat
FROM pa0002
INTO TABLE itab_bdate
FOR ALL ENTRIES IN itab_emp
WHERE pernr EQ itab_emp-pernr.
*TO CHECK EMPLOYEES WHOSE AGE IS NEAR 75 YEARS.
LOOP AT itab_bdate INTO wa_bdate.
new_date = wa_bdate-gbdat.
*TO CALCULATE THE AGE TILL DATE
CALL FUNCTION 'HR_HK_DIFF_BT_2_DATES'
EXPORTING
date1 = sy-datum
date2 = new_date
output_format = '05'
IMPORTING
years = years
months = months
days = days
IF sy-subrc <> 0.
ENDIF.
IF years EQ 64 AND months EQ 4.
IF days GE 23 AND days LE 31.
*FETCH THE DATA IF THE AGE IS NEARING 75 YEARS
SELECT SINGLE sachp FROM pa0001 INTO sup_code WHERE pernr EQ
wa_bdate-pernr AND begda LE sy-datum AND endda GE sy-datum.
SELECT SINGLE usrid FROM t526 INTO itab_usrid WHERE sachx EQ
sup_code.
SELECT SINGLE pernr FROM pa0105 INTO sup_pernr WHERE usrid EQ
itab_usrid AND subty EQ '0001'.
clear sup_email[].
SELECT usrid_long FROM pa0105 INTO TABLE sup_email WHERE pernr EQ
sup_pernr AND subty EQ '0010'.
*EMAIL ADDRESS OF THE SUPERVISOR TO BE NOTIFIED
CLEAR gi_obj_cnt.
CLEAR gi_recievers.
CLEAR gwa_document_data.
Loop at sup_email into wa_email.
write sy-uline+0(5).
write sy-uline+10(5).
write sy-uline+20(5).
write sy-uline+30(5).
write sy-uline+40(5).
write sy-uline+50(5).
write sy-uline+60(5).
write sy-uline+70(5).
smtp_addr = wa_email-usrid_long.
gi_recievers-receiver = smtp_addr.
gi_recievers-rec_type = 'U'.
gi_recievers-com_type = 'INT'.
APPEND gi_recievers.
Endloop.
smtp_addr = '[email protected]'.
gi_recievers-receiver = smtp_addr.
gi_recievers-rec_type = 'U'.
gi_recievers-com_type = 'INT'.
APPEND gi_recievers.
gwa_document_data-obj_name = gc_name.
gwa_document_data-obj_descr = 'RETIRE'.
gwa_document_data-sensitivty = gc_senst.
gwa_document_data-obj_langu = sy-langu.
*CONTENT OF THE EMAIL TO BE SENT
line1 = 'Please note that '.
line2 = wa_bdate-vorna.
line3 = wa_bdate-nachn.
line4 = ' will be 65 years on '.
line50(4) = wa_bdate-gbdat4(4).
date = line5+2(2).
month = line5+0(2).
year = wa_bdate-gbdat+0(4) + 65.
CONCATENATE date month year INTO line5 SEPARATED BY '.'.
line6 = '.Please complete the Retirement Procedure.'.
CONCATENATE line1 line2 line3 line4 line5 line6 INTO gwa_obj_cnt
SEPARATED BY space.
APPEND gwa_obj_cnt TO gi_obj_cnt.
CLEAR gwa_obj_cnt.
DESCRIBE TABLE gi_obj_cnt LINES entries.
READ TABLE gi_obj_cnt INDEX entries.
gwa_document_data-doc_size = ( entries - 1 ) * 255 + STRLEN( gi_obj_cnt
*FUNCTION MODULE TO SEND THE EMAIL TO THE CONCERNED PERSONS
CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
EXPORTING
document_data = gwa_document_data
document_type = 'RAW'
commit_work = 'X'
TABLES
object_content = gi_obj_cnt
receivers = gi_recievers
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8
*MESSAGE TO BE DISPLAYED AFTER THE EXECUTION
endif.
CASE sy-subrc.
WHEN 0.
LOOP AT gi_recievers.
IF gi_recievers-receiver = space.
name = gi_recievers-rec_id.
ELSE.
name = gi_recievers-receiver.
ENDIF.
IF gi_recievers-retrn_code = 0.
WRITE: / name, ': succesfully sent'.
ELSE.
WRITE: / name, ': error occured'.
ENDIF.
ENDLOOP.
WHEN 1.
WRITE: / 'Too many receivers specified !'.
WHEN 2.
WRITE: / 'No receiver got the document !'.
WHEN 4.
WRITE: / 'Missing send authority !'.
WHEN OTHERS.
WRITE: / 'Unexpected error occurred !'.
ENDCASE.
ENDIF.
ENDIF.
ENDLOOP.
In case you have any further clarifications,do let me know.
Regards,
Puneet Jhari. -
FM to get the number of days in Year,month and days by giving number of day
Hi ALL,
This is quit differnt.
I need to give input the 'start date' and the 'number of days' and get the total days from the start date in year,month and day format.
for example.
start date :01.01.2009
number of days as 32
then i should get
years:0
months :1
days :1
Pleas help me out.hi Anusha,
first u pass the date and the days to the following fm you will get the result date....
data:date type sy-datum,
r_date(10) type c.
date = sy-datum.
CALL FUNCTION 'CALCULATE_DATE'
EXPORTING
DAYS = '32'
MONTHS = '0'
START_DATE = date
IMPORTING
RESULT_DATE = r_date
write:/ r_date.
then you need to pass the result date and the date to the following fm to get the required output...
CALL FUNCTION 'HR_HK_DIFF_BT_2_DATES'
EXPORTING
date1 = r_date
date2 = date
IMPORTING
years = v_years
months = v_months
days = v_days
EXCEPTIONS
invalid_dates_specified = 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.
here u will get the difference in days, months and year...
i hope u wil get help from this...
regards
Ashu Singh -
System doesnt calculate avg as per the period
i have one query, this is the most crucial issue going on at my firm
Please advice
Suppose there is an item.its purchased all round the year from jan to dec
ORG in which its being purchased and transacted, issued, received is using avg costing method
so all round the year it would have moving average, which would be varying ..
now in dec , i decide to transact that item in a back date, say for example march..
in this case, the system should take the avg cost that was in march or should it take the avg cost which is currently in the system.
and if it should take the avg that was in march, than all preceding months avg should be updated.
If it takes decembers current avg, than also all avg from march till dec should be updated by the system
Please advice wats the correct logic and system action
thanks
Muhammeduse fm hr_hk_diff_bt_2_Dates
pass gbdat from pa0002 and sy-datum to calculate the age as per system date
br,
vijay -
Script- problem in printing the values in from internal table
Hi all,
I have a requiremnt that i for a particular document no there are number of invoices are there. i.e for a single document no there are 20 invoices in that. i shoudl display the invoice number , invoice date, invoice amount , number of days of intrest , start date of interest, end date of interest and intrest amount.
The problem is i should take the invoice number, invoice date, number of days from TABLE <b>BSEG</b> and inovice amount and start date, end date from table<b> INTITIT</b>. for a particular document number there are diffent invoce numbers in both the table.
i can display everthing but the prob is with invoice amount. it is repating only one values is displying in the ouput. The invoice number in INTITIT Is not changing. I have to write the syntax for that .Please help me The value in Bseg is chaing as per given syntax shown below.
data: begin of hbseg occurs 10.
include structure hsortp.
include structure bseg.
data: end of hbseg.
data: begin of hsortp,
sortp1 like sortp1,
sortp2 like sortp2,
sortp3 like sortp3,
sortp4 like sortp4,
sortp5 like sortp5,
EKVBD LIKE KNB1-EKVBD,
end of hsortp.
loop at hbseg.
WHERE BUKRS = SAVE_BUKRS.
save_bukrs = hbseg-bukrs.
if ( hbseg-kunnr = save_kunnr
and not save_kunnr is initial )
or ( hbseg-lifnr = save_lifnr
and not save_lifnr is initial ).
clear bseg.
move-corresponding hbseg to bseg.
*bseg = bseg.
if bkpf-waers ne *bkpf-waers.
perform curr_document_convert_bseg
using
bkpf-budat
*bkpf-waers
*bkpf-hwaer
bkpf-waers
changing
bseg.
if not bseg-pycur is initial.
alw_waers = bseg-pycur.
perform currency_get_subsequent
using
save_repid
bkpf-budat
bkpf-bukrs
changing
alw_waers.
if alw_waers ne bseg-pycur.
bseg-pycur = alw_waers.
perform convert_foreign_to_foreign_cur
using
bkpf-budat
*bkpf-waers
*bkpf-hwaer
bseg-pycur
changing
bseg-pyamt.
endif.
endif.
endif.
perform fill_waehrungsfelder_bseg.
perform fill_waehrungsfelder_bseg_2.
if bseg-sgtxt(1) ne '*'.
bseg-sgtxt = space.
else.
bseg-sgtxt = bseg-sgtxt+1.
endif.
clear save_bschl.
clear save_umskz.
clear tbslt.
save_bschl = bseg-bschl.
save_umskz = bseg-umskz.
perform read_tbslt.
ADDING VARIBLE V_GSALDF BY SUNIL 5.11.07******
v_gsaldf = rf140-gsaldf + rf140-wrshb.
rf140-gsaldf = v_gsaldf.
clear v_gsaldf.
SUNIL *********************
*rf140-gsaldf = *rf140-gsaldf + *rf140-wrshb.
if xmultk is initial
and xactiv is initial
and linecnt = '1'
and not xumsst is initial
and not save_xumstn is initial.
if bkpf-bstat = 'V'.
perform read_vbset.
else.
perform read_bset.
endif.
describe table hbset lines linecnt.
if linecnt = '1'.
loop at hbset.
move-corresponding hbset to bset.
*bset = bset.
if bkpf-waers ne *bkpf-waers.
perform curr_document_convert_bset
using
bkpf-budat
*bkpf-waers
*bkpf-hwaer
bkpf-waers
changing
bset.
endif.
clear rf140-msatz.
clear rf140-vtext.
save_ktosl = bset-ktosl.
perform read_t687t.
rf140-msatz = bset-kbetr / 10.
*rf140-msatz = rf140-msatz.
rf140-vtext = save_vtext.
*rf140-vtext = rf140-vtext.
if bset-shkzg = 'H'.
rf140-mwshb = bset-fwste.
*rf140-mwshb = *bset-fwste.
rf140-mdshb = bset-hwste.
*rf140-mdshb = *bset-hwste.
else.
rf140-mwshb = 0 - bset-fwste.
*rf140-mwshb = 0 - *bset-fwste.
rf140-mdshb = 0 - bset-hwste.
*rf140-mdshb = 0 - *bset-hwste.
endif.
exit.
endloop.
rf140-wrshb = rf140-wrshb - rf140-mwshb.
*rf140-wrshb = *rf140-wrshb - *rf140-mwshb.
rf140-dmshb = rf140-dmshb - rf140-mdshb.
*rf140-dmshb = *rf140-dmshb - *rf140-mdshb.
endif.
endif.
*****************Begin of Change by Karthikeyan J********************
i_count = i_count + 1.
clear rf140-element.
clear: it_bseg, i_wrbtr,i_totday,i_tempday,i_day,i_bday.
comparing with fields belnr AND SELECT * FROM INTITIT added by sunil 3.11.07*********
select single * from bseg into
corresponding fields of it_bseg where belnr = bseg-rebzg anD GJAHR = BSEG-GJAHR.
select single * from intitit into corresponding fields of it_intitit where gjahr = bseg-gjahr and belnr_to = bseg-belnr and buzei = '2' OR BELNR = INTITIT-BELNR .
added by Jayshree on 09/01/2007
MOVE ' ' TO it_kna1-name1.
SELECT SINGLE name1
INTO CORRESPONDING FIELDS OF it_kna1
FROM ( vbpa AS a INNER JOIN kna1 AS b ON akunnr = bkunnr )
WHERE a~vbeln = it_bseg-vbeln
AND a~parvw = 'zd'.
SELECT SINGLE fkdat
INTO CORRESPONDING FIELDS OF it_kna1
FROM vbrk
WHERE vbrk~vbeln = it_bseg-vbeln.
added by Jayshree on 01/02/2007
CONCATENATE it_kna1-fkdat6(2) it_kna1-fkdat4(2) it_kna1-fkdat+2(2)
INTO vfkdat SEPARATED BY '.'.
CONCATENATE it_bseg-augdt6(2) it_bseg-augdt4(2) it_bseg-augdt+2(2)
INTO vaugdt SEPARATED BY '.'.
i_wrbtr = i_wrbtr + it_bseg-wrbtr.
added as on 29.06.2007 by jayshree again transport on 21.07.2007
tot_wrbtr = tot_wrbtr + i_wrbtr.
i_totday = it_bseg-zbd1t + it_bseg-zbd2t + it_bseg-zbd3t.
CALL FUNCTION 'fima_date_create'
EXPORTING
i_date = it_bseg-zfbdt
I_FLG_END_OF_MONTH = ' '
I_YEARS = 0
I_MONTHS = 0
i_days = i_totday
I_CALENDAR_DAYS = 0
I_SET_LAST_DAY_OF_MONTH = ' '
IMPORTING
e_date = i_bday
E_FLG_END_OF_MONTH =
E_DAYS_OF_I_DATE =
added by JAYSHREE 01.02.2007
CONCATENATE i_bday6(2) i_bday4(2) i_bday+2(2)
INTO vbday SEPARATED BY '.'.
i_day = it_bseg-augdt - i_bday.
CALL FUNCTION 'HR_HK_DIFF_BT_2_DATES'
EXPORTING
date1 = it_bseg-zfbdt
date2 = it_bseg-augdt
OUTPUT_FORMAT = '01'
IMPORTING
YEARS =
MONTHS =
DAYS = i_day
EXCEPTIONS
INVALID_DATES_SPECIFIED = 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.
*added by sunil 5.11.07 ***********
*read table it_intitit with key BELNR_TO = BSEG-BELNR .
*LOOP AT IT_INTITIT.
rf140-element = '521'.
CALL FUNCTION 'write_form'
EXPORTING
window = 'main'
element = '521'
EXCEPTIONS
window = 1
element = 2.
IF sy-subrc = 1.
window = 'main'.
PERFORM message_window.
ENDIF.
IF sy-subrc = 2.
window = 'main'.
ereignis = '521'.
PERFORM message_element.
ENDIF.
IF save_xumstn IS INITIAL.
*-------Umsatzsteuer -
IF xactiv IS INITIAL.
save_waers = rf140-waers.
PERFORM tax_data.
CLEAR taxlines.
DESCRIBE TABLE atax LINES taxlines.
IF NOT taxlines IS INITIAL.
LOOP AT atax.
CLEAR ereignis.
CLEAR rf140-msatz.
CLEAR rf140-vtext.
rf140-msatz = atax-msatz.
*rf140-msatz = atax-msatz.
rf140-vtext = atax-vtext.
*rf140-vtext = atax-vtext.
*******begin of change by karthikeyan on 10.03.06*********************
IF sy-tabix = '1'.
ereignis = '522'.
v_stax = rf140-msatz * rf140-gsaldf / 100.
ELSE.
ereignis = '523'.
v_ecs = rf140-msatz * v_stax / 100.
v_total = rf140-gsaldf + v_stax + v_ecs.
ENDIF.
CALL FUNCTION 'hr_in_chg_inr_wrds'
EXPORTING
amt_in_num = v_total
IMPORTING
amt_in_words = v_spell
EXCEPTIONS
DATA_TYPE_MISMATCH = 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.
***************************end of change******************************
CLEAR rf140-element.
rf140-element = ereignis.
IF NOT ereignis IS INITIAL.
CALL FUNCTION 'write_form'
EXPORTING
window = 'main'
element = ereignis
EXCEPTIONS
window = 1
element = 2.
IF sy-subrc = 1.
window = 'main'.
PERFORM message_window.
ENDIF.
IF sy-subrc = 2.
window = 'main'.
PERFORM message_element.
ENDIF.
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
ENDIF.
ENDLOOP.
'521' is the element name in the main window where i should display the values. before select qurey the values are coming in the bseg but not in table INTITIT. Belnr is the document no with ref to that
there are number of invoices nos. so in both the tables it is selecting single value and displaying but in bseg the invoice number is getting refreshed and new number is coming in that place i.e in field bseg-rebzg but in INTITIT in belnr only it is taking single value it is not getting refreshed.
move-corresponding hbseg to bseg.
*bseg = bseg.
if bkpf-waers ne *bkpf-waers.
this is the syntax whr the values in bseg are getting refresh and new invoice number is selecting.
How to write the syntax for INTITIT? As per invoice number it is giving new values.
The invoice number in Bseg is different campare to in table INTITIT. in output is shoud show the fields as follows
it_besg-rebzg(invoice number of besg) it_besg-zuonr(invoice date) INTITIT-INT_BASAMT(base amount) i_day (no of days ) INTITIT-INT_BEGIN (INTREST START DATE) INTITIT-INT_end(INTREST END DATE) rf140-wrshb(INTREST AMOUNT).
THE VALUE OF IT_BESG-REBZG IS CHANGING BUT THE VALUE IN INTITIT-BELNR ( INVOICE NUMBER) IS NOT CHANGING THAT IS WHY IT IS SHOWING
ONLY SINGLE RECORD.
for both the table documet no is same. in besg-belnr is the document no. in intitit-BELNR_TO is the document no.
here in bseg-rebzg is chaning but in INTITIT-BELNR IS not changing.
If i take loop at INTITIT. ALL the values are repating so i am unable to take loop. so i want to write
a syntax such that intitit-belnr should be refreshed and also for every loop it shoud take new invoice no.
Please help me out it is very urgent.
<b>USEFUL ANSWERS WILL BE REWARDED.</b>
regards,
Sunil kumar.assumption: some mistake in ur posting that, How belnr and date r same for both header records, so i guess, either one is different.
try with AT NEW - ENDAT.
AT NEW belnr.
here use looping, READing of ur itabs.---> so, u need to build couple of itabs to move forth and back.
ENDAT.
pls. note that, when u use this AT NEW all the CHAR fileds of itab wuld show as STARS **.....so, this is the necessity behind building new itabs.
thanq
Edited by: SAP ABAPer on Dec 30, 2008 6:24 PM -
Urgent: dates calculation in alv
hi,
i am making ALV report in alv in whihc i ahve to dispaly the difference between two days i.e. DIFFERRENCE = 7 DAYS.
CAN anybody provide me the example of it as it is urgent for me.
points will be definately rewarded for correct awnser.use function module
HR_HK_DIFF_BT_2_DATES
give output format = 03 and get the value in days.
code is as below :
data : DATE1 type P0001-BEGDA,
DATE2 type P0001-BEGDA,
YEARS type P0347-SCRYY,
MONTHS type P0347-SCRMM,
DAYS type P0347-SCRDD.
date1 = '20070331'.
date2 = '20070101'.
CALL FUNCTION 'HR_HK_DIFF_BT_2_DATES'
EXPORTING
DATE1 = date1
DATE2 = date2
OUTPUT_FORMAT = '03'
IMPORTING
YEARS = years
MONTHS = months
DAYS = days
EXCEPTIONS
INVALID_DATES_SPECIFIED = 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.
write : days.
regards,
sandeep Kaushik -
Program or FM to convert number of days into a CalDay format (ddmmyyy)
Hi ABAP friends,
I input calendar day values via a popup calendar from a spreadsheet to BW. So, the values that are populated in BW are the numbers, and not the date.
For ex. when user selects a calendar day for ex. 11-April-2010, the value in excel is stored as 40279 (which is the number of days starting from 01-Jan-1900) and this is the value that gets stored in BW once we save the data.
I'm looking for a function module or method or whatever that converts the above number (40279) into CalDay and writes it to the 0CALDAY infoobject ???
Please help,
Thanks,
VenkatThanks Pranaam.
Two things:
1. I cannot find this FM. It says FM doesn't exist. SE37 --> HR_HK_DIFF_BT_2_DATES
2. My requirement is actually reverse as you explained. I can certainly hard code the starting date: 01011900, but here the input should be the number of days. and I need the date (date2 in your ex.) based on the no. of days entered.
I found another FM which does exist in my BW system. That is: FIMA_DAYS_AND_MONTHS_AND_YEARS
Based on "From" & "To" dates, it outputs the number of days.
But my requirement is:
Based on the starting date (i.e. always 01011900) and number of days, it should give me the "To" date value. -
Hi all,
Lets try and recollect our very early days in ABAP,when we were learning just the basics.I am sure most will have a memorable incidents of the days.To start with mine i can tell while learning the ABAP for very first time i used to be so much confused with the data declarations,why do we used structures,table type and what was the difference between them,difference with with header line and without it..also why do we need to need to maintain text modules when we can directly text boxes in forms...and a lot more. Now when i have the answers to them with experience the questions seemed so silly..:)
Hoping to hear more silly incidents of our past.
Thanks,
AbhishekHi,
If your calculating dates please do not manually calculate it like that.
You need to determine like week numbers, month and days.
The best way to do it is by using FM related to dates. Play around with these FMs in your program:
Function Modules related to Date and Time Calculations
CALCULATE_DATE - Calculates the future date based on the input .
DATE_TO_DAY - Returns the Day for the entered date.
DATE_COMPUTE_DAY - Returns weekday for a date
DATE_GET_WEEK - Returns week for a date
RP_CALC_DATE_IN_INTERVAL - Add days / months to a date
DAY_ATTRIBUTES_GET - Returns attributes for a range of dates specified
MONTHS_BETWEEN_TWO_DATES - To get the number of months between the two dates.
END_OF_MONTH_DETERMINE_2 - Determines the End of a Month.
HR_HK_DIFF_BT_2_DATES -Find the difference between two dates in years, months and days.
FIMA_DAYS_AND_MONTHS_AND_YEARS - Find the difference between two dates in years, months and days.
WEEK_GET_FIRST_DAY - Get the first day of the week
SD_CALC_DURATION_FROM_DATETIME - Find the difference between two date/time and report the difference in hours
L_MC_TIME_DIFFERENCE - Find the time difference between two date/time
HR_99S_INTERVAL_BETWEEN_DATES - Difference between two dates in days, weeks, months
LAST_DAY_OF_MONTHS - Returns the last day of the month
DATE_CHECK_PLAUSIBILITY - Check for the invalid date.
DATE_2D_TO_4D_CONVERSION - Year entry: 2-character to 4-character.
DAY_IN_WEEK - Input date and will give the name of the day 1-monday,2-Tuesday....
SD_DATETIME_DIFFERENCE - Give the difference in Days and Time for 2 dates -
Hi Friends,
I had a requirement.
I had some data in Internal table.
Ex:
MaterialNo | Description | Quantity | Uom | MRP Controller | Name
123456 | XYZ | 20 | KG | 25 | Kumar
123457 | XYB | 50 | KG | 25 | Kumar
123458 | XYC | 70 | NOS | 45 | Sunil
123459 | XYD | 80 | KG | 45 | Sunil
I want to send the above details as attachments separately to MRP controllers 25 and 45.
First 2 records to MRP controller 25 and last 2 records to MRP controller 45.
What is the function module to use for convert the data into attachment and to send mail.
Attachment should be in HTML or PDF or in XLS format.
Regards,
ArunHi Arun,
Since you have all the data in an internal table,you will have to loo at the internal table with the conditions of sending the mail to different recipents based on the values of MRP controllers and use the Function module 'SO_NEW_DOCUMENT_SEND_API1' for sending the mails as an attachment.
Please refer to the below mentioned code which might help you in wrting the code you want.
REPORT zrat NO STANDARD PAGE HEADING.
*DATA DECLARATION
DATA : BEGIN OF wa_ccode,
bukrs TYPE t001-bukrs,
END OF wa_ccode.
DATA : itab_ccode LIKE TABLE OF wa_ccode.
DATA : BEGIN OF wa_emp,
pernr TYPE pa0001-pernr,
sachp TYPE pa0001-sachp,
sname TYPE pa0001-sname,
END OF wa_emp.
DATA : itab_emp LIKE TABLE OF wa_emp.
DATA : BEGIN OF wa_bdate,
nachn LIKE pa0002-nachn,
vorna LIKE pa0002-vorna,
pernr TYPE pa0002-pernr,
gbdat TYPE pa0002-gbdat,
END OF wa_bdate.
DATA : itab_bdate LIKE TABLE OF wa_bdate.
DATA : new_date LIKE sy-datum.
DATA : diff TYPE i.
DATA : years LIKE p0347-scryy,
months LIKE p0347-scrmm,
days LIKE p0347-scrdd.
DATA : sup_code LIKE pa0001-sachp,
itab_usrid LIKE t526-usrid,
sup_pernr LIKE pa0105-pernr.
DATA : BEGIN OF wa_email,
usrid_long LIKE pa0105-usrid_long,
END OF wa_email.
DATA : sup_email LIKE TABLE OF wa_email.
DATA : gwa_document_data LIKE sodocchgi1,
gc_name TYPE so_obj_nam VALUE 'RETIREMENT',
gc_senst TYPE so_obj_sns VALUE 'P',
gc_size TYPE so_doc_siz VALUE '510',
gi_obj_cnt LIKE TABLE OF solisti1 WITH HEADER LINE,
gi_recievers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
gwa_obj_cnt LIKE LINE OF gi_obj_cnt.
DATA : smtp_addr LIKE adr6-smtp_addr.
DATA : wa_date LIKE sy-datum,
entries LIKE sy-tabix,
name(15),
line1(18) TYPE c,
line2(20) TYPE c,
line3(20) TYPE c,
line4(23) TYPE c,
line5(10) TYPE c,
line6(45) type c,
date(2) TYPE c,
month(2) TYPE c,
year(4) TYPE c.
*START OF SELECTION
SELECT bukrs
FROM t001
INTO TABLE itab_ccode
WHERE land1 EQ 'GB'.
SORT itab_ccode.
DELETE ADJACENT DUPLICATES FROM itab_ccode.
SELECT pernr sachp sname
FROM pa0001
INTO TABLE itab_emp
FOR ALL ENTRIES IN itab_ccode
WHERE bukrs EQ itab_ccode-bukrs AND begda LE sy-datum AND
endda GE sy-datum and persg eq '1'.
SELECT nachn vorna pernr gbdat
FROM pa0002
INTO TABLE itab_bdate
FOR ALL ENTRIES IN itab_emp
WHERE pernr EQ itab_emp-pernr.
*TO CHECK EMPLOYEES WHOSE AGE IS NEAR 75 YEARS.
LOOP AT itab_bdate INTO wa_bdate.
new_date = wa_bdate-gbdat.
*TO CALCULATE THE AGE TILL DATE
CALL FUNCTION 'HR_HK_DIFF_BT_2_DATES'
EXPORTING
date1 = sy-datum
date2 = new_date
output_format = '05'
IMPORTING
years = years
months = months
days = days
IF sy-subrc <> 0.
ENDIF.
IF years EQ 64 AND months EQ 4.
IF days GE 23 AND days LE 31.
*FETCH THE DATA IF THE AGE IS NEARING 75 YEARS
SELECT SINGLE sachp FROM pa0001 INTO sup_code WHERE pernr EQ
wa_bdate-pernr AND begda LE sy-datum AND endda GE sy-datum.
SELECT SINGLE usrid FROM t526 INTO itab_usrid WHERE sachx EQ
sup_code.
SELECT SINGLE pernr FROM pa0105 INTO sup_pernr WHERE usrid EQ
itab_usrid AND subty EQ '0001'.
clear sup_email[].
SELECT usrid_long FROM pa0105 INTO TABLE sup_email WHERE pernr EQ
sup_pernr AND subty EQ '0010'.
*EMAIL ADDRESS OF THE SUPERVISOR TO BE NOTIFIED
CLEAR gi_obj_cnt.
CLEAR gi_recievers.
CLEAR gwa_document_data.
Loop at sup_email into wa_email.
write sy-uline+0(5).
write sy-uline+10(5).
write sy-uline+20(5).
write sy-uline+30(5).
write sy-uline+40(5).
write sy-uline+50(5).
write sy-uline+60(5).
write sy-uline+70(5).
smtp_addr = wa_email-usrid_long.
gi_recievers-receiver = smtp_addr.
gi_recievers-rec_type = 'U'.
gi_recievers-com_type = 'INT'.
APPEND gi_recievers.
Endloop.
smtp_addr = '[email protected]'.
gi_recievers-receiver = smtp_addr.
gi_recievers-rec_type = 'U'.
gi_recievers-com_type = 'INT'.
APPEND gi_recievers.
gwa_document_data-obj_name = gc_name.
gwa_document_data-obj_descr = 'RETIRE'.
gwa_document_data-sensitivty = gc_senst.
gwa_document_data-obj_langu = sy-langu.
*CONTENT OF THE EMAIL TO BE SENT
line1 = 'Please note that '.
line2 = wa_bdate-vorna.
line3 = wa_bdate-nachn.
line4 = ' will be 65 years on '.
line50(4) = wa_bdate-gbdat4(4).
date = line5+2(2).
month = line5+0(2).
year = wa_bdate-gbdat+0(4) + 65.
CONCATENATE date month year INTO line5 SEPARATED BY '.'.
line6 = '.Please complete the Retirement Procedure.'.
CONCATENATE line1 line2 line3 line4 line5 line6 INTO gwa_obj_cnt
SEPARATED BY space.
APPEND gwa_obj_cnt TO gi_obj_cnt.
CLEAR gwa_obj_cnt.
DESCRIBE TABLE gi_obj_cnt LINES entries.
READ TABLE gi_obj_cnt INDEX entries.
gwa_document_data-doc_size = ( entries - 1 ) * 255 + STRLEN( gi_obj_cnt
*FUNCTION MODULE TO SEND THE EMAIL TO THE CONCERNED PERSONS
CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
EXPORTING
document_data = gwa_document_data
document_type = 'RAW'
commit_work = 'X'
TABLES
object_content = gi_obj_cnt
receivers = gi_recievers
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8
*MESSAGE TO BE DISPLAYED AFTER THE EXECUTION
endif.
CASE sy-subrc.
WHEN 0.
LOOP AT gi_recievers.
IF gi_recievers-receiver = space.
name = gi_recievers-rec_id.
ELSE.
name = gi_recievers-receiver.
ENDIF.
IF gi_recievers-retrn_code = 0.
WRITE: / name, ': succesfully sent'.
ELSE.
WRITE: / name, ': error occured'.
ENDIF.
ENDLOOP.
WHEN 1.
WRITE: / 'Too many receivers specified !'.
WHEN 2.
WRITE: / 'No receiver got the document !'.
WHEN 4.
WRITE: / 'Missing send authority !'.
WHEN OTHERS.
WRITE: / 'Unexpected error occurred !'.
ENDCASE.
ENDIF.
ENDIF.
ENDLOOP.
In case you have any further clarifications,do let me know.
Regards,
Puneet Jhari. -
How to send a reminder maill at 3 months before retiring date?
Dear all,
if I need to send a reminder mail to the related HR administrator before 3 months of the employee's retire date, how should I do it?
Should I write a batch program for it?
Thanks a lot for any suggestions!Hello Lucy
You can shedule this program for running every day at 12 o clock.it will not affect system performance.Check infotype 41date type - 42 last working day.(provided you are updating while hiring date type 42).
Program Logic :
1. Check infotype 41 date type 42.
2.Check the difference in dates and months (system date and date type 42) using function module (HR_HK_DIFF_BT_2_DATES).
3.If 3 months ,send a remainder mail.
Hope this will help you for coding.
Regards,
Manoj.
Message was edited by:
manoj kumar -
Issue in sending a mail using FM 'SO_NEW_DOCUMENT_ATT_SEND_API1'
HI Abappers,
I have contents of the attachmnet to be sent in an internal table. when i pass this table to the FM 'SO_NEW_DOCUMENT_ATT_SEND_API1' , the text attachment shows a slant format. i mean all the contents of the attachment shift to right and has no proper alignment.
What can be done.? pLease help...Hi,
You must have skipped some data declaration part which causes this.
Please refer to the below mentioned code for reference:
REPORT zrat NO STANDARD PAGE HEADING.
*DATA DECLARATION
DATA : BEGIN OF wa_ccode,
bukrs TYPE t001-bukrs,
END OF wa_ccode.
DATA : itab_ccode LIKE TABLE OF wa_ccode.
DATA : BEGIN OF wa_emp,
pernr TYPE pa0001-pernr,
sachp TYPE pa0001-sachp,
sname TYPE pa0001-sname,
END OF wa_emp.
DATA : itab_emp LIKE TABLE OF wa_emp.
DATA : BEGIN OF wa_bdate,
nachn LIKE pa0002-nachn,
vorna LIKE pa0002-vorna,
pernr TYPE pa0002-pernr,
gbdat TYPE pa0002-gbdat,
END OF wa_bdate.
DATA : itab_bdate LIKE TABLE OF wa_bdate.
DATA : new_date LIKE sy-datum.
DATA : diff TYPE i.
DATA : years LIKE p0347-scryy,
months LIKE p0347-scrmm,
days LIKE p0347-scrdd.
DATA : sup_code LIKE pa0001-sachp,
itab_usrid LIKE t526-usrid,
sup_pernr LIKE pa0105-pernr.
DATA : BEGIN OF wa_email,
usrid_long LIKE pa0105-usrid_long,
END OF wa_email.
DATA : sup_email LIKE TABLE OF wa_email.
DATA : gwa_document_data LIKE sodocchgi1,
gc_name TYPE so_obj_nam VALUE 'RETIREMENT',
gc_senst TYPE so_obj_sns VALUE 'P',
gc_size TYPE so_doc_siz VALUE '510',
gi_obj_cnt LIKE TABLE OF solisti1 WITH HEADER LINE,
gi_recievers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
gwa_obj_cnt LIKE LINE OF gi_obj_cnt.
DATA : smtp_addr LIKE adr6-smtp_addr.
DATA : wa_date LIKE sy-datum,
entries LIKE sy-tabix,
name(15),
line1(18) TYPE c,
line2(20) TYPE c,
line3(20) TYPE c,
line4(23) TYPE c,
line5(10) TYPE c,
line6(45) type c,
date(2) TYPE c,
month(2) TYPE c,
year(4) TYPE c.
*START OF SELECTION
SELECT bukrs
FROM t001
INTO TABLE itab_ccode
WHERE land1 EQ 'GB'.
SORT itab_ccode.
DELETE ADJACENT DUPLICATES FROM itab_ccode.
SELECT pernr sachp sname
FROM pa0001
INTO TABLE itab_emp
FOR ALL ENTRIES IN itab_ccode
WHERE bukrs EQ itab_ccode-bukrs AND begda LE sy-datum AND
endda GE sy-datum and persg eq '1'.
SELECT nachn vorna pernr gbdat
FROM pa0002
INTO TABLE itab_bdate
FOR ALL ENTRIES IN itab_emp
WHERE pernr EQ itab_emp-pernr.
*TO CHECK EMPLOYEES WHOSE AGE IS NEAR 75 YEARS.
LOOP AT itab_bdate INTO wa_bdate.
new_date = wa_bdate-gbdat.
*TO CALCULATE THE AGE TILL DATE
CALL FUNCTION 'HR_HK_DIFF_BT_2_DATES'
EXPORTING
date1 = sy-datum
date2 = new_date
output_format = '05'
IMPORTING
years = years
months = months
days = days
IF sy-subrc <> 0.
ENDIF.
IF years EQ 64 AND months EQ 4.
IF days GE 23 AND days LE 31.
*FETCH THE DATA IF THE AGE IS NEARING 75 YEARS
SELECT SINGLE sachp FROM pa0001 INTO sup_code WHERE pernr EQ
wa_bdate-pernr AND begda LE sy-datum AND endda GE sy-datum.
SELECT SINGLE usrid FROM t526 INTO itab_usrid WHERE sachx EQ
sup_code.
SELECT SINGLE pernr FROM pa0105 INTO sup_pernr WHERE usrid EQ
itab_usrid AND subty EQ '0001'.
clear sup_email[].
SELECT usrid_long FROM pa0105 INTO TABLE sup_email WHERE pernr EQ
sup_pernr AND subty EQ '0010'.
*EMAIL ADDRESS OF THE SUPERVISOR TO BE NOTIFIED
CLEAR gi_obj_cnt.
CLEAR gi_recievers.
CLEAR gwa_document_data.
Loop at sup_email into wa_email.
write sy-uline+0(5).
write sy-uline+10(5).
write sy-uline+20(5).
write sy-uline+30(5).
write sy-uline+40(5).
write sy-uline+50(5).
write sy-uline+60(5).
write sy-uline+70(5).
smtp_addr = wa_email-usrid_long.
gi_recievers-receiver = smtp_addr.
gi_recievers-rec_type = 'U'.
gi_recievers-com_type = 'INT'.
APPEND gi_recievers.
Endloop.
smtp_addr = '[email protected]'.
gi_recievers-receiver = smtp_addr.
gi_recievers-rec_type = 'U'.
gi_recievers-com_type = 'INT'.
APPEND gi_recievers.
gwa_document_data-obj_name = gc_name.
gwa_document_data-obj_descr = 'RETIRE'.
gwa_document_data-sensitivty = gc_senst.
gwa_document_data-obj_langu = sy-langu.
*CONTENT OF THE EMAIL TO BE SENT
line1 = 'Please note that '.
line2 = wa_bdate-vorna.
line3 = wa_bdate-nachn.
line4 = ' will be 65 years on '.
line50(4) = wa_bdate-gbdat4(4).
date = line5+2(2).
month = line5+0(2).
year = wa_bdate-gbdat+0(4) + 65.
CONCATENATE date month year INTO line5 SEPARATED BY '.'.
line6 = '.Please complete the Retirement Procedure.'.
CONCATENATE line1 line2 line3 line4 line5 line6 INTO gwa_obj_cnt
SEPARATED BY space.
APPEND gwa_obj_cnt TO gi_obj_cnt.
CLEAR gwa_obj_cnt.
DESCRIBE TABLE gi_obj_cnt LINES entries.
READ TABLE gi_obj_cnt INDEX entries.
gwa_document_data-doc_size = ( entries - 1 ) * 255 + STRLEN( gi_obj_cnt
*FUNCTION MODULE TO SEND THE EMAIL TO THE CONCERNED PERSONS
CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
EXPORTING
document_data = gwa_document_data
document_type = 'RAW'
commit_work = 'X'
TABLES
object_content = gi_obj_cnt
receivers = gi_recievers
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8
*MESSAGE TO BE DISPLAYED AFTER THE EXECUTION
endif.
CASE sy-subrc.
WHEN 0.
LOOP AT gi_recievers.
IF gi_recievers-receiver = space.
name = gi_recievers-rec_id.
ELSE.
name = gi_recievers-receiver.
ENDIF.
IF gi_recievers-retrn_code = 0.
WRITE: / name, ': succesfully sent'.
ELSE.
WRITE: / name, ': error occured'.
ENDIF.
ENDLOOP.
WHEN 1.
WRITE: / 'Too many receivers specified !'.
WHEN 2.
WRITE: / 'No receiver got the document !'.
WHEN 4.
WRITE: / 'Missing send authority !'.
WHEN OTHERS.
WRITE: / 'Unexpected error occurred !'.
ENDCASE.
ENDIF.
ENDIF.
ENDLOOP.
In case you have any further clarifications,do let me know.
Regards,
Puneet Jhari. -
Calculate average for some dates
Hi,
I would like to calculate average for some dates. Is there any function module or any process, please provide me.
venkat.Use this FM HR_HK_DIFF_BT_2_DATES
Example:
DATA: DATE1 type P0001-BEGDA,
DATE2 type P0001-BEGDA,
YEARS type P0347-SCRYY,
MONTHS type P0347-SCRMM,
DAYS type P0347-SCRDD.
DATE1 = '20070331'.
DATE2= '20070101'.
CALL FUNCTION 'HR_HK_DIFF_BT_2_DATES'
EXPORTING
DATE1 = date1
DATE2 = date2
OUTPUT_FORMAT = '03'
IMPORTING
YEARS = years
MONTHS = months
DAYS = days
EXCEPTIONS
INVALID_DATES_SPECIFIED = 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.
Regards,
Joan
Maybe you are looking for
-
My iPhone 5 won't sync with the Nike Plus sensor
My iPhone 5 won't sync with Ike Plus sensor, new or old.
-
Max number of records in a cube & architectural issues
Hi, Sorry if my question was already done but i can't find the same question with the research button (may be i have not the good words for search, I'm not english). I am on a BIG BIG IP project. The forecast volume of planned records is about 1.000.
-
1099 MISC forms for 2009 Layout
Does anybody know if the SAP Notes for 1099 forms for 2009 layout has been released? I would appreciate if you can provide the SAP Notes Numbers. We are on ECC 6.0 Regards, Marco
-
Change CSS styles for Acces Web App
Here's the problem, the #s4-mini-header needs to be set to display:none so the SharePoint header is not shown. Ideally this would be conditional based on group membership (i.e. Site Owners would see the section, for read only it would be hidden) I n
-
DATE FROM THE GIVEN WEEK NUMBER AND YEAR
hi to all With weeknr, yearnr i need to find STARTDATE (first day of the week), ENDDATE (last day of the week) The first day of the week is always a Monday. example 44 2007 week nr is 44 year is 2007 how to find it. is there any standard function m