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: 

how to use match code for variant input parameter field?

former_member396478
Participant
0 Kudos

Hi all,

Before posting my question, I searched a lot for my requirement, but i am not getting exact solution,

few links referred in sdn, but not helping me ,

http://scn.sap.com/thread/1084156http://scn.sap.com/thread/905304

In my report,

I have a parameter in selection screen.

pa_var like disvariant-variant.

And i used this function module 'REUSE_ALV_VARIANT_F4' to fill my gs_variant only inside f4_variant_help,

But if user write something inside pa_var without using the help?

I understand that need to define match code for my variant parameter

How i need to use match code for this parameter? Any standard match code available or i need to create custom match code?

have idea on defining match code for standard table fields, but not for variant!.

Could you please guide me!.

Thanks,

Regards

Kannan

5 REPLIES 5

PeterJonker
Active Contributor
0 Kudos

I am not sure what your requirement is, but I can answer the question;

"But if user write something inside pa_var without using the help?"

The program will use this value.

It is called a search HELP, and is used to HELP the user find an input. The user does not HAVE TO use the search help.

If you want to check the user input, you can do this in event AT SELECTION-SCREEN ON <fieldname> or in event AT SELECTION-SCREEN.

You can check the following sample program for more info :

BCALV_TEST_LIST_LAYOUT

arindam_m
Active Contributor
0 Kudos

Hi,

Why dont you create your custom matchcode. Check the below link to get started:

http://help.sap.com/saphelp_40b/helpdata/EN/cf/21ef1f446011d189700000e8322d00/content.htm

Cheers,

Arindam

raymond_giuseppi
Active Contributor
0 Kudos

I don't understand you requirement, you already managed the search help with REUSE_ALV_VARIANT_F4. If you want to check existence of user input, call REUSE_ALV_VARIANT_EXISTENCE

* Search help

at selection-screen on value-request for variant.

  is_variant-variant = variant.

  is_variant-report = sy-repid.

  call function 'REUSE_ALV_VARIANT_F4'

    exporting

      is_variant         = is_variant

      i_save             = 'A'

      i_display_via_grid = 'X'

    importing

      es_variant         = is_variant

    exceptions

      not_found          = 1

      program_error      = 2

      others             = 3.

  if sy-subrc = 0.

    variant = is_variant-variant.

  endif.

* Input check

at selection-screen on variant.

  is_variant-variant = variant.

  is_variant-report = sy-repid.

  check is_variant-variant is not initial.

  call function 'REUSE_ALV_VARIANT_EXISTENCE'

    exporting

      i_save        = 'A'

    changing

      cs_variant    = is_variant

    exceptions

      wrong_input   = 1

      not_found     = 2

      program_error = 3

      others        = 4.

  if sy-subrc ne 0.

    message e204(0k) with is_variant-variant.

  endif.

Regards,

Raymond

0 Kudos

Hi Guiseppi,

Thanks for your support.

my client advised to use match code object in parameter input field.

pa_var like disvariant-variant.

i looked one more solution , given by you earlier in some other discussion

"

  • Check table LTDX with variant and report name, from this table you will get also handle, user name and other key required by existence check modules.
  • Insure that in REUSE_ALV_VARIANT_SELECT/REUSE_ALV_VARIANT_EXISTENCE (F4, check) or LVC_VARIANT_SELECT/LVC_VARIANT_EXISTENCE_CHECK you pass the correct value for type (user dependant or not)"

http://scn.sap.com/thread/3317515

for using match code in my report, should i create search help based on ltdx table? or any standard search help available

could you please guide me

Thanks

Regards

former_member300076
Participant
0 Kudos

Hi,

Try using the FM LVC_VARIANT_F4 AT SELECTION-SCREEN ON VALUE REQUEST FOR pa_var.

Here some code:

AT SELECTION-SCREEN ON VALUE-REQUEST FOR pv_varnt.
  
PERFORM variant_f4  CHANGING pv_varnt.

*&---------------------------------------------------------------------*
*&      Form  VARIANT_F4
*&---------------------------------------------------------------------*
FORM variant_f4  CHANGING pv_varnt TYPE slis_vari.
   DATA :ls_varnt   TYPE disvariant.


   ls_varnt-report                 = sy-repid.

   CALL FUNCTION 'LVC_VARIANT_F4'
     EXPORTING
       is_variant                  = ls_varnt
       i_save                      = 'A'
     IMPORTING
       es_variant                  = ls_varnt
     EXCEPTIONS
       not_found                   = 1
       program_error               = 2
       OTHERS                      = 3.

   IF sy-subrc EQ 0.
     pv_varnt                      = ls_varnt-variant.
   ENDIF.

ENDFORM.                    " VARIANT_F4


Regards

Sam,