Skip to Content

Performance issue while updating BSEG-VBRK-ZUONR USING Wait upto 2 seconds statement

Hi Developers,

I am recently updated BSEG-VBRK-ZUONR with "Wait upto 2 seconds" as shown in below program.

I have succeed with the output, But while running in production and testing instead of 2 Hours process time it take 1 day process time.


If I remove, "Wait statement" Billing Document getting Generated fine, But Updating concern TABLE is not happening.

Here is my code!!!!!!!!! Please suggest me alternate solution!!!!!!!!!!!!

read table it_return into wa_return1 with key type = 'S'.

if sy-subrc = 0.

clear: wa_vbrk, wa_vbrk1, wa_bkpf, wa_bseg.

wait UP TO 2 SECONDS.

select single vbeln

fkart

fktyp

zuonr from vbrk into wa_vbrk where vbeln = wa_return1-message_v1.

if ( sy-subrc = 0 and wa_vbrk-fkart = 'ZEBO' ).

wait UP TO 2 SECONDS.

select single bukrs

belnr

gjahr

blart from bkpf into wa_bkpf where xblnr = wa_vbrk-vbeln.

if sy-subrc = 0.

wait UP TO 2 SECONDS.

select * from bseg into table it_bseg where belnr = wa_bkpf-belnr.

if sy-subrc = 0.

wa_fldtab-fname = 'ZUONR'.

wa_fldtab-aenkz = 'X'.

append wa_fldtab to it_fldtab.

loop at it_bseg into wa_bseg.

read table it_header into wa_header1 with key header_id = wa_header-header_id.

wait UP TO 2 SECONDS.

select single

bukrs belnr gjahr buzeI koart umskz bschl mwart mwskz

from bseg into corresponding fields of wa_buztab

where belnr = WA_BSEG-BELNR and

bukrs = WA_BSEG-BUKRS and

gjahr = WA_BSEG-GJAHR and

BUZEI = WA_BSEG-BUZEI.

append wa_buztab to it_buztab.

move wa_header1-pos_vbeln to wa_bseg-zuonr.

call function 'FI_ITEMS_MASS_CHANGE'

exporting

s_bseg = wa_bseg

importing

errtab = it_errtab[]

tables

it_buztab = it_buztab

it_fldtab = it_fldtab

exceptions

bdc_errors = 1

others = 2.

wait up to 2 seconds.

clear: wa_header1, it_buztab, it_errtab, wa_bseg.

endloop.

endif.

endif.

endif.

endif.

read table it_return into wa_return1 with key type = 'S'.

clear: wa_vbrk, wa_vbrk1.

wait UP TO 2 SECONDS.

select single vbeln

fkart

fktyp

zuonr from vbrk into wa_vbrk where vbeln = wa_return1-message_v1.

if ( sy-subrc eq 0 and wa_vbrk-fkart = 'ZEBO' ).

call function 'BAPI_TRANSACTION_COMMIT'

exporting

wait = 'X'.

read table it_header into wa_header1 with key header_id = wa_header-header_id.

update vbrk set: zuonr = wa_header1-pos_vbeln where vbeln = wa_return1-message_v1.

endif.


Is that Possible to Update the BSEG, while Generation Billing document using BAPI_BILLINGDOC_CREATEMULTIPLE?


Or any alternate solution?



Regards,

Sudarshan D

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Posted on Sep 06, 2016 at 02:30 PM

    The real question is: why did you put 5 times "WAIT UP TO 2 SECONDS" ?

    What do you expect from them?!


    My suggestion: think about what are you doing, throw your code away and rethink it all.

    Add a comment
    10|10000 characters needed characters exceeded

    • I know Matthew, as I try to suggest

      My suggestion: think about what are you doing, throw your code away and rethink it all.

      I cannot find a logic in that code.

      Btw,@sudarshan rajamdavid debug can trigger COMMIT to db... that's why you have different beaviohur. That plus the fact that to debug you need more than milliseconds just to skip a row of code, like the system does.

      I firmly stay on my idea: throw all away, think about what do you want to achieve and rewrite the code

  • Posted on Sep 07, 2016 at 04:25 AM

    Hi,

    5 times wait statement and they are before select statement then select statement with in a loop, read statement with out BINARY SEARCH these are the basic visible things which affect performance.

    You must know about PERFORMANCE TUNING IN ABAP and then re-write your code again.

    thank you!!

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 06, 2016 at 02:59 PM

    Could you

    1. Wrap the call of FI_ITEMS_MASS_CHANGE in an RFC enabled FM, add a small SELECT SINGLE FROM BSEG BYPASSING BUFFER in a small DO/ENDDO loop with a WAIT UP TO 1 SECONDS at the start of the wrapper FM.
    2. Call this FM IN BACKGROUND TASK before the COMMIT WORK, remove also the WAIT option of the COMMIT speeding up your main job
    3. Most of the time the select will be initially successful (particularly when many documents are posted) as those FM are queued after end of update tasks

    NB: Those RFC call in background can be monitored thru transaction SM58

    Regards,

    Raymond

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 07, 2016 at 12:50 AM

    Sudharshan,

    Talk to your functional team once again about the standard field updates and you might want to consider a function module with parallel processing to increase the perfornance. Do try to use Commit statements for database updates.

    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.