2007 Feb 28 5:55 AM
Hi,
I am having a parameter p_MATNR. This field should also have asterisk logic(). for example if i enter material number '48hg' it should retrieve all the material numbers that match that pattern.
Can anybody provide me the logic for the above one.
Thanks...
2007 Feb 28 6:44 AM
Hi anil,
1. 1 -
> will give all MATNR containing 1 anywhere in the code.
2. just copy paste.
3.
report abc.
*----
DATA : MARA LIKE MARA OCCURS 0 WITH HEADER LINE.
DATA : MYMATNR LIKE MARA-MATNR.
PARAMETERS : S_MATNR LIKE MARA-MATNR.
*----
<b>MYMATNR = S_MATNR.
REPLACE ALL OCCURRENCES OF '*' IN MYMATNR WITH '%'.</b>SELECT * FROM MARA
INTO TABLE MARA
WHERE <b>MATNR LIKE MYMATNR.</b>
LOOP AT MARA.
WRITE 😕 MARA-MATNR.
ENDLOOP.
regards,
amit m.
IF p_matnr CA '*'.
ELSE.
CONCATENATE p_matnr '*' INTO p_matnr.
ENDIF.
SELECT matnr FROM MARA
INTO TABEL itab
WHERE matnr LIKE p_matnr.Also u can do like this
ranges r_id for mara-matnr.
r_id-low = 'VP*'. (p_matnr)
r_id-sign = 'I'.
r_id-option = 'CP'.
append r_id.
select matnre
into table i_table
from mara
where matnr in r_id.
2007 Feb 28 5:57 AM
IF p_matnr CA '*'.
ELSE.
CONCATENATE p_matnr '*' INTO p_matnr.
ENDIF.
SELECT matnr FROM MARA
INTO TABEL itab
WHERE matnr LIKE p_matnr.Also u can do like this
ranges r_id for mara-matnr.
r_id-low = 'VP*'. (p_matnr)
r_id-sign = 'I'.
r_id-option = 'CP'.
append r_id.
select matnre
into table i_table
from mara
where matnr in r_id.
2007 Feb 28 5:59 AM
Hi
For Parameter we can use Eq,> ,< only.
It cann't be possible your requirement with Parameters.
But it can be achieved with select-options.
Opt for select-option for your requirement.
Regards,
kumar
2007 Feb 28 6:00 AM
Hi,
This can be achieved using RANGES in your code.
RANGES: gr_matnr FOR mara-matnr.
gr_matnr-sign = 'I'.
gr_matnr-option = 'CS'.
gr_matnr-low = p_matnr.
APPEND gr_matnr.
CLEAR: gr_matnr.
Use this in the WHERE clause saying:
WHERE matnr IN gr_matnr.
Please, let me know if further details are required from my side.
Thanks & Regards,
Goutham.
2007 Feb 28 6:19 AM
Hi,
With out using ranges and select-options can u provide the coding.
i need to do it only with parameters.
Thanks...
2007 Feb 28 6:02 AM
2007 Feb 28 6:03 AM
if you are using select
select matnr into mara-matnr from mara where matnr like '048%'.
it wil fetch the data whose first 3 digit is 048.
if it is a select-option
then
S_op-low = '048*'.
s_op-sign = 'I'.
s_op-option = 'CP'.
append s_op.
regards
shiba dutta
2007 Feb 28 6:04 AM
translate p_matnr using '*%'.
select matnr from mara into table itab where matnr like p_matnr.
2007 Feb 28 6:22 AM
that meaans your select query should do like that...
just check my previous reply.
here
if p_matnr ca '*'.
concatenate p_matnr '%' into p_matnr.
endif.
select matnr into mara-matnr from mara where matnr like p_matnr.
regards
shiba dutta
2007 Feb 28 6:30 AM
Hi,
Thank u for ur reply.
Yes my requirement is same.
But it is not working. it is giving no records found.
Thanks..
2007 Feb 28 6:33 AM
Have u tried my code.
IF p_matnr CA '*'.
ELSE.
CONCATENATE p_matnr '*' INTO p_matnr.
ENDIF.
SELECT matnr FROM MARA
INTO TABEL itab
WHERE matnr LIKE p_matnr.
2007 Feb 28 6:34 AM
Hi anil,
have u tried my reply
search p_matnr for '*'.
if sy-subrc eq 0
translate p_matnr using '*%'.
endif.
select matnr from mara into table itab where matnr like p_matnr.
2007 Feb 28 6:34 AM
Hi,
the code should be as follows :
replace all occurences of '*' in p_matnr with '%'.
then apply the select statement. In SAP, the '' is not determined by SAP if used in ABAP Code. Instead '%' works similar to ''.
Try it.
Please award points if helpful.
Thanks,
Himanshu.
2007 Feb 28 6:43 AM
anil,
DATA: STR1 VALUE '*',
STR2 VALUE '%'.
parameters : p_matnr like mara-matnr.
AT selection-screen.
REPLACE STR1 WITH STR2 INTO p_matnr.
Start-of-selection.
select matnr into mara-matnr from mara where matnr like p_matnr.
Pl.s mark if useful
2007 Feb 28 6:44 AM
Hi anil,
1. 1 -
> will give all MATNR containing 1 anywhere in the code.
2. just copy paste.
3.
report abc.
*----
DATA : MARA LIKE MARA OCCURS 0 WITH HEADER LINE.
DATA : MYMATNR LIKE MARA-MATNR.
PARAMETERS : S_MATNR LIKE MARA-MATNR.
*----
<b>MYMATNR = S_MATNR.
REPLACE ALL OCCURRENCES OF '*' IN MYMATNR WITH '%'.</b>SELECT * FROM MARA
INTO TABLE MARA
WHERE <b>MATNR LIKE MYMATNR.</b>
LOOP AT MARA.
WRITE 😕 MARA-MATNR.
ENDLOOP.
regards,
amit m.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |