Skip to Content
author's profile photo Former Member
Former Member

updating table

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)

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Dec 19, 2007 at 02: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.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      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.

  • author's profile photo Former Member
    Former Member
    Posted on Dec 19, 2007 at 03: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.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.