Conflict: READ TABLE itab2 INDEX 1 vs Modify itab1 from index sy-tabix
The below simple code is for each itab1 line, create a new itab2 by using select statement, and then grab the max value of field f in itab2 and fill it into a corresponding field in itab1.
However the statement:
READ TABLE itab2 into gs_itab1 INDEX 1.
causes the conflict with our another statement in the end of itab1 loop:
Modify itab1 from gs_itab1 index sy-tabix.
that the below Modify statement always modify itab1 at 1st row and also causes an unlimited loop that the program is hung up. Our code looks as the following:
Loop AT itab1 into gs_itab1.
use Select statement to fill in itab2...
SORT itab2 BY f DESCENDING. "f is a field of itab2
READ TABLE itab2 into gs_itab1 INDEX 1.
Modify itab1 from gs_itab1 index sy-tabix.
EndLoop.
However the last two lines of statements in the itab1 loop causes the program hang!
Any solution?
Thanks in advance!
Hi,
I got confused while going thru the code...
according to code
first u loop itab1 and get tht in gs_itab1 and then a select query to get data from some table and store in itab2.
Here are u using any where condition, if yes u may probably check aganst gs_itab1 rite? if yes
first suggestion...why cant u put the select statement above the loop and get all the values to an internal table and then read the internal table in the loop stmt. Yes i can see u r sorting it based on some 'f'..just a suggestion
Now here can u follow this code...
Loop AT itab1 ASSIGNING <fs_itab1>,
use Select statement to fill in itab2...
SORT itab2 BY f DESCENDING. "f is a field of itab2
READ TABLE itab2 into <fs_itab1> index 1.
EndLoop.
Please let me know if its not ok
<REMOVED BY MODERATOR>
Regards,
ABAPer007
Edited by: Alvaro Tejada Galindo on Apr 11, 2008 12:26 PM
Similar Messages
-
How to read table fields form a table having length of 7 characters
HI all,
could you please tell me how to read table fields from a table having length 7 characters, i have requirement that in my ztable i have 30 fields out of which 20 fields are location fields, i want to select 20 fields which have 7 characters length.
please could any body suggest me on this issue.
thanks,
sre.hi,
try like this
create a data variable of type i as
data: len type i.
create internal table for 20 fields as
data:begin of itab,
fld 1 type .......
end of itab.
data:itab type itab1 occurs 0 with header line.
loop at itab2. // original internal table which all fields.
read table itab2 with index sy-tabix.
len = strlen (itab2-fld).
if len eq 7.
move itab2 itab1.
append itab1.
endif.
endloop.
if helpful reward some points.
with regards,
Suresh.A -
Sy-tabix in relation to LOOP AT and READ TABLE
Hi All,
As per SAP documentation,
1) While looping through an internal table (LOOP AT), sy-tabix contains the index number of current row(for standard and sorted tables)
2)When successfully reading from an internal table(READ TABLE), sy-tabix is set to the index of the result row.
But what happens when READ TABLE is used while looping through another internal table?
i.e. Loop at TAB1...
write sy-tabix.
READ TABLE TAB2...
write sy-tabix.
endloop.
If we are looping through 1st row of TAB1 and the result of read statement is found in 3rd row of TAB2, I expected that sy-tabix before READ would be 1 and after the READ be 3.
But, I found that sy-tabix remains unchanged at 1. Can someone expalin why?
Thanks,
JaganHi
If after reading the table TAB2 the system variable SY-TABIX has still the previous value, that menas the READ TABLE fails or it was read the first record of TAB2.
After READ TABLE TAB2 try to check the SY-SUBRC:
LOOP AT TAB1.
WRITE: / 'TAB1 index:', SY-TABIX.
READ TABLE TAB2 .........
IF SY-SUBRC = 0.
WRITE: 'TAB2 index:', SY-TABIX.
Try this:
DATA: BEGIN OF ITAB OCCURS 0,
FIELD1,
END OF ITAB.
DATA: BEGIN OF ITAB2 OCCURS 0,
FIELD1,
END OF ITAB2.
DATA: INDEX TYPE I.
DO 10 TIMES.
APPEND ITAB.
ENDDO.
DO 10 TIMES.
APPEND ITAB2.
ENDDO.
LOOP AT ITAB.
WRITE: / 'ITAB:', SY-TABIX.
INDEX = SY-TABIX + 2.
READ TABLE ITAB2 INDEX INDEX.
IF SY-SUBRC = 0.
WRITE: 'ITAB2:', SY-TABIX.
ENDIF.
ENDLOOP.
Max -
"Read table" and field symbols
Hello all,
I have a (hopefully simple) question. Let's suppose I want to do the following:
loop at itab1 assigning <fs1>.
read table itab2 assigning <fs2> with table key <fs1>-field1.
if sy-subrc eq 0.
move <fs2>-field1 to ls_out-field1.
endif.
read table itab3 assigning <fs3> with table key <fs1>-field2.
if sy-subrc eq 0.
move <fs3>-field1 to ls_out-field2.
endif.
endloop.
It's also possible to do the following instead:
loop at itab1 assigning <fs1>.
unassign: <fs2>,
<fs3>.
read table itab2 assigning <fs2> with table key <fs1>-field1.
read table itab3 assigning <fs3> with table key <fs1>-field2.
if <fs2> is assigned.
move <fs2>-field1 to ls_out-field1.
endif.
if <fs3> is assigned.
move <fs3>-field1 to ls_out-field2.
endif.
endloop.
My question is: is it "better" to check sy-subrc after each read, and then do a move statement within that if statement, or is it better to check whether the field symbol is assigned each time I want to fill in a field and read everything at the same time?
I'm only really concerned about the case where you don't want to drop out of the loop after the read (so if the read fails you just don't fill any data in). I'm also discounting potential human error (otherwise the sy-subrc method wins hands-down).Just to close this one (albeit somewhat belatedly). I asked Harry Dietz (the ABAP Performance blogging fella) what he would suggest, and he says sy-subrc all the way. Checking that an integer is zero is considerably faster than checking for the assignment, or otherwise, of a field symbol. Furthermore, whilst the field symbol method has the potential to be faster than the sy-subrc method given some compiler optimizations, unfortunately these optimizations don't exist in the ABAP compiler - they're there in the Java compiler though! Shame really. Apparently the ABAP compiler is a pretty simple beast.
Anyway - thanks Harry for clearing this one up! -
I selected some data from table and put into internal table.I want to change some fields by some calculations.I tried using read stmt.it fetches only one record.I need to change group of records(not in dbase.)in internal table.How to do this?
Hi Khanna,
You can do in this way... implement for your requirement...
Types: begin of ty_tab1,
a type i,
b type i,
c type i,
end of ty_tab1.
Data: itab1 type table of ty_tab1,
wa1 type ty_tab1.
wa1-a = 10.
wa1-b = 20.
append wa1 to itab1.
wa1-a = 15.
wa1-b = 25.
append wa1 to itab1.
loop at itab1 into wa1.
wa1-c = wa1-a + wa1-b.
modify itab1 from wa1 transporting c.
clear wa1.
endloop.
Reward Points if this helps.
Satish -
Modify ztable from internal table
Hi,
I have a Ztable in which i have 4 diff fields....1 2 3 4
and an internal table in whch i have same number of fields...
Internal table :
1 2 3 4
a w x 9
a w x 10
a w x 11
a w x 13
a w x 12
When I am using Modify it only appends last record into ztable as below:
Ztable : 1 2 3 4
a w x 12
Internal table has 6 records and z table should be appended with 6 records too...
if varid-report = 'ZFINRR1001' and
varid-VARIANT = 'CITI - ZBA' or
varid-VARIANT = 'WACHOVIA - ZBA'.
Modify ZV12_SWEEP from t_data_new.
endif.
Any suggestions will be aprreciated!
Regards,
Kittu>
Kittu wrote:
> When I am using Modify it only appends last record into ztable
>
> Modify ZV12_SWEEP from t_data_new.
Hi,
You only get last record appended because your MODIFY statement uses t_data_new as a working area and not as a table.
To append the content of your internal table, use the FROM TABLE option as below :
MODIFY zv12_sweep FROM TABLE t_data_new.
Regards.
Nicolas -
Regarding modifying database from internal table
Hi ABAP Experts,
I am facing an issue regarding modifying DB table from itab.
All the records of itab are not getting reflected in DB table using Modify statement.
Syntax is as follows -
Locking DB table using enque FM
MODIFY abc FROM TABLE i_abc.
Unlocking DB table using deques FM
Please suggest what could be wrong with this. Helpful suggestion will be appreciated.
Thanks in adv,
AkashHi,
First Delete entries from the table(hope it is a custom table),
for example
DELETE FROM <DatabaseTable name> WHERE <primarykey = 'somevalue'>.
'After deleting those records.....then use insert statement
IF sy-subrc = 0.
INSERT <DatabaseTable name> FROM TABLE <InternalTable name> ACCEPTING DUPLICATE KEYS.
ENDIF.
Thanks & REgards -
Invalid Cursor when I want to modify itab with READ TABLE ?
Following code causes a core dump and says invalid cursor.
What should I do if I want to change gt_itab .?
REPORT ZEV_READ_TABLE.
data: begin of gt_itab occurs 0,
key like vbrk-vbeln,
name(10) type C,
amount type i,
end of gt_itab .
start-of-SELECTION.
gt_itab-key = 1.
gt_itab-name = 'erkan'.
gt_itab-amount = 10.
append gt_itab.
gt_itab-key = 2.
gt_itab-name = 'dilem'.
gt_itab-amount = 20.
append gt_itab.
LOOP AT gt_itab.
write:/ gt_itab-key,
gt_itab-name,
gt_itab-amount.
ENDLOOP.
Read table gt_itab with key Key = 1.
if sy-subrc = 0.
gt_itab-amount = 100.
modify gt_itab.
endif.
Kind Regards.
Erkan VAROLChange the code this way & try
modify gt_itab index sy-tabix.
a® -
Read Table ITAB with key Dynamic Value index 1
Here is sample Intenral table
Columnname-C01 / C02 / C03
Value-123 / 456 /789
I would like to search value of the internal table according to dynamic value given by the code.
i.e.
read table ITAB with key <Dynamic Value> index 1.Hi,
Apart from read, you can also use <b>SEARCH</b> statement.
Syntax
SEARCH
Searches for strings.
Syntax
SEARCH <f>|<itab> FOR <g> [ABBREVIATED]
[STARTING AT <n1>]
[ENDING AT <n2>]
[AND MARK]
[IN BYTE MODE|IN CHARACTER MODE].
Searches the field <f> or table <itab> for the string in the field <g>. The result is stored in SY-FDPOS. The additions let you hide intermediate characters, search from and to a particular position, and convert the found string into uppercase. In Unicode programs, you must specify whether the statement is a character or byte operation, using the IN BYTE MODE or IN CHARACTER MODE (default) additions.
Hope this information is useful to you.
Regards,
Saumya -
Hai friends after read,how to write the modify stmt
READ TABLE IT_makt into wa_makt with key matnr = wa_ekpo-matnr.
hi check this...
types: begin of ttab ,
vbeln(10) type c ,
vkorg(4) type c,
dele(4) type c,
end of ttab ,
begin of ttab1 ,
vbeln(10) type c,
dele(4) type c,
end of ttab1 .
data: itab type table of ttab with header line,
itab1 type table of ttab1 with header line,
wa like line of itab ,
wa1 like line of itab1 .
itab-vbeln = '0000000001'.
itab-vkorg = '1000'.
itab-dele = 'DEL'.
append itab .
itab-vbeln = '0000000002'.
itab-vkorg = '1000'.
itab-dele = 'DEL'.
append itab .
itab-vbeln = '0000000003'.
itab-vkorg = '1000'.
itab-dele = 'DEL'.
append itab .
itab1-vbeln = '0000000001'.
itab1-dele = 'TST'.
append itab1 .
itab1-vbeln = '0000000002'.
itab1-dele = 'GRE'.
append itab1 .
sort itab by vbeln.
sort itab1 by vbeln.
loop at itab into wa.
data:v_index type sy-index .
v_index = sy-tabix.
read table itab1 into wa1 with key vbeln = wa+0(10).
wa14(4) = wa110(4).
modify itab index v_index from wa .
endloop.
loop at itab.
write:/ itab-vbeln,itab-vkorg,itab-dele .
endloop. -
Dear All,
Please let me know which one of the two should I use to improve the performance, for tables containing a lot of data ?
Regards,
Thanks in anticipation.
Alok.Hi,
Follow below steps.
In se30 transaction you can look for
Tip&TRicks button on application toolbar
apart from below conventions
Follow below steps
1) Remove corresponding from select satement
2) Remove * from select
3) Select field in sequence as defined in database
4) Avoid unnecessary selects
i.e check for internal table not initial
5) Use all entries and sort table by key fields
6) Remove selects ferom loop and use binary search
7) Try to use secondary index when you don't have
full key.
8) Modify internal table use transporting option
9) Avoid nested loop . Use read table and loop at itab
from sy-tabix statement.
10) free intrenal table memory wnen table is not
required for further processing.
11)
Follow below logic.
FORM SUB_SELECTION_AUFKTAB.
if not it_plant[] is initial.
it_plant1[] = it_plant[].
sort it_plant1 by werks.
delete adjacent duplicates from it_plant1 comparing werks
SELECT AUFNR KTEXT USER4 OBJNR INTO CORRESPONDING FIELDS OF TABLE I_AUFKTAB
FROM AUFK
FOR ALL ENTRIES IN it_plant1
WHERE AUFNR IN S_AUFNR AND
KTEXT IN S_KTEXT AND
WERKS IN S_WERKS AND
AUART IN S_AUART AND
USER4 IN S_USER4 AND
werks eq it_plant1-werks.
free it_plant1.
Endif.
ENDFORM. "SUB_SELECTION_AUFKTAB
Regards
Amole -
i have to fetch belnr from bkpf table, and tax amount(fwste) from bset table.
if for a particular belnr suppose if this belnr 1700000000 has 5 line items in bset table than i need tax amount for all those 5 line items it means i need addition of that tax amount in output
for eg in bset table
belnr fwste lifnr curr
17000000000 0.00 0002300000 usd
2.00
0.00
4.00
in ouput i should get only subtotal has
1700000000 6.00 00023000000 usd
please help how to do its urgent
below is the code
SELECT bukrs
belnr
gjahr
xblnr
waers
budat
usnam
tcode
awkey
FROM bkpf
INTO TABLE gt_bkpf
WHERE bukrs IN s_bukrs
AND gjahr IN s_gjahr
AND tcode EQ 'MIRO'.
SELECT bukrs
belnr
gjahr
buzei
koart
lifnr
zlspr
FROM bseg
INTO TABLE gt_bseg
FOR ALL ENTRIES IN gt_bkpf
WHERE bukrs EQ gt_bkpf-bukrs
AND belnr EQ gt_bkpf-belnr
AND gjahr EQ gt_bkpf-gjahr
AND lifnr IN s_lifnr
AND zlspr IN s_zlspr
and koart eq 'K'.
AND bschl EQ '31'.
gt_bseg1[] = gt_bseg[].
SORT gt_bseg1[] BY lifnr.
DELETE ADJACENT DUPLICATES FROM gt_bseg1[] COMPARING lifnr.
IF gt_bseg1[] IS NOT INITIAL.
SELECT lifnr
name1
FROM lfa1
INTO TABLE gt_lfa1
FOR ALL ENTRIES IN gt_bseg1
WHERE lifnr EQ gt_bseg1-lifnr.
and lifnr eq s_lifnr.
ENDIF.
IF gt_bkpf[] IS NOT INITIAL.
SELECT belnr
gjahr
tcode
WAERS
zuonr
FROM rbkp
INTO TABLE gt_rbkp
FOR ALL ENTRIES IN gt_bkpf
WHERE gjahr EQ gt_bkpf-gjahr
AND tcode EQ gt_bkpf-tcode
AND belnr EQ gt_bkpf-awkey+0(10).
tax amount
SELECT bukrs
belnr
gjahr
buzei
fwste
FROM bset
INTO TABLE gt_bset
FOR ALL ENTRIES IN gt_bkpf
WHERE bukrs EQ gt_bkpf-bukrs
AND belnr EQ gt_bkpf-belnr
AND gjahr EQ gt_bkpf-gjahr.
and fwste ne 0 .
ENDIF.
IF gt_rbkp[] IS NOT INITIAL.
SELECT belnr
gjahr
buzei
cobl_nr
wrbtr
menge
mwskz
meins
FROM rbco
INTO TABLE gt_rbco
FOR ALL ENTRIES IN gt_rbkp
WHERE belnr EQ gt_rbkp-belnr.
ENDIF.
SELECT ebeln
ernam
FROM ekko
INTO TABLE gt_ekko
FOR ALL ENTRIES IN gt_rbkp
WHERE ebeln EQ gt_rbkp-zuonr+0(10).
IF gt_ekko[] IS NOT INITIAL.
SELECT banfn
bnfpo
ernam
ebeln
FROM eban
INTO TABLE gt_eban
FOR ALL ENTRIES IN gt_ekko
WHERE ebeln EQ gt_ekko-ebeln.
ENDIF.
ENDFORM. " RETRIEVE_DATA
*& Form MODIFY_DATA
text
--> p1 text
<-- p2 text
FORM modify_data .
*Sorting all Internal Tables .
SORT gt_bseg BY bukrs belnr gjahr.
SORT gt_bkpf BY bukrs belnr gjahr.
SORT gt_lfa1 BY lifnr.
SORT gt_rbkp BY belnr.
SORT gt_rbco BY belnr.
SORT gt_ekko BY ebeln.
SORT gt_bset BY belnr.
SORT gt_bset
SORT gt_eban BY ebeln.
SORT gt_bkpf .
SORT gt_bseg .
SORT gt_lfa1 .
SORT gt_rbkp .
SORT gt_rbco .
SORT gt_ekko .
SORT gt_bset.
SORT gt_eban .
LOOP AT GT_BSEG WHERE BELNR NE ' '.
MOVE gt_bseg-pswsl TO gt_final-pswsl.
MOVE gt_bseg-lifnr TO gt_final-lifnr.
MOVE gt_bseg-zlspr TO gt_final-zlspr.
READ TABLE GT_BKPF WITH KEY BELNR = GT_BSEG-BELNR BINARY SEARCH.
IF SY-SUBRC = 0.
MOVE gt_bkpf-bukrs TO gt_final-bukrs.
MOVE gt_bkpf-belnr TO gt_final-belnr.
MOVE gt_bkpf-xblnr TO gt_final-xblnr.
MOVE gt_bkpf-budat TO gt_final-budat.
MOVE gt_bkpf-usnam TO gt_final-usnam.
ENDIF.
READ TABLE gt_lfa1 WITH KEY lifnr = gt_bseg-lifnr BINARY SEARCH.
IF sy-subrc = 0.
MOVE gt_lfa1-name1 TO gt_final-name1.
ENDIF.
READ TABLE gt_rbkp WITH KEY belnr = gt_bkpf-awkey+0(10)
gjahr = gt_bkpf-gjahr
BINARY SEARCH.
IF sy-subrc = 0.
MOVE gt_rbkp-belnr TO gt_final-rbelnr.
MOVE gt_rbkp-waers TO gt_final-waers.
MOVE gt_rbkp-zuonr TO gt_final-zuonr.
endif.
READ TABLE gt_rbco WITH KEY belnr = gt_rbkp-belnr BINARY SEARCH.
IF sy-subrc = 0.
MOVE gt_rbco-buzei TO gt_final-buzei.
MOVE gt_rbco-wrbtr TO gt_final-wrbtr.
MOVE gt_rbco-menge TO gt_final-menge.
MOVE gt_rbco-meins TO gt_final-meins.
MOVE gt_rbco-mwskz TO gt_final-mwskz.
endif.
READ TABLE gt_ekko WITH KEY ebeln = gt_rbkp-zuonr+0(10) BINARY SEARCH.
IF sy-subrc = 0.
MOVE gt_ekko-ernam TO gt_final-ernam.
endif.
READ TABLE gt_eban WITH KEY ebeln = gt_ekko-ebeln BINARY SEARCH.
IF sy-subrc = 0.
MOVE gt_eban-ernam TO gt_final-ernam.
ENDIF.
READ TABLE GT_BSET WITH KEY BELNR = GT_BKPF-BELNR BINARY SEARCH.
IF SY-SUBRC = 0.
MOVE GT_BSET-FWSTE TO GT_FINAL-FWSTE.
ENDIF.
APPEND gt_final.
endloop.
please help where to add code and how to write
thanks in advancedeclare itab with fields belnr and fwste.... and write code as below...!!!
SELECT bukrs
belnr
gjahr
xblnr
waers
budat
usnam
tcode
awkey
FROM bkpf
INTO TABLE gt_bkpf
WHERE bukrs IN s_bukrs
AND gjahr IN s_gjahr
AND tcode EQ 'MIRO'.
SELECT bukrs
belnr
gjahr
buzei
koart
lifnr
zlspr
FROM bseg
INTO TABLE gt_bseg
FOR ALL ENTRIES IN gt_bkpf
WHERE bukrs EQ gt_bkpf-bukrs
AND belnr EQ gt_bkpf-belnr
AND gjahr EQ gt_bkpf-gjahr
AND lifnr IN s_lifnr
AND zlspr IN s_zlspr
and koart eq 'K'.
AND bschl EQ '31'.
gt_bseg1[] = gt_bseg[].
SORT gt_bseg1[] BY lifnr.
DELETE ADJACENT DUPLICATES FROM gt_bseg1[] COMPARING lifnr.
IF gt_bseg1[] IS NOT INITIAL.
SELECT lifnr
name1
FROM lfa1
INTO TABLE gt_lfa1
FOR ALL ENTRIES IN gt_bseg1
WHERE lifnr EQ gt_bseg1-lifnr.
and lifnr eq s_lifnr.
ENDIF.
IF gt_bkpf[] IS NOT INITIAL.
SELECT belnr
gjahr
tcode
WAERS
zuonr
FROM rbkp
INTO TABLE gt_rbkp
FOR ALL ENTRIES IN gt_bkpf
WHERE gjahr EQ gt_bkpf-gjahr
AND tcode EQ gt_bkpf-tcode
AND belnr EQ gt_bkpf-awkey+0(10).
tax amount
SELECT bukrs
belnr
gjahr
buzei
fwste
FROM bset
INTO TABLE gt_bset
FOR ALL ENTRIES IN gt_bkpf
WHERE bukrs EQ gt_bkpf-bukrs
AND belnr EQ gt_bkpf-belnr
AND gjahr EQ gt_bkpf-gjahr.
and fwste ne 0 .
ENDIF.
IF gt_rbkp[] IS NOT INITIAL.
SELECT belnr
gjahr
buzei
cobl_nr
wrbtr
menge
mwskz
meins
FROM rbco
INTO TABLE gt_rbco
FOR ALL ENTRIES IN gt_rbkp
WHERE belnr EQ gt_rbkp-belnr.
ENDIF.
SELECT ebeln
ernam
FROM ekko
INTO TABLE gt_ekko
FOR ALL ENTRIES IN gt_rbkp
WHERE ebeln EQ gt_rbkp-zuonr+0(10).
IF gt_ekko[] IS NOT INITIAL.
SELECT banfn
bnfpo
ernam
ebeln
FROM eban
INTO TABLE gt_eban
FOR ALL ENTRIES IN gt_ekko
WHERE ebeln EQ gt_ekko-ebeln.
ENDIF.
ENDFORM. " RETRIEVE_DATA
*& Form MODIFY_DATA
text
--> p1 text
<-- p2 text
FORM modify_data .
*Sorting all Internal Tables .
SORT gt_bseg BY bukrs belnr gjahr.
SORT gt_bkpf BY bukrs belnr gjahr.
SORT gt_lfa1 BY lifnr.
SORT gt_rbkp BY belnr.
SORT gt_rbco BY belnr.
SORT gt_ekko BY ebeln.
SORT gt_bset BY belnr.
SORT gt_bset
SORT gt_eban BY ebeln.
SORT gt_bkpf .
SORT gt_bseg .
SORT gt_lfa1 .
SORT gt_rbkp .
SORT gt_rbco .
SORT gt_ekko .
SORT gt_bset.
SORT gt_eban .
<b>sort gt_bset by belnr.
loop at gt_bset.
at end of belnr.
itab-belnr = gt_bset-belnr.
sum.
itab-fwste = gt_bset-fwste.
append itab.
clear itab.
endat.
endloop.
delete adjacent duplicates from gt_bset comparing belnr.
loop at gt_bset.
read table itab with key belnr = gt_bset-belnr.
if sy-subrc = 0.
gt_bset-fwste = itab-fwste.
modify gt_bset index sy-tabix.
endif.
endloop.</b>
LOOP AT GT_BSEG WHERE BELNR NE ' '.
MOVE gt_bseg-pswsl TO gt_final-pswsl.
MOVE gt_bseg-lifnr TO gt_final-lifnr.
MOVE gt_bseg-zlspr TO gt_final-zlspr.
READ TABLE GT_BKPF WITH KEY BELNR = GT_BSEG-BELNR BINARY SEARCH.
IF SY-SUBRC = 0.
MOVE gt_bkpf-bukrs TO gt_final-bukrs.
MOVE gt_bkpf-belnr TO gt_final-belnr.
MOVE gt_bkpf-xblnr TO gt_final-xblnr.
MOVE gt_bkpf-budat TO gt_final-budat.
MOVE gt_bkpf-usnam TO gt_final-usnam.
ENDIF.
READ TABLE gt_lfa1 WITH KEY lifnr = gt_bseg-lifnr BINARY SEARCH.
IF sy-subrc = 0.
MOVE gt_lfa1-name1 TO gt_final-name1.
ENDIF.
READ TABLE gt_rbkp WITH KEY belnr = gt_bkpf-awkey+0(10)
gjahr = gt_bkpf-gjahr
BINARY SEARCH.
IF sy-subrc = 0.
MOVE gt_rbkp-belnr TO gt_final-rbelnr.
MOVE gt_rbkp-waers TO gt_final-waers.
MOVE gt_rbkp-zuonr TO gt_final-zuonr.
endif.
READ TABLE gt_rbco WITH KEY belnr = gt_rbkp-belnr BINARY SEARCH.
IF sy-subrc = 0.
MOVE gt_rbco-buzei TO gt_final-buzei.
MOVE gt_rbco-wrbtr TO gt_final-wrbtr.
MOVE gt_rbco-menge TO gt_final-menge.
MOVE gt_rbco-meins TO gt_final-meins.
MOVE gt_rbco-mwskz TO gt_final-mwskz.
endif.
READ TABLE gt_ekko WITH KEY ebeln = gt_rbkp-zuonr+0(10) BINARY SEARCH.
IF sy-subrc = 0.
MOVE gt_ekko-ernam TO gt_final-ernam.
endif.
READ TABLE gt_eban WITH KEY ebeln = gt_ekko-ebeln BINARY SEARCH.
IF sy-subrc = 0.
MOVE gt_eban-ernam TO gt_final-ernam.
ENDIF.
READ TABLE GT_BSET WITH KEY BELNR = GT_BKPF-BELNR BINARY SEARCH.
IF SY-SUBRC = 0.
MOVE GT_BSET-FWSTE TO GT_FINAL-FWSTE.
ENDIF.
APPEND gt_final.
endloop. -
Difficulty While reading Table....
Hi All,
i trying to read data from table with multiple condition but it is giving me error,
my code is :
loop at struct.
ind = sy-tabix.
read table itabMAST with key matnr = struct-matnr and WERKS = company and stlan = '5'.
if sy-subrc = 0.
move itabMAST-stlnr to struct-stlnr.
endif.
modify struct index ind transporting stlnr.
endloop.
and error message is giving is
Unable to interpret "WERKS". Possible causes: incorrect Spelling or Comma error.
Pls Help...
Thanks in Advance,
YunusHi, here is another example:
IF sy-subrc <> 0.
MOVE it_equz-hequi TO it_equz_dum2-hequi.
READ TABLE it_equz_dum1 WITH KEY equnr = it_equz-equnr
hequi = it_equz-hequi
BINARY SEARCH.
IF sy-subrc = 0.
SELECT SINGLE anlnr
shtxt
FROM itob
INTO (it_itob-anlnr, it_itob-shtxt)
WHERE equnr EQ it_equz_dum1-hequi.
IF sy-subrc = 0.
MOVE it_itob-anlnr TO it_finaltab-asset_dum.
MOVE it_itob-anlnr TO it_finaltab-asset.
MOVE it_itob-shtxt TO it_finaltab-description.
endif.
endif.
endif. -
Error in reading table.
READ TABLE mat_tab INDEX ind.
IF sy-subrc = 0.
mat_tab-act_ind = 'A'.
mat_tab-proc_ind = 'X'.
WRITE MAT_TAB TO MAT_TAB INDEX IND.
Here I am getting error 'MAT_TAB cannot be converted to char type field.'
plz help me.I think instead of
WRITE MAT_TAB TO MAT_TAB INDEX IND.
you need
modify MAT_TAB INDEX IND. -
Field symbols and READ TABLE with system code 4
Hi,
I have a hashed table and I am using field symbols to point to it to retrieve the field content. I then use it in the READ TABLE statement in the following way:
Loop at x_data assign <fs>.
ASSIGN COMPONENT 'xxx' OF STRUCTURE <fs> TO <c1>.
ASSIGN COMPONENT 'xxx' OF STRUCTURE <fs> TO <c2>.
READ TABLE ZZZZ assign <fs> with table key a1 = <c1>
a2 = <c2>.
If sy-subrc = 0.
endif.
I ran the debugger and I keep getting a 4. I am not able to get the value from a1 and a2 to see what it is and why it is causing a 4 sy-subrc. I know the value from the hashed table and the values c1 and c2 are the same, so the sy-subrc should be 0.
How would I read a hashed table using field symbols? I know that usig a standard table, I have to sort the table on the key fields() before I actually can do the READ TABLE using the binary search.
Please advise. Thanks
RTHai Rob
Go through the following Code
Field-Symbols are place holders for existing fields.
A Field-Symbol does not physically reserve space for a field but points to a field, which is not known until run time of the program.
Field-Symbols are like Pointers in Programming language C .
Syntax check is not effective.
Syntax :
Data : v1(4) value abcd.
Field-symbols <fs>.
Assign v1 to <fs>.
Write:/ <fs>.
DATA: BEGIN OF LINE,
COL1 TYPE I,
COL2 TYPE I,
END OF LINE.
DATA ITAB LIKE SORTED TABLE OF LINE WITH UNIQUE KEY COL1.
FIELD-SYMBOLS <FS> LIKE LINE OF ITAB.
DO 4 TIMES.
LINE-COL1 = SY-INDEX.
LINE-COL2 = SY-INDEX ** 2.
APPEND LINE TO ITAB.
ENDDO.
READ TABLE ITAB WITH TABLE KEY COL1 = 2 ASSIGNING <FS>.
<FS>-COL2 = 100.
READ TABLE ITAB WITH TABLE KEY COL1 = 3 ASSIGNING <FS>.
DELETE ITAB INDEX 3.
IF <FS> IS ASSIGNED.
WRITE '<FS> is assigned!'.
ENDIF.
LOOP AT ITAB ASSIGNING <FS>.
WRITE: / <FS>-COL1, <FS>-COL2.
ENDLOOP.
The output is:
1 1
2 100
4 16
Thanks & regards
Sreenivasulu P
Maybe you are looking for
-
Error While enahling CDC(Change data capture) on Table.
I am enabling Change data capture (CDC) on SQL server 2012 Enterprise edition(11.0.2100.60) . I am able to enable it on Database level with below SQL, but failed to enable on Table level. Use DatabaseName GO Exec sys.sp_cdc_enable_db GO EXEC sys.sp_
-
Unable to install iis manager on windows 8 home edition
Hi I get an error while trying to install IIS manager from "Turn on off windows features" on a windows 8 machine. Just before trying to install this I install Visual Studio community online and rebooted my machine. Visual Studio works fine. I also m
-
Reader 10.1.2 prints half-sized
I am trying to print .pdf documents from Reader 10.1.2 on a Windows 7 machine. The documents are 8.5" x 11", and I am printing to 8.5" x 11" paper. I have tried setting the Size option to both Fit and Actual Size. The Page Setup and printer Propertie
-
How do i fix "Pages" from giving me "Pages unexpectedly close" message?
When i bought my Macbook pages was working just fine and the other day i tried opening it. It didnt want to open. Can someone Help me??
-
How can I play mov file on ipad2?
How can I play mov file on ipd2? Anyone? Thanks.