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

BAPI_INQUIRY_CREATEFROMDATA



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Interfaces | Интерфейсы -> BAPI
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Sun Jun 15, 2008 2:12 pm    Post subject: BAPI_INQUIRY_CREATEFROMDATA Reply with quote

BAPI_INQUIRY_CREATEFROMDATA - Customer inquiry: Create customer inquiry

1. using the CE_C_PROCESSING
information: while running the report there exists a instance number local 99999... 1

Code:
***************************
report  zz_alr_create_variants                                      .

data: new_instance like  inob-cuobj.
data: functionkey like sy-ucomm.
data: et_values   type table of   ibvalue0.
data: wa_et_values like line of et_values.

call function 'CE_C_PROCESSING'
  exporting
    instance                             =   '000000000000000000'
    reference_instance                   =   '000000000000000000'
    date                                 = sy-datum
*DISPLAY                              = ' '
    object_id                            = 'MARA'
    object                               = '000000000309120110'
    owner_id                             = 'MARAT'
*HEADER_SCREEN                        =
    plant                                = '0220'
*NO_DIALOG                            = ' '
*MATERIAL_VARIANT                     = '000000000309120112'
    no_f8                                = ' '
    no_f11                               = ' '
    sub_type                             = '01'
    simulation                           = ' '
    type                                 = 'E'
*EFFECTIVITY                          =
    initialization                       = 'X'
*CALLED_FROM_SALES                    = ' '
*BOM_APPLICATION                      =
*IS_BUSINESS_OBJECT                   =

 importing
   return_with_functionkey              = functionkey
   new_instance                         = new_instance

*TABLES
*APPLICATION_INPUT                    =
*APPLICATION_OUTPUT                   =

 exceptions
   internal_error                       = 1
   instance_not_found                   = 2
   reference_instance_not_found         = 3
   instance_is_a_classification         = 4
   no_plant                             = 5
   no_quantity                          = 6
   no_connection_to_configuration       = 7
   material_variant_not_allowed         = 8
   internal_error_ecm                   = 9
   eoasl_not_allowed                    = 10
   maxasl_not_allowed                   = 11
   xc_unprocessed_data                  = 12
   xc_failure_processing_data           = 13
   no_bom                               = 14
   others                               = 15
          .
break alr.
if sy-subrc  0.

*MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.

write: new_instance.

 call function 'CUCB_GET_VALUES_FROM_INSTANCE'
    exporting
      iv_instance                        = new_instance

*IS_BUSINESS_OBJECT                 =
*IV_MOMENT                          =
   importing
     et_values                          = et_values

*EXCEPTIONS
*INVALID_INSTANCE                   = 1
*INSTANCE_IS_A_CLASSIFICATION       = 2
*OTHERS                             = 3
            .
  if sy-subrc  0.
*MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  endif.

*Ausgabe
  loop at et_values into wa_et_values.
   write: / wa_et_values-atinn,
             wa_et_values-atwrt.

  endloop.


*******************
2. create orders
at the moment I use a material which is konfigured... in the future I get the values from a z table.... ( create by step 1 )

Code:
********
report  zzalr_order_mv                                              .

*MV Bestellen fur Online Ordering
data: g_cuobj like mara-cuobf.

*
data: et_values   type table of   ibvalue0.
data: wa_et_values like line of et_values.
data: order_header_in   like   bapisdhead.

data:
wa_order_items_in   like   bapiitemin,
it_order_items_in type table of bapiitemin,

wa_order_partners   like   bapipartnr,
it_order_partners   type table of bapipartnr,
wa_order_items_out   like   bapiitemex,
it_order_items_out   type table of   bapiitemex,

wa_order_cfgs_ref   like   bapicucfg,
it_order_cfgs_ref   type table of   bapicucfg,
wa_order_cfgs_inst   like   bapicuins,
it_order_cfgs_inst   type table of   bapicuins,
wa_order_cfgs_part_of   like   bapicuprt,
it_order_cfgs_part_of   type table of   bapicuprt,

wa_order_cfgs_value   like   bapicuval,
it_order_cfgs_value   type table of   bapicuval.

data: g_wa_bapi_return1    like bapireturn1.
data:   bapi_vbeln like  bapivbeln-vbeln.
data: h_atnam like cabn-atnam.

parameters: p_matnr like mara-matnr default '000000000309120112'.
parameters: p_kmat like mara-matnr default '000000000309120110'.
parameters: p_buchen type flag default 'X'.

start-of-selection.

  select single cuobf from mara into g_cuobj where
  matnr = p_matnr.

*Auslesen der Config
  call function 'CUCB_GET_VALUES_FROM_INSTANCE'
    exporting
      iv_instance                        = g_cuobj

*IS_BUSINESS_OBJECT                 =
*IV_MOMENT                          =

   importing
     et_values                          = et_values

*EXCEPTIONS
*INVALID_INSTANCE                   = 1
*INSTANCE_IS_A_CLASSIFICATION       = 2
*OTHERS                             = 3
            .
  if sy-subrc  0.
*MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  endif.

  order_header_in-doc_type = 'AF'.
  order_header_in-sales_org = '0220'.
  order_header_in-distr_chan = '20'.
  order_header_in-division = '03'.
  order_header_in-req_date_h = sy-datum.
  order_header_in-purch_date = sy-datum.
  order_header_in-price_list = 'FA'.
  order_header_in-price_date = '20080324'.

  wa_order_items_in-itm_number = '000010'.
  wa_order_items_in-material = p_kmat.

  wa_order_items_in-req_qty = '0000000001000'.
  wa_order_items_in-sales_unit = 'ST'.
  wa_order_items_in-po_itm_no = '000010'.

  append wa_order_items_in to it_order_items_in.

  wa_order_partners-partn_role = 'AG'.
  wa_order_partners-partn_numb = '0000015584'.
  append wa_order_partners to it_order_partners.

*Befullen der Tabellen mit Konfiguration.
  wa_order_cfgs_ref-posex = '000010'.
  wa_order_cfgs_ref-config_id = '000001'.
  wa_order_cfgs_ref-root_id = '00000001'.
  append wa_order_cfgs_ref to it_order_cfgs_ref.


  wa_order_cfgs_inst-config_id  = '000001'.
  wa_order_cfgs_inst-inst_id = '00000001'.
  wa_order_cfgs_inst-obj_type = 'MARA'.
  wa_order_cfgs_inst-class_type = '300'.

  append wa_order_cfgs_inst to it_order_cfgs_inst.

*wa_order_cfgs_part_of-CONFIG_ID   = '000001'.
*wa_order_cfgs_part_of-PARENT_ID = '00000001'
*wa_order_cfgs_part_of-INST_ID = '00000001'.
*wa_order_cfgs_part_of-PART_OF_NO = '0010'.
*wa_order_cfgs_part_of-OBJ_KEY = 'PROD111'.
*append wa_order_cfgs_part_of to it_order_cfgs_part_of.
*


*Konfiguration aus Vorlage ubernehmen
  loop at et_values into wa_et_values.

*Eintexten fur?s Bapi...
    select single atnam from cabn into h_atnam
    where atinn = wa_et_values-atinn.

    wa_order_cfgs_value-config_id = '000001'.
    wa_order_cfgs_value-inst_id = '00000001'.
    wa_order_cfgs_value-charc = h_atnam.
    wa_order_cfgs_value-value = wa_et_values-atwrt.
    append wa_order_cfgs_value to it_order_cfgs_value.

  endloop.

*Preis aus Konfiguration holen..(Trick: Simulation einer Order anlegen,
*gibt kein Bapi fur?s Anfragen.... )

  call function 'BAPI_SALESORDER_SIMULATE'
    exporting
      order_header_in           = order_header_in

*CONVERT_PARVW_AUART       = ' '

*IMPORTING

*SALESDOCUMENT             =
*SOLD_TO_PARTY             =
*SHIP_TO_PARTY             =
*BILLING_PARTY             =
*RETURN                    =

    tables
      order_items_in            =    it_order_items_in
      order_partners            =    it_order_partners
      order_items_out           =    it_order_items_out
      order_cfgs_ref            =    it_order_cfgs_ref
      order_cfgs_inst           =    it_order_cfgs_inst
      order_cfgs_part_of        =    it_order_cfgs_part_of
      order_cfgs_value          =    it_order_cfgs_value

*ORDER_SCHEDULE_IN         =
*ORDER_ITEMS_OUT           =    it_order_items_out
*ORDER_CFGS_REF            =
*ORDER_CFGS_INST           =
*ORDER_CFGS_PART_OF        =
*ORDER_CFGS_VALUE          =
*ORDER_CFGS_BLOB           =
*ORDER_CCARD               =
*ORDER_CCARD_EX            =
*ORDER_SCHEDULE_EX         =
*ORDER_CONDITION_EX        =
*ORDER_INCOMPLETE          =
*MESSAGETABLE              =
*EXTENSIONIN               =
*PARTNERADDRESSES          =

            .

  if p_buchen = 'X'.

    call function 'BAPI_INQUIRY_CREATEFROMDATA'
      exporting
        order_header_in           = order_header_in
        without_commit            = 'X'

*CONVERT_PARVW_AUART       = ' '

     importing
       salesdocument             = bapi_vbeln

*SOLD_TO_PARTY             =
*SHIP_TO_PARTY             =
*BILLING_PARTY             =

        return                    = g_wa_bapi_return1
      tables
        order_items_in            =    it_order_items_in
        order_partners            =    it_order_partners
        order_items_out           =    it_order_items_out
        order_cfgs_ref            =    it_order_cfgs_ref
        order_cfgs_inst           =    it_order_cfgs_inst
        order_cfgs_part_of        =    it_order_cfgs_part_of
        order_cfgs_value          =    it_order_cfgs_value
              .

*Verbuchen ...
    call function 'BAPI_TRANSACTION_COMMIT'.

    write: 'hallo hier die nummer: '.
    write: bapi_vbeln.

  endif.

*Ausgabe Preis Info.
  loop at it_order_items_out into wa_order_items_out.

    write:
    wa_order_items_out-itm_number,
    wa_order_items_out-po_itm_no,
    wa_order_items_out-material,
    wa_order_items_out-mat_entrd,
    wa_order_items_out-short_text,
    wa_order_items_out-subtotal_1,
    wa_order_items_out-qty_req_dt,
    wa_order_items_out-sales_unit,
    wa_order_items_out-net_value1.

  endloop.
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 -> Interfaces | Интерфейсы -> BAPI 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 can 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.