Application Development and Automation 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: 
Read only

selection screen

Former Member
0 Likes
639

HI,

i have the material number in the selection screen ..when i select the material number i want to display the material description in same line ...

How can i achieve it?

Regards

BAlu

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
619

You can do it like this.




report zrich_0002 .

selection-screen begin of line.
selection-screen comment (20) matnr.
parameters: p_matnr type mara-matnr.
selection-screen comment (40) maktx.
selection-screen end of line.

at selection-screen output.
matnr = 'Material Number'.
if maktx is initial.
  select single maktx into maktx
         from makt
        where matnr = p_matnr
          and spras = sy-langu.
 endif.


at selection-screen on value-request for p_matnr.


data: dynfields type table of dynpread with header line.
data: return type table of ddshretval with header line.


  call function 'F4IF_FIELD_VALUE_REQUEST'
       exporting
            tabname           = 'MARA'
            fieldname         = 'MATNR'
            dynpprog          = sy-cprog
            dynpnr            = sy-dynnr
            dynprofield       = 'P_MATNR'
       tables
            return_tab        = return
       exceptions
            field_not_found   = 1
            no_help_for_field = 2
            inconsistent_help = 3
            no_values_found   = 4
            others            = 5.

  read table return with key fieldname = 'P_MATNR'.

* Add it back to the dynpro.
  dynfields-fieldname = return-retfield.
  dynfields-fieldvalue =  return-fieldval.
  append dynfields.


  clear dynfields.
  dynfields-fieldname = 'MAKTX'.
  call function 'CONVERSION_EXIT_ALPHA_INPUT'
    exporting
      input         = return-fieldval
    IMPORTING
      OUTPUT        = p_matnr.

  select single maktx into dynfields-fieldvalue
         from makt
        where matnr = p_matnr
          and spras = sy-langu.
  append dynfields.


* Update the dynpro values.
  call function 'DYNP_VALUES_UPDATE'
       exporting
            dyname     = sy-cprog
            dynumb     = sy-dynnr
       tables
            dynpfields = dynfields
       exceptions
            others     = 8.

start-of-selection.

This will also handle if you do F4 help on the MATNR field, and select a material, the description will be filled in automatically.

Regards,

Rich Heilman

7 REPLIES 7
Read only

Former Member
0 Likes
619

Hi Balu,

Do you want to display the description as a comment with the parameter??

Like :

Material Number 000001, On pressing enter the desc. comes in line as:

Material Number 000001 Material 1

Thanks and Best Regards,

Vikas Bittera.

Read only

Former Member
0 Likes
619

Sure, but you should need to modify the Search Help....Or you can use this FM...

<b>F4IF_INT_TABLE_VALUE_REQUEST</b>

Greetings,

Blag.

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
620

You can do it like this.




report zrich_0002 .

selection-screen begin of line.
selection-screen comment (20) matnr.
parameters: p_matnr type mara-matnr.
selection-screen comment (40) maktx.
selection-screen end of line.

at selection-screen output.
matnr = 'Material Number'.
if maktx is initial.
  select single maktx into maktx
         from makt
        where matnr = p_matnr
          and spras = sy-langu.
 endif.


at selection-screen on value-request for p_matnr.


data: dynfields type table of dynpread with header line.
data: return type table of ddshretval with header line.


  call function 'F4IF_FIELD_VALUE_REQUEST'
       exporting
            tabname           = 'MARA'
            fieldname         = 'MATNR'
            dynpprog          = sy-cprog
            dynpnr            = sy-dynnr
            dynprofield       = 'P_MATNR'
       tables
            return_tab        = return
       exceptions
            field_not_found   = 1
            no_help_for_field = 2
            inconsistent_help = 3
            no_values_found   = 4
            others            = 5.

  read table return with key fieldname = 'P_MATNR'.

* Add it back to the dynpro.
  dynfields-fieldname = return-retfield.
  dynfields-fieldvalue =  return-fieldval.
  append dynfields.


  clear dynfields.
  dynfields-fieldname = 'MAKTX'.
  call function 'CONVERSION_EXIT_ALPHA_INPUT'
    exporting
      input         = return-fieldval
    IMPORTING
      OUTPUT        = p_matnr.

  select single maktx into dynfields-fieldvalue
         from makt
        where matnr = p_matnr
          and spras = sy-langu.
  append dynfields.


* Update the dynpro values.
  call function 'DYNP_VALUES_UPDATE'
       exporting
            dyname     = sy-cprog
            dynumb     = sy-dynnr
       tables
            dynpfields = dynfields
       exceptions
            others     = 8.

start-of-selection.

This will also handle if you do F4 help on the MATNR field, and select a material, the description will be filled in automatically.

Regards,

Rich Heilman

Read only

0 Likes
619

Thanq Rich,

but if select one material number the description is coming ...after that if i entered wrong material number the description should b clear.....

Plz help me

Regards

BAlu

Read only

0 Likes
619

Ok, so just modify this event as you see below.



at selection-screen output.
clear maktx.
matnr = 'Material Number'.
  select single maktx into maktx
         from makt
        where matnr = p_matnr
          and spras = sy-langu.


Regards,

Rich Heilman

Read only

0 Likes
619

HI,

still its not clearing?

Read only

0 Likes
619

Please add this piece of code in richs code.

AT SELECTION-SCREEN OUTPUT.
  MATNR = 'Material Number'.

  SELECT SINGLE MAKTX INTO MAKTX
         FROM MAKT
        WHERE MATNR = P_MATNR
          AND SPRAS = SY-LANGU.

<b>  IF SY-SUBRC <> 0.
    CLEAR MAKTX.
  ENDIF.</b>

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_MATNR.

Hope this helps.

Shreekant