‎2007 Jan 15 4:32 AM
Hi All,
I am executing these queries in a subroutine but when i execute the program, the previous contents of the internal table t_litem gets cleared up after executing the second query and it only contains kdmat, i want the kdmat value to be assigned to the kdmat field of the same row as posnr matnr arktx fkimg and netwr are.
SELECT posnr matnr arktx fkimg netwr
INTO CORRESPONDING FIELDS OF TABLE t_litem
FROM vbrp
WHERE vbeln = t_xhdr-vbeln.
SELECT kdmat
INTO CORRESPONDING FIELDS OF TABLE t_litem
FROM vbap
WHERE vbeln = t_xhdr-sordno.
please suggest the way to do it.
thanks
‎2007 Jan 15 4:52 AM
Hi,
data : begin of t_vbrp occurs 0,
vbeln type vbrp-vbeln,
posnr type vbrp-posnr,
matnr type vbrp-matnr,
arktx type vbrp-arktx,
fkimg type vbrp-fkimg,
netwr type vbrp-netwr,
end of t_vbrp.
data : begin of t_vbap occurs 0,
vbeln type vbap-vbeln,
kdmat type vbap-kdmat,
end of t_vbap.
if not t_xhdr[] is initial.
SELECT vbeln posnr matnr arktx fkimg netwr
INTO TABLE t_vbrp
FROM vbrp
for all entries in t_xdhr
WHERE vbeln = t_xhdr~vbeln.
SELECT vbeln kdmat
INTO TABLE t_vbap
FROM vbap
for all entries in t_xdhr
WHERE vbeln = t_xhdr~sordno.
endif.
loop at t_xhdr.
loop at t_vbrp where key vbeln = t_xhdr-vbeln.
move-corresponding t_vbrp to t_litem.
clear t_vbap.
read table t_vbap with key vbeln = t_xhdr-sordno.
if sy-subrc eq 0.
t_vbrp-kdmat = t_litem-kdmat.
endif.
append t_litem.
endloop.
KIndly reward points by clicking the star on the left of reply,if it helps.
‎2007 Jan 15 4:35 AM
Hi
I guess you should make use of FOR ALL ENTRIES in your second query.
SELECT posnr matnr arktx fkimg netwr
INTO CORRESPONDING FIELDS OF TABLE t_litem
FROM vbrp
WHERE vbeln = t_xhdr-vbeln.
SELECT kdmat
INTO CORRESPONDING FIELDS OF TABLE t_litem
FROM vbap
FOR ALL ENTRIES IN t_litem
WHERE vbeln = t_litem-sordno.
PLZ REWARD POINTS
Message was edited by:
Vijay Kamath
‎2007 Jan 15 4:38 AM
When u are using the Select statement it will refresh the internal table data and stores the new vlaues.
So use 2 internal table for your 2 select queries and using Read table fetch the kdmat from the second internal table.
If u want the data in the same table then you can use joins.
‎2007 Jan 15 4:38 AM
hi,
Please use appending into CORRESPONDING FIELDS OF TABLE t_litem
in the second select.
SELECT posnr matnr arktx fkimg netwr
INTO CORRESPONDING FIELDS OF TABLE t_litem
FROM vbrp
WHERE vbeln = t_xhdr-vbeln.
SELECT kdmat
appending into CORRESPONDING FIELDS OF TABLE t_litem
FROM vbap
WHERE vbeln = t_xhdr-sordno.
Regards,
Ishaq
‎2007 Jan 15 4:41 AM
Hi,
SELECT Aposnr Amatnr Aarktx Afkimg Anetwr Bkdmat
INTO CORRESPONDING FIELDS OF TABLE t_litem
for all entries in T_XHDR
FROM vbrp as A inner join vbap as B
WHERE VBRP~vbeln = t_xhdr-vbeln
and VBAPVBELN = VBRPVBELN .
Hope this helps.
Regards
Subramanian
‎2007 Jan 15 4:42 AM
USE APPENDING CLAUSE IN UR SELECT QUERY..
PRESS f1 FOR MORE HELP.
AMIT
‎2007 Jan 15 4:44 AM
Hi,
Take 2 internal tables with atleast one common field in both ...
after getting both the tables U can loop at the first one and read the
second one which has the KDMAT field ..
Take both the Internal table contents into Final one.
Loop at i_1.
read i_2 with key c_f1 = i_1-c_f1. " c_f1 = common field
if sy-subrc = 0.
move corresponding i_1 into final.
move corresponding i_2 into final.
append final.
endif.
endloop.
Regards,
GSR.
‎2007 Jan 15 4:45 AM
Rahul,
uSE BELOW CODE.
SELECT Aposnr Amatnr Aarktx Afkimg Anetwr Bkdmat
INTO CORRESPONDING FIELDS OF TABLE t_litem
for all entries of table T_XHDR
FROM vbrp as A inner join vbap as B
WHERE VBRP~vbeln = t_xhdr-vbeln
and VBAPVBELN = VBRPVBELN .
‎2007 Jan 15 4:47 AM
Hi,
Code as follows:
SELECT posnr matnr arktx fkimg netwr
INTO CORRESPONDING FIELDS OF TABLE t_litem
FROM vbrp
WHERE vbeln = t_xhdr-vbeln.
SELECT kdmat
INTO CORRESPONDING FIELDS OF TABLE t_litem
FROM vbap <b>FOR ALL ENTRIES IN t_litem</b>
WHERE vbeln =<b>t_litem-sordno</b>.
hope this helps.
Reward if helpful.
Regards,
Sipra
‎2007 Jan 15 4:51 AM
Hi,
SELECT posnr matnr arktx fkimg netwr
INTO TABLE t_litem
FROM vbrp
WHERE vbeln = t_xhdr-vbeln.
fetch II table into one more ITAB.
SELECT kdmat
INTO CORRESPONDING FIELDS OF TABLE s_litem
FROM vbap
WHERE vbeln = t_xhdr-sordno.
sort t_litem by vbeln.
loop at t_litem into wa.
read table s_item from wa1 index vbeln = wa-vbeln.
if sy-subrc = 0.
wa-kdmat = wa1-kdmat.
endif.
modify i_litem by wa transporting kdmat.
endloop.
hope this will help you.
Thanks
Shiva
‎2007 Jan 15 4:52 AM
Hi,
data : begin of t_vbrp occurs 0,
vbeln type vbrp-vbeln,
posnr type vbrp-posnr,
matnr type vbrp-matnr,
arktx type vbrp-arktx,
fkimg type vbrp-fkimg,
netwr type vbrp-netwr,
end of t_vbrp.
data : begin of t_vbap occurs 0,
vbeln type vbap-vbeln,
kdmat type vbap-kdmat,
end of t_vbap.
if not t_xhdr[] is initial.
SELECT vbeln posnr matnr arktx fkimg netwr
INTO TABLE t_vbrp
FROM vbrp
for all entries in t_xdhr
WHERE vbeln = t_xhdr~vbeln.
SELECT vbeln kdmat
INTO TABLE t_vbap
FROM vbap
for all entries in t_xdhr
WHERE vbeln = t_xhdr~sordno.
endif.
loop at t_xhdr.
loop at t_vbrp where key vbeln = t_xhdr-vbeln.
move-corresponding t_vbrp to t_litem.
clear t_vbap.
read table t_vbap with key vbeln = t_xhdr-sordno.
if sy-subrc eq 0.
t_vbrp-kdmat = t_litem-kdmat.
endif.
append t_litem.
endloop.
KIndly reward points by clicking the star on the left of reply,if it helps.