Skip to Content
avatar image
Former Member

$batch : Multiple Line Items

Dear Friends,

I am sure there are loads of materials / discussions on the $batch topic.

I shall try and keep it simple as I am unable to find my example.

My requirement is to Create Multiple LineItems for an existing OrderHeader in a single session.  ( $batch does this well )

Is there a sample piece of code i can use for collecting all the LineItems fired as part of the ChangeSet($batch) and pass the Internal Table of LineItems to the Create LineItems?

-- This is because i understand ...internally, the ChangeSet Begin and ...End would be invoked for each POST LineItems under one ChangeSet?

..Apologies, if i am talking no sense!!

Suresh BJ

Tags edited by: jitendra kansal

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    avatar image
    Former Member
    Oct 20, 2014 at 09:08 AM

    Ashwin / Ron / Atanu

    Many thanks for your replies.

    We are currently on SP08 ; So, I understand the following ..

    1) Client Side

    $batch

    -- ChangeSet001

    POST LineItem01

    POST LineItem02

    POST LineItem03

    -- ChangeSet001

    2) Server Side : SP08

    Gateway internally invokes POST 3 times (POST LineItem01 ; LineItem02 ; LineItem03) although the response to Client would be once ( lets say, all the POST messages go through successfully).

    3) Server Side : SP09

    A new feature in the form of ChangeSet_Process to collect LineItem01,LineItem02,LineItem03 is possible.

    Many thanks once again,

    Suresh

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Exactly !!  😊

      just an addition for Point number 2: You get only one payload back from server containing the response for every operation separately.  It is not like 'All the operations are successful' , rather 'Operation 1 successful, <-----> Operation 2 failed '

  • avatar image
    Former Member
    Oct 17, 2014 at 11:06 AM

    Hi Suresh

    Unless you are placing each LineItems instance into a separate consecutive changsets, the end method won't be called more than once. Building a batch request like this is rather pointless. The typical use case is to post all changes to the LineItems in one changeset. Then the "end" method is called once all of the change (entity update) operations have finished.

    The original framework processing for $batch chains the individual update operations, there is no mass update feature unless you subvert the framework in some way to provide your own solution. Ideally there should be such a feature ans as Ashwin has pointed out, this looks set to arrive in SP09.

    Ron.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 16, 2014 at 06:17 PM

    Hello Suresh,

    According to me, during run-time Instantiation happens for each change and i dont see any why we can collect everything and pass to our back end logic.

    May be in new release this may be possible. Not sure about it.

    Please refer below

    $batch Processing - SAP NetWeaver Gateway - SAP Library

    Refer the comments as well.

    Batch Request in Netweaver Gateway(Multiple Operations into a Single Request)

    In SP 09 i read there is some improvements done for BATCH and m not very if its applicable for deep entity operations as i have not gone through it and checked cos we are still on old SP 😔

    Go through that column and see if it can help.

    From SAP NetWeaver Gateway Hub and Backend SPS09 Onwards
    • Custom header ($batch response header) is supported for $batch requests.
    • A selection of generic HTTP headers for $batch requests are available for the data provider when processing each $batch operation.
    • Performance improvement for $batch change-set processing when the data provider is able to handle the entire operation of change set at once at end of change set. For this to be possible, the data provider must implement the change set handling API to process all change set operations within one API (CHANGESET_PROCESS) and return the consolidated result of all operations to the SAP NetWeaver Gateway Framework.

    Need to wait other experts in the forum to comment on this.

    Regards,

    Ashwin

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 20, 2014 at 06:02 AM

    Yes.. this would be possible in SP9. Now you have the option to collect the information from chageset and post them together as per your need.

    A sample code may look like this

    1. somehow you need to tell the Gateway framework that you want to process OrderHeader/OrderItems together. This means for every changeset it should not call the CREATE_ENTITY(or update or delete). Rather it should be called once. This can be done in the CHANGESET_BEGIN method

    DATA: ls_operation_info  TYPE /iwbep/s_mgw_operation_info.
    IF ls_operation_info-entity_set  <> 'MY_ENTITYSET_NAME' 
    cv_defer_mode = abap_true.
    ENDIF.
    

    This code will enable DEFERRED mode for your entityset/entitysets and will tell the framework not to call CREATE/UPDATE/DELETE methods separately.

    2. Now you need to collect the payloads from the changeset in the method CHANGESET_PROCESS. You will find all the contents of the changeset in parameter it_changeset_request in the method CHANGESET_PROCESS. Now you need to collect all the payload data and process.

    Hope this gives some idea..

    Add comment
    10|10000 characters needed characters exceeded