Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

select single problem

Former Member
0 Likes
1,816

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?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,675

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

11 REPLIES 11
Read only

Former Member
0 Likes
1,675

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

Read only

Former Member
0 Likes
1,675

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

Read only

0 Likes
1,675
select maktx  into var_maktx  " var_maktx is variable jusr like maktx
       FROM MAKT
       
      WHERE SPRAS = 'EN'
       and matnr = '12345' .      
endselect.
Read only

Former Member
0 Likes
1,675

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

Read only

Former Member
0 Likes
1,675

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

Read only

Former Member
0 Likes
1,675

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.

Read only

Former Member
0 Likes
1,676

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

Read only

0 Likes
1,675

I want to retrieve a single maktx(material description) for a particular material number.

So I am trying to retrieve single maktx only.

Read only

0 Likes
1,675

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

Read only

0 Likes
1,675

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

Read only

Former Member
0 Likes
1,675

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