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: 

Internal table logic

Former Member
0 Kudos

Hi,

I am giving value range for date in select option in the selection screen say from 20.07.2008 to 30.07.2008 . In this case I need to capture the 10 dates from 20th to 30th and all these date values shuld be there in my internal table...

Pls let me know how can i do this

Regards

Saravan

9 REPLIES 9

former_member262988
Active Contributor
0 Kudos

hi,

write select command with conditio where date in <select-option date table )

like select <>

......

where date in s_date.

Former Member
0 Kudos

Hi ,

try this

CSCP_PARA1_GET_PERIODS

I_TIMEUNIT D

after getting the data into table

delete et_dates where not datum in s_date.

regards

Prabhu

Former Member
0 Kudos

Hi,

try this. it may help you.

while selectoption-low LE select option-high.

move selectoption-low to workarea.

append work area to internal table.

add 1 to select option-low.

endwhile

Former Member
0 Kudos

Hi,

loop at internal_tab into work_area upto 10 records.

select loop and press F1

Thanks,

Sendil

raymond_giuseppi
Active Contributor
0 Kudos

Say, there is a date, DATS type, field in internal table itab, wa_itab a work area of same structure, and a SELECT-OPTIONS so_date then do a


LOOP AT so_date WHERE SIGN = 'I'.
CASE SO_DATE-option.
  WHEN 'BT'.
    wa_itab-date = so_date-low.
    WHILE itab-date LE so_date-high.
       APPEND wa_itab to itab.
       ADD 1 TO itab-date.
    ENDWHILE.   
   WHEN 'EQ'.
    wa_itab-date = so_date-low.
    APPEND wa_itab to itab. 
  ENDCASE.
ENDLOOP.

Use function module [SELECT_OPTIONS_RESTRICT|https://www.sdn.sap.com/irj/sdn/directforumsearch?q=select_options_restrict&objid=f50&daterange=all&searchid=14638616&forumid=50&rankby=10001&start=0] to restrict select-options available so there are only EQ and BT options and I include sign.

Regards

Former Member
0 Kudos

Hii!

Check this sample code


REPORT z_sdn.

SELECT-OPTIONS:
  s_date FOR sy-datum.

DATA:
  w_diff TYPE i.

DATA:
  BEGIN OF fs_emp,
    empname(10) TYPE c,
    date TYPE sy-datum,
  END OF fs_emp.

DATA:
  t_emp LIKE
  TABLE OF
        fs_emp.

START-OF-SELECTION.

w_diff = s_date-high - s_date-low.
w_diff = w_diff + 1.
 DO w_diff TIMES.
   fs_emp-empname = 'XYZ'.
   fs_emp-date = s_date-low.
   APPEND fs_emp TO t_emp.
   s_date-low = s_date-low + 1.
 ENDDO.


 LOOP AT t_emp INTO fs_emp.
  WRITE:
   / fs_emp-empname,
     fs_emp-date.

ENDLOOP.

Regards

Abhijeet

Former Member
0 Kudos

Hi,

TYPES: BEGIN OF ty_rtab ,

sign TYPE c LENGTH 1,

option TYPE c LENGTH 2,

low LIKE date field,

high LIKE date field,

END OF ty_rtab.

data: wa_mardc3 TYPE ty_rtab.

LOOP AT so_date INTO wa_mardc3 .

CLEAR wa_tab-date.

CASE wa_mardc3-option.

WHEN 'BT'.

wa_tab-date = so_date-low.

WHILE ( wa_tab-date LE so_date-high ) .

APPEND wa_tab TO it_tab.

wa_tab-date = wa_tab-date + 1.

ENDWHILE.

WHEN 'EQ'.

wa_mardc2-date = wa_mardc3-low.

APPEND wa_mardc2 TO it_mardc2.

ENDCASE.

ENDLOOP.

"Wa_tab is the work area where you want to append the values.

Regards,

Sreeja

Former Member
0 Kudos

hai,

give

select-option corresponding field for tablename-fieldname.

and after that

in select condition give

select * from table name into table internaltable name where select option fieldname in same select option fieldname.

former_member787646
Contributor
0 Kudos

Hi

Try this.

Data: date1 type SY-DATUM.

Data: n1(2) type n, n2(2) type n.

n1 = so_obj-low+6(2).

n2 = so_obj-high+6(2).

date1 = so_obj-low.

while (n1 <= n2)

date1+6(2) = n1.

ITAB-FLD = date1. (" Adding the date to the internal table field )

n1 = n1 + 1.

endwhile.

Hope it helps.

Murthy