2011 Feb 04 3:30 PM
Hello,
I used below codes. But my custom table's BUDAT field wasn't updated. Why? Can the problem be that there isnt any maintenance dialog for this custom table? Thaks in advance.
SELECT *
FROM (gv_table)
INTO TABLE <gt_ce>
WHERE vrgar = 'C'
AND rbeln IN s_rbeln
AND timestmp > gv_tmstst AND
timestmp <= gv_tmsten
ORDER BY ('BELNR').
LOOP AT <gt_ce> ASSIGNING <fs_struc>.
lv_tbx = sy-tabix.
ASSIGN COMPONENT 'BUDAT' OF STRUCTURE <fs_struc> TO <fs_budat>.
ASSIGN COMPONENT 'HZDAT' OF STRUCTURE <fs_struc> TO <fs_hzdat>.
ASSIGN COMPONENT 'PALEDGER' OF STRUCTURE <fs_struc> TO <fs_paledger>.
ASSIGN COMPONENT 'VRGAR' OF STRUCTURE <fs_struc> TO <fs_vrgar>.
ASSIGN COMPONENT 'VERSI' OF STRUCTURE <fs_struc> TO <fs_versi>.
ASSIGN COMPONENT 'PERIO' OF STRUCTURE <fs_struc> TO <fs_perio>.
ASSIGN COMPONENT 'PAOBJNR' OF STRUCTURE <fs_struc> TO <fs_paobjnr>.
ASSIGN COMPONENT 'PASUBNR' OF STRUCTURE <fs_struc> TO <fs_pasubnr>.
ASSIGN COMPONENT 'BELNR' OF STRUCTURE <fs_struc> TO <fs_belnr>.
ASSIGN COMPONENT 'POSNR' OF STRUCTURE <fs_struc> TO <fs_posnr>.
<fs_budat> = <fs_hzdat> - 1.
MODIFY <gt_ce> FROM <fs_struc> INDEX lv_tbx.
UPDATE (gv_table) SET BUDAT = <fs_budat> WHERE
paledger = <fs_paledger> AND
vrgar = <fs_vrgar> AND
versi = <fs_versi> AND
perio = <fs_perio> AND
paobjnr = <fs_paobjnr> AND
pasubnr = <fs_pasubnr> AND
belnr = <fs_belnr> AND
posnr = <fs_posnr>.
ENDLOOP.
<< Moderator message - Everyone's problem is important. But the answers in the forum are provided by volunteers. Please do not ask for help quickly. >>
Edited by: Rob Burbank on Feb 4, 2011 10:34 AM
2011 Feb 04 3:36 PM
Maybe you should do some debugging to see what the value of <fs_hzdat> is.
Rob
2011 Feb 04 3:39 PM
I debugged but can not see the problem. The field comes correctly and internal table is modified correctly but only problem is update. I can not update the custom table.
2011 Feb 04 3:58 PM
Man, this is so over-engineered, and you modified FS_BUDAT not sure you actually updated FS_STRUC... consider this simple way to do this (we use field symbols so we don't have to do that MODIFY stuff....!)
SELECT * FROM (gv_table)
INTO TABLE <gt_ce>
WHERE vrgar = 'C'
AND rbeln IN s_rbeln
AND ( timestmp > gv_tmstst AND
timestmp <= gv_tmsten ).
sort <gt_ce> by belnr.
LOOP AT <gt_ce> ASSIGNING <fs_struc>.
if <fs_struc> is assigned.
<fs_struc>-budat = <fs_struc>-hzdat - 1. "debug here to be sure BUDAT and HZDAT contain/do what is expected.
endif.
endloop.
UPDATE (gv_table) from table <gt_ce>.
2011 Feb 04 4:14 PM
I debugged and I am sure that BUDAT field of <fs_struc> is changed correctly and <fs_struc> change internal table correctly. There isn^t any problem to change BUDAT field of <fs_struc> and internal table. I also try again like your advice. but this is dynamic table so I use as <fs_struc> type any. so it gives error that <fs_struc>-budat is not available.
2011 Feb 04 6:06 PM
2011 Feb 07 11:27 AM
i think the update statement will only work if there is a old record conatains with same key.
simply change your code to modify command. it will work.
thanks
2011 Feb 05 11:22 AM
Hi,
You didn't tell what is the sy-subrc after the UPDATE statement.
Use COMMIT WORK AND WAIT after the UPDATE statement (If update is success).
Also just check if you have multiple entries matching below criteria. Because UPDATE is used inside the loop. If you have more than one entry matching below criteria, only data of last entry is updated to all. Make sure that you are passing the correct keys in WHERE clause.
To avoid this update the data base table at one shot using MODIFY FROM table statement outside the loop which is good in performance point of view also instead of individual updates in side the loop.
WHERE
paledger = <fs_paledger> AND
vrgar = <fs_vrgar> AND
versi = <fs_versi> AND
perio = <fs_perio> AND
paobjnr = <fs_paobjnr> AND
pasubnr = <fs_pasubnr> AND
belnr = <fs_belnr> AND
posnr = <fs_posnr>.
Thanks,
Vinod.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |