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

file pattern (string)

former_member671224
Participant
0 Likes
701

I need to find out the files from the internal table which are in the given date range.

for example Files will be in the following format,

<b> fielname_YYYYMMDD</b>

here <b>yyyymmdd</b> is the date. If the date range is 20071002 to 20071004 then i need to fetch 3 files from the internal table. the files are

<b>filename_20071002

filename_20071003

filename_20071004</b>

can someone help me how to do this in an efficient way.

Regards,

Amal

1 ACCEPTED SOLUTION
Read only

ferry_lianto
Active Contributor
0 Likes
668

Hi,

Please try this.


data: l_datum like sy-datum,
      l_date1 like sy-datum,
      l_date2 like sy-datum.     

l_date1 = '20071002'.
l_date2 = '20071004'.

loop at itab.
  clear l_datum.
  l_datum = itab-file+9(8). 
 
  if l_datum between l_date1 and l_date2.  
    move itab-file to itab2-file.
    append itab2.
  endif.

endloop.

Regards,

Ferry Lianto

3 REPLIES 3
Read only

Former Member
0 Likes
668

Hi,

Let's assume if you have v_date_low and v_date_high




* Create a new intenral table to have the dates.
  DATA: t_date type standard table of sydatum.
  data: s_date type sydatum.  

  DO.

    if sy-index = 1.
      s_date = v_date_low.
      append s_date to t_date.
      continue.
    endif.

    v_date_low = v_date_ low + 1.    " Increment the date low

    s_date = v_date_low.
    append s_date to t_date.

* Exit condition.
    if v_date_low = v_date_high.
      exit.
    endif.    


  ENDDO.

***Now you have all the dates in the intenral table T_DATE.

  LOOP AT t_date into s_date.

* concatenate to get the filename.
    CONCATENATE 'FILENAME' s_date INTO v_filename.

* Call the function module RZL_READ_DIR_LOCAL with the variable v_filename
* to get the file contents.


  ENDLOOP.

Thanks

Naren

Read only

ferry_lianto
Active Contributor
0 Likes
669

Hi,

Please try this.


data: l_datum like sy-datum,
      l_date1 like sy-datum,
      l_date2 like sy-datum.     

l_date1 = '20071002'.
l_date2 = '20071004'.

loop at itab.
  clear l_datum.
  l_datum = itab-file+9(8). 
 
  if l_datum between l_date1 and l_date2.  
    move itab-file to itab2-file.
    append itab2.
  endif.

endloop.

Regards,

Ferry Lianto

Read only

0 Likes
668

Thanks Ferry,

Your Suggestion solved my problem.