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

adding input value to sy-datum

kishorepallapothula
Participant
0 Likes
1,745

Hi SAP Guys,

please go through this code.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

SELECTION-SCREEN COMMENT /1(79) g_text.

SELECTION-SCREEN COMMENT /1(79) g1_text.

SELECTION-SCREEN SKIP.

PARAMETERS: v_date(2).

SELECTION-SCREEN END OF BLOCK b1.

-


-


-


maildt1 = sy-datum + v_date.

select * -


= maidt1.

Here i am not able to add the v_date & sy-datum to maildt1.

Any one please help me.

will reward with points.

kishore

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,299

Hi Kishore,

Declare maildt1 type sy-datum.

Data: maildt1 type sy-datum.

Then am sure that this code will work.

Reward Points if useful.

Thanks,

Tej..

10 REPLIES 10
Read only

Former Member
0 Likes
1,299

Hi Kishore,

The code that you have provided is without the data declaration so herewith find my code wherein am adding and subtracting days from sy-datum.

This should help you.

SUBTRACTING.

data: v_temp type sy-datum value '20070813',

v_temp1 type i.

v_temp1 = sy-datum - v_temp.

write:/ v_temp1.

ADDING.

data: v_temp type i value '2',

v_temp1 type sy-datum.

v_temp1 = sy-datum + v_temp.

write:/ v_temp1.

Reward Points if useful.

Thanks,

Tej..

Read only

0 Likes
1,299

hi tej,

please see the total code.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

SELECTION-SCREEN COMMENT /1(79) g_text.

SELECTION-SCREEN COMMENT /1(79) g1_text.

SELECTION-SCREEN SKIP.

PARAMETERS: v_date(2).

SELECTION-SCREEN END OF BLOCK b1.

INITIALIZATION.

CONCATENATE

'Program to send e-mail alert for performance bond,' ' security deposits

&' INTO g_text.

CONCATENATE

'insurance policies on X no.of days due before ' ' the expiry date.'

INTO g1_text.

****internal tables****

DATA: BEGIN OF itab_zcr OCCURS 0,

ikonr(10) TYPE c, "Contract number

iruno(5) TYPE n, "Line number

insrc(60) TYPE c, "Insurance company

ipoly(60) TYPE c, "Policy number

iexdt LIKE sy-datum, "Policy Expiry date

igrup(3) TYPE c, "Purchasing group

ilfnr(10) TYPE c, "Vendor

ikdtb LIKE sy-datum, "Contract Valid from

ikdte LIKE sy-datum, "Contract Valid to

inam1(40) TYPE c, "Vendor name

ireqs(12) TYPE c, "Requisitioner

ighod(12) TYPE c, "Purchasing group HOD

iinty(2) TYPE c, "Policy type

itext(60) TYPE c, "Policy name

END OF itab_zcr.

DATA: BEGIN OF itab_dd07t OCCURS 0,

idvlu LIKE dd07t-domvalue_l, "Policy type

idtxt LIKE dd07t-ddtext, "Policy name

END OF itab_dd07t.

DATA: BEGIN OF itab_toid OCCURS 0,

itoid(12) TYPE c, "Receiver name

END OF itab_toid.

****end of internal tables****

*

****data decleration****

DATA: itab_adr6 LIKE adsmtp OCCURS 0 WITH HEADER LINE.

DATA : idocument TYPE sodocchgi1,

irecievers TYPE somlreci1,

int_irecievers TYPE STANDARD TABLE OF somlreci1,

ioutput TYPE solisti1 OCCURS 0 WITH HEADER LINE.

DATA: text1(225) TYPE c.

DATA: text2(225) TYPE c.

DATA: header LIKE ekpo-afnam.

DATA: requisitioner LIKE ekpo-afnam.

DATA: itype LIKE zcrinsur-istyp VALUE IS INITIAL.

DATA: idocno LIKE ekko-konnr VALUE IS INITIAL.

DATA: maildt1 TYPE sy-datum.

****end of data decleration****

*

****perform statement****

maildt1 = sy-datum + v_date.

CONCATENATE 'The following security deposit(s) and/or insurance'

'policy(ies) is/are going to expire in 1 month' '’' 's time.' INTO text1

SEPARATED BY space.

CONCATENATE 'Please ensure that all relevant security deposit(s) and/or'

'insurance policy(ies) is/are valid and enforceable during the'

'contractual period before commencement of any work or service at sites.

' INTO text2 SEPARATED BY space.

PERFORM select_data.

