‎2015 Dec 13 12:36 AM
Hello Experts,
Im trying to generate a secondary list using get cursor i/p range of mat no. when the user double clicks on mat no. it should display the selected material no. in sec list but im getting only the last mat no. details. I have tried hide and clear statements too but for me its not coming.
IF FNAM = 'WA_MARA-MATNR'.
SELECT SINGLE * FROM MARA INTO WA_MARA WHERE MATNR = FVAL .
WRITE:/ WA_MARA-MATNR, WA_MARA-MBRSH, WA_MARA-MTART, WA_MARA-MATKL, WA_MARA-MEINS, WA_MARA-ERSDA, WA_MARA-ERNAM.
ELSEIF FNAM = ''.
...
...
...
...
...
ENDIF.
ENDFORM.
O/P:
Basic list:
23 ROH EA 1
38 HALB PC M
43 HAWA HR 1
58 HIBE PC M
59 HIBE PC M
68 FHMI PC A
78 DIEN PC M
88 FERT PC M
89 FERT PC M
98 HALB PC M
Secondary list if mat no.
98 M HALB 002 PC
only last value is coming
‎2015 Dec 13 1:00 PM
Hello Vishal n Aditya,
Thank you for your response. This is the code
Data: it_mara type table of mara,
wa_mara type mara.
Data: it_makt type table of makt,
wa_makt type makt.
Data: fnam(30), fval(50).
select-options: s_matnr for wa_mara-matnr.
initialization.
at selection-screen.
start-of-selection.
at line-selection.
perform DISPLAY_SECONDARYLIST.
form get_details.
select * from mara into table it_mara where matnr in s_matnr.
loop at it_mara into wa_mara.
write: / wa_mara-matnr, wa_mara-mtart, wa_mara-meins, wa_mara-mbrsh.
endloop.
endform.
form DISPLAY_SECONDARYLIST.
get cursor field fnam value fval.
condense FNAM.
condense FVAL.
if FNAM = 'WA_MARA-MATNR'.
SELECT SINGLE * FROM MARA INTO WA_MARA WHERE MATNR = FVAL .
WRITE:/ WA_MARA-MATNR, WA_MARA-MBRSH, WA_MARA-MTART, WA_MARA-MATKL, WA_MARA-MEINS, WA_MARA-ERSDA, WA_MARA-ERNAM.
ELSEIF FNAM = 'WA_MARA-MTART'.
SELECT * FROM MARA INTO TABLE IT_MARA UP TO 50 ROWS WHERE MTART = FVAL.
LOOP AT IT_MARA INTO WA_MARA.
WRITE:/ WA_MARA-MATNR, WA_MARA-MTART, WA_MARA-MATKL.
ENDLOOP.
ENDIF.
ENDFORM.
Thanks,
Viky
‎2015 Dec 13 2:59 AM
‎2015 Dec 13 4:57 AM
Hi,
GET CURSOR FIELD <fnam> VALUE <fval>. " this is your statement
CONDENSE FNAM.
CONDENSE FVAL.
have you declared FNAM and FVAL properly..
and condense them as well after assigning value to them..
please paste your code for better understanding.
thanks!!
‎2015 Dec 13 1:00 PM
Hello Vishal n Aditya,
Thank you for your response. This is the code
Data: it_mara type table of mara,
wa_mara type mara.
Data: it_makt type table of makt,
wa_makt type makt.
Data: fnam(30), fval(50).
select-options: s_matnr for wa_mara-matnr.
initialization.
at selection-screen.
start-of-selection.
at line-selection.
perform DISPLAY_SECONDARYLIST.
form get_details.
select * from mara into table it_mara where matnr in s_matnr.
loop at it_mara into wa_mara.
write: / wa_mara-matnr, wa_mara-mtart, wa_mara-meins, wa_mara-mbrsh.
endloop.
endform.
form DISPLAY_SECONDARYLIST.
get cursor field fnam value fval.
condense FNAM.
condense FVAL.
if FNAM = 'WA_MARA-MATNR'.
SELECT SINGLE * FROM MARA INTO WA_MARA WHERE MATNR = FVAL .
WRITE:/ WA_MARA-MATNR, WA_MARA-MBRSH, WA_MARA-MTART, WA_MARA-MATKL, WA_MARA-MEINS, WA_MARA-ERSDA, WA_MARA-ERNAM.
ELSEIF FNAM = 'WA_MARA-MTART'.
SELECT * FROM MARA INTO TABLE IT_MARA UP TO 50 ROWS WHERE MTART = FVAL.
LOOP AT IT_MARA INTO WA_MARA.
WRITE:/ WA_MARA-MATNR, WA_MARA-MTART, WA_MARA-MATKL.
ENDLOOP.
ENDIF.
ENDFORM.
Thanks,
Viky
‎2015 Dec 13 3:19 PM
Hi Vivek,
When your get_details form gets called ????
I want to point two issues in you code.
1st one is apply the conversion routine to the FVAL. as it is holding the value which is in external formt. So here your SELECT statement is getting failed at the same time you are clearing the workarea which is " WA_MARA" holding the value i.e the last record of the loop which is executed to show the basic list. So it is displaying the last record of the basic list.
2nd one is declare one more variable of type MATNR and pass this to the select statement of the secodary list.
Modify your code as below :
data lv_matnr type matnr. "local variable of type MATNR.
GET CURSOR FIELD fnam VALUE fval.
CONDENSE fnam.
CONDENSE fval.
clear: wa_mara,lv_matnr.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT' " apply conversion routine
EXPORTING
input = fval
IMPORTING
OUTPUT = lv_matnr
.
IF fnam = 'WA_MARA-MATNR'.
SELECT SINGLE * FROM mara INTO wa_mara WHERE matnr = lv_matnr .
WRITE:/ wa_mara-matnr, wa_mara-mbrsh, wa_mara-mtart, wa_mara-matkl, wa_mara-meins, wa_mara-ersda, wa_mara-ernam.
endif
Regards,
Vishal
‎2015 Dec 13 5:08 PM
Hi Vivek.
you are using same work area.
Try to validate using.
if FNAM = 'WA_MARA-MATNR'.
SELECT SINGLE * FROM MARA INTO WA_MARA WHERE MATNR = FVAL .
if sy-subrc is initial.
WRITE:/ WA_MARA-MATNR, WA_MARA-MBRSH, WA_MARA-MTART, WA_MARA-MATKL, WA_MARA-MEINS, WA_MARA-ERSDA, WA_MARA-ERNAM.
endif.
Hope it helpful,
Regards,
Venkat.
‎2015 Dec 14 2:49 AM