Skip to Content
author's profile photo
Former Member

F4 Help on one field should populate data on another field

Dear All....

I am using the FM - F4IF_INT_TABLE_VALUE_REQUEST for F4 help on one field of the selection screen. Based on the selected value, a values corresponding to it should appear on another field.

My Code -

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_svn.

SELECT qmnum serialnr

INTO TABLE t_qmel

FROM qmel

WHERE qmart = 'ZD'.

SORT t_qmel BY qmnum.

  • Display the f4 Help Values for SVN

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

retfield = 'QMNUM'

dynpprog = sy-repid

dynpnr = sy-dynnr

dynprofield = 'P_SVN'

window_title = text-015

value_org = 'S'

TABLES

value_tab = t_qmel

return_tab = t_retval.

READ TABLE t_retval INTO w_retval_wa INDEX 1.

IF sy-subrc = 0.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = w_retval_wa-fieldval

IMPORTING

output = w_qmel_wa-qmnum.

w_retval_wa-fieldval = w_qmel_wa-qmnum.

READ TABLE t_qmel INTO w_qmel_wa WITH KEY qmnum = w_retval_wa-fieldval

BINARY SEARCH.

IF sy-subrc = 0.

p_esn = w_qmel_wa-serialnr.

ENDIF.

ENDIF.

But this is however not working.

Please let me know where I am going wrong.

I have serached SDN thoroghly but could not get my solution.

Please guide me....

Regards,

Pankaj Agarwal.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

