Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

updating table

Former Member
0 Kudos
95

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)

1 ACCEPTED SOLUTION

Former Member
0 Kudos
44

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.

5 REPLIES 5

Former Member
0 Kudos
45

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.

0 Kudos
44

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.

Former Member
0 Kudos
44

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.

0 Kudos
44

can i know the structure of the ur z tables...with data types and lenghs.

0 Kudos
44

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.