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

Date format( high - low )

naveen_inuganti2
Active Contributor
0 Likes
2,707

Hi.... All....

I came back with one more question related to date....

Iam having date field as select-option in selection screen...

>data: g_date like sy-datum

>

> select-options s_date for g_date

so here..

s_date-high should be last month last date

and...

s_date-low should be 7 months back month's first date.

Ex: This is July,

so s_month-high = 06/30/2008

s_month-low = 12/01/2007

Got it!!!

Thanks,

Please try this,

Get back to me,

Dont worry about points,

Naveen Inuganti.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,941

make use of FM

RP_CALC_DATE_IN_INTERVAL

OIL_LAST_DAY_OF_PREVIOUS_MONTH

regards

Prabhu

8 REPLIES 8
Read only

Former Member
0 Likes
1,942

make use of FM

RP_CALC_DATE_IN_INTERVAL

OIL_LAST_DAY_OF_PREVIOUS_MONTH

regards

Prabhu

Read only

Subhankar
Active Contributor
0 Likes
1,941

Please check it

initialization.

  • Set the default value for Date in the selecction Screen

PERFORM sub_set_date.

&----


*& Form sub_set_date

&----


  • Set default value in date field of the selection screen

----


  • No parameter

----


form sub_set_date .

s_cretd-low = ( sy-datum - 210 ).

s_cretd-high = sy-datum.

append s_cretd.

endform. " sub_set_date

Read only

Former Member
0 Likes
1,941

Hi,

You can do as below :

Use the FM


CALL FUNCTION 'CCM_GO_BACK_MONTHS'
    EXPORTING
      currdate   = sy-datum
      backmonths = '1'
    IMPORTING
      newdate    = gv_datum.

  gv_monat = gv_datum+4(2).
  gv_gjahr = gv_datum(4).

"Now in gv_monat you will have last month.

Use FM 

 CALL FUNCTION 'LAST_DAY_IN_PERIOD_GET'
    EXPORTING
    i_gjahr              = gv_gjahr
      i_periv              = 'K4'
      i_poper              = gv_monat
 IMPORTING
     e_date               = gv_lastday
 EXCEPTIONS
   input_false          = 1
   t009_notfound        = 2
   t009b_notfound       = 3
   OTHERS               = 4
            .

Now you will have last month last date.

And similar use FM CCM_GO_BACK_MONTHS for 7 months. And get the period and use FM FIRST_DAT_IN_MONTH. To get 7th month first day.

And for period use type t00pb-poper .

Thanks,

Sriram POnna.

Read only

Former Member
0 Likes
1,941

Pl. check this sample code. May be it will solve ur purpose.

REPORT zdemo LINE-SIZE 40 LINE-COUNT 10(4) no standard page

heading.

data: g_date like sy-datum.

select-options s_date for g_date.

initialization.

data: l_date(2) type n.

l_date = sy-datum+6(2).

s_date-high = sy-datum - l_date.

s_date-sign = 'I'.

s_date-option = 'BT'.

CALL FUNCTION 'RE_ADD_MONTH_TO_DATE'

EXPORTING

months = '-7'

olddate = sy-datum

IMPORTING

NEWDATE = s_date-low

.

s_date-low+6(2) = '01'.

append s_date.

Regards,

Joy.

Read only

vinod_vemuru2
Active Contributor
0 Likes
1,941

Hi Naveen,

Check below code. it is working fine.


SELECT-OPTIONS: so_date FOR sy-datum.
CONSTANTS: lc_sub TYPE c VALUE '-',
           lc_x   TYPE c VALUE 'X'.
DATA: l_mon(3)    TYPE c,
      l_date      TYPE sy-datum,
      l_date1     TYPE sy-datum.

INITIALIZATION.
  MOVE sy-datum TO l_date1.
  l_date1+4(2) = l_date1+4(2) - 1.
  CALL FUNCTION 'SLS_MISC_GET_LAST_DAY_OF_MONTH'
       EXPORTING
            day_in            = l_date1
       IMPORTING
            last_day_of_month = so_date-high
       EXCEPTIONS
            day_in_not_valid  = 1
            OTHERS            = 2.

  CLEAR: l_date, l_mon.
  MOVE: sy-datum  TO l_date,
        '07' TO l_mon.

  CALL FUNCTION 'HR_PT_ADD_MONTH_TO_DATE'
       EXPORTING
            dmm_datin = l_date
            dmm_count = l_mon
            dmm_oper  = lc_sub
            dmm_pos   = lc_x
       IMPORTING
            dmm_daout = so_date-low
       EXCEPTIONS
            unknown   = 1
            OTHERS    = 2.

  so_date-low+6(2) = '01'.
  APPEND so_date.

Thanks,

Vinod.

Read only

Former Member
0 Likes
1,941

Hi..

may be this FM could help you...

RP_CALC_DATE_IN_INTERVAL_SG u2013 add/subtract year/month/days from a date

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,941

Try something like this

select-options:so_dat1 for sy-datum.

initialization.

CALL FUNCTION 'RE_BE_CALC_START_DATE'
  EXPORTING
    id_daberi         = sy-datum
 IMPORTING
   ED_DATE_COR       = so_dat1-high.

CALL FUNCTION 'CCM_GO_BACK_MONTHS'
  EXPORTING
    currdate         = so_dat1-high
    backmonths       = '007'
 IMPORTING
   NEWDATE          = so_dat1-low    .

append so_dat1.
Read only

Former Member
0 Likes
1,941

Hi,

You ca try the below code for this.

data: l_month type char2,

l_diff type char2.

select-options: sy_datum for sy-datum.

initialization.

sy_datum-high = sy-datum.

l_month = sy_datum-high+4(2).

l_diff = l_month - 7.

if l_month > 7.

sy_datum-low+4(2) = l_month - 7.

else.

sy_datum-low+4(2) = 12 - l_diff.

sy_datum-low0(4) = sy_datum-high0(4) - 1.

Sy_datum-low+6(2) = 01.

endif.

append sy_datum.