10 Answers

  • Best Answer
    author's profile photo
    Former Member
    Mar 24, 2009 at 08:36 AM

    Thanks to all for their Inputs.

    I have got the solution for my requirement, sharing the same for future reference...

    We can use the "CallBack_Form" functionality of the FM - F4IF_INT_TABLE_VALUE_REQUEST, which has numerous options to modify and enhance your F4 Help. The Documentation of this FM is very nicely maintained which gives all detialed information.

    I am able to populate the corresponding column value to the second Input Field on the Selection Screen, using the same as said above.

    Once Again...Thanks to all....

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Mar 23, 2009 at 10:43 AM

    call f4 again and transport this values to another field

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 23, 2009 at 10:44 AM

    my understanding about your req is :

    if you select a value in the first field , then a correspoding value should appear in the second field. or another input field.

    For this kind of requirement , apart from using f4_*_request. you should try to implment / create a search help exit.

    In that exit, write a piece of code how you should populate value for the second input filed.

    Plz try writing exit for the search help.... search ideas pertaining to this.

    Thanks,

    Uma

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Thanks Tarun / Suhas,

      Uma, can you guide me how will Search Help Exit serve the purpose.

      I have created Search Helps but never used Search Help Exits.

      Currently I am will satisfy myself by pressing enter and then populating the value in the second inout field.

      But this will be a good learning if we can avoid the use of pressing enter and populate the value.

      Regards,

      Pankaj Agarwal.

  • Mar 23, 2009 at 10:50 AM

    u can use the functioncode for this.

    assign a function code 'CODE1' for the 1st field.

    if fcode = 'CODE1'

    write the logic for populating the second field with the required value.

    endif.

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Mar 23, 2009 at 10:51 AM

    1. Dont pass sy-repid directly, pass it as local variable or direct program name

    2. the value in the t_qmel table and conversion value of p_svn are different

    3. Finally assigning getting value into some other input parameter p_esn something..but it does not allow assign getting value into another screen parameter p_esn with in the p_svn. copy teh return value into the local variable and after that (out of the p_esn) reassign the same value into p_esn.

    check all these, let me know wht is stopping u and where?

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Mar 23, 2009 at 10:55 AM

    Hello,

    check whether the slect query is fetching any data 1st....

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 23, 2009 at 10:57 AM

    Hi,

    Refer this demo code to get a S.help for BELNR based on user input for BUKRS:-

    PARAMETERS : p_belnr TYPE belnr,
                 p_bukrs TYPE bukrs.
     
    DATA : BEGIN OF itab OCCURS 0,
             belnr TYPE belnr,
           END OF itab.
     
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_belnr.
     
      PERFORM f4_belnr_help USING p_belnr.
     
    *&---------------------------------------------------------------------*
    *&      Form  f4_belnr_help
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *      -->P_BELNR text
    *----------------------------------------------------------------------*
    FORM f4_belnr_help USING p_belnr.
     
      DATA : itab TYPE STANDARD TABLE OF it WITH HEADER LINE,
             tb_dynpfields LIKE dynpread OCCURS 0 WITH HEADER LINE,
             v_bukrs TYPE bukrs.
     
      CLEAR:   tb_dynpfields.
      REFRESH: tb_dynpfields.
     
      MOVE 'P_BUKRS' TO tb_dynpfields-fieldname.
      APPEND tb_dynpfields.
     
      CALL FUNCTION 'DYNP_VALUES_READ'
        EXPORTING
          dyname                               = 'Z_F4' "program name
          dynumb                               = '1000' "screen number
        TABLES
          dynpfields                           = tb_dynpfields
        EXCEPTIONS
          INVALID_ABAPWORKAREA                 = 1
          INVALID_DYNPROFIELD                  = 2
          INVALID_DYNPRONAME                   = 3
          INVALID_DYNPRONUMMER                 = 4
          INVALID_REQUEST                      = 5
          NO_FIELDDESCRIPTION                  = 6
          INVALID_PARAMETER                    = 7
          UNDEFIND_ERROR                       = 8
          DOUBLE_CONVERSION                    = 9
          STEPL_NOT_FOUND                      = 10
          OTHERS                               = 11.
     
      IF sy-subrc  0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
     
      READ TABLE tb_dynpfields INDEX 1.
      IF sy-subrc EQ 0.
        v_bukrs = tb_dynpfields-fieldvalue.
      ENDIF.
     
      SELECT belnr from <db_table> INTO TABLE itab WHERE bukrs = v_bukrs.
      CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
        EXPORTING
          retfield               = 'BELNR' "internal table field
          dynpprog               = 'Z_F4' "program name
          dynpnr                 = '1000' "screen number
          dynprofield            = 'P_BELNR' "screen field name
          value_org              = 'S'
        TABLES
          value_tab              = itab "internal table
        EXCEPTIONS
          PARAMETER_ERROR        = 1
          NO_VALUES_FOUND        = 2
          OTHERS                 = 3.
     
      IF sy-subrc  0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
     
    ENDFORM.                    " f4_belnr_help
    

    Hope this helps you.

    Regards,

    Tarun

    Add comment
    10|10000 characters needed characters exceeded

    • Hi,

      >

      > Tarun,

      >

      > Your code will work when one will press F4 on the second input field.

      > My requirement is that when the user presses F4 on the first input field and gets its relevant data, another value corresponding to the selected data should get populated at the same time on another input field, at the same time.

      I guess you cant fetch these values simultaneously. You need to select F4 on the first field and select a value and hit enter to fill value in the next field corresponding to the field1 value.

      Include a query in AT SELECTION-SCREEN

      But make sure that only one entry exists for the field1 value, else the first value encountered will be displayed.

      In that case, you can use the code in previous reply.

      Hope this helps you.

      Regards,

      Tarun

  • Mar 23, 2009 at 10:59 AM

    Hello Pankaj,

    1. Check if the SELECT stmt is fetching any data.

    2. I can find that in the code:

    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_svn

    But you have passed value to some other param:

    p_esn = w_qmel_wa-serialnr.

    Rest i feel your code is OK.

    BR,

    Suhas

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Suhas Saha

      Suhas,

      The event AT SELECTION-SCREEN OUTPUT is not called after completion of AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_svn. We need to press Enter in order to call this AT SELECTION-SCREEN OUTPUT, which does not serve my purpose.

      I hope my purpose is clear now.

  • author's profile photo
    Former Member
    Mar 23, 2009 at 11:01 AM

    Hi friend try this code for ur requirement, it works exatly as u want.....

    SELECT-OPTIONS : CODE FOR QASE-CODE1.

    DATA: BEGIN OF INTTAB OCCURS 10,

    CODE LIKE QPCT-CODE,

    KURZTEXT LIKE QPCT-KURZTEXT,

    END OF INTTAB.

    AT SELECTION-SCREEN ON VALUE-REQUEST FOR CODE-LOW.

    SELECT CODE KURZTEXT FROM QPCT INTO TABLE INTTAB WHERE CODEGRUPPE = 'QCREMARK'.

    CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

    EXPORTING

    RETFIELD = 'CODE'

    DYNPPROG = SY-CPROG

    DYNPNR = SY-DYNNR

    DYNPROFIELD = 'CODE-LOW'

    WINDOW_TITLE = 'Select Quality Remark Code'

    VALUE_ORG = 'S'

    TABLES

    VALUE_TAB = inttab

    EXCEPTIONS

    PARAMETER_ERROR = 1

    NO_VALUES_FOUND = 2

    OTHERS = 3.

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Mar 23, 2009 at 11:22 AM

    &----


    *& AT SELECTION SCREEN ON VALUE-REQUEST FOR FIELD

    &----


    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_ebeln.

    PERFORM f4_hlp_ebeln.

    &----


    *& Form F4_HLP_EBELN

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM f4_hlp_ebeln .

    TYPES: BEGIN OF ty_ebeln,

    ebeln TYPE ebeln ,

    END OF ty_ebeln.

    DATA: lt_ebeln TYPE TABLE OF ty_ebeln.

    CLEAR: lt_ebeln[].

    SELECT ebeln

    FROM zmt_po_mic_ded

    INTO TABLE lt_ebeln.

    IF sy-subrc = 0.

    SORT lt_ebeln[] BY ebeln.

    DELETE ADJACENT DUPLICATES FROM lt_ebeln COMPARING ALL FIELDS.

    CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

    EXPORTING

    retfield = 'EBELN'

    dynpprog = sy-repid

    dynpnr = sy-dynnr

    dynprofield = 'P_EBELN'

    value_org = 'S'

    callback_program = sy-repid

    TABLES

    value_tab = lt_ebeln[]

    EXCEPTIONS

    parameter_error = 1

    no_values_found = 2

    OTHERS = 3.

    IF sy-subrc <> 0.

    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    ENDIF.

    ENDIF.

    ENDFORM. " F4_HLP_EBELN

    &----


    &----


    DATA: t_dynfields TYPE TABLE OF dynpread,

    t_valhlp TYPE TABLE OF ty_valhlp.

    DATA: w_dynfields TYPE dynpread.

    CLEAR: t_dynfields[], t_valhlp[].

    DATA: l_ebeln TYPE ebeln.

    w_dynfields-fieldname = 'P_EBELN'.

    w_dynfields-fieldvalue = p_ebeln.

    APPEND w_dynfields TO t_dynfields.

    CLEAR w_dynfields.

    CALL FUNCTION 'DYNP_VALUES_READ'

    EXPORTING

    dyname = sy-repid

    dynumb = sy-dynnr

    translate_to_upper = c_x

    TABLES

    dynpfields = t_dynfields

    EXCEPTIONS

    invalid_abapworkarea = 1

    invalid_dynprofield = 2

    invalid_dynproname = 3

    invalid_dynpronummer = 4

    invalid_request = 5

    no_fielddescription = 6

    invalid_parameter = 7

    undefind_error = 8

    double_conversion = 9

    stepl_not_found = 10

    OTHERS = 11.

    IF sy-subrc <> 0.

    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    ENDIF.

    READ TABLE t_dynfields INTO w_dynfields INDEX 1.

    IF sy-subrc = 0.

    l_ebeln = w_dynfields-fieldvalue.

    SELECT ebeln

    ebelp

    FROM ekpo

    INTO TABLE t_valhlp

    WHERE ebeln = l_ebeln.

    IF sy-subrc = 0.

    SORT t_valhlp[] BY ebeln ebelp.

      • here we get the value of ebelp depending on the selection of EBELN ***

      endif.

      ENDIF.

      Add comment
      10|10000 characters needed characters exceeded

      • Former Member

        Dear Shalini,

        Thanks for putting up so much of your effort....

        I am very much able to get the values and in much a short code as compared to yours.

        My problem is that I am unable to show this value in the Input Field of the Selection Screen.

        Again, the F4 FM will populate the value in the First Input Field.

        Based on this value I will fetch the second value, which I need to populate on another Input Filed of the Selection Screen.

        As in your code Shalini, now you have got the value of EBELN, now tell me how will you show it on the selection screen within the same event.