This website is not affiliated with, sponsored by, or approved by SAP AG.

Reference to DD_STIDA

Development (ABAP Development WorkBench, ABAP/4 programming)

Moderators: Snowy, thx4allthefish, YuriT, Gothmog

Reference to DD_STIDA

Postby rpinxt » Tue Mar 10, 2015 11:07 am

So I want to make a reference to DD_STIDA being the 'open item at key date' to be able to calculate dates between this key date and the due date.

I was able to do something similar by using SY-DATLO but that is always real time.

Now I made a reference like this :
Code: Select all
WRITE DD_STIDA TO RP_ODATE.


Today is 10th of March 2015.
Now when I use this field and set open item at key date as 10.03.2015 (european) it gives output but like :
15.20.1003

First it looked like rubisch but actually if you look closer and rearrange the numbers it is the same date!
But 1003 should come first and then the year being 2015 and not 1520.

So should I add something to the code to put it to DD.MM.YYYY or should I reference DD_STIDA in another way?
Thanks!
rpinxt
 
Posts: 146
Joined: Mon Jul 23, 2012 8:02 am

Re: Reference to DD_STIDA

Postby Gothmog » Tue Mar 10, 2015 11:36 am

It seems you're fillling your date field with DDMMYYYY.
The internal date format is YYYYMMDD.

By the way, DD_STIDA is neither a data element, a domain nor a field of a table or structure, so I have no idea what you're precisely tablking about.
Please provide the data types of your fields (and how you fill them), it makes for an easier response.
68 74 74 70 3a 2f 2f 74 69 6e 79 75 72 6c 2e 63 6f 6d 2f 62 64 6f 37 6d 77 67
Gothmog
 
Posts: 1941
Joined: Wed Sep 12, 2007 4:46 am
Location: Probably not home

Re: Reference to DD_STIDA

Postby rpinxt » Wed Mar 11, 2015 6:27 am

I want to calculate days between a given date and the due date.

Now I have a code which gives me the current user system date :
Code: Select all
CLEAR RP_CDATE.
RP_CDATE = SY-DATLO.


My due date calculated is document date (is in the tables) added with the number of days from the payment term.
This works just fine.

RP_CDATE -/- Due Date is the number of days I need.

However this only works with the current date.
If I look back at lets say 28-02-2015 it will give the wrong number of days.
It should take 28-2-2015 -/- due date.

So in logical database DDF there is a Program Selctions field called "Open items at key date".
If I could use the date that the user fills there in my calculations the calculation would also be correct historically speaken.

I saw DD_STIDA was linked to that selection parameter so thats why I wanted to load RP_ODATE with that selection.
Then my calculation would be RP_ODATE -/- due date.
rpinxt
 
Posts: 146
Joined: Mon Jul 23, 2012 8:02 am

Re: Reference to DD_STIDA

Postby Gothmog » Wed Mar 11, 2015 8:07 am

Don't use write to affect a date value to a date field.
Using WRITE will format the date to the presentation format (i.e. DD.mm.YYYY).
You want to keep the internal format (YYYYMMDD).

Use MOVE, or =.
68 74 74 70 3a 2f 2f 74 69 6e 79 75 72 6c 2e 63 6f 6d 2f 62 64 6f 37 6d 77 67
Gothmog
 
Posts: 1941
Joined: Wed Sep 12, 2007 4:46 am
Location: Probably not home

Re: Reference to DD_STIDA

Postby rpinxt » Wed Mar 11, 2015 8:15 am

Aha!
Using MOVE totally fixed the issue :)
So again I was struggling with internal format and presentation format.

Thanks very much for the valuable lessons Gothmog!
rpinxt
 
Posts: 146
Joined: Mon Jul 23, 2012 8:02 am


Return to ABAP

Who is online

Users browsing this forum: No registered users and 9 guests





loading...


This website is not affiliated with, sponsored by, or approved by SAP AG.