‎2009 Feb 23 4:29 AM
Hi ,
iam getting syntax error please suggest
read table tbl_bseg with key buzid = ( 'W' OR 'T' OR 'S' ) BINARY SEARCH.
‎2009 Feb 23 4:37 AM
Hi,
YOu can't take the multiple values at at time.
instead take the ranges for those values an compare..
like
Ranges: r_buzid for xxx-buzid " consider your table
r_buzid-sign = 'I'
r_buzid-option = 'EQ'
r_buzid-low = 'W'.
append r_buzid.
r_buzid-sign = 'I'
r_buzid-option = 'EQ'
r_buzid-low = 'T'.
append r_buzid.
r_buzid-sign = 'I'
r_buzid-option = 'EQ'
r_buzid-low = 'S'.
append r_buzid.
read table tbl_bseg with key buzid = r_buzid BINARY SEARCH.hope it works.
Regards!
‎2009 Feb 23 4:37 AM
Hi,
YOu can't take the multiple values at at time.
instead take the ranges for those values an compare..
like
Ranges: r_buzid for xxx-buzid " consider your table
r_buzid-sign = 'I'
r_buzid-option = 'EQ'
r_buzid-low = 'W'.
append r_buzid.
r_buzid-sign = 'I'
r_buzid-option = 'EQ'
r_buzid-low = 'T'.
append r_buzid.
r_buzid-sign = 'I'
r_buzid-option = 'EQ'
r_buzid-low = 'S'.
append r_buzid.
read table tbl_bseg with key buzid = r_buzid BINARY SEARCH.hope it works.
Regards!
‎2009 Feb 23 4:45 AM
Hi,
First make ranges as Prashant said above, then in the loop of range read the table.
Thanks,
Krishna...
‎2009 Feb 23 5:02 AM
Check the follwoing test code
DATA: BEGIN OF it OCCURS 10,
name(1),
END OF it.
it-name = 'A'.
APPEND it TO it.
it-name = 'Z'.
APPEND it TO it.
it-name = 'C'.
APPEND it TO it.
it-name = 'D'.
APPEND it TO it.
it-name = 'X'.
APPEND it TO it.
it-name = 'Y'.
APPEND it TO it.
SORT it BY name.
READ TABLE it INTO it WITH KEY name = 'A' BINARY SEARCH.
IF sy-subrc EQ 0.
WRITE: / 'Read Table', it-name.
ENDIF.
*if you want read more records from internal table using one key field than you must use Loop at
LOOP AT it INTO it WHERE name = 'A' OR name = 'C'.
WRITE: / 'Loop At', it-name.
ENDLOOP.Edited by: tahir naqqash on Feb 23, 2009 10:05 AM
Edited by: tahir naqqash on Feb 23, 2009 10:08 AM
‎2009 Feb 23 5:21 AM
Hi,
Read statement is not conditional . You can use rangrs or loop at the internal table and put the restrictions in where clause. Also , sort the internal table before reading it.Sorting and reading sequence should be same ; otherwise binary search may not work properly.
‎2009 Feb 23 5:21 AM
hi,
You can use " if " and "Sy-subrc" in combination to "read " the data with all the OR clause.
This time of Read statement that u have used will not work.
Thanks
Suraj
‎2009 Feb 23 6:12 AM
‎2009 Feb 23 6:14 AM
Hi:
In read syntax, AND / Or is not appilcable so you have to check the required conditions put it under loop.
Regards
Shashi
‎2009 Feb 23 6:17 AM
hi,
in read staement conditional operators are not allowed.U insert that inro one range variable.then loop on tht range.
‎2009 Feb 23 6:23 AM
Hi ,
1. If possible, you can get data only for BUZID = 'W' , 'T' or 'S' while selecting the data at first step itself.
2. If step not possible, then you can write following loop statement.
LOOP AT tbl_bseg WHERE ( buzid eq 'W'
or buzid eq 'T'
or buzid eq 'S' ).
Process as per your requirement.
Here if you have requirement like, you have to process only 1 record, then just getting once into
loop, after first processing you use 'EXIT'.
Let me know your requirement.
ENDLOOP.
‎2009 Feb 23 6:24 AM
Hi ,
1. If possible, you can get data only for BUZID = 'W' , 'T' or 'S' while selecting the data at first step itself.
2. If step not possible, then you can write following loop statement.
LOOP AT tbl_bseg WHERE ( buzid eq 'W'
or buzid eq 'T'
or buzid eq 'S' ).
Process as per your requirement.
Here if you have requirement like, you have to process only 1 record, then just getting once into
loop, after first processing you use 'EXIT'.
Let me know your requirement.
ENDLOOP.