0

I have 3 bapi named BAPI_SALESORDER_GETLIST,BAPI_SALESORDER_GETSTATUS and BAPI_SALESORDER_GETDETAILBOS.

  1. Here in the first bapi I have to input Customer Number and Sales Organization as input and retrieve Sales Document Number (SD_DOC) and from_Date.

  2. This Sales Document Number(SD_Doc) retrieved from 1st BAPI has to be given as input to other bapi named BAPI_SALESORDER_GETSTATUS to retrieve some data.

  3. and the same Sales Document Number has to be given input to the third BAPI that is BAPI_SALESORDER_GETDETAILBOS to retrieve some particular data.

To my knowledge I have done some work with the bapi and up till now in the service I have created I have given only customer number as input to the URI in the SAP GATEWAY CLIENT

for example:

/sap/opu/odata/sap/ZOPENSALESORDER_SRV/openSalesOrderSet?$filter=Customerno eq '1'

If anyone can help regarding this would be very grateful for that.

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Sumit Ghewade
  • 473
  • 4
  • 16
  • Can you show us what you've tried so far? – gkubed Aug 17 '16 at 19:16
  • i have created service using BAPI_SALESORDER_GETLIST to retrieve the customer name, From date ,status, created by etc i'm consuming this service in sap view. and for this bapi the only input i was passing was customer number. the above is the example of service i have created using bapi BAPI_SALESORDER_GETLIST – Sumit Ghewade Aug 18 '16 at 06:15
  • I can see that that's what you're trying to accomplish, but what is your actual problem? – gkubed Aug 18 '16 at 12:32
  • actually the thing is suppose i get all the sales document number from the first bapi how can i pass all those numbers one by one to the other bapi. – Sumit Ghewade Aug 18 '16 at 14:19
  • the only thing i know is to create service and give one customer name to it and retrieve relevant data. scenario here is i have to pass multiple input to the bapi how can i achieve it. can i do it by writing query in sap gateway client or can i write query in se37. – Sumit Ghewade Aug 18 '16 at 14:22
  • If using service is a particular requirement here, then you should state this in your question, because such piping can be achieved in a multiple ways. What obstacle have you faced during service creation? Give us the code. – Suncatcher Nov 23 '16 at 10:52

1 Answers1

0

First of all i would like to tell you guys that I have THREE bapis out of which i rquired my data.1)BAPI_SALESORDER_GETLIST 2)BAPI_SALESORDER_GETSTATUS and 3)BAPI_SALESORDER_GETDETAILBOS.

  1. For the First Bapi i'll give input Customer Number(KUNNR) and Sales Organization(VKORG) , then i'll get sale document number as output.
  2. This sales document number will be given to the next bapi BAPI_SALESORDER_GETSTATUS to obtain other relevant data.
  3. And the same sales document number will also be given to the third bapi BAPI_SALESORDER_GETDETAILBOS.

I'll first tell you the steps

  • Specify the input parameters in the Import parameter. In my scenario i have kunnr and vkorg. click here for the image1

  • Then internal tables are already made as i'm only going to use the standard bapi's. so in table section just write the name of you bapi and you are good to go.click here for the image2

  • Then in the source section start your coding:

     DATA: "lt_bapiorders TYPE TABLE OF bapiorders,
            lt_statusinfo TYPE TABLE OF  bapisdstat,
            lt_orderitem TYPE TABLE OF bapisditbos,
          lt_orderscheduleline TYPE TABLE OF bapisdhedu.  
    
    
    
      FIELD-SYMBOLS: <lfs_order> TYPE bapiorders,
                     <lfs_statinfo> TYPE bapisdstat,
                     <lfs_orderitem> TYPE bapisditbos,
                     <lfs_orderscheduleline> TYPE bapisdhedu.
    
      "Fecth all the sales order for a customer
      CALL FUNCTION 'BAPI_SALESORDER_GETLIST'
        EXPORTING
          customer_number             = kunnr
          sales_organization          = vkorg
        TABLES
          sales_orders                = order.
    
      "Get status for the sales order
      LOOP AT order ASSIGNING <lfs_order> .
        IF <lfs_order> IS ASSIGNED.
        WRITE:/ <lfs_order>-sd_doc.
    
            "This function call is for getting the status of the
            "Sales document number derived from the BAPI_SALESORDER_GETLIST
              CALL FUNCTION 'BAPI_SALESORDER_GETSTATUS'
                EXPORTING
                  salesdocument       = <lfs_order>-sd_doc
               TABLES
                 statusinfo          = lt_statusinfo.
    
            APPEND LINES OF lt_statusinfo TO statusinfo_lt.
            "Read Processing and delivery Status
            READ TABLE lt_statusinfo ASSIGNING <lfs_statinfo> INDEX 1.
            IF sy-subrc EQ 0.
            WRITE: / 'Delivery Status', <lfs_statinfo>-dlv_stat_h,
                     'Required Date', <lfs_statinfo>-req_date_h,
                     'Delivery Number',<lfs_statinfo>-deliv_numb,
                     'Delivery Date',<lfs_statinfo>-deliv_date.
            ENDIF.
    
            CALL FUNCTION 'BAPI_SALESORDER_GETDETAILBOS'
              EXPORTING
                salesdocument            = <lfs_order>-sd_doc
    
             TABLES
    
               orderitems               = lt_orderitem
               orderschedulelines       = lt_orderscheduleline.
      APPEND LINES OF lt_orderitem to orderitem.
            "Read Processing and delivery Details
            READ TABLE lt_orderitem ASSIGNING <lfs_orderitem> INDEX 1.
            IF sy-subrc EQ 0.
            WRITE: / 'Material', <lfs_orderitem>-material,
                     'Plant', <lfs_orderitem>-plant,
                     'Short-text',<lfs_orderitem>-short_text,
                     'Req_qty',<lfs_orderitem>-req_qty,
                     'doc_number',<lfs_orderitem>-doc_number.
            ENDIF.
    
      APPEND LINES OF lt_orderscheduleline to orderscheduleline.
            "Read processing and delivery details -goods issue time
            READ TABLE orderscheduleline ASSIGNING <lfs_orderscheduleline> INDEX 1.
            IF sy-subrc EQ 0.
            WRITE: / 'Goods Issue Date', <lfs_orderscheduleline>-gi_date.
            ENDIF.
                      .
    
    
        ENDIF.
      ENDLOOP.
    

Then execute it.

img1

img2

SternK
  • 11,649
  • 22
  • 32
  • 46
Sumit Ghewade
  • 473
  • 4
  • 16