2007 Dec 19 1:41 PM
hi,
my issue is updating ztable which i have created . this table gets updated with records after processing a batch session. batch session is for posting FI documents. ztable gets updated with the document number after processing the session. when there is only one transaction per session the ztable is getting updated with the respestive document no. but they r multiple transactions per session i.e multiple FI documents r created its updating the table with only document no. i.e first FI document no.. please help me in resolving this issue.
data : v_bktxt like bkpf-bktxt.
ata: v_cnt(5) type n value 0,
v_cnt1(5) type n value 0.
v_cnt = v_cnt + 1.
loop at t_bseg.
if v_bktxt(1) EQ '1'.
move: v_cnt to zbatch_log-cnt,
v_bktxt+1(10) to zbatch_log-batchid,
t_bseg-belnr to zbatch_log-belnr1.
insert zbatch_log.
endif.
endloop.
This is the basic code. what i was suggested to do is
if v_bktxt ( 1 ) EQ '1'
then check whether batchidno. exists in zbatch_log table
if NO
then move v_cnt, v_bktxt, t_bseg-belnr to zbatch_log table(my ztable).
if YES
then check the last value of v_cnt in zbatch_log table .
store it ina variable .
then move v_bktxt, t_bseg-belnr and increment the stored variable and increment the counter.
i am not getting how to chech the ztable table whether the entries r already there r not please help me with this code.
(in my ztable v_cnt and batchid are primary keys)
2007 Dec 19 2:23 PM
check this code..
data : v_bktxt like bkpf-bktxt.
ata: v_cnt(5) type n value 0,
v_cnt1(5) type n value 0.
v_cnt = v_cnt + 1.
select *
from zbatch_log
into table it_batch.
sort it_batch by v_cnt descending.
loop at t_bseg.
select single *
from zbatc_log
into wa_zbatch_log
where batch+0(1) = '1'.
if sy-subrc ne 0.
move: v_cnt to zbatch_log-cnt,
v_bktxt+1(10) to zbatch_log-batchid,
t_bseg-belnr to zbatch_log-belnr1.
insert zbatch_log.
else.
read table it_batch index 1. -
which gives the latest/recent counter number.
move it_batch-cnt to count.
count = count + 1.
count to zbatch_log-cnt,
v_bktxt+1(10) to zbatch_log-batchid,
t_bseg-belnr to zbatch_log-belnr1.
insert zbatch_log.
endif.
endloop.
2007 Dec 19 2:23 PM
check this code..
data : v_bktxt like bkpf-bktxt.
ata: v_cnt(5) type n value 0,
v_cnt1(5) type n value 0.
v_cnt = v_cnt + 1.
select *
from zbatch_log
into table it_batch.
sort it_batch by v_cnt descending.
loop at t_bseg.
select single *
from zbatc_log
into wa_zbatch_log
where batch+0(1) = '1'.
if sy-subrc ne 0.
move: v_cnt to zbatch_log-cnt,
v_bktxt+1(10) to zbatch_log-batchid,
t_bseg-belnr to zbatch_log-belnr1.
insert zbatch_log.
else.
read table it_batch index 1. -
which gives the latest/recent counter number.
move it_batch-cnt to count.
count = count + 1.
count to zbatch_log-cnt,
v_bktxt+1(10) to zbatch_log-batchid,
t_bseg-belnr to zbatch_log-belnr1.
insert zbatch_log.
endif.
endloop.
2007 Dec 19 3:24 PM
hi lakshmi,
hi lakshmi,
i tried with ur code but its not giving me the correct result.
data : v_bktxt like bkpf-bktxt.
ata: v_cnt(5) type n value 0,
v_cnt1(5) type n value 0.
v_cnt = v_cnt + 1.
select *
from zbatch_log
into table it_batch.
sort it_batch by v_cnt descending.
loop at t_bseg.
select single *
from zbatc_log
into wa_zbatch_log
where batch+0(1) = '1'.
if sy-subrc ne 0.
move: v_cnt to zbatch_log-cnt,
v_bktxt+1(10) to zbatch_log-batchid,
t_bseg-belnr to zbatch_log-belnr1.
insert zbatch_log.
else.
read table it_batch index 1. -
which gives the latest/recent counter number.
move it_batch-cnt to count.
count = count + 1.
count to zbatch_log-cnt,
v_bktxt+1(10) to zbatch_log-batchid,
t_bseg-belnr to zbatch_log-belnr1.
insert zbatch_log.
endif.
endloop.
notation in bold one giving error so i have changed that to
select single batchid
from zbatch_log
into t_batchid1
where batchid = v_bktxt+1(10).
can u suggest me somemore.
2007 Dec 19 3:22 PM
hi lakshmi,
i tried with ur code but its not giving me the correct result.
data : v_bktxt like bkpf-bktxt.
ata: v_cnt(5) type n value 0,
v_cnt1(5) type n value 0.
v_cnt = v_cnt + 1.
select *
from zbatch_log
into table it_batch.
sort it_batch by v_cnt descending.
loop at t_bseg.
select single *
from zbatc_log
into wa_zbatch_log
where batch+0(1) = '1'.
if sy-subrc ne 0.
move: v_cnt to zbatch_log-cnt,
v_bktxt+1(10) to zbatch_log-batchid,
t_bseg-belnr to zbatch_log-belnr1.
insert zbatch_log.
else.
read table it_batch index 1. -
which gives the latest/recent counter number.
move it_batch-cnt to count.
count = count + 1.
count to zbatch_log-cnt,
v_bktxt+1(10) to zbatch_log-batchid,
t_bseg-belnr to zbatch_log-belnr1.
insert zbatch_log.
endif.
endloop.
notation in bold one giving error so i have changed that to
select single batchid
from zbatch_log
into t_batchid1
where batchid = v_bktxt+1(10).
can u suggest me somemore.
2007 Dec 20 6:39 PM
can i know the structure of the ur z tables...with data types and lenghs.
2007 Dec 24 6:34 AM
hi lakshmi
issue got resolved and thank u very much for ur help with ur idea of code i did some modifications and got the result thanks once again.