2007 May 15 6:12 PM
hi
i had a requirement where the date range was a selection parameter and accordingly i was pulling sales order using vbrk-fkdate field. this was the code i had written.
SELECT-options: p_fkdat for vbrk-fkdat obligatory ,
p_kunag for vbrk-kunag no-extension no intervals,
p_matnr for vbrp-matnr no-extension no intervals,
p_augru for vbrp-augru_auft no-extension no intervals,
p_vbeln for vbrk-vbeln no-extension no intervals.
SELECT *
FROM vbrk
INNER JOIN vbrp ON vbrkvbeln = vbrpvbeln
INNER JOIN kna1 ON vbrkkunag = kna1kunnr
INTO corresponding fields of TABLE itab
where
vbrkvbeln in p_vbeln and vbrkkunag in p_kunag and vbrpmatnr in p_matnr and vbrpaugru_auft in p_augru and vbrk~fkdat in P_fkdat .
**********************************************
now the functional guy needs only the month and year to be entered in selection screen, and i need to get sales order data for the months entered. ( eg aug 06 - sep 06 )
how should i modify the code.
2007 May 15 6:25 PM
Hi,
You can use Ranges..
Check this.
PARAMETERS: p_year TYPE spmon.
RANGES: r_date FOR sy-datum.
CONCATENATE p_year(4) p_year+4(2) '01' INTO r_date-low.
r_date-sign = 'I'.
r_date-option = 'BT'.
r_date-high = r_date-low.
CALL FUNCTION 'RE_LAST_DAY_OF_MONTH'
EXPORTING
i_datum = r_date-low
IMPORTING
e_tt = r_date-high+6(2).
APPEND r_date.
SELECT * FROM vbrk WHERE fkdat IN r_date.
Thanks,
Naren
2007 May 15 6:18 PM
You need concatenate day value is 01 always for Starting period and 30 or 31 for last period.
then use this value in range and do compare in select query
Reward Points if it is useful.
Thanks
Seshu
2007 May 15 6:24 PM
You can use this FM <b>RP_LAST_DAY_OF_MONTHS</b> to determine the last day of each month -:)
Greetings,
Blag.
2007 May 15 6:25 PM
Hi,
You can use Ranges..
Check this.
PARAMETERS: p_year TYPE spmon.
RANGES: r_date FOR sy-datum.
CONCATENATE p_year(4) p_year+4(2) '01' INTO r_date-low.
r_date-sign = 'I'.
r_date-option = 'BT'.
r_date-high = r_date-low.
CALL FUNCTION 'RE_LAST_DAY_OF_MONTH'
EXPORTING
i_datum = r_date-low
IMPORTING
e_tt = r_date-high+6(2).
APPEND r_date.
SELECT * FROM vbrk WHERE fkdat IN r_date.
Thanks,
Naren
2007 May 15 6:27 PM
Hi
Declare the select-options for date field as some table field like S021-SPMON.
check this SPMON field it is Year and Month combination.
fetch the data as it is except that date field in where condition
SELECT * FROM vbrk INTO corresponding fields of TABLE itab
INNER JOIN vbrp ON vbrkvbeln = vbrpvbeln
INNER JOIN kna1 ON vbrkkunag = kna1kunnr
where vbrkvbeln in p_vbeln and vbrkkunag in p_kunag and vbrpmatnr in p_matnr and vbrpaugru_auft in p_augru .
loop at itab.
if ( itab-fkdat0(4) <> s_date0(4) and
itab-fkdat4(2) <> s_date4(2) ).
delete itab index sy-tabix.
endif.
endloop.
Reward points if useful
Regards
Anji
2007 May 15 10:37 PM
thank u all fir ur quick replies.
I tried Anji 's code i am getting a runtime error.
this is the code i tried , but i am not getting the data in ITAB.
****************************************************
tables : vbrk , vbrp, knvv,KOnV, S021.
DATA:begin of itab occurs 0,
kunag like vbrk-kunag,
vbeln like vbrk-vbeln,
fkdat like vbrk-fkdat,
knumv like vbrk-knumv,
gjahr like vbrk-gjahr,
augru_auft like vbrp-augru_auft,
posnr like vbrp-posnr,
matnr like vbrp-matnr,
vrkme like vbrp-vrkme,
fkimg like vbrp-fkimg,
ktgrm like vbrp-ktgrm,
kdmat like vbap-kdmat,
kzwi1 like vbrp-kzwi1,
end of itab.
SELECTION-SCREEN BEGIN OF BLOCK blk WITH FRAME.
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
SELECT-options: p_kunag for vbrk-kunag no-extension no intervals,
p_matnr for vbrp-matnr no-extension no intervals,
p_augru for vbrp-augru_auft no-extension no intervals,
p_vbeln for vbrk-vbeln no-extension no intervals.
ranges : p_fkdat for sy-datum.
PARAMETERS: p_year TYPE spmon,
p_year1 type spmon.
RANGES: r_date FOR sy-datum.
SELECTION-SCREEN END OF BLOCK blk1.
CONCATENATE p_year(4) p_year+4(2) '01' INTO p_fkdat-low.
concatenate p_year1(4) p_year+4(2) '01' into p_fkdat-high.
p_fkdat-sign = 'I'.
p_fkdat-option = 'BT'.
CALL FUNCTION 'RE_LAST_DAY_OF_MONTH'
EXPORTING
i_datum = p_fkdat-high
IMPORTING
e_tt = p_fkdat-high+6(2).
APPEND p_fkdat.
SELECT *
FROM vbrk
INNER JOIN vbrp ON vbrkvbeln = vbrpvbeln
INNER JOIN kna1 ON vbrkkunag = kna1kunnr
INTO corresponding fields of TABLE itab
where
vbrkvbeln in p_vbeln and vbrkkunag in p_kunag and vbrpmatnr in p_matnr and vbrpaugru_auft in p_augru and vbrk~fkdat in p_fkdat.
*******************************************************************
Please suggest something. thanks
2007 May 15 10:40 PM
Can you see below code :
tables : vbrk , vbrp, knvv,KOnV, S021.
DATA:begin of itab occurs 0,
kunag like vbrk-kunag,
vbeln like vbrk-vbeln,
fkdat like vbrk-fkdat,
knumv like vbrk-knumv,
gjahr like vbrk-gjahr,
augru_auft like vbrp-augru_auft,
posnr like vbrp-posnr,
matnr like vbrp-matnr,
vrkme like vbrp-vrkme,
fkimg like vbrp-fkimg,
ktgrm like vbrp-ktgrm,
kdmat like vbap-kdmat,
kzwi1 like vbrp-kzwi1,
end of itab.
*SELECTION-SCREEN: BEGIN OF BLOCK blk WITH FRAME.
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
SELECT-options: p_kunag for vbrk-kunag no-extension no intervals,
p_matnr for vbrp-matnr no-extension no intervals,
p_augru for vbrp-augru_auft no-extension no intervals,
p_vbeln for vbrk-vbeln no-extension no intervals.
ranges : p_fkdat for sy-datum.
PARAMETERS: p_year TYPE spmon,
p_year1 type spmon.
RANGES: r_date FOR sy-datum.
SELECTION-SCREEN END OF BLOCK blk1.
start-of-selection.
CONCATENATE p_year(4) p_year+4(2) '01' INTO p_fkdat-low.
concatenate p_year1(4) p_year+4(2) '01' into p_fkdat-high.
p_fkdat-sign = 'I'.
p_fkdat-option = 'BT'.
CALL FUNCTION 'RE_LAST_DAY_OF_MONTH'
EXPORTING
i_datum = p_fkdat-high
IMPORTING
e_tt = p_fkdat-high+6(2).
APPEND p_fkdat.
SELECT *
FROM vbrk
INNER JOIN vbrp ON vbrkvbeln = vbrpvbeln
INNER JOIN kna1 ON vbrkkunag = kna1kunnr
INTO corresponding fields of TABLE itab
where
vbrkvbeln in p_vbeln and vbrkkunag in p_kunag and vbrp~matnr in
2007 May 15 11:02 PM
thank you all.
my code was working fine even before the last reply by me. I was just putting the entry in a wrong way.
giving points to all and closing this thread.