2007 Aug 16 2:45 PM
Hi all,
I have two internal tables say x and y .
internal table X has quota , trpid, as fields.
internal table Y has quota ,trpid and plants as fieds.
i will loop the internal table Y .
For each loop,
i want to load the quota value from X to Y where X-trpid = Y-trpid.
So can anyone tell me how can i acheive this using READ statemnet.
If this cannot be acheived with READ then please tell me how can i do that.
Hi
LOOP AT Y.
READ TABLE X WITH KEY TRPID = Y-TRPID.
IF SY-SUBRC = 0.
Y-quota = X-quota.
MODIFY Y.
ENDIF.
ENDLOOP. "Y
Cheers
~Arun
Reward Points if useful
Message was edited by:
Arun Shekhar
2007 Aug 16 2:48 PM
put like this.
loop at itabx.
read table itaby with quota = itabx-quota.
if sy-subrc eq 0.
itabx-value = itaby-value.
modify itabx.
endif.
endloop.
2007 Aug 16 2:50 PM
loop at Y.
read table X with key TRPID = Y-TRPID.
IF SY-SUBRC EQ 0.
Y-quota = X-quota.
MODIFY Y.
ENDIF.
endloop. " Y
REWARD POINTS IF FOUND USEFUL, Get back in case of query.
Cheers!!!
Message was edited by:
Tripat Pal Singh
2007 Aug 16 2:52 PM
Hi,
First u need to sort table X ,and use binary search , for better performance.
below is ur code:
sort X by trpid.
loop at y into wa_y.
read table x into wa_x with key trpid = wa_y-trpid binary search.
if sy-subrc = 0.
wa_y-quota = wa_x-quota.
modify y with wa_y transporting quota.---> to overwrite the new QUOTA value in Y
endif.
endloop.
Revert back if any issues,
Reward with points if helpful.
Regards,
Naveen
2007 Aug 16 2:53 PM
Hi
LOOP AT Y.
READ TABLE X WITH KEY TRPID = Y-TRPID.
IF SY-SUBRC = 0.
Y-quota = X-quota.
MODIFY Y.
ENDIF.
ENDLOOP. "Y
Cheers
~Arun
Reward Points if useful
Message was edited by:
Arun Shekhar
2007 Aug 16 2:57 PM
HI Hema,
How are the entries related.. is it like for one entry in y table there are more than one entry in x table then you have to use loop with in loop , here are the both the conditions.
1) For each entry in Y there are more than one entries in X
sort y by quota trpid.
sort x by quota trpid.
loop at y.
loop at x where quota eq y-quota
and trpid eq y-trpid.
z-value = x-value.
append z.
endloop.
endloop.
2) For each y there is one entry in x table.
sort y by quota trpid.
sort x by quota trpid.
loop at y.
read table x with key quota = y-quota
trpid = y-trpid binary search.
if sy-subrc eq 0.
z-value = x-value.
append z.
Endif.
endloop.
Mahesh
2007 Aug 16 3:03 PM
sort it_x by trpid.
loop at it_y assigning <fs_y>.
read table it_x assigning <fs_x> with key trpid = <fs_y>-trpid binary search.
if sy-subrc eq 0.
<fs_y>-quota = <fs_x>-quota.
endif.
endloop.
I think it can help u.
2007 Aug 16 3:10 PM
Hi,
You can code like this:
Data : wrk_tabix like sy-tabix.
IF the same entry is there in X & Y.
sort X by trpid.
loop at y into wa_y.
wrk_tabix = sy-tabix.
read table x into wa_x with key trpid = wa_y-trpid binary search.
if sy-subrc = 0.
wa_y-quota = wa_x-quota.
endif.
modify y with wa_y index wrk_tabix.
endloop.
elseif the same entries are not there, instead of Read statement use LOOP statement for Y.
Reward if helps.
Regards,
Neslin.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |