SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

BAPISDORDER_GETDETAILEDLIST



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> SD
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Thu Sep 20, 2007 12:25 pm    Post subject: BAPISDORDER_GETDETAILEDLIST Reply with quote

BAPISDORDER_GETDETAILEDLIST - Sales Order: List of All Order Data

Code:
CONSTANTS:  gc_cross               TYPE c VALUE 'X'
           .

DATA:  lt_sales_doc               TYPE TABLE OF sales_key
      ,lt_order_headers_out       TYPE TABLE OF bapisdhd
      ,lt_order_items_out         TYPE TABLE OF bapisdit
      ,lt_order_items_in          TYPE TABLE OF bapisditm
      ,lt_order_schedules_out     TYPE TABLE OF bapisdhedu
      ,lt_orders_cfgs_cucref_out  TYPE TABLE OF bapicucfgm
      ,lt_orders_cfgs_curfinst    TYPE TABLE OF bapicurefm
      ,lt_orders_cfgs_ins_out     TYPE TABLE OF bapicuinsm
      ,lt_orders_cfgs_prts_out    TYPE TABLE OF bapicuprtm
      ,lt_orders_cfgs_vals_out    TYPE TABLE OF bapicuvalm
      ,lt_orders_cfgs_curef_in    TYPE TABLE OF bapicucfg
      ,lt_orders_cfgs_curefins_in TYPE TABLE OF bapicuref
      ,lt_orders_cfgs_ins_in      TYPE TABLE OF bapicuins
      ,lt_orders_cfgs_prts_in     TYPE TABLE OF bapicuprt
      ,lt_orders_cfgs_vals_in     TYPE TABLE OF bapicuval
      ,lt_order_partners_out      TYPE TABLE OF bapisdpart
      ,lt_order_partners_in       TYPE TABLE OF bapiparnr
      ,lt_order_schedules_in      TYPE TABLE OF bapischdl
      ,lt_order_item_inx          type table of BAPISDITMX
      ,lt_return                  type table of BAPIRET2
      ,lt_orders_cfgs_blob_out    type table of BAPICUBLBM
      ,lt_orders_cfgs_variant_out type table of BAPICUVKM


      ,lwa_order_header_in        TYPE bapisdhd1
      ,lwa_order_header_out       TYPE bapisdhd
      ,lwa_bapi_view              TYPE order_view
      ,lwa_sales_doc              TYPE sales_key
      ,lwa_order_items            TYPE bapisdit
      ,lwa_order_schedules        TYPE bapisdhedu
      ,lwa_orders_cfgs_ref_in     TYPE bapicucfg
      ,lwa_orders_cfgs_curef_out    TYPE bapicucfgm
      ,lwa_orders_cfgs_curfinst_out TYPE bapicurefm
      ,lwa_orders_cfgs_curef_in     TYPE bapicuref
      ,lwa_orders_cfgs_ins_out      TYPE bapicuinsm
      ,lwa_orders_cfgs_ins_in       TYPE bapicuins
      ,lwa_orders_cfgs_prts_in      TYPE bapicuprt
      ,lwa_orders_cfgs_prts_out     TYPE bapicuprtm
      ,lwa_orders_cfgs_vals_out     TYPE bapicuvalm
      ,lwa_orders_cfgs_vals_in      TYPE bapicuval
      ,lwa_order_items_in           TYPE bapisditm
      ,lwa_order_partner_in         TYPE bapiparnr
      ,lwa_order_partner_out        TYPE bapisdpart
      ,lwa_order_schedules_in       TYPE bapischdl
      ,lwa_order_schedules_out      TYPE bapisdhedu
      ,lwa_order_item_inx           type BAPISDITMX


      ,lv_sales_doc               TYPE vbeln
      ,lv_index                   TYPE i
      .





**selection screen

PARAMETER p_vbeln TYPE vbeln OBLIGATORY.

* define order views
lwa_bapi_view-header = gc_cross.
lwa_bapi_view-item = gc_cross.
lwa_bapi_view-sdschedule = gc_cross.
lwa_bapi_view-configure = gc_cross.
lwa_bapi_view-partner =  gc_cross.

* fill order structure
lwa_sales_doc-vbeln = p_vbeln.
APPEND lwa_sales_doc TO lt_sales_doc.


CALL FUNCTION 'BAPISDORDER_GETDETAILEDLIST'
  EXPORTING
    i_bapi_view                   = lwa_bapi_view
*   I_MEMORY_READ                 =
  TABLES
    sales_documents               = lt_sales_doc
    order_headers_out             = lt_order_headers_out
    order_items_out               = lt_order_items_out
    order_schedules_out           = lt_order_schedules_out
*    ORDER_BUSINESS_OUT            =
    order_partners_out            = lt_order_partners_out