PERFORM toid.

****end of perform statement****

*

****selection of expiry document****

FORM select_data.

*

SELECT DISTINCT aebeln arunno ansrco apolcy a~expdt

bekgrp blifnr bkdatb bkdate c~name1

dafnam eehod a~istyp

FROM zcrinsur AS a INNER JOIN ekko AS b

ON aebeln = bebeln

INNER JOIN lfa1 AS c

ON blifnr = clifnr

INNER JOIN ekpo AS d

ON aebeln = dkonnr

INNER JOIN zpurch_grp AS e

ON bekgrp = eekgrp

INTO TABLE itab_zcr

WHERE expdt = maildt1.

*

SELECT DISTINCT aebeln aitem avsgtx aguarn a~expdt

bekgrp blifnr bkdatb bkdate c~name1

dafnam eehod

FROM zcrsecde AS a INNER JOIN ekko AS b

ON aebeln = bebeln

INNER JOIN lfa1 AS c

ON blifnr = clifnr

INNER JOIN ekpo AS d

ON aebeln = dkonnr

INNER JOIN zpurch_grp AS e

ON bekgrp = eekgrp

APPENDING TABLE itab_zcr

WHERE expdt = maildt1.

*

Here i want to add the sy-datum with v_date which is the input value.

kishore

Read only

Former Member
0 Likes
1,299

Hi Kishore,

Have you declared maildt1 as date type??

DATA MAILDT1 TYPE SY-DATUM.

DATA VN_DATE(2) TYPE N.

As V_DATE(2) is a character variable, move this to numeric variable.

VN_DATE = V_DATE.

MAILDT1 = SY-DATUM + VN_DATE.

Otherwise, declare a parameter which is of type N with 2 positions from data dictionary data element.

thanks,

Vinay

Read only

Former Member
0 Likes
1,299

Hi Kishore

declare

PARAMETERS: v_date(2) type N.

write in intialization event

maildt1 = sy-datum + v_date.

it will add the number of days ( v_date ) to sy datum

reward points to all helpful answers

kiran.M

Read only

0 Likes
1,299

Hi Kiran,

I did which you told but i am not getting the addition of sy-datum + v_date.

please check the below code.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

SELECTION-SCREEN COMMENT /1(79) g_text.

SELECTION-SCREEN COMMENT /1(79) g1_text.

SELECTION-SCREEN SKIP.

PARAMETERS: v_date(2) type N.

SELECTION-SCREEN END OF BLOCK b1.

-


-


DATA: maildt1 TYPE sy-datum.

-


-


INITIALIZATION.

maildt1 = sy-datum + v_date.

-


-


SELECT DISTINCT aebeln arunno ansrco apolcy a~expdt

bekgrp blifnr bkdatb bkdate c~name1

dafnam eehod a~istyp

FROM zcrinsur AS a INNER JOIN ekko AS b

ON aebeln = bebeln

INNER JOIN lfa1 AS c

ON blifnr = clifnr

INNER JOIN ekpo AS d

ON aebeln = dkonnr

INNER JOIN zpurch_grp AS e

ON bekgrp = eekgrp

INTO TABLE itab_zcr

WHERE expdt = maildt1.

please do help me.

if my problem solves i will sure give the points.

kishore

Read only

0 Likes
1,299

Hi Kishore

chk this one

data: date like sy-datum,

date1 like sy-datum.

date = sy-datum.

CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'

EXPORTING

date = date

days = 01 day added

months = 00

SIGNUM = '+'

years = 00

IMPORTING

CALC_DATE = date1. " new date

reward points to all helpful answers

kiran.M

Read only

0 Likes
1,299
      • define v_date as type integer, it will solve your problem, see the example below

REPORT ZTRIP_TEST .

parameters: v_date type i.

data:maildt1 like sy-datum.

maildt1 = sy-datum + v_date.

write maildt1.

***make corresponding changes to your program

Reward points if useful.

Get back in case of query.

Cheers!!!

Read only

Former Member
0 Likes
1,300

Hi Kishore,

Declare maildt1 type sy-datum.

Data: maildt1 type sy-datum.

Then am sure that this code will work.

Reward Points if useful.

Thanks,

Tej..

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,299

HERE THE V_DATA IS TYPE C.

I GUESS WE CANNOT SUM IT WITH SY-DATUM.

TRY DECLARING IT AS N OR I AND ADD IT WITH SY-DATUM.

Read only

kishorepallapothula
Participant
0 Likes
1,299

thank you this is answered