‎2009 Feb 23 6:30 AM
I am trying to retrieve single makt-maktx value from makt
where makt-matnr = mseg-matnr
and makt-spras = 'EN'.
But for all entries not allowed in case of select single.
So how can I fetched makt-maktx for the above condition?
even if i use read statement, how to use the above conditions?can anybody please help?
‎2009 Feb 23 6:43 AM
Hello,
How many materials are you picking up from table MSEG?
Assuming multiple material will be picked up from table MSEG you'll need to get the description of each material hence SELECT SINGLE... wouldn't solve the issue.
If you use SELECT SINGLE... it implies only one record is fetched at a time.
When description of multiple materials are to be fetched obviously it should be quried in the below way
SELECT MATNR
MAKTX
FROM MAKT
INTO TABLE TBL_MAKT "Table containing fields matnr, maktx
FOR ALL ENTRIES IN TBL_MSEG
WHERE MATNR EQ TBL_MSEG-MATNR
AND SPRAS EQ 'EN'.
Hope this helps.
Regards,
Farheen
‎2009 Feb 23 6:37 AM
Hi ,
you can use join for this.
SELECT single maktx
into wf_maktx
FROM makt AS a INNER JOIN mseg AS b
ON bmatnr = amatnr
AND b~spras = 'EN'.
i hope it will work.
regards,
Lokesh
Edited by: Lokesh Tripathi on Feb 23, 2009 7:37 AM
‎2009 Feb 23 6:37 AM
TEST THE SAMOLE CODE
tables: makt , mseg.
data: BEGIN OF it OCCURS 10,
matnr like mseg-matnr,
maktx like makt-maktx,
end of it.
select makt~maktx mseg~matnr into CORRESPONDING FIELDS OF TABLE IT
FROM MAKT
inner join mseg on ( makt~matnr = mseg~matnr )
WHERE MAKT~SPRAS = 'EN'.
.Edited by: tahir naqqash on Feb 23, 2009 11:38 AM
‎2009 Feb 23 6:53 AM
select maktx into var_maktx " var_maktx is variable jusr like maktx
FROM MAKT
WHERE SPRAS = 'EN'
and matnr = '12345' .
endselect.
‎2009 Feb 23 6:41 AM
Hi:
I would suggest to use the function module ISM_SD_SELECT_MAKT
and it would an internal table as export parameter, this internal table should be put under the loop and the rest condition you can under this loop and then move the final data into another table.
Regards
Shashi
‎2009 Feb 23 6:41 AM
Hi,
Select single is for a single value and you are retrieving single value, and you cannot use for all enries in select single, so there is no point of using for all entries in this case, if you want to use for all entries you have to take a internal table not a single field. Like:
Select matnr
from makt
into table t_itab1 for all entries
in t_itab2
where matnr = t_itab2-matnr
* and makt-matnr = mseg-matnr
and makt-spras = 'EN'.With luck,
Pritam.
Edited by: Pritam Ghosh on Feb 23, 2009 7:55 AM
‎2009 Feb 23 6:42 AM
Hello
select single * not working for ALL ENTRIES.
use:
select single * from makt where matnr = mseg-matnr and spras = 'EN'.
if sy-subrc = 0.
name = makt-maktx.
endif.
‎2009 Feb 23 6:43 AM
Hello,
How many materials are you picking up from table MSEG?
Assuming multiple material will be picked up from table MSEG you'll need to get the description of each material hence SELECT SINGLE... wouldn't solve the issue.
If you use SELECT SINGLE... it implies only one record is fetched at a time.
When description of multiple materials are to be fetched obviously it should be quried in the below way
SELECT MATNR
MAKTX
FROM MAKT
INTO TABLE TBL_MAKT "Table containing fields matnr, maktx
FOR ALL ENTRIES IN TBL_MSEG
WHERE MATNR EQ TBL_MSEG-MATNR
AND SPRAS EQ 'EN'.
Hope this helps.
Regards,
Farheen
‎2009 Feb 23 6:50 AM
I want to retrieve a single maktx(material description) for a particular material number.
So I am trying to retrieve single maktx only.
‎2009 Feb 23 6:54 AM
Hi,
Check this
TABLES: MSEG, MAKT.
DATA: BEGIN OF IT_MSEG OCCURS 0,
MATNR LIKE MSEG-MATNR,
END OF IT_MSEG.
SELECT-OPTIONS: S_MATNR FOR MSEG-MATNR.
SELECT MATNR FROM MSEG INTO TABLE IT_MSEG WHERE MATNR IN S_MATNR.
LOOP AT IT_MSEG.
SELECT SINGLE MAKTX FROM MAKT INTO MAKT-MAKTX
WHERE MAKT~MATNR = IT_MSEG-MATNR
AND MAKT~SPRAS = 'EN'.
WRITE:/ MAKT-MAKTX.
ENDLOOP.thanks\
Mahesh
‎2009 Feb 23 7:09 AM
and if you want to retrieve single maktx only, you have to do it in this way:
Data:
Begin of fs_itab,
matnr type matnr,
End of fs_itab.
Data:
t_itab like standard table of fs_itab.
Data:
wa_matnr type matnr.
Data:
w_index type i value 1,
w_lines type i.
Select matnr from mseg into table t_itab.
Describe table t_itab lines w_lines.
While w_index le w_lines.
Read table t_itab into fs_itab index w_index.
Select single maktx
from makt
into wa_matnr
where matnr = fs_itab-matnr
and spras = 'EN'.
If sy-subrc <> 0.
Endif.
w_index = w_index + 1.
Endwhile.With luck,
Pritam.
Edited by: Pritam Ghosh on Feb 23, 2009 8:11 AM
‎2009 Feb 23 6:53 AM
Hi ,
Let say you have data in itab_mseg.
Take this data into temp_mseg data.
temp_mseg[] = itab_mseg[] .
sort temp_mseg by matnr.
delete adjacent duplicates from temp_mseg.
select matnr
maktx
into table itab_makt
for all entries in temp_mseg
from makt
where matnr eq temp_makt-matnr
and spras eq 'EN' -
u can take sy-langu
if sy-subrc eq 0.
sort itab_makt by matnr.
endif.
Then when u want to read , use as follows:
let say ....
loop at itab_mseg.
read table itab_makt with key matnr = itab_mseg-matnr binary search.
if sy-subrc eq 0.
use MAKTX.....
write : \1(40) itab_makt-maktx .
endif.
Hope this help you.
Regards,
Anil