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

Get Days in Select-Option

0 Likes
2,292

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
Read only

naimesh_patel
Active Contributor
0 Likes
1,649

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

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.

5 REPLIES 5
Read only

Former Member
0 Likes
1,649

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

Read only

naimesh_patel
Active Contributor
0 Likes
1,650

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

Read only

Former Member
0 Likes
1,649

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

Read only

Former Member
0 Likes
1,649

hi look at the table..

TCALS for the factory calender dates

Read only

0 Likes
1,649

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.