Skip to Content
avatar image
Former Member

At selection screen on value request

Hi ,

Iam having a select-option. Instead of F4 i have to select data from a database table.

eg.

select-option : ccg for setnode-setname.

After selecting data from setnode table with respect to some condition, how can i place the selected values in the select-option field . can anyone explaim me on this.

Regards,

Phyrose.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • avatar image
    Former Member
    Oct 10, 2007 at 06:19 AM

    Hi,

    You need to use the FM F4IF_INT_TABLE_VALUE_REQUEST. plese see the sample code below. i have build the F4 manullay. you can build it using the databse .

    DATA: lt_retval TYPE STANDARD TABLE OF ddshretval,

    ls_retval LIKE ddshretval,

    lt_dynmap TYPE STANDARD TABLE OF dselc,

    ls_dynmap TYPE dselc,

    dynp_values TYPE STANDARD TABLE OF dynpread ,

    wa_dynp_values TYPE dynpread,

    lt_values TYPE TABLE OF seahlpres,

    lt_fields TYPE TABLE OF dfies,

    ls_field TYPE dfies,

    ls_return TYPE ddshretval.

    CLEAR ls_field.

    ls_field-fieldname = 'SKILLS'.

    ls_field-intlen = 15.

    ls_field-leng = 15.

    ls_field-outputlen = 15.

    ls_field-scrtext_m = 'SKILLS AVALIABLE'.

    APPEND ls_field TO lt_fields.

    CLEAR ls_field.

    ls_field-fieldname = 'DESCRIPTION'.

    ls_field-intlen = 25.

    ls_field-leng = 25.

    ls_field-outputlen = 25.

    ls_field-scrtext_m = 'DESCRIPTION'.

    APPEND ls_field TO lt_fields.

    PERFORM fill_values USING 'C' 'C programming'.

    PERFORM fill_values USING 'C+' 'C+ Programming'.

    PERFORM fill_values USING 'ABAP' 'ABAP Language'.

    PERFORM fill_values USING 'JAVA' 'JAVA programming'.

    PERFORM fill_values USING 'SAP SCRIPT' 'Working with SAP Scripts'.

    PERFORM fill_values USING 'SMART FORMS' 'Smart forms'.

    CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

    EXPORTING

    • DDIC_STRUCTURE = 'VTTK'

    retfield = 'SKILLS'

    • PVALKEY = ' '

    dynpprog = sy-repid

    • DYNPNR = '0100'

    • DYNPROFIELD = 'P_SKILLS'

    • STEPL = 0

    • WINDOW_TITLE =

    • VALUE = ' '

    • VALUE_ORG = 'S'

    • MULTIPLE_CHOICE = ' '

    • DISPLAY = ' '

    • CALLBACK_PROGRAM = ' '

    • CALLBACK_FORM = ' '

    • MARK_TAB =

    • IMPORTING

    • USER_RESET =

    TABLES

    value_tab = gt_values

    field_tab = lt_fields

    return_tab = lt_retval

    • DYNPFLD_MAPPING = Lt_dynmap

    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.

    CLEAR ls_retval.

    READ TABLE lt_retval INTO ls_retval INDEX 1.

    MOVE ls_retval-fieldval TO p_skills.

    REFRESH gt_values[].

    ENDFORM. " f4_help_for_skills

    &----


    *& Form fill_values

    &----


    • text

    ----


    • --->P_0290 Skill

    ----


    FORM fill_values USING pa_value

    pa_desc.

    DATA ls_values TYPE seahlpres.

    CLEAR ls_values.

    ls_values-string = pa_value.

    APPEND ls_values TO gt_values.

    CLEAR ls_values.

    ls_values-string = pa_desc.

    APPEND ls_values TO gt_values.

    ENDFORM. " fill_values<b></b><b></b><b></b>

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 10, 2007 at 06:19 AM

    Hi Phyrose,

    Use FM F4IF_INT_TABLE_VALUE_REQUEST.

    Search forum using this FM you will get lots of sample code.

    Regards,

    Atish

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 10, 2007 at 06:22 AM

    Hi Camila,

    For this you have to use the event.

    <i>

    AT SELECTION-SCREEN ON VALUE-REQUEST FOR <Selection screen field name>
      PERFORM GET_DATA USING <Selection screen field name>

    Then Write the logic to fetch the data in the subroutine.</i>

    <b>Below is the sample code:</b>

    AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_REVNR-HIGH.
    
      PERFORM GET_REVISION_NUMBER USING 'S_REVNR-HIGH' 'REVNR'.
    
    
    *&---------------------------------------------------------------------*
    *&      Form  GET_REVISION_NUMBER
    *&---------------------------------------------------------------------*
    *       F4 Lookup for Revision Service Order revision
    *----------------------------------------------------------------------*
    *      -->P_0123   fieldname
    *      -->P_0124   fieldtype
    *----------------------------------------------------------------------*
    FORM GET_REVISION_NUMBER USING
                  VALUE(FIELD_NAME) LIKE  HELP_INFO-DYNPROFLD
                  VALUE(FIELD_TYPE) LIKE  DFIES-FIELDNAME.
    
      DATA: I_RETURN TYPE DDSHRETVAL OCCURS 0 WITH HEADER LINE.
    
      DATA: BEGIN OF I_REV OCCURS 0,
               REVNR LIKE T352R-REVNR,
            END   OF I_REV.
      DATA: V_S TYPE C VALUE 'S'.
      IF I_REV[] IS INITIAL.
        SELECT REVNR
               INTO TABLE I_REV
               FROM T352R.
        SORT I_REV BY REVNR.
        DELETE ADJACENT DUPLICATES FROM I_REV COMPARING REVNR.
      ENDIF.
    
      CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
        EXPORTING
          RETFIELD        = FIELD_TYPE
          DYNPPROG        = SY-REPID
          DYNPNR          = SY-DYNNR
          DYNPROFIELD     = FIELD_NAME
          VALUE_ORG       = V_S
        TABLES
          VALUE_TAB       = I_REV
          RETURN_TAB      = I_RETURN
        EXCEPTIONS
          PARAMETER_ERROR = 1
          NO_VALUES_FOUND = 2
          OTHERS          = 3.
      IF SY-SUBRC = 0.
      ENDIF.
    
    ENDFORM.                    " GET_REVISION_NUMBER

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 10, 2007 at 06:24 AM

    Hi

    you can do it like this

    creat a structure what ever values you want from that database table

    like this

    TYPES : BEGIN OF ST_OBJID_SH,

    OTYPE TYPE HRP1000-OTYPE,

    OBJID TYPE HRP1000-OBJID,

    END OF ST_OBJID_SH.

    DATA : IT_OBJID_SH TYPE STANDARD TABLE OF ST_OBJID_SH.

    DATA : WA_OBJID_SH TYPE ST_OBJID_SH.

    write the logic like this

    on what condition do you want for that select-option

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

    • IF S_OBJID IS NOT INITIAL.

    SELECT OTYPE OBJID FROM HRP1000

    INTO TABLE IT_OBJID_SH

    WHERE OTYPE = 'D'.

    IF SY-SUBRC EQ 0.

    • SEARCH HELP FOR QUALIFICATION.

    CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

    EXPORTING

    • DDIC_STRUCTURE = ' '

    RETFIELD = 'OBJID'

    • PVALKEY = ' '

    DYNPPROG = SY-REPID

    DYNPNR = SY-DYNNR

    DYNPROFIELD = 'S_OBJID'

    • STEPL = 0

    • WINDOW_TITLE =

    • VALUE = ' '

    VALUE_ORG = 'S'

    • MULTIPLE_CHOICE = ' '

    • DISPLAY = ' '

    • CALLBACK_PROGRAM = ' '

    • CALLBACK_FORM = ' '

    • MARK_TAB =

    • IMPORTING

    • USER_RESET =

    TABLES

    VALUE_TAB = IT_OBJID_SH

    • FIELD_TAB =

    • RETURN_TAB = RETURN_TAB

    • DYNPFLD_MAPPING =

    • 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.

    .

    <b>reward if usefull</b>

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 10, 2007 at 06:25 AM

    Hi Camila,

    Use the below code.

    tables: setnode.

    DATA: BEGIN OF it_setname OCCURS 0,

    setname LIKE t001k-bwkey,

    END OF it_setname.

    SELECTION-SCREEN: BEGIN OF BLOCK main WITH FRAME TITLE text-001.

    select-options : ccg for setnode-setname.

    SELECTION-SCREEN END OF BLOCK main.

    *----


    • Validation Section

    *----


    INITIALIZATION.

    SELECT DISTINCT setname FROM setnode INTO TABLE it_setname.

    AT SELECTION-SCREEN ON VALUE-REQUEST FOR ccg-low.

    CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

    EXPORTING

    retfield = 'SETNAME'

    dynpprog = sy-repid

    dynpnr = sy-dynnr

    dynprofield = 'CCG'

    value_org = 'S'

    TABLES

    value_tab = it_setname

    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.

    AT SELECTION-SCREEN ON VALUE-REQUEST FOR ccg-high.

    CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

    EXPORTING

    retfield = 'SETNAME'

    dynpprog = sy-repid

    dynpnr = sy-dynnr

    dynprofield = 'CCG'

    value_org = 'S'

    TABLES

    value_tab = it_setname

    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.

    Add comment
    10|10000 characters needed characters exceeded