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

Problem in achiveing the desired select statement

Former Member
0 Likes
813

Dear All,

I am not getting the exact logic to achieve the below.

can you help me on this?

The screen input should have a range (separate “From” and “To” fields) and the data would be in mm/yyyy format. The posting period would be “mm” and “yyyy” would represent the fiscal year

For example if the user provides a range of 01/2005 to 12/2005, the report needs to run for the entire fiscal year. Likewise if the range is 07/2004 to 06/2005 then it needs to run for the later 6 periods of 2004 and the first 6 periods of 2005.

thanks

Dear All,

I am not getting the exact logic to achieve the below.

can you help me on this?

The screen input should have a range (separate “From” and “To” fields) and the data would be in mm/yyyy format. The posting period would be “mm” and “yyyy” would represent the fiscal year

For example if the user provides a range of 01/2005 to 12/2005, the report needs to run for the entire fiscal year. Likewise if the range is 07/2004 to 06/2005 then it needs to run for the later 6 periods of 2004 and the first 6 periods of 2005.

thanks

5 REPLIES 5
Read only

Former Member
0 Likes
789

Have month and year as seperate input fields..

Calculate date as ..

datefld+0(4) = i_year.

datefld+4(2) = i_month.

datefld+6(2) = '01'.

Run you select query with datefld.

Is this what you need?

Read only

0 Likes
789

to get period in the selection screen and the F4 for the same use the following

parameters: p_mon type rscalmonth .

at selection-screen on value-request for p_mon.

perform month_f4.

form month_f4 .

data: begin of mf_dynpfields occurs 1.

include structure dynpread.

data: end of mf_dynpfields.

data: mf_returncode like sy-subrc,

mf_monat like isellist-month,

mf_hlp_repid like sy-repid.

field-symbols: <mf_feld>.

  • Wert von Dynpro lesen

get cursor field mf_dynpfields-fieldname.

append mf_dynpfields.

mf_hlp_repid = sy-repid.

do 2 times.

call function 'DYNP_VALUES_READ'

exporting

dyname = mf_hlp_repid

dynumb = sy-dynnr

tables

dynpfields = mf_dynpfields

exceptions

invalid_abapworkarea = 01

invalid_dynprofield = 02

invalid_dynproname = 03

invalid_dynpronummer = 04

invalid_request = 05

no_fielddescription = 06

undefind_error = 07.

if sy-subrc = 3.

  • Aktuelles Dynpro ist Wertemengenbild

mf_hlp_repid = 'SAPLALDB'.

else.

read table mf_dynpfields index 1.

  • Unterstriche durch Blanks ersetzen

translate mf_dynpfields-fieldvalue using '_ '.

exit.

endif.

enddo.

if sy-subrc = 0.

  • Konvertierung ins interne Format

call function 'CONVERSION_EXIT_PERI_INPUT'

exporting

input = mf_dynpfields-fieldvalue

importing

output = mf_monat

exceptions

error_message = 1.

if mf_monat is initial.

  • Monat ist initial => Vorschlagswert aus akt. Datum ableiten

mf_monat = sy-datlo(6).

endif.

call function 'POPUP_TO_SELECT_MONTH'

exporting

actual_month = mf_monat

importing

selected_month = mf_monat

return_code = mf_returncode

exceptions

factory_calendar_not_found = 01

holiday_calendar_not_found = 02

month_not_found = 03.

if sy-subrc = 0 and mf_returncode = 0.

  • ASSIGN (MF_DYNPFIELDS-FIELDNAME) TO <MF_FELD>. " ==>> note 148804

  • <MF_FELD> = MF_MONAT.

call function 'CONVERSION_EXIT_PERI_OUTPUT'

exporting

input = mf_monat

importing

output = mf_dynpfields-fieldvalue.

collect mf_dynpfields.

call function 'DYNP_VALUES_UPDATE'

exporting

dyname = mf_hlp_repid

dynumb = sy-dynnr

tables

dynpfields = mf_dynpfields

exceptions

invalid_abapworkarea = 01

invalid_dynprofield = 02

invalid_dynproname = 03

invalid_dynpronummer = 04

invalid_request = 05

no_fielddescription = 06

undefind_error = 07.

endif.

endif.

endform .

Regards

Raja

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
789

Hi,

data d1 type sy-datum.

data d2 type sy-datum.

Then concatenate 01 with the inputs you get and put it in d1.

For the to period add 1 month with the input you got(if 12th month,then add 1 year and make the month as 01) and concatenate 01 with it.Store the result in d2.

Then use d1 to select data from database.

select * from db into table itab where date between d1 and d2.

Kindly reward points by clicking the star on the left of reply,if it helps.

Read only

andreas_mann3
Active Contributor
0 Likes
789

hi,

which date-field has the db-table ?

1) date like bkpf-budat

-> so you've to transform the periods from your 2nd sample to: 20040701 - 20050630

Use : concatenate or fm LAST_DAY_OF_MONTHS

2) year and month in db-table

if there are more than 1 year, you've to split the interval in an internal table

data : begin of per occurs 0,

year(4)

month_from(2),

month_to(2),

end of per.

-> loop that table to select the right periods from your db-table.

Andreas

Read only

Former Member
0 Likes
789

Hi Amit,

One question, in the format mm/yyyy, what does mm stand for? Is it the month or is it the period. As there is a lot of difference. Period may not start at the start of the month and may not end at the end of the month.

Just be cautious!!

Regards,

Srikanth