2006 Sep 11 3:39 PM
i have to select either kunn2 or lifnr field value from knvp into an internal table field say x based on another field (partner function) value from same table knvp.I appreciate if anyone can suggest me how to proceed with this.
2006 Sep 11 3:55 PM
Hi,
data:begin of itab occurs 0,
field1 like knvp-field1,
end of itab.
<b>IF PFUN is initial. (partner function)
select kunn2 into table itab
from knvp.
else.
select lifnr into table itab
from knvp.
endif.</b>
regards,
sowjanya.
i have to select either kunn2 or lifnr field value from knvp into an internal table field say x based on another field (partner function) value from same table knvp.I appreciate if anyone can suggest me how to proceed with this.
2006 Sep 11 3:49 PM
Hi Priyanka,
Do you have partner function as parameter or select-option or as range and do you need either kunn2 or lifnr, i mean lifnr when kunn2 is initial and kunn2 when lifnr is initial ?
Based on what i understood, here is the code.
If you have partner function as parameter:
data: t_kunn2 like knvp-kunn2,
t_lifnr like knvp-lifnr.
select kunn2 lifnr from knvp into ( t_kunn2, t_lifnr )
where parvw eq p_parvw.
if t_kunn2 is initial.
move t_lifnr to itab-field.
append itab.
clear itab.
else.
move t_kunn2 to itab-field.
append itab.
clear itab.
endif.
endselect.
if you have partner function as select-option or range, then
select kunn2 lifnr from knvp into ( t_kunn2, t_lifnr )
where parvw in p_parvw.
if t_kunn2 is initial.
move t_lifnr to itab-field.
append itab.
clear itab.
else.
move t_kunn2 to itab-field.
append itab.
clear itab.
endif.
endselect.
Hope this will help you.
Regards,
Vivek
PS: Award points if helpful
2006 Sep 11 3:53 PM
Unfortunately you cannot do that in a single select statement but you can do the below.
SELECT kunn2 into table itab
from knvp
where partnerfunction = 'X'.
SELECT lifrn appending table itab
from knvp
where partnerfunction = 'Y'.
regards
Anurag
Message was edited by: Anurag Bankley
2006 Sep 11 3:53 PM
Hi
First you can select all the relevant data from knvp into an internal table.
Now, loop on this internal table, based on partner function, populate the kunn2 or lifnr into field of another internal table (remember it should be wide enough to hold both kinda values).
Regards,
Raj
2006 Sep 11 3:55 PM
Hi,
data:begin of itab occurs 0,
field1 like knvp-field1,
end of itab.
<b>IF PFUN is initial. (partner function)
select kunn2 into table itab
from knvp.
else.
select lifnr into table itab
from knvp.
endif.</b>
regards,
sowjanya.
2006 Sep 11 4:05 PM
i have to move the values into the same field .
i have already selected partner function and other fields except for field 'x' from different tables into itab.
its like
if itab-parvw = 'CR'
select kunn2 from knvp into x field of itab.
else
select lifnr from knvp into x field of itab.
i dont understand how to select different fields into same field.
2006 Sep 11 4:17 PM
2006 Sep 11 4:23 PM
Hi Priyanka,
do this:
loop at itab.
zindex = sy-tabix.
if itab-parvw = 'CR'.
select single kunn2 from knvp into itab-field where parvw = itab-pravw.
else.
select single lifnr from knvp into itab-field where parvw = itab-parvw.
endif.
modify itab index zindex.
endloop.
Regards,
Vivek
2006 Sep 11 4:30 PM
2006 Sep 11 4:31 PM
Since you already have the data in itab....the best way to do it is using the below code.
Select kunn2 into lval from knvp where condition.
itab-field = lval.
modify itab transporting field where parvw = 'CR'.
Select lifnr into lval from knvp where condition.
itab-field = lval.
modify itab transporting field where parvw <> 'CR'.
2006 Sep 11 4:34 PM
Hi Priyanka,
If your problem is solved, can you close the thread by assigning points to useful answers.
Regards,
Vivek
2006 Sep 11 4:43 PM
2006 Sep 11 5:03 PM
i have written this code.itab-field is already populated for other values of parvw.i am just trying to change that for 'CR' value.
loop at itab.
if itab-parvw = 'CR'.
select lifnr from knvp into itab-field where parvw = 'CR' and kunnr = itab-kunnr.
modify itab transporting field.
endselect.
endif .
endloop.
i still dont see the values for field for 'CR' value.Its just blank still.
2006 Sep 11 5:08 PM
Please check if you have the corresponding correct data in KNVP.
Ur code seems to be fine..
<b>loop at itab.
if itab-parvw = 'CR'.
select lifnr from knvp into itab-field where parvw = 'CR' and kunnr = itab-kunnr
<i>and vkorg = 'ABC' and vtweg = '10' and spart = '10'.</i>
modify itab.endselect.
endif .
endloop.</b>
<b><u>--> It might be possible that the lifnr field is blank for the other sales org ..try and check if you can qualify the select with all possible where fields.</u></b>
Message was edited by: Anurag Bankley
Message was edited by: Anurag Bankley
2006 Sep 11 5:24 PM
2006 Sep 11 3:57 PM
Hi
Try this code
SELECT * FROM mska INTO TABLE gt_cms018
WHERE ( werks = g_werks_coil OR werks = g_werks_manf )
AND line EQ p_line.
regards,
vin..
2006 Sep 11 4:07 PM
Hi,
since both are character fields, no problem in moving
in the itab
declare the field as char(10)
and based on the condition move whichever field you want
<b>data:begin of itab occurs 0,
f1(10) type c,
-
end of itab.</b>
if itab-parvw = 'CR'.
select kunn2 from knvp into f1 of itab.
append itab.
else.
select lifnr from knvp into f1 of itab.
append itab.
i hope this helps.
Regards,
Sowjanya
Message was edited by: sowjanya suggula
2006 Sep 11 4:20 PM
hi,
sorry try like this
data:begin of itab occurs 0,
f1(10) type c,
parvw like knvp-parvw,
end of itab.
select parvw from knvp into corresponding fields of table itab up to 10 rows.
if sy-subrc = 0.
loop at itab.
if itab-parvw = 'CR'.
<b>select kunn2 from knvp into itab-f1.
modify itab index sy-tabix.</b>
endselect.
else.
<b>select lifnr from knvp into itab-f1.
modify itab index sy-tabix.</b>
endselect.
endif.
endloop.
endif.
Message was edited by: sowjanya suggula
Message was edited by: sowjanya suggula
Message was edited by: sowjanya suggula
2006 Sep 11 5:07 PM
hi priyanka,
try exactly what i have coded
it is wroking from my end
2006 Sep 11 5:30 PM
Hi,
Try this..
DATA: V_PARVW TYPE KNVP-PARVW.
loop at itab1.
if itab1-parvw = 'CR'.
select lifnr from knvp into itab-field where parvw = <b>'SP'</b> and kunnr = itab-kunnr.
endif.
endloop.
This might work..
Thanks,
Naren
Message was edited by: Narendran Muthukumaran
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |