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

REGARDING LIST BOX

Former Member
0 Likes
975

HAI SDN MEMBERS,

IN THE GUISCREEN I HAVE TWO FIELDS ONE IS SHIPMENT TYPE AND ANOTHER ONE IS SHIPMENT PREFIX AND THE BOTH THE FIELDS ARE HAVING LIST BOXES

SHIPMENT TYPE IS P OR H

SHIPMENT PREFIX FOR 'P 'IS A,V

SHIPMENT PREFIX FOR 'H' IS VVA,

IF WE CHOOSE P IN THE FIRST LIST BOX ONLY A,V SHOULD BE ABLE TO SELECT IN THE SHIPMENTPREFIX LIST BOX

IF WE CHOOSE H IN THE FIRST LIST BOX ONLY VVA,VVS SHOULD BE ABLE TO SELECT IN SHIPMENT PREFIX LIST BOX.

CAN ANY ONE HELP ME REGARDING CODING

THANKS

ELIAS

HAI SDN MEMBERS,

IN THE GUISCREEN I HAVE TWO FIELDS ONE IS SHIPMENT TYPE AND ANOTHER ONE IS SHIPMENT PREFIX AND THE BOTH THE FIELDS ARE HAVING LIST BOXES

SHIPMENT TYPE IS P OR H

SHIPMENT PREFIX FOR 'P 'IS A,V

SHIPMENT PREFIX FOR 'H' IS VVA,

IF WE CHOOSE P IN THE FIRST LIST BOX ONLY A,V SHOULD BE ABLE TO SELECT IN THE SHIPMENTPREFIX LIST BOX

IF WE CHOOSE H IN THE FIRST LIST BOX ONLY VVA,VVS SHOULD BE ABLE TO SELECT IN SHIPMENT PREFIX LIST BOX.

CAN ANY ONE HELP ME REGARDING CODING

THANKS

ELIAS

8 REPLIES 8
Read only

Former Member
0 Likes
943

This code works as you request but for another application.

You will need this line in your Global area:


TYPE-POOLS             vrm.

This in the main body


MODULE init_0110 OUTPUT.

  REFRESH ltype_result. CLEAR ltype_result.
* Drop down values

  SELECT ltype ltypex
    INTO TABLE ltype_result
*    into ( ltype_val-key, ltype_val-text )
    FROM zlmltyp
    WHERE auth NE '9'.    "System Only
*    APPEND ltype_val TO ltype_result.
*  ENDSELECT.

* Field name to assign drop down values
  ltype_field = 'WK_LTYPE'.
  CALL FUNCTION 'VRM_SET_VALUES'
       EXPORTING
            id              = ltype_field
            values          = ltype_result
       EXCEPTIONS
            id_illegal_name = 1
            OTHERS          = 2.
  IF sy-subrc <> 0.

  ENDIF.

  IF prev_ltype NE wk_ltype.
    CLEAR: wk_status.
  ENDIF.

  REFRESH lstat_result. CLEAR lstat_result.
* Drop down values

  SELECT status statx
    INTO TABLE lstat_result
    FROM zlmstyp
    WHERE ltype = wk_ltype
      AND auth NE '9'.    "System Only

  SORT lstat_result.

* Field name to assign drop down values
  lstat_field = 'WK_STATUS'.
  CALL FUNCTION 'VRM_SET_VALUES'
       EXPORTING
            id              = lstat_field
            values          = lstat_result
       EXCEPTIONS
            id_illegal_name = 1
            OTHERS          = 2.
  IF sy-subrc <> 0.

  ENDIF.

  prev_ltype = wk_ltype.
ENDMODULE.                 " init_0110  OUTPUT

Additionally, you will need to change the Value list parm to "A" for From Program and you will need a Fuction Code on your Primary List Box

Read only

former_member196299
Active Contributor
0 Likes
943

Hi Elias ,

As per your requirement you need to fill the 2nd list box based on the selected value of 1st listbox as we can not provide control to selections of list box values . So Its better to fill the 2nd list box according to the selections made on the 1st one .

In PAI you can use this logic :

check the value of the value selected in the 1st list box .

accordingly fill the 1nd listbox .

This code sample will make you understand how to fill the listbox and retrieve values from it ..

&----


*& Report ZTRY

*&

&----


*&

*&

&----


REPORT ZTRY.

TYPE-POOLS: VRM.

DATA: NAME TYPE VRM_ID,

LIST TYPE VRM_VALUES,

VALUE LIKE LINE OF LIST.

PARAMETERS: PS_PARM(10) AS LISTBOX VISIBLE LENGTH 10.

AT SELECTION-SCREEN OUTPUT.

NAME = 'PS_PARM'.

VALUE-KEY = '1'.

Fill the list with values LINE 1 and LINE 2 .

VALUE-TEXT = 'LINE 1'.

APPEND VALUE TO LIST. VALUE-KEY = '2'.

VALUE-TEXT = 'LINE 2'.

APPEND VALUE TO LIST.

Set the dropdown list for the required screen field

CALL FUNCTION 'VRM_SET_VALUES' EXPORTING ID = NAME VALUES = LIST.

START-OF-SELECTION.

WRITE: / 'PARAMETER:', PS_PARM.

Hope this is of help .

Regards,

Ranjita

Read only

0 Likes
943

it is not a report program i have already desinged a screen for shipment type and prefix and i have table and i have draged and dropped that fields in layout

yes for report it is ok ,but i have fixed ranges for shipment type if i select p or h according i should be able to select for shipment prefix

Read only

0 Likes
943

