Application Development 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: 

Get Days in Select-Option

0 Kudos

Hello,

I need to know the number of days in a select option type date.

I think to do a select to a table that has all days with the range and count the number of rows that have the select but I don't know what table have all days of calendar.

Thanks.

1 ACCEPTED SOLUTION

naimesh_patel
Active Contributor
0 Kudos

Will this help you ?


DATA W_FKDAT TYPE VBRK-FKDAT.

SELECT-OPTIONS: S_FKDAT FOR W_FKDAT.

START-OF-SELECTION.
  DATA: L_DAYS TYPE I,
        L_DIFF TYPE I.

* I   BT    20080101 20080110
* E   BT    20080112 20080113

  LOOP AT S_FKDAT.
    IF S_FKDAT-OPTION = 'BT'.
      L_DIFF =  S_FKDAT-HIGH - S_FKDAT-LOW.
    ELSEIF S_FKDAT-OPTION = 'EQ'.
      L_DIFF = 1.
    ENDIF.

    IF S_FKDAT-SIGN = 'I'.   " Including  ... so ADD
      L_DAYS = L_DAYS + L_DIFF.
    ELSEIF S_FKDAT-SIGN = 'E'.  " Excluding ... so subtract
      L_DAYS = L_DAYS - L_DIFF.
    ENDIF.

  ENDLOOP.

  WRITE: L_DAYS.

Regards,

Naimesh Patel

5 REPLIES 5

Former Member
0 Kudos

Hi

There's no table of calendar days: the field date is long 10 char so the date can be a value from 00010101 (01.01.0001) to 99991231 (31.12.9999).

Max

naimesh_patel
Active Contributor
0 Kudos

Will this help you ?


DATA W_FKDAT TYPE VBRK-FKDAT.

SELECT-OPTIONS: S_FKDAT FOR W_FKDAT.

START-OF-SELECTION.
  DATA: L_DAYS TYPE I,
        L_DIFF TYPE I.

* I   BT    20080101 20080110
* E   BT    20080112 20080113

  LOOP AT S_FKDAT.
    IF S_FKDAT-OPTION = 'BT'.
      L_DIFF =  S_FKDAT-HIGH - S_FKDAT-LOW.
    ELSEIF S_FKDAT-OPTION = 'EQ'.
      L_DIFF = 1.
    ENDIF.

    IF S_FKDAT-SIGN = 'I'.   " Including  ... so ADD
      L_DAYS = L_DAYS + L_DIFF.
    ELSEIF S_FKDAT-SIGN = 'E'.  " Excluding ... so subtract
      L_DAYS = L_DAYS - L_DIFF.
    ENDIF.

  ENDLOOP.

  WRITE: L_DAYS.

Regards,

Naimesh Patel

Former Member
0 Kudos

Is this what you are looking for:

REPORT ztest LINE-SIZE 80 MESSAGE-ID 00.

SELECT-OPTIONS s_dt FOR sy-datum OBLIGATORY.

DATA: no_days TYPE i.

IF s_dt-high IS INITIAL.
  no_days = 0.
ELSE.
  no_days = s_dt-high - s_dt-low.
ENDIF.

WRITE: /001 'Number of days -', no_days.

Rob

Former Member
0 Kudos

hi look at the table..

TCALS for the factory calender dates

0 Kudos

Thanks, I did a little thing to the code but it works


DATA W_FKDAT TYPE VBRK-FKDAT.
 
SELECT-OPTIONS: S_FKDAT FOR W_FKDAT.
 
START-OF-SELECTION.
  DATA: L_DAYS TYPE I,
        L_DIFF TYPE I.
 
* I   BT    20080101 20080110
* E   BT    20080112 20080113
 
  LOOP AT S_FKDAT.
    IF S_FKDAT-OPTION = 'BT'.
      L_DIFF =  S_FKDAT-HIGH - S_FKDAT-LOW + 1. "here
    ELSEIF S_FKDAT-OPTION = 'EQ'.
      L_DIFF = 1.
    ENDIF.
 
    IF S_FKDAT-SIGN = 'I'.   " Including  ... so ADD
      L_DAYS = L_DAYS + L_DIFF.
    ELSEIF S_FKDAT-SIGN = 'E'.  " Excluding ... so subtract
      L_DAYS = L_DAYS - L_DIFF.
    ENDIF.
 
  ENDLOOP.
 
  WRITE: L_DAYS.