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: 

Check field in a select-opton

Former Member
0 Kudos

Hi, is there anyone that can help me to solve this problem?

I have 2 seach field in a report,

Filed 1 and field 2

The user put in a value in field 1, the search in field 2 i dependet of what the user have put in into field 1, so, when the user press PF4 in field 2, different value will show up (dependent of value in field 1).

That is no problem if the user press enter between or run the program but if he/she fill in value in field 1 and then directly press PF4 in field 2, there is no value in the SO-table from field 1.

How to check the value?? Please help...

BR//

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Did you try using the FM DYNP_VALUES_READ in your F4 handling for the second field ? That would give you the value of Field 1 before the actual PAI data-transfer.

Regards,

Anand Mandalika.

10 REPLIES 10

Former Member
0 Kudos

Hi,

Did you try using the FM DYNP_VALUES_READ in your F4 handling for the second field ? That would give you the value of Field 1 before the actual PAI data-transfer.

Regards,

Anand Mandalika.

0 Kudos

Hi Anand it seems to work ok but the problem is now when you have a range or multiple selections.

//BR Janne

0 Kudos

Hello Janne,

In case you have got a select-options on the screen, then all you need to do is use the select-options' LOW as the field name. For example, in the earlier code sample, if P_1 were to be a SELECT-OPTIONS, the code would be something like this :

tables t001.
select-options p_1 for t001-bukrs.
.
.
.
.
.
.

  perform read_field using    'P_1-LOW'
                     changing field_value.

Is that your requirement? Or do you expect the entire Selection Table to be available to you in your program?

Regards,

Anand Mandalika.

P.S. If the answers have helped you, please reward the responses you get appropriately.

0 Kudos

Hi Anad

Thank for your help but I have to take care of all values in the selection table, so, this works fine with a single value but if you must take care of all values from field 1 is it still a problem, I only get one value.

BR//Janne

0 Kudos

Hello Janne,

Now isn't that pretty much straightforward? The moment the user hits the multiple-selections button on the screen, the values of the selection table are available in the program directly. Because, the PAI will get triggerred in this case.

I hope you're able to see the point. Look at this code :


at selection-screen on value-request for p_2.
  
  if P_1 is initial.
    perform read_field using    'P_1'
                       changing field_value.
    message i398(00)  with FIELD_VALUE .
  else.
*  If the user had entered multiple selections, then the 
*  values are available directly in the selection table. 
*  You do not need to call the DYNP_VALUES_READ in this 
*  case.    
     loop at P_1.
       message i398(00) with P_LOW.
  endif.

Please do get back if you have further doubts. Also please close this thread and reward all the responses that have proved to be helpful to you.

Regards,

Anand Mandalika.

0 Kudos

Hi Anand

It works fine, I done a "cut and paste" error...

Thanks for your support.

BR//Janne

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi ,

Create search help which consists of field1 and field2.

Then attach that search help in selection screen of field2.

Regards,

J.Jayanthi

Former Member
0 Kudos

Hi,

I don't see a real need to create a search help in this case. Here's the sample code which demonstrates the usage of the above Function Module. Besides, the FM itself has very good documentation. I would encourage you to go ahead and read that.

REPORT  ZANAND_TEST.

parameters: p_1 type n,
            p_2 type i.

data:  field_value type DYNFIELDVALUE.

at selection-screen on value-request for p_2.

  perform read_field using    'P_1'
                     changing field_value.

  message i398(00)  with FIELD_VALUE .

*&---------------------------------------------------------------------*
*&      Form  read_field
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_FIELD_NAME   text
*      <--P_FIELD_VALUE  text
*----------------------------------------------------------------------*
form read_field  using    value(p_fieldname)
                 changing p_field_value.

  data: dyname like d020s-prog value 'ZANAND_TEST',
        dynumb like d020s-dnum value '1000'.

  data: begin of dynpfields occurs 3.
        include structure dynpread.
  data: end of dynpfields.

  move p_fieldname to dynpfields-fieldname.
  append dynpfields.

  call function 'DYNP_VALUES_READ'
       exporting
            dyname               = dyname
            dynumb               = dynumb
            translate_to_upper   = 'X'
       tables
            dynpfields           = dynpfields
       exceptions
            invalid_abapworkarea = 01
            invalid_dynprofield  = 02
            invalid_dynproname   = 03
            invalid_dynpronummer = 04
            invalid_request      = 05
            no_fielddescription  = 06
            undefind_error       = 07.

  read table dynpfields index 1.

  move dynpfields-fieldvalue to p_field_value.


endform.                    " read_field

You might want to comment out the PERFORM statement and observe the current behaviour of your report.

Regards,

Anand Mandalika.

Former Member
0 Kudos

Use FM 'F4IF_INT_TABLE_VALUE_REQUEST'.

The internal table VALUE_TAB will have to be populated with the values that has to be displayed when you press F4. The logic to fill this internal table has to be coded by you. and you will have

select field2 from <table> where field1 in <sel_opt_for_field1>.

The Fm has to eb called in the F4 event.

0 Kudos

Hi,

Here is the sample coding for the function module F4IF_INT_TABLE_VALUE_REQUEST.

F4IF_INT_TABLE_VALUE_REQUEST:F4 help that returns the values selected in an internal table. Very handy when programming your very own F4 help for a field.

Example:

data:

begin of t_values occurs 2,

value like kna1-begru,

end of t_values,

t_return like ddshretval occurs 0 with header line.

t_values = 'PAR*'.

append t_values.

t_values = 'UGG'.

append t_values.

call function 'F4IF_INT_TABLE_VALUE_REQUEST'

exporting

retfield = 'BEGRU'

value_org = 'S'

tables

value_tab = t_values

return_tab = t_return

exceptions

parameter_error = 1

no_values_found = 2

others = 3.

if sy-subrc = 0.

read table t_return index 1.

o_begru-low = t_return-fieldval.

if o_begru-low = 'PAR*'.

o_begru-option = 'CP'.

else.

o_begru-option = 'EQ'.

endif.

o_begru-sign = 'I'.

append o_begru to s_begru.

else.

o_begru = i_begru.

endif.