Elias pasha, In your case what you have to do is that Set(give) Function Code for the 1st List Box. Means set Function code for the field u want to set List box. when you set Dunction code when u select the value from List box event is triggered then based on the value of the field(1st List box field), Fill up the second listbox. here is the procedure. To get Drop Drown Box on screen . Follow these steps. 1.Go to T.Code SE51 and Select Laypout for the Screen. 2.Double click on the field for which u want Dropdown box. 3.Then U will see Name ,Text ,DROPDOWN.Click on that and select List Box or ListBox with key . Better to to select first one. 4.Save and Activate ur screen . 5.Enter the following piece of code in the PBO of the screen.(Change for ur requirement). 6 Set function code to trigger event not in all cases. Check the sample code to get Listbox data.

TYPE-POOLS :vrm.
DATA:
  i_natio TYPE vrm_values, "-->Table that is passed through FM vrm_set_values
  w_natio LIKE LINE OF i_natio.
 
DATA: 
BEGIN OF i_t005t OCCURS 0,
    land1 TYPE t005t-land1,
    natio TYPE t005t-natio,
END OF i_t005t.

IF i_t005t[] IS INITIAL.
  SELECT land1 natio
     FROM t005t
       INTO TABLE i_t005t
   WHERE spras = sy-langu.
  IF sy-subrc = 0.
  LOOP AT i_t005t .
      w_natio-key = i_t005t-land1.
      w_natio-text = i_t005t-natio.
      APPEND w_natio TO i_natio.
      CLEAR w_natio.
  ENDLOOP.
  ENDIF.
ENDIF.

CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
                       id = 'I_IT0002-NATIO' "-->Field for which dropdown is needed.
                values = i_natio
EXCEPTIONS
   id_illegal_name = 1
            OTHERS = 2.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
I hope that it helps. Regards, Venkat.O

Read only

0 Likes
943

Hi venkat,

I have followed ur code but i am not getting the list displayed for my field.

my fields are EMPIDTO AND NAMETO, TABLE NAME -ZRIF_TO....i am having records in my table.....please let me know where i am going wrong.

MODULE STATUS_0100 OUTPUT.

  • SET PF-STATUS 'xxxxxxxx'.

  • SET TITLEBAR 'xxx'.

TYPE-POOLS :vrm.

DATA:

i_natio TYPE vrm_values, "-->Table that is passed through FM vrm_set_values

w_natio LIKE LINE OF i_natio.

DATA:

BEGIN OF i_t005t OCCURS 0,

EMPIDTO TYPE ZRIF_TO-EMPIDTO,

NAMETO TYPE ZRIF_TO-NAMETO,

END OF i_t005t.

IF i_t005t[] IS INITIAL.

SELECT SINGLE EMPIDTO NAMETO

FROM ZRIF_TO

INTO (ZRIF_TO-EMPIDTO, ZRIF_TO-NAMETO)

WHERE SLNO = ZRIF_TO-SLNO.

IF sy-subrc = 0.

LOOP AT i_t005t .

w_natio-key = i_t005t-EMPIDTO.

w_natio-text = i_t005t-NAMETO.

APPEND w_natio TO i_natio.

CLEAR w_natio.

ENDLOOP.

ENDIF.

ENDIF.

CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

id = 'I_IT0002-EMPIDTO' "-->Field for which dropdown is needed.

values = i_natio

EXCEPTIONS

id_illegal_name = 1

OTHERS = 2.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDMODULE.

Read only

0 Likes
943

Hi venkat,

onemore request from me please do send me the procedure to save the text box which is created through screen painter.

Read only

Former Member
0 Likes
943

Hi Pasha,

The below code might be useful for you

REPORT  zdemo.

TYPE-POOLS: vrm.
data:
  g_name   TYPE vrm_id,
  g_list   TYPE vrm_values,
  g_list1  TYPE vrm_values,
  g_value        LIKE LINE OF g_list,
  g_resulttab    TYPE match_result_tab.

DEFINE fill_list_data.
  g_value-key = &1.
  g_value-text = &2.
  append g_value to &3.
END-OF-DEFINITION.

SELECTION-SCREEN BEGIN OF BLOCK block1.
PARAMETERS:
            p_stype AS LISTBOX VISIBLE LENGTH 15 DEFAULT 'P' USER-COMMAND UC1,
            p_sprfx(15) AS LISTBOX VISIBLE LENGTH 15.
SELECTION-SCREEN END OF BLOCK block1.

AT SELECTION-SCREEN OUTPUT.

g_name = 'P_STYPE'.
perform fill_list_box using g_name.

AT SELECTION-SCREEN ON p_stype. "VALUE-REQUEST FOR p_stype.

g_name = 'P_SPRFX'.
perform fill_list_box using g_name.


START-OF-SELECTION.
END-OF-SELECTION.

form fill_list_box using g_name.
clear: g_list,g_list1.
case g_name.
  when 'P_STYPE'.
    fill_list_data: 'P' 'P' g_list,
                    'H' 'H' g_list.
    CALL FUNCTION 'VRM_SET_VALUES'
      EXPORTING
        id     = g_name
        values = g_list.
  when 'P_SPRFX'.
    clear g_list1.
    refresh g_list1.
    if p_stype eq 'P'.
      fill_list_data: 'A' 'A' g_list1,
                      'V' 'V' g_list1.
    else.
      fill_list_data: 'VVA' 'VVA' g_list1,
                      'VVS' 'VVS' g_list1.
    endif.
    CALL FUNCTION 'VRM_SET_VALUES'
      EXPORTING
        id     = g_name
        values = g_list1.
endcase.



endform.

Read only

0 Likes
943

it is not a report program i have already desinged a screen for shipment type and prefix and i have table and i have draged and dropped that fields in layout

yes for report it is ok ,but i have fixed ranges for shipment type if i select p or h according i should be able to select for shipment prefix