READ STATEMENT Clarrification
Hi all,
Can we use READ STATEMENT In ABAP to directly Read the DATA BASE TABLE like MARA.
Hi,
Sorry but you cannot use the READ statement to read the data directly from the database table.......you have to select the data from it into the internal table of same type...and read the internal table.
Pooja
Similar Messages
-
Logical expression( = , =, , ) in read statement
Hi All,
Is it possible to use the logical expressions like (<= , >=, <, >) in the read statement?While you can only use "=" with the READ statement, you can use the READ statement to position the cursor at the first record you want and then use the LOOP with your operators to get only those records you want (assuming standard tables that have been correctly sorted). This can be very efficient.
There have been many discussion about this in the forums. Please search and you'll see them.
Rob -
Problem with READ Statement in the field routine of the Transformation
Hi,
I have problem with read statement with binary search in the field routine of the transformation.
read statement is working well when i was checked in the debugging mode, it's not working properly for the bulk load in the background. below are the steps i have implemented in my requirement.
1. I selected the record from the lookuo DSO into one internal table for all entried in source_packeage.
2.i have read same internal table in the field routine for each source_package entry and i am setting the flag for that field .
Code in the start routine
select source accno end_dt acctp from zcam_o11
into table it_zcam
for all entries in source_package
where source = source_package-source
and accno = source_package-accno.
if sy-subrc = 0.
delete it_zcam where acctp <> 3.
delete it_zcam where end_dt initial.
sort it_zcam by surce accno.
endif.
field routine code:
read table it_zcam with key source = source_package-source
accno = source_package-accno
binary search
transportin no fields.
if sy-subrc = 0.
RESULT = 'Y'.
else.
RESULT = 'N'.
endif.
this piece of code exist in the other model there its working fine.when comes to my code it's not working properly, but when i debug the transformation it's working fine for those accno.
the problem is when i do full load the code is not working properly and populating the wrong value in the RESULT field.
this field i am using in the report filter.
please let me know if anybody has the soluton or reason for this strage behaviour.
thanks,
Rahim.i suppose the below is not the actual code. active table of dso would be /bic/azcam_o1100...
1. is the key of zcam_o11 source and accno ?
2. you need to get the sortout of if endif (see code below)
select source accno end_dt acctp from zcam_o11
into table it_zcam
for all entries in source_package
where source = source_package-source
and accno = source_package-accno.
if sy-subrc = 0.
delete it_zcam where acctp 3.
delete it_zcam where end_dt initial.
endif.
sort it_zcam by surce accno.
field routine code:
read table it_zcam with key source = source_package-source
accno = source_package-accno
binary search
transportin no fields.
if sy-subrc = 0.
RESULT = 'Y'.
else.
RESULT = 'N'.
endif. -
Issue with read statement with one more key missing in mapping
Hi All ,
I have such data in two internals table :
IT_bdc
vbeln posnr
90000593 10
90000576 10
90000672 10
90000672 20
90000672 30
it_konv
kbetr vbeln
6250 90000576
12160000 90000593
500000 90000672
600000 90000672
700000 90000672
My current program statement is :
LOOP AT it_bdc.
READ TABLE it_konv WITH KEY
vbeln = it_bdocs-vbeln.
currency = it_konv-waers.
endloop.
as you can see the posnr is missing in it_konv how can i modify this read statement so
that vbeln posnr from it_bdc should get correct kbetr from it_konv.
Kindly help in this mapping.Hi
sort it_konv by vbeln
then
loop at it_bdc.
read table it_konv with key vbeln = it_bdc-vbeln binary search.
if sy-subrc = 0.
perform your logic/task.
endif.
endloop.
also it depends what you want to do after reading it_konv.
in my logic if there is a vbeln in it_konv which s present in it_bdc then sy-subrc will be 0
and you can perform your logic.
and if there will be no matching vbeln in it_konv then sy-subrc will not be 0.
check the values in debugging.
Thanks
Lalit -
Error: unexpected XML reader state. expected: END but found: START:
I am getting following error while invoking method 'GetVersionInfo' (.net web service over dll) which takes one input parameter(string) and gives two output parameters(both short):
ERROR at line 1:
ORA-29532: Java call terminated by uncaught Java exception: deserialization
error: unexpected XML reader state. expected: END but found: START:
{UPPLink}pnVersionMajor
ORA-06512: at "SYS.UTL_DBWS", line 388
ORA-06512: at "SYS.UTL_DBWS", line 385
ORA-06512: at line 40
Expected Request is as follows:
POST /UPPLink/UPPLink.asmx HTTP/1.1
Host: 172.16.1.38
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "UPPLink/GetVersionInfo"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetVersionInfo xmlns="UPPLink">
<ignore>string</ignore>
</GetVersionInfo>
</soap:Body>
</soap:Envelope>
EXpected Response is as follows:
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetVersionInfoResponse xmlns="UPPLink">
<GetVersionInfoResult>
<pnVersionMajor>short</pnVersionMajor>
<pnVersionMinor>short</pnVersionMinor>
</GetVersionInfoResult>
</GetVersionInfoResponse>
</soap:Body>
</soap:Envelope>
The PL/SQL code I am using is as follows:
DECLARE
service_ sys.utl_dbws.SERVICE;
call_ sys.UTL_DBWS.call;
service_qname sys.utl_dbws.QNAME;
port_qname sys.utl_dbws.QNAME;
operation_qname sys.utl_dbws.QNAME;
string_type_qname sys.utl_dbws.QNAME;
number_type_qname sys.utl_dbws.QNAME;
retx ANYDATA;
strEntry VARCHAR2(100);
retx_string VARCHAR2(100);
majorVersion NUMBER;
minorVersion NUMBER;
params sys.utl_dbws.ANYDATA_LIST;
v_outputs sys.utl_dbws.anydata_list;
BEGIN
dbms_output.put_line('Starting Function');
service_qname := sys.utl_dbws.to_qname(null, 'UPPLink');
strEntry := 'vab';
dbms_output.put_line('Creating Service');
service_ := sys.utl_dbws.create_service(HTTPURITYPE('http://172.16.1.38/UPPLink/UPPLink.asmx?WSDL'), service_qname);
dbms_output.put_line('Creating Operation');
operation_qname := sys.utl_dbws.to_qname(null, 'GetVersionInfo');
dbms_output.put_line('Calling Service');
call_ := sys.utl_dbws.create_call(service_, null, operation_qname);
sys.utl_dbws.set_property(call_, 'SOAPACTION_USE', 'true');
sys.utl_dbws.set_property(call_, 'SOAPACTION_URI', 'UPPLink/GetVersionInfo');
sys.utl_dbws.set_property(call_, 'OPERATION_STYLE', 'rpc');
string_type_qname := sys.utl_dbws.to_qname('http://www.w3.org/2001/XMLSchema', 'string');
number_type_qname := sys.utl_dbws.to_qname('http://www.w3.org/2001/XMLSchema', 'short');
sys.utl_dbws.add_parameter(call_, 'ignore', string_type_qname, 'ParameterMode.IN');
sys.utl_dbws.add_parameter(call_, 'pnVersionMinor', number_type_qname, 'ParameterMode.OUT');
sys.utl_dbws.set_return_type(call_, number_type_qname);
params(0) := ANYDATA.convertvarchar2(strEntry);
dbms_output.put('Invoking with Input Parameter: ');
dbms_output.put_line(ANYDATA.ACCESSVARCHAR2(params(0)));
retx := sys.utl_dbws.invoke(call_, params);
dbms_output.put_line('Invoke complete');
majorVersion := retx.accessnumber;
dbms_output.put_line('Major Version ' || majorVersion);
v_outputs := SYS.utl_dbws.get_output_values(call_);
minorVersion := ANYDATA.AccessNumber(v_outputs(1));
dbms_output.put_line('Minor Version ' || minorVersion);
sys.utl_dbws.release_service(service_);
END;
/Actually, the name needs to match what is specified in the WSDL file.
-
M or P master data table to be used in routine read statement
Hi
I update of a DSO i had a requirment for a routine to get the Attribute of a Infoobject.
So which master data table M or P table i need to use in my read statement and why
ThanksUse M table as it it the view on time dependent(P table) and time independent(Q table) tables.
M table is view on time dependent and time independent attributes, you can see characteristic values and all the attributes for the Characteristic.
The tables that go in the view are the Master Data Table and the Time-Dependent Master Data Table. If the characteristic only has time-dependent attributes, only the time-dependent master data table goes in. If the characteristic has only non-time-dependent attributes, only the master data table goes in. -
hi,
my code is ;
select vbeln audat kunnr auart
from vbak
into table t_vbak2
for all entries in t_vbfa2
where vbeln = t_vbfa2-vbelv
and audat in r_daterange
and kunnr = partner_number.
if not t_vbak2[] is initial.
sort t_vbak2 by vbeln audat auart.
endif.
now if i use read statement :
read table t_vbak2 into wa_vbak2
with key vbeln = wa_vbfa1-vbelv
audat in r_daterange
kunnr = partner_number binary search.
i get a syntax error.
can any one help me with this..
Thanks,
Challa.You can't use the IN operator in your READ statement, only = as you are trying to read with key. In your case, you must use the LOOP statement.
Loop at t_vbak2 into wa_vbak2
where vbeln = wa_vbfa1-vbelv
and audat in R_daterange
and kunnr = Partner_Number.
* Do whatever you need to do
Exit. " This is so you only read one record.
Endloop.
Regards,
RIch Heilman -
I have doubt in Read statement
Hi All.
I have doubt in Read statement .i need to convert following select statement as read statement .how can i change help me.
IF p_field1 IS INITIAL
AND p_field2 IS INITIAL
AND p_field3 IS INITIAL
AND p_field4 IS INITIAL
AND p_field5 IS INITIAL.
SELECT *
FROM zdbt
INTO TABLE itab
WHERE field5 = p_field5
ORDER BY PRIMARY KEY.
IF sy-subrc <> 0.
MESSAGE s035.
ENDIF.
ENDIF.
regards,
Jay.hi
The READ statement is as below:
When u have a table already with values and to improve the performance u need to use this.
Reading Lines of Tables
To read a single line of any table, use the statement:
READ TABLE <itab> <key> <result>.
For the statement to be valid for any kind of table, you must specify the entry using the key and
not the index. You specify the key in the <key> part of the statement. The <result> part can
specify a further processing option for the line that is retrieved.
If the system finds an entry, it sets SY-SUBRC to zero, if not, it takes the value 4, as long as it is
not influenced by one of the possible additions. If the internal table is an index table, SY-TABIX
is set to the index of the line retrieved. If the table has a non-unique key and there are duplicate
entries, the first entry is read.
Thanks
Shiva -
Hi,
AM using Read statement to read internal table as below.
Read itab into wa with key x = y.
if sy-subrc eq 0.
do some thing.
endif.
However the work area wa is not useful to me in my program. when am doing extended check it is issueing warning saying wa is not used. HOW TO CLOSE THIS WARNING.
Regards,
AAkashjust before read statement do
CLEAR WA.
This should remove the error.
Cheers
VJ -
Read statement in internal table.
PLease help me to figure out what a read statement does???
Please show me through examples how a read statements selects data from a table ,,,puts into internal table & finally we are able to read it through work area????
thanx... <REMOVED BY MODERATOR>
Edited by: Alvaro Tejada Galindo on Mar 10, 2008 7:27 PMHey saswat ,
just wanted to give a simplified example of ur query , if not understood please ask
REPORT Z_PRGM_TRY_READ NO STANDARD PAGE HEADING.
TABLES : MARA , MARD.
SELECT-OPTIONS : S_MATNR FOR MARA-MATNR.
TYPES : BEGIN OF LT_MARA ,
MATNR LIKE MARA-MATNR ,
ERSDA LIKE MARA-ERSDA ,
MBRSH LIKE MARA-MBRSH ,
END OF LT_MARA .
DATA : TT_MARA TYPE STANDARD TABLE OF LT_MARA INITIAL SIZE 0 ,
WA_MARA TYPE LT_MARA .
TYPES : BEGIN OF LT_MARD ,
MATNR LIKE MARD-MATNR ,
WERKS LIKE MARD-WERKS ,
LGORT LIKE MARD-LGORT ,
PSTAT LIKE MARD-PSTAT ,
END OF LT_MARD.
DATA : TT_MARD TYPE STANDARD TABLE OF LT_MARD INITIAL SIZE 0 ,
WA_MARD TYPE LT_MARD.
TYPES : BEGIN OF LT_FINAL ,
MATNR LIKE MARA-MATNR ,
ERSDA LIKE MARA-ERSDA ,
MBRSH LIKE MARA-MBRSH ,
WERKS LIKE MARD-WERKS ,
LGORT LIKE MARD-LGORT ,
PSTAT LIKE MARD-PSTAT ,
END OF LT_FINAL .
DATA : TT_FINAL TYPE STANDARD TABLE OF LT_FINAL INITIAL SIZE 0 ,
WA_FINAL TYPE LT_FINAL .
SELECT MARA~MATNR
ERSDA
MBRSH
INTO CORRESPONDING FIELDS OF TABLE TT_MARA FROM MARA WHERE MARA~MATNR IN S_MATNR .
SELECT MARD~MATNR
WERKS
LGORT
PSTAT
INTO CORRESPONDING FIELDS OF TABLE TT_MARD FROM MARD
FOR ALL ENTRIES IN TT_MARA
WHERE MATNR = TT_MARA-MATNR.
LOOP AT TT_MARA INTO WA_MARA.
READ TABLE TT_MARD INTO WA_MARD WITH KEY MATNR = WA_MARA-MATNR .
IF SY-SUBRC = 0.
WA_FINAL-MATNR = WA_MARA-MATNR .
WA_FINAL-ERSDA = WA_MARA-ERSDA.
WA_FINAL-MBRSH = WA_MARA-MBRSH.
WA_FINAL-WERKS = WA_MARD-WERKS.
WA_FINAL-LGORT = WA_MARD-LGORT.
WA_FINAL-PSTAT = WA_MARD-PSTAT.
APPEND WA_FINAL TO TT_FINAL.
CLEAR WA_FINAL.
ENDIF.
ENDLOOP.
LOOP AT TT_FINAL INTO WA_FINAL.
WRITE : / WA_FINAL-MATNR , WA_FINAL-ERSDA , WA_FINAL-MBRSH , WA_FINAL-WERKS ,
WA_FINAL-LGORT , WA_FINAL-PSTAT.
ENDLOOP. -
Hello Experts,
Can I use both index and key addition in READ statment like
Read table itab from index i with key id = 'XYZ'.
Actually I am using that but the read statement is not following both the addition.Is there any other way out in which I can do that.I dont want to use LOOP...ENDLOOPHi *priya singh *.
You are not able to use index and with key parley in read statement. you should use LOOP..END LOOP only..
See following...
I think in your requirement you want i th record which is satisfied id = 'XYZ'.
use following code...
loop at itab into wa where id = 'XYZ'.
if sy-index eq = i.
" Assign/take values here
EXIT. " --> Immediately exit the loop after satisfied your condition
exit.
endloop.
Regards,
Mahi. -
Read statement in ECC6.0
Hi all,
I am working on ECC6.0 , but when i use Read statement it gives me erro that it is obsolute in ECC6.0.
So please suggest a way to proceed.
Regards,
NileshHi Nilesh,
READ statement is NOT Obsolete in ECC 6.0. It is very much in use. I think the syntax that you used might not be correct. Kindly verify with below syntax..
READ TABLE itab INTO ls_itab WITH KEY (Key fields) BINARY SEARCH.
WITH KEY
can be used or
WITH INDEX
can also be used..
<b>Reward points for helpful answers</b>.
Best Regards,
Ram. -
Can't I use Field NE SPACE in READ statement ?
What is wrong with the below statments
READ TABLE t_zdadp_rpt WITH TABLE KEY t_zdadp_rpt-zdesc NE SPACE.
READ TABLE t_zdadp WITH TABLE KEY zdesc NE SPACE.
Could you pleae helpHi,
In the first statement u have to specify only field name also in read statement no need for table key its just key..U cannot use NE symbol for read statement.
READ TABLE t_zdadp_rpt WITH TABLE KEY t_zdadp_rpt-zdesc NE SPACE.
READ TABLE t_zdadp WITH TABLE KEY zdesc NE SPACE.
plz correct the code like this
READ TABLE t_zdadp WITH KEY zdesc Eq SPACE.
if sy-subrc ne 0.
do what ever u want.
endif.
reward if helpful.
Regards,
nagaraj -
Can we use more than one or in read statement
READ TABLE itab_return INTO wa_return
WITH KEY type = 'E' or
= 'i'.hi.
No u cannot use 'and' or 'or' in read statement.
you can do as
FOR AND condition
read table itab into wa with key type = 'I'.
if sy-subrc = 0.
read table itab into wa with key type = 'E'.
endif.
FOR OR condition
read table itab into wa with key type = 'I'.
read table itab into wa with key type = 'E'.
if sy-subrc = 0.
<code>
endif.
regards
prasanth -
Can put condition in read statement for a particular fild please suggest?
hi i have a requirement as belo
1 ) i am reading a table with read statement now i want to read with one more condition like
where status<> Z
to add to this read statement as below can i add the above condition to the below statement?? let me know
how to check on this one more condition in below read statement
loop at itrecord1 into wa_Record
READ TABLE it_main INTO wa_inv_master WITH KEY
/' CUSIP = wa_record-primarykeyfield1 BINARY SEARCH.
here one more condition i need to put whilereading that where statu <>z which is best way todo
IF SY-SUBRC = 0.
APPEND wa_record TO itrecord1.
clear wa_record.
else.
APPEND wa_record TO itrecord2.
clear : wa_record.
ENDIF.
ENDLOOP.
so how to put the condition in above statment can put in the read statement as that is most convinient will that work?
regards
aroraHello arora.
You can restrict the READ to an internal table, using "n" conditions in WITH KEY statement.
Use:
READ TABLE it_main INTO wa_inv_master
WITH KEY cusip = wa_record-primarykeyfield1
field2 = wa_record-field2
fieldn = wa_record-fieldn
BINARY SEARCH.
Remember that if you want restrictions like ">=", "<=", "<" or "<", must use LOOP, not READ.
Regards.
Valter Oliveira.
Maybe you are looking for
-
Data transfer very slow on mac pro!! mac H/W unable to fit specifications.
Hi, I am installinginternal disks on the quad mac pro and the transfer ratet in the mac are very slow!!! the disks are: barracuda 7200.10 disks, 500 GB. Sta II 300, max ST3500630AS firmware 3.AAE . throughput:300mb.jumpred off to get the 300. MAC tel
-
Can't find the ODS in query designer
Hi Gurus; I am using SAP_BW 30B. I just created an ODS but I can't find the ODS under the InfoArea menu in query designer. I am not sure if it is related but, I tried to check the box for BEx Reporting under ODS settings. When I save or activate the
-
HT201210 where can i find the back up file for my iphone?
its not backing up. its said i have to delete the corrupted back up file first, but where can i find the back up file? thanks
-
Audio not working in pavilion dm3 after harddrive change and operating system reload
I had hard drive failure on my Hp Pavilion dm3 and so I got a new hard drive and had the operating system reloaded and upgraded from Windows 7 Home Premium to Windows 7 Professional. My audio isn't working unless I have external speakers plugged in.
-
NOKIA 303: gmail sender name setting?
Hello everybody! Just bought the new asha 303. I use primarily gmail on the device and I'm not able from the pre-installed nokia e-mail application to send an e-mail with my name as the sender of a message instead of the e-mail address. Only from the