*   ORDER_ADDRESS_OUT             =
*   ORDER_STATUSHEADERS_OUT       =
*   ORDER_STATUSITEMS_OUT         =
*   ORDER_CONDITIONS_OUT          =
*   ORDER_COND_HEAD               =
*   ORDER_COND_ITEM               =
*   ORDER_COND_QTY_SCALE          =
*   ORDER_COND_VAL_SCALE          =
*   ORDER_CONTRACTS_OUT           =
*   ORDER_TEXTHEADERS_OUT         =
*   ORDER_TEXTLINES_OUT           =
*   ORDER_FLOWS_OUT               =
    order_cfgs_curefs_out         = lt_orders_cfgs_curfinst
    order_cfgs_cucfgs_out         = lt_orders_cfgs_cucref_out
    order_cfgs_cuins_out          = lt_orders_cfgs_ins_out
    order_cfgs_cuprts_out         = lt_orders_cfgs_prts_out
    order_cfgs_cuvals_out         = lt_orders_cfgs_vals_out
    ORDER_CFGS_CUBLBS_OUT         = lt_orders_cfgs_blob_out
    ORDER_CFGS_CUVKS_OUT          = lt_orders_cfgs_variant_out
*   ORDER_BILLINGPLANS_OUT        =
*   ORDER_BILLINGDATES_OUT        =
*   ORDER_CREDITCARDS_OUT         =
*   EXTENSIONOUT                  =
          .


READ TABLE lt_order_headers_out INTO lwa_order_header_out INDEX 1.
lv_index = lwa_order_header_out-purch_no+14(6).
ADD 1 TO lv_index.
lwa_order_header_out-purch_no+14(6) = lv_index.
lwa_order_header_in-DOC_TYPE = lwa_order_header_out-DOC_TYPE.
lwa_order_header_in-SALES_ORG = lwa_order_header_out-SALES_ORG.
lwa_order_header_in-DISTR_CHAN = lwa_order_header_out-DISTR_CHAN.
lwa_order_header_in-DIVISION = lwa_order_header_out-DIVISION.
lwa_order_header_in-purch_no_c = lwa_order_header_out-purch_no.
lwa_order_header_in-PURCH_DATE = sy-datum.

LOOP AT lt_order_partners_out INTO lwa_order_partner_out
   WHERE partn_role = 'AG'.
  lwa_order_partner_in-partn_role = lwa_order_partner_out-partn_role.
  lwa_order_partner_in-partn_numb = lwa_order_partner_out-customer.
  APPEND lwa_order_partner_in TO lt_order_partners_in.
  CLEAR lwa_order_partner_in.
ENDLOOP.


LOOP AT lt_order_items_out INTO lwa_order_items
  WHERE hg_lv_item IS INITIAL.

  READ TABLE lt_order_schedules_out INTO lwa_order_schedules_out WITH
KEY itm_number = lwa_order_items-itm_number.

  lwa_order_schedules_in-itm_number =
                                   lwa_order_schedules_out-itm_number.
  lwa_order_schedules_in-req_qty    = lwa_order_schedules_out-req_qty.
  APPEND lwa_order_schedules_in TO lt_order_schedules_in.

  lwa_order_items_in-itm_number = lwa_order_items-itm_number.
  lwa_order_items_in-material   = lwa_order_items-material.
  lwa_order_items_in-po_itm_no  =  lwa_order_items-itm_number.
  lwa_order_items_in-target_qty = lwa_order_schedules_out-req_qty.
  APPEND lwa_order_items_in TO lt_order_items_in.

  lwa_order_item_inx-itm_number = lwa_order_items-itm_number.
  lwa_order_item_inx-po_itm_no = gc_cross.
  lwa_order_item_inx-CONFIG_ID = gc_cross.
  lwa_order_item_inx-INST_ID   = gc_cross.
  append lwa_order_item_inx to lt_order_item_inx.


  CLEAR lwa_order_items_in.
ENDLOOP.

LOOP AT lt_orders_cfgs_cucref_out INTO lwa_orders_cfgs_curef_out.
  lwa_orders_cfgs_ref_in-posex      = lwa_orders_cfgs_curef_out-posex.
  lwa_orders_cfgs_ref_in-config_id  =
                                    lwa_orders_cfgs_curef_out-config_id.
  lwa_orders_cfgs_ref_in-root_id    = lwa_orders_cfgs_curef_out-root_id.
  lwa_orders_cfgs_ref_in-COMPLETE   =
                                     lwa_orders_cfgs_curef_out-COMPLETE.
  lwa_orders_cfgs_ref_in-CONSISTENT =
                                   lwa_orders_cfgs_curef_out-CONSISTENT.
  APPEND lwa_orders_cfgs_ref_in TO lt_orders_cfgs_curef_in.
  CLEAR lwa_orders_cfgs_ref_in.
ENDLOOP.

LOOP AT lt_orders_cfgs_curfinst  INTO lwa_orders_cfgs_curfinst_out.
  lwa_orders_cfgs_curef_in-posex     =
                                     lwa_orders_cfgs_curfinst_out-posex.
  lwa_orders_cfgs_curef_in-config_id =
                                 lwa_orders_cfgs_curfinst_out-config_id.
  lwa_orders_cfgs_curef_in-inst_id   =
                                   lwa_orders_cfgs_curfinst_out-inst_id.
  APPEND lwa_orders_cfgs_curef_in TO lt_orders_cfgs_curefins_in.
  CLEAR lwa_orders_cfgs_curef_in.
