[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 262
  • Last Modified:

How to compare data (up or down) based on monthly date

Hi group,

I have a report that has data for each month.This report will be run every on 1st of every  month. The report will have to display sells and whether the sales are going up or down based on 1st of each month. I need help with the code. How do I compare the dates? How do I tell the program which date is previos when comparing to the current one?

Thank you

gal
0
galinbg
Asked:
galinbg
  • 3
  • 2
1 Solution
 
jonvaughanCommented:
if you have the dates in a date field with a domain of datum ( which most are ) then you can simply use the <> operators.

Jon
0
 
jonvaughanCommented:
try this noddy program ....

REPORT zzjontest LINE-SIZE 255 LINE-COUNT 60 NO STANDARD PAGE HEADING.

parameters: p_dat1 like sy-datum ,
            p_dat2 like sy-datum default sy-datum.



 write: / 'date 1 ', p_dat1,  'is  '.

 if p_dat1 > p_dat2.
  write: 'After '.
 else.
  write: 'Before '.
 endif.

 write:  'date 2' , p_dat2.
0
 
galinbgAuthor Commented:
Thanks for the suggestion.

I did pretty much the dame thing. I select all data in one intrnal table where PERIOD= P_PERIOD
and than I specify G_PERIOD = P_PERIOD - 1. Again I select all the data where PERIOD = G_PERIOD.

But there is one problem. If an user selects 2005/01 as selection option than the program will read the old period as 2005/00. Do you have any idea how can I reset the code to skip bening 00 af the end?

Thanks again

Galin
0
 
jonvaughanCommented:
Use the offset to identify the period and explicitly handle the 01 to 12 conversion.
This assumes that the internal format of the period field is YYYYMM which it should be ....

if p_period+4(2) = 01.

  g_period(4) = g_period(4) - 1.
  g_period+4(2) = 12.

else.

g_period = p_period -1.

endif.

Cheers
Jon
0
 
galinbgAuthor Commented:
Nice,

Thanks Jon
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now