Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Internal table conversion to read

Former Member
0 Likes
1,176

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.

10 REPLIES 10
Read only

Former Member
0 Likes
1,144

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

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,144

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.

Read only

0 Likes
1,144

Hi Keshu,

Can we use Aggregate functions in FOR ALL ENTRIES Statement, i tried its throwing error

Reagrds,

Kumar M

Read only

0 Likes
1,144

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.

Read only

0 Likes
1,144

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

Read only

0 Likes
1,144

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

Read only

0 Likes
1,144

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

Read only

0 Likes
1,144

could anyone explian please..

Read only

matt
Active Contributor
0 Likes
1,144

Your question is not clear. Where is your data? Have you selected data from /bic/azvfosp2w00 into an internal table already?

Read only

Former Member
0 Likes
1,144

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.