ENDLOOP.

LOOP AT lt_orders_cfgs_ins_out INTO lwa_orders_cfgs_ins_out.
  lwa_orders_cfgs_ins_in-config_id = lwa_orders_cfgs_ins_out-config_id.
  lwa_orders_cfgs_ins_in-inst_id = lwa_orders_cfgs_ins_out-inst_id.
  lwa_orders_cfgs_ins_in-obj_type = lwa_orders_cfgs_ins_out-obj_type.
 lwa_orders_cfgs_ins_in-class_type = lwa_orders_cfgs_ins_out-class_type.
  lwa_orders_cfgs_ins_in-obj_key       =
                                         lwa_orders_cfgs_ins_out-obj_key
.
  lwa_orders_cfgs_ins_in-quantity      =
                                      lwa_orders_cfgs_ins_out-quantity.
  lwa_orders_cfgs_ins_in-QUANTITY_UNIT =
                                lwa_orders_cfgs_ins_out-QUANTITY_UNIT.
  lwa_orders_cfgs_ins_in-COMPLETE      =
                                      lwa_orders_cfgs_ins_out-COMPLETE.
  lwa_orders_cfgs_ins_in-CONSISTENT    =
                                    lwa_orders_cfgs_ins_out-CONSISTENT.
  APPEND lwa_orders_cfgs_ins_in TO lt_orders_cfgs_ins_in.
  CLEAR lwa_orders_cfgs_ins_in.
ENDLOOP.

LOOP AT lt_orders_cfgs_prts_out INTO lwa_orders_cfgs_prts_out.
 lwa_orders_cfgs_prts_in-config_id = lwa_orders_cfgs_prts_out-config_id.
 lwa_orders_cfgs_prts_in-parent_id = lwa_orders_cfgs_prts_out-parent_id.
  lwa_orders_cfgs_prts_in-inst_id = lwa_orders_cfgs_prts_out-inst_id.
  lwa_orders_cfgs_prts_in-part_of_no =
                                    lwa_orders_cfgs_prts_out-part_of_no.
  lwa_orders_cfgs_prts_in-obj_type = lwa_orders_cfgs_prts_out-obj_type.
  lwa_orders_cfgs_prts_in-class_type =
                                    lwa_orders_cfgs_prts_out-class_type.
  lwa_orders_cfgs_prts_in-obj_key = lwa_orders_cfgs_prts_out-obj_key.
  lwa_orders_cfgs_prts_in-SALES_RELEVANT =
                                lwa_orders_cfgs_prts_out-SALES_RELEVANT.
  APPEND lwa_orders_cfgs_prts_in TO lt_orders_cfgs_prts_in.
  CLEAR lwa_orders_cfgs_prts_in.
ENDLOOP.

LOOP AT lt_orders_cfgs_vals_out INTO lwa_orders_cfgs_vals_out.
 lwa_orders_cfgs_vals_in-config_id = lwa_orders_cfgs_vals_out-config_id.
  lwa_orders_cfgs_vals_in-inst_id   = lwa_orders_cfgs_vals_out-inst_id.
  lwa_orders_cfgs_vals_in-charc     = lwa_orders_cfgs_vals_out-charc.
  lwa_orders_cfgs_vals_in-value     = lwa_orders_cfgs_vals_out-value.
  APPEND lwa_orders_cfgs_vals_in TO lt_orders_cfgs_vals_in.
  CLEAR lwa_orders_cfgs_vals_in.
ENDLOOP.


CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
  EXPORTING
*   SALESDOCUMENTIN               =
    order_header_in               = lwa_order_header_in
*   ORDER_HEADER_INX              =
*   SENDER                        =
*   BINARY_RELATIONSHIPTYPE       =
*   INT_NUMBER_ASSIGNMENT         =
*   BEHAVE_WHEN_ERROR             =
*   LOGIC_SWITCH                  =
*   TESTRUN                       =
*   CONVERT                       = ' '
 IMPORTING
   salesdocument                 = lv_sales_doc
  TABLES
    RETURN                        = lt_return
    order_items_in                = lt_order_items_in
    ORDER_ITEMS_INX               = lt_order_item_inx
    order_partners                = lt_order_partners_in
    order_schedules_in            = lt_order_schedules_in
*   ORDER_SCHEDULES_INX           =
*   ORDER_CONDITIONS_IN           =
*   ORDER_CONDITIONS_INX          =
   order_cfgs_ref                = lt_orders_cfgs_curef_in
   order_cfgs_inst               = lt_orders_cfgs_ins_in
   order_cfgs_part_of            = lt_orders_cfgs_prts_in
   order_cfgs_value              = lt_orders_cfgs_vals_in
*   ORDER_CFGS_BLOB               =
*   ORDER_CFGS_VK                 =
   order_cfgs_refinst            = lt_orders_cfgs_curefins_in
*   ORDER_CCARD                   =
*   ORDER_TEXT                    =
*   ORDER_KEYS                    =
*   EXTENSIONIN                   =
*   PARTNERADDRESSES              =
          .

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
* EXPORTING
*   WAIT          =
* IMPORTING
*   RETURN        =
          .
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> SD All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.