2009 Sep 24 10:04 AM
Hi,
I have created a dynamic table and a dynamic work area.
FIELD-SYMBOLS: <FS_DATA> type ref to DATA,
<FS_1> TYPE ANY TABLE,
<FS_2>,
<FS>
Here I have my data in <FS_1> table and <FS_2> is work area of <FS_1>. I have looped at <FS_1> into <FS_2> and done my required operations, by using,
READ TABLE GI_STREN INTO WA_STREN
WITH KEY BOLNR = <LV_BOLNR> LFDAT = LV_DATE LFUHR = <LV_LFUHR>.
IF SY-SUBRC = 0.
ASSIGN COMPONENT LV_DATE OF STRUCTURE <FS_2> TO <FS>.
<FS> = WA_STREN-ANZPK
ENDIF.
Now, I am getting my data in the dynamic work area <FS_2>. But I am not able to update my dynamic internal table from its work area using modify statement. Can some one please guide me how to modify a dynamic internal table from its work area.
Thanks and Regards,
Avinash Bolisetty
Hi,
I have created a dynamic table and a dynamic work area.
FIELD-SYMBOLS: <FS_DATA> type ref to DATA,
<FS_1> TYPE ANY TABLE,
<FS_2>,
<FS>
Here I have my data in <FS_1> table and <FS_2> is work area of <FS_1>. I have looped at <FS_1> into <FS_2> and done my required operations, by using,
READ TABLE GI_STREN INTO WA_STREN
WITH KEY BOLNR = <LV_BOLNR> LFDAT = LV_DATE LFUHR = <LV_LFUHR>.
IF SY-SUBRC = 0.
ASSIGN COMPONENT LV_DATE OF STRUCTURE <FS_2> TO <FS>.
<FS> = WA_STREN-ANZPK
ENDIF.
Now, I am getting my data in the dynamic work area <FS_2>. But I am not able to update my dynamic internal table from its work area using modify statement. Can some one please guide me how to modify a dynamic internal table from its work area.
Thanks and Regards,
Avinash Bolisetty
2009 Sep 24 10:08 AM
try READ...ASSIGNING to assign your dynamic work area before any data transfer. data will be updated automatically.
2009 Sep 24 10:19 AM
Here, I may not be able to use Read.... Assigning as I have to change all the fields present in <FS_1> table. based on data in some other (GI_STERN) table.
I am putting my code here.
<p>
LOOP AT FS_1 INTO FS_2. <br>
ASSIGN COMPONENT 'BOLNR' OF STRUCTURE FS_2 TO LV_BOLNR. <br>
ASSIGN COMPONENT 'LFUHR' OF STRUCTURE FS_2 TO LV_LFUHR. <br>
LV_DATE = S_LFDAT-LOW. <br>
DO GV_DDIFF TIMES. <br>
READ TABLE GI_STREN INTO WA_STREN <br>
WITH KEY BOLNR = LV_BOLNR <br>
LFDAT = LV_DATE <br>
LFUHR = LV_LFUHR.<br>
IF SY-SUBRC = 0. <br>
ASSIGN COMPONENT LV_DATE OF STRUCTURE FS_2 TO FS. <br>
FS = WA_STREN-ANZPK <br>
ENDIF. <br>
MODIFY FS_1 FROM FS_2. <br>
CLEAR WA_STREN. <br>
LV_DATE = LV_DATE + 1. <br>
ENDDO. <br>
ENDLOOP.<br>
</P>
Edited by: Avinash Bolisetty on Sep 24, 2009 11:22 AM
2009 Sep 24 10:30 AM
You don't need to write a modify command to update the table because
... ASSIGNING <FS>
The field symbol <FS> points directly to the assigned line in memory. Unlike work areas, in
which the contents of the line are only available indirectly, field symbols allow you to read and
change table entries directly.
Also, check the loop statement.
Is should be LOOP AT ITAB ASSIGNING <FS>.
In your case, you may try working with two work areas <w1> <w2> and . One work area( <w1> ) will point to the memory location which need to be update. After you logice just assign the values from work area <w2> to <w1>.
2009 Sep 24 10:26 AM
Hi Avinash,
Instead of using Read Table, Try using Read Line with index and modify the table with the workarea.
You can also refer to a demo program, DEMO_LIST_READ_LINE.
I hope it will help you.
Regards,
Nidhi Kothiyal
2009 Sep 24 10:54 AM
Loop <table> Assigning <workarea>
worked.. Its updated automatically.
Rather than loop table into wa..
Thank you
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |