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: 

Search helps

Former Member
0 Kudos
161

Hi,

I am working with a search help that i have created.

The problem is that i have a field DATE, that i need to consider the from - to period.

Do you know if this is possible to do? I mean in a Search help having 2 possibilities (from dd.mm.aaaa to dd.mm.aaaa) for one single field Date?

Thanks

Best regards

1 ACCEPTED SOLUTION

Former Member
0 Kudos
126

Hi,

It is not possible to have such search help for date field.

System by default gives some search help for every date field.

If you wants to create such type of search help means,

you creat a Db table with such field and fill values in it and we can create a search help using that custom table.

reward if useful

regards,

ANJI

9 REPLIES 9

Former Member
0 Kudos
127

Hi,

It is not possible to have such search help for date field.

System by default gives some search help for every date field.

If you wants to create such type of search help means,

you creat a Db table with such field and fill values in it and we can create a search help using that custom table.

reward if useful

regards,

ANJI

Former Member
0 Kudos
126

Thanks!

Former Member
0 Kudos
126

Hi,

I don't understand your requirement, but here's a little demo program that gives a custom search help for a date field without creating anything in the dictionary.

The search help shows dates within 40 days on the current date, and shows the financial period for each of these dates.

So it refers to our own 'Z1' for the period definitions.

Also I've used a custom FM to convert the date chosen to an internal value, but I'm sure you'll be able to do that another way.

John

REPORT YJNM_DATE_F4 .

parameters:

p_date type sydatum.

data:

datestring type string,

date_from type sydatum,

date_to type sydatum,

begin of value_tab occurs 0,

date type sydatum,

period type poper,

end of value_tab,

value_row like line of value_tab,

return_row type DDSHRETVAL,

return_tab like table of return_row,

per type poper, "period

yr type bdatj, "year

fper type poper, "from period

fyr type bdatj, "from year

tper type poper, "to period

tyr type bdatj, "to year

begin of period,

yr type bdatj,

per type poper,

stdat type sydatum,

endat type sydatum,

end of period,

periods like table of period.

----


initialization.

  • allow 40 days either side of current date

date_from = sy-datum - 40.

date_to = sy-datum + 40.

perform:

populate_periods,

populate_value_tab.

----


at selection-screen on value-request for p_date.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

RETFIELD = 'DATE'

VALUE_ORG = 'S'

TABLES

VALUE_TAB = value_tab

RETURN_TAB = return_tab.

loop at return_tab into return_row.

CALL FUNCTION 'Z_CONVERT_VALUE_TO_INTERNAL'

EXPORTING

EXTERNAL_VALUE = return_row-fieldval

DATA_ELEMENT = 'SYDATUM'

IMPORTING

INTERNAL_VALUE = datestring.

p_date = datestring.

endloop.

----


start-of-selection.

----


FORM populate_periods .

CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'

EXPORTING

I_DATE = date_from

I_PERIV = 'Z1'

IMPORTING

E_BUPER = fper

E_GJAHR = fyr

EXCEPTIONS

INPUT_FALSE = 1

T009_NOTFOUND = 2

T009B_NOTFOUND = 3

OTHERS = 4.

CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'

EXPORTING

I_DATE = date_to

I_PERIV = 'Z1'

IMPORTING

E_BUPER = tper

E_GJAHR = tyr

EXCEPTIONS

INPUT_FALSE = 1

T009_NOTFOUND = 2

T009B_NOTFOUND = 3

OTHERS = 4.

per = fper.

yr = fyr.

do.

clear period.

period-yr = yr.

period-per = per.

CALL FUNCTION 'FIRST_DAY_IN_PERIOD_GET'

EXPORTING

I_GJAHR = yr

I_PERIV = 'Z1'

I_POPER = per

IMPORTING

E_DATE = period-stdat

EXCEPTIONS

INPUT_FALSE = 1

T009_NOTFOUND = 2

T009B_NOTFOUND = 3

OTHERS = 4.

CALL FUNCTION 'LAST_DAY_IN_PERIOD_GET'

EXPORTING

I_GJAHR = yr

I_PERIV = 'Z1'

I_POPER = per

IMPORTING

E_DATE = period-endat

EXCEPTIONS

INPUT_FALSE = 1

T009_NOTFOUND = 2

T009B_NOTFOUND = 3

OTHERS = 4.

append period to periods.

if per = 12.

add 1 to yr.

per = 1.

else.

add 1 to per.

endif.

if yr = tyr and per > tper.

exit.

endif.

if yr > tyr.

exit.

endif.

enddo.

ENDFORM. " populate_periods

----


FORM populate_value_tab .

clear value_row.

value_row-date = date_from.

do.

if value_row-date > date_to.

exit.

endif.

loop at periods into period

where stdat le value_row-date and

endat ge value_row-date.

value_row-period = period-per.

endloop.

append value_row to value_tab.

add 1 to value_row-date.

clear value_row-period.

enddo.

ENDFORM. " populate_value_tab

Former Member
0 Kudos
126

Thanks a lot for your answers.

Only to clarify, what i need is a search-help that allows me to chose from a period (from - to).

Example:

I have a field Sales Order Number for example. When i press F4 in that field i want that appears a search help with a field Date: with 2 areas. One for 'From' and another one 'To'. I never saw in standard 2 areas for a same field in a search help.

Thanks

BR

Former Member
0 Kudos
126

unanswered

Former Member
0 Kudos
126

Oh, I get what you want, I think.

When your search help is used, a dialog box appears.

In this dialog box, there is a date field - just like a date-parameter on a selection screen.

But you want something more like a select-option for the date.

For example, you would like the dialog box to have both a from-date parameter and a to-date parameter (both for the same database date field).

Is that correct?

John

0 Kudos
126

Yes, is that!!

Former Member
0 Kudos
126

OK, it can be done. I think your requirement could be of wide interest.

I made a little demo search help called YVBRK for billing-document number that selects by range of billing date.

In SE10, I created YVBRK. It has:

selection method VBRK (simply the database table for billing-document header);

dialog type 'Dialog with value restriction' (to get a dialog box);

search-help exit Y_VBRK_F4_EXIT (described below);

search-help parameters VBELN, KUNAG (sold-to), FKDAT1 (data element YFKDAT1 - from-date), FKDAT2 (data element YFKDAT2 - from-date) and FKDAT (billing date);

IMP and EXP are checked for VBLEN only;

hit-list 1,2,3 are VBELN, KUNAG, FKDAT;

dialog-box 1,2,3 are KUNAG, FKDAT1, FKDAT2.

Understandably, there are warning messages.

In SE10, I created the data elements FKDAT1 and FKDAT2 with the descriptions / field labels that I wanted YVBRK to use ('Billing-date from', 'Billing-date to').

In SE37, I copied the FM F4IF_SHLP_EXIT as Y_VBRK_F4_EXIT, which I then amended. You need to copy the global data from F4IF_SHLP_EXIT into your own global data.

Then I amended the source code of Y_VBRK_F4_EXIT to:

FUNCTION Y_VBRK_F4_EXIT.

*"----


""Local interface:

*" TABLES

*" SHLP_TAB TYPE SHLP_DESCR_TAB_T

*" RECORD_TAB STRUCTURE SEAHLPRES

*" CHANGING

*" VALUE(SHLP) TYPE SHLP_DESCR_T

*" VALUE(CALLCONTROL) LIKE DDSHF4CTRL STRUCTURE DDSHF4CTRL

*"----


data:

selopt1 type DDSHSELOPT,

selopt2 type DDSHSELOPT.

IF CALLCONTROL-STEP = 'SELECT'.

  • construct select-option for FKDAT

selopt2-shlpname = 'YVBRK'.

selopt2-shlpfield = 'FKDAT'.

selopt2-sign = 'I'.

selopt2-option = 'BT'.

  • from-date

read table shlp-selopt into selopt1

with key shlpname = 'YVBRK'

shlpfield = 'FKDAT1'.

if sy-subrc eq 0.

selopt2-low = selopt1-low.

else.

clear selopt2-low.

endif.

  • to-date

read table shlp-selopt into selopt1

with key shlpname = 'YVBRK'

shlpfield = 'FKDAT2'.

if sy-subrc eq 0.

selopt2-high = selopt1-low.

else.

selopt2-high = '99991231'.

endif.

append selopt2 to shlp-selopt.

ENDIF.

ENDFUNCTION.

This creates a select-option for FKDAT based on those for FKDAT1 and FKDAT2.

The select-options for FKDAT1 and FKDAT2 do not have to be deleted, as they have no effect when selecting from VBRK.

John

Former Member
0 Kudos
126

Hi,

An obvious point that I should have mentioned before:

As an example take the billing-document search-help in transaction VF03.

Suppose you want to select for a range of billing dates.

In the search-help selection tab, focus on billing-date by clicking on that field.

Click on the "Multiple selection" button. It is at the foot of the tab, to the right of the green tick.

In the frame headed "Area; Billing date", enter the required date-range.

Click the tick.

Enter you other selection criteria.

Click the tick.

John