‎2006 Dec 31 4:33 AM
Hi,
I have one problem.
Suppose I have two delivery doc no & delivery item. Now i m getting the delivery quantity from lips table based on delivery doc no & delivery item.
Now i have to modify my same table having field delivery qty.
sample coding.
data: begin of ty_str,
del_doc like vbfa-vbeln,
del_item like vbfa-posnn,
lfimg like lips-lfimg,
end of ty_str.
data: gt_str like table of ty_str,
gs_str like line of gt_str.
*consider my records r in gt_str.
loop at gt_str into gs_str.
select single lfimg from lips into lv_lfimg where vbeln = gs_str-del_doc
and posnr = gs_str-del_item.
*now i wanted to modify the field lfimg in table gt_str based on del_doc & del_item.
endloop.
Any body will pls suggest me the solution.
‎2006 Dec 31 5:21 AM
Hello Neha
Simply modify your itab like this:
loop at gt_str into gs_str.
select single lfimg from lips into lv_lfimg
where vbeln = gs_str-del_doc
and posnr = gs_str-del_item.
*now i wanted to modify the field lfimg in table gt_str based on del_doc & del_item.
IF ( syst-subrc = 0 ).
gs_str-lfimg = lv_lfimg.
MODIFY gt_str FROM gs_str.
ENDIF.
endloop.I would suggest the following simplification:
loop at gt_str into gs_str.
select single lfimg from lips into gs_str-lifmg " lv_lfimg
where vbeln = gs_str-del_doc
and posnr = gs_str-del_item.
*now i wanted to modify the field lfimg in table gt_str based on del_doc & del_item.
IF ( syst-subrc = 0 ).
MODIFY gt_str FROM gs_str.
ENDIF.
endloop.Furthermore, if you have many records in gt_str then you should replace the SELECT SINGLE with an array fetch:
DATA:
gt_tmp TYPE TABLE of ty_str,
gs_tmp TYPE ty_str.
IF ( gt_str IS NOT INITIAL ).
SELECT * FROM lips INTO CORRESPONDING FIELDS OF TABLE gt_tmp
FOR ALL ENTRIES IN gt_str
WHERE vbeln = gs_str-del_doc
AND posnr = gs_str-del_item.
ENDIF.
SORT gt_tmp BY vbeln posnr. " for BINARY SEARCH
loop at gt_str into gs_str.
READ gt_tmp INTO gs_tmp
WITH KEY vbeln = gs_str-del_doc
posnr = gs_str-del_item
BINARY SEARCH.
*now i wanted to modify the field lfimg in table gt_str based on del_doc & del_item.
IF ( syst-subrc = 0 ).
MODIFY gt_str FROM gs_tmp. " gs_str.
ENDIF.
endloop.Regards
Uwe
‎2006 Dec 31 5:24 AM
hi,
1) select the fields outside the loop.
2) Then loop into the itab into work area and modify the itab using
3) MODIFY ITAB TRANSPORTING < key fields in table >.
This modify statement would help.