2009 Jan 29 6:28 AM
Hi guru's,
In the selection screen i have only one field i.e Date
I am having the one internal table it_tab in that i have the data like this
for example
Date material number
1.01.2009 11111
2.01.2009 22222
4.01,2009 44444
In the above exampel ther is no materials at 03.01.2009 that is why i am not getting the data on that particular date...
But i want the data in the internal table it_itab like this....
Date material number
1.01.2009 11111
2.01.2009 22222
3.01.2009 00000
4.01,2009 44444 .
can any one suggest me how to do this...
Thanks & Best Regards
Praveen.
2009 Jan 29 9:03 AM
Hi Praveen,
If you want to include range of dates mentioned entered in the select options, then
START-OF-SELECTION.
w_dat = so_date-low. "Intialise the date
WHILE w_dat LE so_date-high. "Only upto to range mentioned in select option
READ TABLE it_tab INTO wa_tab WITH KEY date = w_dat.
IF sy-subrc NE 0. "If the date is not there
wa_tab-date = w_dat.
wa_tab-matnr = '0000'.
APPEND wa_tab TO it_tab. "Appended
ENDIF.
w_dat = w_dat + 1. "Increment the date
ENDWHILE.
"Now the table it_tab contains all the dates of select option range
SORT it_tab BY date.Regards,
Manoj Kumar P
Hi guru's,
In the selection screen i have only one field i.e Date
I am having the one internal table it_tab in that i have the data like this
for example
Date material number
1.01.2009 11111
2.01.2009 22222
4.01,2009 44444
In the above exampel ther is no materials at 03.01.2009 that is why i am not getting the data on that particular date...
But i want the data in the internal table it_itab like this....
Date material number
1.01.2009 11111
2.01.2009 22222
3.01.2009 00000
4.01,2009 44444 .
can any one suggest me how to do this...
Thanks & Best Regards
Praveen.
2009 Jan 29 6:30 AM
2009 Jan 29 6:35 AM
hi,
loop the internal table.
take the first date in one variable.
then in second date in another variable check whether it is sequencence if not append that date by incrementing by one.
2009 Jan 29 6:36 AM
Hi,
Then first pass all your dates to your internal table.
Then select the materials and try to pass them to appropriate rows / Columns & modify internal table.
2009 Jan 29 6:40 AM
Hi
I hope your question means that you want to copy data from it_tab to it_itab but you want it to have entries for all the dates. Try the following then:
data: st_dt like sy-datum.
read table it_tab index 1 .
st_dt = it_tab-date. "initialise start date
loop at it_tab.
if st_dt eq it_tab-date.
read table it_tab into it_itab.
append it_itab.
else.
it_itab-date = st_dt.
it_itab-mat_no = 0.
append it_itab.
endif.
st_dt = st_dt + 1.
endloop.
Hope this helps
Regards,
Jayanthi.K
2009 Jan 29 7:19 AM
hi jayanthi...
i am having the selection screen field date... if i enter the value in the selection screen like this..
for exampple...
date 01.03.2009 to 31.03.2009
i have to loop the table up to 31.03.2009..
but according to ur suggestion its working after 31.03.2009 also...
pls suggest me how to do this....
Thnak & Best Regards,
Praveen.
2009 Jan 29 8:59 AM
Hi
The code I gave loops through all entries of it_tab alone and fills in the dates in between.
If you want it to limit between two dates, store the dates in st_dt and end_dt and use the following code.
loop at it_tab.
if st_dt eq it_tab-date.
read table it_tab into it_itab.
append it_itab.
else.
it_itab-date = st_dt.
it_itab-mat_no = 0.
append it_itab.
endif.
st_dt = st_dt + 1.
if st_dt eq end_dt.
exit.
endif.
endloop.
Hope it works now
Regards,
Jayanthi.K
2009 Jan 29 6:42 AM
Hello,
Try this code:
LOOP AT S_DATE. "S_DATE --> Selection-screen date
READ TABLE ITAB TRANSPORTING NO FIELDS
WITH KEY DATE = S_DATE-LOW.
IF SY-SUBRC NE 0.
ITAB-DATE = S_DATE-LOW.
APPEND ITAB.
ENDIF.
ENDLOOP.
Hope this helps.
BR,
Suhas
2009 Jan 29 6:42 AM
hi,
give your first date 01.01.2009 to function module get the next date ie 02.01.2009.
check out put of FM with internal table second row. if it not equal insert the Fm output date to internal table,
try this FM
RP_CALC_DATE_IN_INTERVAL
2009 Jan 29 7:01 AM
Hi Praveen,
you can try this code,
DATA: w_dat TYPE sy-datum,
w_lines TYPE i.
it_tab1 = it_tab. "it_tab1 is of same structure as it_tab
READ TABLE it_tab INTO wa_tab INDEX 1.
w_dat = wa_tab-date. "Get the date of first record
DESCRIBE TABLE it_tab LINES w_lines. "Get the total lines
DO.
w_dat = w_dat + 1. "Increment the date
READ TABLE it_tab INTO wa_tab WITH KEY date = w_dat.
IF sy-subrc NE 0. "If that date is not there append it to the copied int tab
wa_tab-date = w_dat.
wa_tab-matnr = '0000'.
APPEND wa_tab TO it_tab1.
ELSEIF sy-tabix = w_lines. "If date is there and if it last record end the loop
EXIT.
ENDIF.
ENDDO.
SORT it_tab1 BY date. "Sort it based on date.
i/p: it_tab
01.01.2009 1111
02.01.2009 2222
04.01.2009 3333
06.01.2009 4444o/p: it_tab1
01.01.2009 1111
02.01.2009 2222
03.01.2009 0000
04.01.2009 3333
05.01.2009 0000
06.01.2009 4444Regards,
Manoj Kumar P
2009 Jan 29 8:53 AM
HI manoj,
thanks for ur sugetion...
acoording to the total lines of it_tab ur looping the table...
but when i enter the data in the selection screen
date 01.03.2009 to 31.03.2009.
i am getting the data up to
27.01.2009... only in this case according to ur suggestion the last record of the internal table is 27.01.2009...
but i want the data up to 31.01.2009...
how can i do...
pls let me know if any issue...
Thanks & Best Regards,
Prveen.
Edited by: praveen rao on Jan 29, 2009 9:53 AM
2009 Jan 29 9:02 AM
Hello,
Did you check my code? Is it not working as per your requirement ?
Suhas
2009 Jan 29 9:03 AM
Hi Praveen,
If you want to include range of dates mentioned entered in the select options, then
START-OF-SELECTION.
w_dat = so_date-low. "Intialise the date
WHILE w_dat LE so_date-high. "Only upto to range mentioned in select option
READ TABLE it_tab INTO wa_tab WITH KEY date = w_dat.
IF sy-subrc NE 0. "If the date is not there
wa_tab-date = w_dat.
wa_tab-matnr = '0000'.
APPEND wa_tab TO it_tab. "Appended
ENDIF.
w_dat = w_dat + 1. "Increment the date
ENDWHILE.
"Now the table it_tab contains all the dates of select option range
SORT it_tab BY date.Regards,
Manoj Kumar P
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |