06-18-2009 11:12 AM
Hi,
I have a scenario like this. I have sales orders in one internal table. I have to move all these sales orders to a range table.
So, as you know range table has 4 fields (SIGN, OPTION, LOW and HIGH).
I want my sales orders to be moved to LOW field of the range table. Is there any single line statement to achieve this ? I dont want to loop on the internal table to move it to the range table.
Any help on this would be highly appreciated.
Thanks,
Babu Kilari
06-18-2009 11:17 AM
Hi,
I dont think that there may be a solution to move records in one go, as the structures for the tables will be different.
Rather you wil have to use a loop statement and then assign it to range table.
Regards,
Tarun
06-18-2009 11:17 AM
Hi,
I dont think that there may be a solution to move records in one go, as the structures for the tables will be different.
Rather you wil have to use a loop statement and then assign it to range table.
Regards,
Tarun
06-18-2009 11:38 AM
Hi Tarun.
Thanks for the reply. Yes, I can be able to do that with the help of loop statement.
I was searching for a single line statement because this entire operation would be in a loop.
If I do it with loop-endloop it would be like loop inside a loop which is a performance overheard.
Hope you got my point.
Thanks,
Babu Kilari
06-18-2009 11:46 AM
Hi,
I agree on your point..
But there seems no other option available to move the records.
An alternative is to use the same internal table for selecting further data using FOR ALL ENTRIES on the sales order field.
But make sure that you dont have duplicate sales order in the internal table.
Also this option wil eliminate, getting a dump if the range table has more than 20-25 entries (i guess) and you use that range table in where clause to fetch the data.
So its better that either you take another internal table with only one field (VBELN).
Now you can move only the sales order from your internal table into this new internal table.
And then use this new ITAB as per your requirement.
Hope this solves your problem.
Thanks & Regards,
Tarun
06-18-2009 11:58 AM
Hi,
In continuation to the above reply...
Refer this code, it wil solve your problem.
DATA : itab TYPE STANDARD TABLE OF vbap,
wa TYPE vbap.
TYPES : BEGIN OF tab1,
vbeln TYPE vbeln_va,
END OF tab1.
DATA : itab1 TYPE STANDARD TABLE OF tab1,
wa1 TYPE tab1.
START-OF-SELECTION.
SELECT * FROM vbap
UP TO 100 ROWS
INTO TABLE itab.
IF sy-subrc = 0.
APPEND LINES OF itab TO itab1. "<--transfer all data in one go
ENDIF.
SORT itab1[] BY vbeln.
DELETE ADJACENT DUPLICATES FROM itab1 COMPARING vbeln.
Now use itab1 to fetch the further data using FOR ALL ENTRIES
Hope this helps you.
Thanks & Regards,
Tarun
06-18-2009 11:25 AM
Hi,
Why cant you use that internal table as For all Entries in a select query to restrict the order numbers?
Regards
Karthik D
06-18-2009 11:33 AM
Hi,
define one range like s_range1
range1-sign = 'I'
range1-option = 'EQ'
loop at itab
rangel-low = itab-field1
append range1
endloop
select .......field1 in range1
Regards,
Sneha.
06-18-2009 11:34 AM
Hi babu,
Declare a range,
RANGES : R_vbeln FOR vbak-VBELN.
loop at <tab>.
r_vbeln-SIGN = 'I'.
r_vbeln -OPTION = 'EQ'.
r_vbeln-LOW = tab-vbeln.
append r_vbeln.
endloop.
Regards,
Murugesh R
Edited by: Murugesh Kumar Ramasamy on Jun 18, 2009 4:05 PM
Edited by: Murugesh Kumar Ramasamy on Jun 18, 2009 4:05 PM
06-18-2009 11:37 AM
Hi ,
I do not think that it would possible from by a single statement without loop.
But once I faced similar type of problem and I used the FOR ALL ENTRIES of
instead of using the Select-options.
Regards
Pinaki
06-18-2009 11:40 AM
Hi Pinak,
May I know how did u move the entries to a particular field in the target internal table using FOR ALL ENTRIES?
Thanks,
Babu Kilari
06-18-2009 11:58 AM
Hi,
First of all I am sorry ....
I might have missunderstood your question.
thats why I told you insted of using select-option we can use the table value in select ,Like -
TABLES : spfli.
DATA : BEGIN OF fs,
carrid TYPE spfli-carrid,
END OF fs.
DATA : t_itab LIKE TABLE OF fs,
t_sbook like table of sbook.
fs-carrid = 'AA'.
append fs to t_itab.
fs-carrid = 'UA'.
append fs to t_itab.
select * from sbook into table t_sbook for all entries in t_itab
where carrid = t_itab-carrid.
Regards
Pinaki
09-16-2021 7:50 AM
Hi,
DATA: it_scarr TYPE TABLE OF scarr.
"fill your internal table
SELECT * FROM scarr INTO TABLE it_scarr.
DATA: gr_carr TYPE RANGE OF scarr-carrid.
"write the column carrid of your internal table in your range
gr_carr = VALUE #( FOR <fs_scarr> IN it_scarr
(
sign = 'I'
option = 'EQ'
low = <fs_scarr>-carrid
high = ''
) ).
regards
CC
09-16-2021 7:51 AM
Thanks for coming to SAP Community for answers. Please post your question as a new question here:
Since you're new in asking questions here, check out our tutorial about asking and answering questions (if you haven't already), as it provides tips for preparing questions more effectively, that draw responses from our members.
Please note, that your post here won't be answered.