‎2007 Jul 25 9:11 AM
Hi gurus,
I am developing one report program.
Selection screen has two parameter fields.
first one is matnr and second one is description.
my qauestion is when I give the material number and press the enter the description of material should be displayed in second parameter.
Plese any body could help me.
Regards,
Shashikumar.G
‎2007 Jul 25 9:15 AM
check this code out
TYPE-POOLS: vrm, slis.
DATA: lifnr LIKE lfa1-lifnr.
DATA: v_repid LIKE sy-repid .
DATA: plnt(10) TYPE n, flg TYPE i.
DATA: name TYPE vrm_id,
mrp(55) TYPE c,
list TYPE vrm_values,
var1(10) TYPE c,
var2(30) TYPE c,
value LIKE LINE OF list.
DATA:BEGIN OF itabt024d OCCURS 0,
dispo LIKE t024d-dispo,
dsnam LIKE t024d-dsnam,
conc(55) TYPE n,
END OF itabt024d.
DATA:BEGIN OF strumarc,
matnr LIKE marc-matnr,
maktx LIKE makt-maktx,
END OF strumarc.
DATA: i_fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE.
DATA: itabmarc LIKE strumarc OCCURS 0 WITH HEADER LINE.
DATA:itabt001w LIKE TABLE OF t001w WITH HEADER LINE.
RANGES: r_werks FOR t001w-werks,
r_mrpdesc FOR itabt024d-dispo .
r_werks-option = 'EQ'.
r_werks-sign = 'I'.
r_mrpdesc-option = 'EQ'.
r_mrpdesc-sign = 'I'.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: plant LIKE r_werks AS LISTBOX VISIBLE LENGTH 10
USER-COMMAND
c1 MODIF ID pln.
PARAMETERS: vendor LIKE r_mrpdesc AS LISTBOX VISIBLE LENGTH 50 MODIF ID
det USER-COMMAND c1.
SELECTION-SCREEN END OF BLOCK b1.
INITIALIZATION.
flg = 1.
IF flg = 1.
CLEAR vendor.
CLEAR plant.
ENDIF.
AT SELECTION-SCREEN.
AT SELECTION-SCREEN OUTPUT.
PERFORM fetch_plant.
AT SELECTION-SCREEN ON plant.
PERFORM fetch_mrp.
AT SELECTION-SCREEN ON vendor.
PERFORM materials.
START-OF-SELECTION.
REFRESH i_fieldcat.
i_fieldcat-col_pos = 1 .
i_fieldcat-fieldname = 'MATNR'.
i_fieldcat-seltext_m = 'Part No'.
i_fieldcat-outputlen = 30.
i_fieldcat-fix_column = 'X'.
APPEND i_fieldcat.
CLEAR i_fieldcat.
i_fieldcat-col_pos = 2 .
i_fieldcat-fieldname = 'MAKTX'.
i_fieldcat-seltext_m = 'Part Description'.
i_fieldcat-outputlen = 30.
i_fieldcat-fix_column = 'X'.
APPEND i_fieldcat .
CLEAR i_fieldcat.
v_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = v_repid
i_grid_title = 'Parts Under Selected MRP Controller'
it_fieldcat = i_fieldcat[]
TABLES
t_outtab = itabmarc.
*&---------------------------------------------------------------------*
*& Form ASSIGN_LISTBOX_VALUES
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM assign_listbox_values .
REFRESH list.
IF flg = 1.
LOOP AT r_werks.
name = 'PLANT'.
value-key = r_werks-low.
value-text = r_werks-low.
APPEND value TO list.
ENDLOOP.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = name
values = list.
CLEAR plant.
ELSEIF flg = 0.
CLEAR itabt024d-conc.
LOOP AT itabt024d.
name = 'VENDOR'.
value-key = itabt024d-dispo.
value-text = itabt024d-conc.
APPEND value TO list.
ENDLOOP.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = name
values = list.
ENDIF.
ENDFORM. " ASSIGN_LISTBOX_VALUES
*&---------------------------------------------------------------------*
*& Form GET_LIST_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM get_list_data .
REFRESH list.
IF flg = 1.
SELECT DISTINCT werks FROM t001w INTO r_werks-low.
* WHERE kunnr EQ 'TSL' OR kunnr EQ '0000050001'.
APPEND r_werks.
ENDSELECT.
CLEAR r_werks.
SORT r_werks ASCENDING.
DELETE ADJACENT DUPLICATES FROM r_werks.
CLEAR r_werks.
ELSEIF flg = 0.
CLEAR itabt024d.
CLEAR itabt024d-conc.
SELECT dispo dsnam INTO TABLE itabt024d FROM t024d
WHERE werks EQ plant.
CLEAR itabt024d.
SORT itabt024d ASCENDING.
DELETE ADJACENT DUPLICATES FROM itabt024d.
CLEAR itabt024d.
LOOP AT itabt024d.
CONCATENATE itabt024d-dispo ' - ' itabt024d-dsnam INTO itabt024d-conc.
MODIFY itabt024d.
ENDLOOP.
ENDIF.
ENDFORM. " get_list_data
*&---------------------------------------------------------------------*
*& Form FETCH_PLANT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM fetch_plant .
REFRESH list.
IF flg = 1.
LOOP AT SCREEN.
IF screen-group1 = 'DET'.
screen-input = '0'.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
PERFORM get_list_data.
PERFORM assign_listbox_values.
flg = 0.
ENDIF.
ENDFORM. " fetch_plant
*&---------------------------------------------------------------------*
*& Form FETCH_MRP
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM fetch_mrp .
REFRESH list.
CLEAR vendor.
IF flg = 0 .
CONDENSE plant.
IF plant NE ' '.
LOOP AT SCREEN.
IF screen-group1 = 'DET'.
screen-active = '0'.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
PERFORM get_list_data.
PERFORM assign_listbox_values.
ENDIF.
flg = 2.
ENDIF.
ENDFORM. " fetch_mrp
*&---------------------------------------------------------------------*
*& Form MATERIALS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM materials .
IF flg = 2.
IF vendor NE ' '.
CONDENSE vendor.
SELECT matnr INTO CORRESPONDING FIELDS OF
TABLE itabmarc FROM marc WHERE werks EQ plant
AND dispo EQ vendor.
CLEAR itabmarc.
LOOP AT itabmarc.
SELECT maktx FROM makt INTO (itabmarc-maktx) WHERE matnr =
itabmarc-matnr.
MODIFY itabmarc.
ENDSELECT.
ENDLOOP.
CLEAR itabmarc.
ENDIF.
ENDIF.
ENDFORM. " materials
‎2007 Jul 25 9:22 AM
Hi,
U write ur logic in the 'At Selection-Screen' Event.
If u press enter then capture the value of the enter. (sy-ucomm).
Then u write the select query to retrieve the description of the material from
makt table and pass it to the description parameter .
Cheers,
Simha.
‎2007 Jul 25 9:27 AM
Hello,
Check this sample:
parameters: p_matnr like mara-matnr,
p_maktx like makt-maktx.
at selection-screen output.
loop at screen.
if screen-name = 'P_MAKTX'.
screen-input = 0.
screen-output = 1.
modify screen.
endif.
endloop.
at selection-screen on P-MATNR.
IF NOT P_MATNR IS INITIAL.
SELECT SINGLE MAKTX FROM MAKT INTO P_MAKTX WHERE MATNR = P_MATNR
AND SPRAS = SY-LANGU .
ENDIF.
If useful reward.
Vasanth
‎2007 Jul 25 9:28 AM
Just copy the following in ur report.
REPORT zselect.
TABLES: makt.
DATA: BEGIN OF i_makt OCCURS 1,
maktx LIKE makt-maktx,
END OF i_makt.
PARAMETERS: p_matnr LIKE makt-matnr OBLIGATORY,
p_maktx LIKE makt-maktx.
AT SELECTION-SCREEN.
SELECT maktx FROM makt INTO CORRESPONDING FIELDS OF TABLE i_makt WHERE matnr = p_matnr.
LOOP AT i_makt.
IF sy-subrc = 0.
p_maktx = i_makt-maktx.
ENDIF.
ENDLOOP.
Reward if useful
anju
‎2007 Jul 25 9:32 AM
Hi,
Use this code..
parameters:
p_matnr like mara-matnr,
p_MAKTX like makt-MAKTX.
at selection-screen.
select single maktx
from makt
into p_maktx
where matnr eq p_matnr
and spras eq sy-langu.
Regards,
Omkar.
‎2007 Jul 25 9:34 AM
Hi,
try this:
TABLES: MARA, MAKT.
*
PARAMETERS: P_MATNR LIKE MARA-MATNR.
SELECTION-SCREEN: COMMENT 60(30) T_MAKTX.
AT SELECTION-SCREEN OUTPUT.
IF NOT P_MATNR IS INITIAL.
SELECT SINGLE * FROM MAKT WHERE SPRAS = SY-LANGU
AND MATNR = P_MATNR.
WRITE MAKT-MAKTX TO T_MAKTX.
else.
clear t_maktx.
ENDIF.
Regards, Dieter
onother way like this:
TABLES: MARA, MAKT.
*
PARAMETERS: P_MATNR LIKE MARA-MATNR.
parameters: p_maktx like makt-maktx.
AT SELECTION-SCREEN OUTPUT.
IF NOT P_MATNR IS INITIAL.
SELECT SINGLE * FROM MAKT WHERE SPRAS = SY-LANGU
AND MATNR = P_MATNR.
WRITE MAKT-MAKTX TO P_MAKTX.
else.
clear p_maktx.
ENDIF.
Regards, Dieter
Message was edited by:
Dieter Gröhn
‎2007 Jul 25 9:47 AM
Hello,
i have faced the case of text being displayed on the selection screen too but text field should be a display only
The selection screen is for user input...so basically when the material is entered you are not suppose to give text field for material as input unless you have the intention of changing the description as desired from the user.....
so you can use the MATNR on the selection screen and give the text as a display only field...in such a case the following code layout will work....
capture the sy-ucomm....or just write the code
if P_MATNR is not initial.
select ...text..from.. into description field
else.
clear description field
endif.
reward if helpful
Regards
Byju
‎2007 Jul 25 1:39 PM