04-03-2008 9:44 AM
HI Experts,
Pls. let me know that,
1 - Am defining a field my_field in the screen_9001 of MODULE POOL PROG.
So, I wanna to get the DROP DOWN / LIST BOX for it, How to get it done?
Actually, I hv a REFERENCE filed for it in my_Z_table, where I hv records in my_Z_tabel.
pls. explain in detail.
2 - And I wanna display it as MANDATORY input, So, How to get it done?
thanq
04-03-2008 10:12 AM
Hi,
to provide a default value create a variable in ur program with the same name as the screen field name.and initialize it.
suppose ur field name in screen is mara-matnr.
then do like this.
data:mara-matnr(18) value 'TEST'.
rgds,
bharat.
04-03-2008 9:46 AM
Hi,
type-pools: vrm.
data : name type vrm_id,
list type vrm_values,
value like line of list.
if mem = 'S'.
name = 'MODE'.
value-key = '1'.value-text = 'By Lorry-LCV'.
append value to list.
value-key = '2'.value-text = 'By Lorry-FTL'.
append value to list.
value-key = '3'.value-text = 'By Lorry-Speed'.
append value to list.
value-key = '4'.value-text = 'By Courier'.
append value to list.
value-key = '5'.value-text = 'By Air'.
append value to list.
value-key = '6'.value-text = 'By Train'.
append value to list.
value-key = '7'.value-text = 'By Car'.
append value to list.
value-key = '8'.value-text = 'By Hand'.
append value to list.
value-key = '9'.value-text = 'By own Vehicle'.
append value to list.
value-key = '10'.value-text = 'By MRT-BUS'.
append value to list.
call function 'VRM_SET_VALUES'
exporting
id = name
values = list.
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
mem = 'R'.
endif.
Regards,
V.Balaji
Reward if Usefull...
04-03-2008 9:50 AM
thanq.
1 - U mean, this is same as REPORT prog. LIST BOX?
2 - Wht is MEM here ,
3 - Wht is MODE here
4 - How to show OBLIGATORY field, other filed
5 - In another field of same screen, I wanna to put a DEFAULT value in my_field_2 of screen_9001.
thanq
Edited by: Srinivas on Apr 3, 2008 4:51 AM
04-03-2008 9:57 AM
Hi,
making the field mandatory:
in the field attributes of the screen field(double click on the field in screen one window will appear to you) select the tab PROGRAM in lower part of it.There will be a field called INPUT make the entry as REQUIRED from POSSIBLE state.
rgds,
bharat.
04-03-2008 9:57 AM
hi,
find the code below and u will get the answers
type-pools: vrm.
data: name type vrm_id,
list type vrm_values,
value like line of list.
data : v_temp type werks.
types : begin of t_werks,
werks type werks,
end of t_werks.
data : wa_t001w type t001w.
data : wa_werks type t_werks.
data : it_werks type standard table of t_werks.
parameters: p_werks type werks as listbox visible length 50 obligatory.
parameters : p_obj1 as listbox visible length 100 obligatory default 'B'.
data p(4) type c value 0.
at selection-screen output .
clear list .
refresh list .
name = 'P_WERKS'.
select werks from t001w into table it_werks.
loop at it_werks into wa_werks.
p = p + 1.
value-key = p.
value-text = wa_werks-werks.
append value to list .
endloop.
call function 'VRM_SET_VALUES'
exporting
id = name
values = list.
name = 'P_OBJ1'.
clear list .
refresh list .
value-key = 'A'.
value-text = 'Object A'.
append value to list .
value-key = 'B'.
value-text = 'Object B'.
append value to list .
call function 'VRM_SET_VALUES'
exporting
id = name
values = list
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.
start-of-selection.
set pf-status 'Z11_AP_CONTEXTMENU'.
loop at it_werks into wa_werks.
write:/ wa_werks.
endloop.
at user-command.
case sy-ucomm.
when 'PLANT'.
select name1 from t001w into wa_t001w-name1 where werks = v_temp.
write:/ wa_t001w-name1.
endselect.
when 'CANCEL'.
leave program.
endcase.
&----
*& Form on_ctmenu_request
&----
text
----
-->L_MENU text
----
form on_ctmenu_request using l_menu type ref to cl_ctmenu.
data lin type i.
get cursor line lin value v_temp.
if sy-lsind = 0.
call method l_menu->add_function
exporting
fcode = 'PLANT'
text = 'PLANT'.
endif.
call method l_menu->add_function
exporting
fcode = 'CANCEL'
text = 'CANCEL'.
endform. "on_ctmenu_request
reward if helpful
04-03-2008 9:58 AM
hi srinivas this is to display the listbox with entries of a db table ....it is a module pool...but may it helps for u check it ....because the logic is same ....in the report and in the module pool...
report.
TYPE-POOLS : vrm.
TABLES:vbak,vbap.
DATA : v(80) TYPE c.
DATA: wa_vbak TYPE vbak,
it_vbak TYPE vbak OCCURS 0 WITH HEADER LINE,
wa_vbap TYPE vbap,
it_vbap TYPE vbap OCCURS 0 WITH HEADER LINE.
DATA: l_name TYPE vrm_id,
li_list TYPE vrm_values ,
v_count TYPE i,
l_value LIKE LINE OF li_list.
PARAMETERS: p_test(20) AS LISTBOX VISIBLE LENGTH 60 MODIF ID DAT.
INITIALIZATION.
AT SELECTION-SCREEN OUTPUT.
PERFORM get_data.
LOOP AT it_vbak.
l_value-key = it_vbak-vbeln .
l_value-text = it_vbak-vbeln .
APPEND l_value TO li_list.
ENDLOOP.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = 'P_TEST'
values = li_list
EXCEPTIONS
id_illegal_name = 1
OTHERS = 2.
AT SELECTION-SCREEN ON P_TEST.
clear : li_list , li_list[].
SELECT vbeln
matnr
meins
FROM vbap
INTO CORRESPONDING FIELDS OF TABLE it_vbap
WHERE vbeln = p_test.
START-OF-SELECTION.
SELECT vbeln
matnr
meins
FROM vbap
INTO CORRESPONDING FIELDS OF TABLE it_vbap
WHERE vbeln = p_test.
LOOP AT it_vbap.
WRITE 😕 it_vbap-vbeln, it_vbap-matnr,it_vbap-meins.
ENDLOOP.
&----
*& Form get_Data
&----
text
----
--> p1 text
<-- p2 text
----
FORM get_data .
SELECT vbeln
FROM vbak
INTO CORRESPONDING FIELDS OF TABLE it_vbak.
ENDFORM. " get_Data
regards,
venkat.
04-03-2008 10:12 AM
Hi,
to provide a default value create a variable in ur program with the same name as the screen field name.and initialize it.
suppose ur field name in screen is mara-matnr.
then do like this.
data:mara-matnr(18) value 'TEST'.
rgds,
bharat.
04-03-2008 10:18 AM
thanq
Got it.
just curious that,
I hv named the I/O field in the screen as P_MATNR.
In TOP INCLUDE , again , I defined as P_MATNR like MARA-MATNR.
So,
1 - Why shuld I define 2 times in the same (MODULE POOL) prog.
2 - Does SAP do not confuse, with same name, defining 2 times?
thanq
04-03-2008 10:25 AM
Hi,
In ur include u have define the data element while on screen u definr the acreen element . So SAP will not get confused as both are different . If it was happening so it will give an error of field already declared , bt it doesn't happens
regards
Paliwal
04-03-2008 10:38 AM
Hi,
the screen element is different from program variable.even if the screen element is I/O field or tabstrip or table control it needs to be defined in program also.screen field name is valid up to that screen if u want to interact with the screen fields u need to define them in program.
rgds,
bharat.
04-03-2008 10:55 AM
thanq
When I saw the element list in the screen, the first field/line is in BLUE color? any reason?
thanq