‎2009 Nov 18 7:18 AM
Hi All,
I am new to ABAP, could you please help me to convert the following Select statement into READ.
I searched in forum but i could nt find any thread that will be helping in.
loop at itab_neword .
select max( /bic/zpviewdt ) from /bic/azvfosp2w00 into variable_ord
where
doc_number = itab_neword-doc_number and
s_ord_item = itab_neword-s_ord_item and
sched_line = itab_neword-sched_line.
wa_pdate-DOC_NUMBER = itab_neword-DOC_NUMBER.
wa_pdate-S_ORD_ITEM = itab_neword-S_ORD_ITEM.
wa_pdate-sched_line = itab_neword-SCHED_LINE.
wa_pdate-pdate = variable_ord.
APPEND wa_pdate to it_pdate.
clear variable_ord.
endloop.
‎2009 Nov 18 7:28 AM
Hi,
select doc_number
s_ord_item
sched_line
/bic/zpviewdt from /bic/azvfosp2w00 into table itab_w00
for all entries in itab_neword
where doc_number = itab_neword-doc_number and
s_ord_item = itab_neword-s_ord_item and
sched_line = itab_neword-sched_line.
sort itab_w00 by doc_number ASCENDING /bic/zpviewdt DESCENDING
loop at itab_neword .
read table itab_w00 with key doc_number = itab_neword-doc_number and
s_ord_item = itab_neword-s_ord_item and
sched_line = itab_neword-sched_line binary search.
wa_pdate-DOC_NUMBER = itab_neword-DOC_NUMBER.
wa_pdate-S_ORD_ITEM = itab_neword-S_ORD_ITEM.
wa_pdate-sched_line = itab_neword-SCHED_LINE.
wa_pdate-pdate = itab_w00-/bic/zpviewdt.
APPEND wa_pdate to it_pdate.
clear itab_newword, clear itab_w00.
endloop.
Regards,
Kumar M.
Edited by: Kumar M on Nov 18, 2009 8:28 AM
‎2009 Nov 18 7:31 AM
if itab_neword[] is not initial.
select max( /bic/zpviewdt ) from /bic/azvfosp2w00 into table it_variable_ord
for all entries in itab_neword
where
doc_number = itab_neword-doc_number and
s_ord_item = itab_neword-s_ord_item and
sched_line = itab_neword-sched_line.
endif.
if it_variable_ord[] is not initial.
loop at itab_neword .
read table it_variable_ord with key doc_number = itab_neword-doc_number
s_ord_item = itab_neword-s_ord_item
sched_line = itab_neword-sched_line.
if sy-subrc = 0.
"move the values
endif.
endloop.
endif.
‎2009 Nov 18 7:42 AM
Hi Keshu,
Can we use Aggregate functions in FOR ALL ENTRIES Statement, i tried its throwing error
Reagrds,
Kumar M
‎2009 Nov 18 8:11 AM
HI ,
you follow as like
1) You declatre the range table for three fields doc_number , s_ord_item and sched_line.
loop at itab_neword into wa.
here you filled the ranges table .
endloop.
select max( /bic/zpviewdt ) from /bic/azvfosp2w00 into table it_variable_ord
where
doc_number in ranges_table1 and
s_ord_item in ranges_table2 and
sched_line in ranges_table3 .
sort it_variable_ord by doc_number s_ord_item sched_line
loop at itab_neword .
read table it_variable_ord with key doc_number = itab_neword-doc_number
s_ord_item = itab_neword-s_ord_item
sched_line = itab_neword-sched_line.
if sy-subrc = 0.
"move the values
endif.
‎2009 Nov 18 8:44 AM
Dear Shambu,
Could you please give me the syntax for Range Table.I got literally confused as how to declare it as each range has
r_mdate-sign =
r_mdate-option =.
r_mdate-low =
r_mdate-high
Could you please define the range for the current scenario you suggested
‎2009 Nov 18 9:23 AM
There is no need of range statement here.
@ Kumar - Im sorry no aggregate functions can be used with for all entries .
if itab_neword[] is not initial.
select doc_number s_ord_item s_ord_item /bic/zpviewdt from /bic/azvfosp2w00 into table it_variable_ord
for all entries in itab_neword
where
doc_number = itab_neword-doc_number and
s_ord_item = itab_neword-s_ord_item and
sched_line = itab_neword-sched_line.
endif.
if it_variable_ord[] is not initial.
sort gt_line by doc_number s_ord_item sched_line ASCENDING /bic/zpviewdt DESCENDING .
loop at itab_neword .
read table it_variable_ord with key doc_number = itab_neword-doc_number
s_ord_item = itab_neword-s_ord_item
sched_line = itab_neword-sched_line.
if sy-subrc = 0.
"move the values
endif.
endloop.
Edited by: Keshu Thekkillam on Nov 18, 2009 2:56 PM
‎2009 Nov 18 11:20 AM
Hi Shambhu,
i tried with ur suggestion and changes as follows
Data:r_docnumber type RANGE OF /BIC/AZVFOSDP240-DOC_NUMBER,
wa_docnumber like LINE OF r_docnumber.
Data:r_sitem type RANGE OF /BIC/AZVFOSDP240-S_ORD_ITEM,
wa_sitem LIKE LINE OF r_sitem.
Data:r_sline type RANGE OF /BIC/AZVFOSDP240-SCHED_LINE,
wa_sline like LINE OF r_sline.
REFRESh r_docnumber.
REFRESH r_sitem.
REFRESH r_sline.
select DOC_NUMBER S_ORD_ITEM SCHED_LINE max( /bic/zpviewdt ) from /bic/azvfosp1w00 into table it_pdate where
doc_number in r_docnumber and
s_ord_item in r_sitem and
sched_line in r_sline
group by DOC_NUMBER S_ORD_ITEM SCHED_LINE.
and i feel its working fine.
but i just wonder how its working as R_document number ,r_sitem,r_sline are only declared and not filled up.
but its giving correct output.
could you please explain
regards
Bala
‎2009 Nov 18 12:14 PM
‎2009 Nov 18 9:39 AM
Your question is not clear. Where is your data? Have you selected data from /bic/azvfosp2w00 into an internal table already?
‎2009 Nov 18 11:17 AM
Dear all,
it_neword contains data which was fetched before.
i need to check maximum date in /bic/azvfospw100 for all entries in IT_NEWORD for
matching document number,sales order item and schedule line between 2 tables.