Skip to Content
avatar image
Former Member

Search Helps....

hello everyone,

can someone tell me how to set up a primary in search helps.

I set up a field in search help, but it has duplicate values. So when it is entered, multiple values are displayed. I'm thinking setting up a primary key would be a way to avoid this. But I don't know how to do it. I have made collective and elementary search helps in se11.

can somebody help me on this issue?

Thanks.

Regards,

Fred.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    Apr 03, 2006 at 06:00 PM

    Hi Fred,

    you need to take help of SEARCH help exits.

    and if the Search help is you want to show it in a Report or Some module pool Then you can also use the event

    (if it report)

    at selection-screen on value-request for field.

    or POV

    if it a module pool.

    and call the F4help using the FM <b>F4IF_INT_TABLE_VALUE_REQUEST</b>

    and show the search help. here you need to pass the search help data by selecting the data from table , here you can delte the duplicates and show unique records.

    REPORT  ZTESTF4                                .
    
    DATA: progname TYPE sy-repid,
          dynnum   TYPE sy-dynnr,
          dynpro_values TYPE TABLE OF dynpread,
          field_value LIKE LINE OF dynpro_values.
    
    data: begin of t_t001l occurs 0,
            werks type werks_d,
            lgort type lgort_d,
          end of t_t001l.
    
    data: v_werks type werks_d,
          V_lgort type lgort_d.
    
    
    SELECTION-SCREEN BEGIN OF BLOCK B1.
      PARAMETERS: P_PLANT LIKE MSEG-WERKS,
                  P_STOLOC LIKE MSEG-LGORT.
    SELECTION-SCREEN END OF BLOCK B1.
    
    INITIALIZATION.
      PROGNAME = SY-REPID.
      DYNNUM = SY-DYNNR.
    
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_STOLOC.
    
      CLEAR: field_value, dynpro_values. REFRESH dynpro_values.
      field_value-fieldname = 'P_PLANT'.
      APPEND field_value TO dynpro_values.
    
      CALL FUNCTION 'DYNP_VALUES_READ'
           EXPORTING
                dyname             = progname
                dynumb             = dynnum
                translate_to_upper = 'X'
           TABLES
                dynpfields         = dynpro_values.
    
      READ TABLE dynpro_values INDEX 1 INTO field_value.
    
      select werks lgort into TABLE t_T001L from T001L where werks = field_value-fieldvalue.
    
      CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
           EXPORTING
                retfield    = 'P_STOLOC'
                dynpprog    = progname
                dynpnr      = dynnum
                dynprofield = 'P_STOLOC'
                value_org   = 'S'
           TABLES
                value_tab   = t_T001L.
    
    START-OF-SELECTION.
      WRITE:/ 'TEST F4 PROGRAM'.
    END-OF-SELECTION.

    Regards

    vijay

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      hello vijay,

      thanx for the reply. I kinda see what you're saying. But my question is: Do I have to write a program to do this minor change?

      Right now, I just modified/enhanced the current SAP search help screen. I made a Z...collective search help and Z...elementary search help. I also made a Z...view which the search help is using. When I go back to the transaction, everything is working fine. The only thing is that one entry corresponds to multiple values. These values are exactly the same. The only difference is their date of creation and the end date.

      In other words, it is the same record, but since it has different dates, it pops up all of them. Can I somehow just bring up only record? Can it be done without writing a report?

      Thanks.

      Regards,

      Fred.

  • avatar image
    Former Member
    Apr 03, 2006 at 05:41 PM

    HI,

    --> You can avoid your problem with the Primary key,

    --> even you can declare more Parameters in the search help, when you press F4 then it will popup with all tha parametrs, so you can give the primary key in this parameters, so that you can select the value by the Primary key also

    see the below link, you will get the maximum info

    Elementary --> http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ee5f446011d189700000e8322d00/content.htm

    Collective --> http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ee86446011d189700000e8322d00/content.htm

    Hope this will help

    Thanks

    Sudheer

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      hi sudheer,

      the links that you gave me, they were the same ones i used to create the search helps.

      Can you please guide me how to set up the primary key, so that i can avoid duplicate records popping up for the same entry.

      Thanks.

      Regards,

      Fred.

  • Apr 03, 2006 at 06:12 PM

    Hi Fred,

    If you're using the table as method of your table you should use an exit (as copy of fm std F4IF_SHLP_EXIT_EXAMPLE ) to delete the duplicates data.

    You should insert your code at this point of your exit:

    IF CALLCONTROL-STEP = 'DISP'.
    * PERFORM AUTHORITY_CHECK TABLES RECORD_TAB USING SHLP.
    EXIT.
    ENDIF.

    Also please check this link on how to setup search help in many ways and also some sample code.

    http://fuller.mit.edu/tech/search_helps.ppt

    Hope this will help.

    Regards,

    Ferry Lianto

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 03, 2006 at 06:17 PM

    Hi fred,

    If you are creating ZZZZ search help for a field YYYY, and you want ERNAM (MARA table field --> Name of Person who Created the Object),

    In the Search help creation screen(SE11),give the name as ZZZZ, in the Search help parameter give

    1) MATNR as export(EXP = X, Lpos = 1,SPos = 1)

    2) ERSDA as export(EXP = X, Lpos = 2,SPos = 2)

    3) ERNAM as import(IMP = X, Lpos = 2,SPos = 2)

    if you assign this search help to your field, it will take the MATNR(Primary Key) and ERSDA as inputs and it will give you the ERNAM (based on the MATNR you can select the name)

    Hope this helps you

    Thanks

    Sudheer

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Fred, as Ferry suggested you can create an exit fm (see F4IF_SHLP_EXIT_EXAMPLE).

      You can use this code:

      CHECK callcontrol-step = 'DISP'.

      delete adjacent duplicates from record_tab.

      This will only remove complete duplicates though and may not work for you.

      If you can work out the offsets you need you could put something like this in:

      delete adjacent duplicates from record_tab comparing string+N(L).

      If you set a breakpoint in the fm you should be able to work out the values N and L.

      Table SHLP-FIELDDESCR holds the field details including their offsets within

      the record_tab-string and their internal lengths. For example, if SHLP-FIELDDESCR

      reveals that MATNR is at offset 4 and has INTLEN 18 you could use:

      delete adjacent duplicates from record_tab comparing string+4(18).