2007 Mar 20 6:48 AM
Hi All,
I need fetch matnr werks lgort charg fields where the special stock is K.
For this I wrote the code. But for all entries wont support IN statement.
So in my second query how to give range values. Its giving me error in my code. Please check this and correct the code.
select matnr werks lgort charg sobkz
from lqua
into table i_lqua_details
where matnr in s_matnr
and werks in s_werks
and lgort in s_lgo_fr
and sobkz eq k.
if i_lqua_details[] is not initial.
select matnr werks lgort charg
from mchb
into table i_mchb_details
for all entries in i_lqua_details
where matnr in s_matnr
and werks in s_werks
and lgort in s_lgo_fr
and lvorm eq space.
endif.
I will reward with the valid points.
regards,
Raghu.
Hi All,
I need fetch matnr werks lgort charg fields where the special stock is K.
For this I wrote the code. But for all entries wont support IN statement.
So in my second query how to give range values. Its giving me error in my code. Please check this and correct the code.
select matnr werks lgort charg sobkz
from lqua
into table i_lqua_details
where matnr in s_matnr
and werks in s_werks
and lgort in s_lgo_fr
and sobkz eq k.
if i_lqua_details[] is not initial.
select matnr werks lgort charg
from mchb
into table i_mchb_details
for all entries in i_lqua_details
where matnr in s_matnr
and werks in s_werks
and lgort in s_lgo_fr
and lvorm eq space.
endif.
I will reward with the valid points.
regards,
Raghu.
2007 Mar 20 6:53 AM
Hi,
You have not used the contents of your i_lqua_details internal table in the where condition of the 2nd query. either you take out the for all entries addition or insert the condition
select matnr werks lgort charg
from mchb
into table i_mchb_details
for all entries in i_lqua_details
where matnr eq i_lqua_details-matnr
and werks eq i_lqua_details-werks
and lgort eq i_lqua_details-lgort
and lvorm eq space.
regards,
Mahesh
2007 Mar 20 6:56 AM
Hi Raghu,
Check out the following examples
For Ranges you can use '<=' '>=' or 'between'
Example 1:
data : it_vbap like vbap occurs 0 with header line.
data : it_vbak like vbap occurs 0 with header line.
select *
from vbak
into it_vbak.
if not it_vbak[] is in initial.
select * from vbap
into it_vbap
for all entries in it_vbak
where vbeln eq it_vbak-vbeln.
endif.
Example 2:
CLEAR: G_T_VBRK,G_T_VBFA,G_T_VBAK,G_T_VBPA,G_T_KNA1.
REFRESH: G_T_VBRK,G_T_VBFA,G_T_VBAK,G_T_VBPA,G_T_KNA1.
SELECT VBRKBUKRS VBRKFKART VBRKFKDAT VBRKFKSTO VBRK~KUNRG
VBRKSFAKN VBRKVBELN VBRKVKORG VBRKVTWEG KNA1~KUNNR
KNA1LAND1 KNA1NAME1 INTO CORRESPONDING FIELDS OF
TABLE G_T_VBRK
FROM VBRK INNER JOIN KNA1 ON KNA1KUNNR = VBRKKUNRG
WHERE VBRK~BUKRS IN BUKRS
AND VBRK~VKORG IN VKORG
AND VBRK~FKART IN FKART
AND VBRK~FKDAT IN SP$00004
AND VBRK~FKSTO IN SP$00014
AND VBRK~KUNRG IN SP$00005
AND VBRK~SFAKN IN SP$00015
AND VBRK~VBELN IN SP$00006
AND VBRK~VTWEG IN SP$00008
AND KNA1~LAND1 IN SP$00016.
IF NOT G_T_VBRK[] IS INITIAL.
SELECT * FROM VBPA INTO TABLE G_T_VBPA
FOR ALL ENTRIES IN G_T_VBRK
WHERE VBELN = G_T_VBRK-VBELN
AND PARVW = 'ZE'.
IF NOT G_T_VBPA[] IS INITIAL.
SELECT * FROM KNA1 INTO TABLE G_T_KNA1
FOR ALL ENTRIES IN G_T_VBPA
WHERE KUNNR = G_T_VBPA-KUNNR.
ENDIF.
Example 3:
SELECT matnr mtart
FROM mara
INTO TABLE t_mara
WHERE matnr IN s_matnr.
IF NOT t_mara[] IS INITIAL.
SELECT matnr maktx
FROM makt
INTO TABLE t_makt
FOR ALL ENTRIES IN t_mara
WHERE matnr EQ t_mara-matnr.
ENDIF.
Example 4:
SELECT vbeln posnr matnr
FROM vbap
INTO TABLE it_vbap
FOR ALL ENTRIES IN it_vbak
WHERE vbeln = it_vbak-vbeln.
In the above code, for all entries in internal table it_vbak, corresponding entries from table VBAP will be fetched into table it_vbap comparing values of vbeln.
For Ranges you can use '<=' '>=' or 'between'
Good Luck and thanks
AK
2007 Mar 20 6:57 AM
Hai
select matnr werks lgort charg sobkz
from lqua
into table i_lqua_details
where matnr in s_matnr
and werks in s_werks
and lgort in s_lgo_fr
and sobkz eq k.
if i_lqua_details[] is not initial.
select matnr werks lgort charg
from mchb
into table i_mchb_details
for all entries in i_lqua_details
<b>where matnr in s_matnr
and werks in s_werks
and lgort in s_lgo_fr
and lvorm eq space.</b>
endif.
where matnr eq i_lqua_details-matnr
and werks eq i_lqua_details-werks
and lgort eq i_lqua_details-lgo_fr
and lvorm eq space
**Please reward suitable points***
With Regards
Navin Khedikar
2007 Mar 20 7:00 AM
Raghu,
If use the for all entries for an internal table,in wher condition you have to use interble field to check some condition.
select matnr werks lgort charg
from mchb
into table i_mchb_details
for all entries in i_lqua_details
where matnr in si_lqua_details-matnr
and werks in s_werks
and lgort in s_lgo_fr
and lvorm eq space.
Pls. reard if useful
2007 Mar 20 7:01 AM
In the following code you have to use atleast one field from the internal table
in where condition.
Use atleast one field of i_lqua_details in where condition, as per ur requirement.
if i_lqua_details[] is not initial.
select matnr werks lgort charg
from mchb
into table i_mchb_details
for all entries in i_lqua_details
where matnr in s_matnr
and werks in s_werks
and lgort in s_lgo_fr
and lvorm eq space.
endif.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |